Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,12 @@ - (OATransportStop *) findNearestTransportStopForAmenity:(OAPOI *)amenity
NSString *stopName = [[stop name] lowercaseString];
auto dist = OsmAnd::Utilities::distance(stop.longitude, stop.latitude, lon, lat);

if (([stopName containsString:amenityName] || [amenityName containsString:stopName])
if ((([stopName containsString:amenityName] || [amenityName containsString:stopName])
&& dist < MAX_DISTANCE_BETWEEN_AMENITY_AND_LOCAL_STOPS
&& (!nearestStop
|| [OAUtilities isCoordEqual:[nearestStop getLocation].coordinate destLat:[stop getLocation].coordinate]
|| [OAUtilities isCoordEqual:[stop getLocation].coordinate destLat:CLLocationCoordinate2DMake(lat, lon)])
)
|| [OAUtilities isCoordEqual:[nearestStop getLocation].coordinate destLat:[stop getLocation].coordinate]))
|| [OAUtilities isCoordEqual:[stop getLocation].coordinate destLat:CLLocationCoordinate2DMake(lat, lon)]
|| [stop isConnectedToStop:amenity.obfId])
{
[stopAggregated addLocalTransportStop:stop];
if (!nearestStop)
Expand Down
1 change: 1 addition & 0 deletions Sources/Transport/OATransportStop.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ NS_ASSUME_NONNULL_BEGIN

- (void)findAmenityDataIfNeeded;
- (NSString *)getStopObjectName:(NSString *)lang transliterate:(BOOL)transliterate;
- (BOOL)isConnectedToStop:(uint64_t)stopId;

@end

Expand Down
23 changes: 23 additions & 0 deletions Sources/Transport/OATransportStop.mm
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@

#include <OsmAndCore.h>
#include <OsmAndCore/Utilities.h>
#include <OsmAndCore/QKeyValueIterator.h>
#include <OsmAndCore/Data/TransportStop.h>
#include <OsmAndCore/Data/TransportRoute.h>
#include <OsmAndCore/Data/TransportStopExit.h>

static NSString *CONNECTED_STOP_IDS = @"osmand:connected_stop_ids";


@interface OATransportStop()

Expand All @@ -35,6 +38,7 @@ @implementation OATransportStop

- (instancetype)initWithStop:(std::shared_ptr<const OsmAnd::TransportStop>)stop
{
self = [super init];
if (self)
{
_stop = stop;
Expand All @@ -46,6 +50,10 @@ - (instancetype)initWithStop:(std::shared_ptr<const OsmAnd::TransportStop>)stop
self.latitude = stop->location.latitude;
self.longitude = stop->location.longitude;
self.stopId = stop->id.id;
for (const auto& entry : OsmAnd::rangeOf(OsmAnd::constOf(stop->localizedNames)))
{
self.localizedNames[entry.key().toNSString()] = entry.value().toNSString();
}

NSMutableArray<CLLocation *> *extiLocations = [NSMutableArray new];
const auto stopExits = stop->exits;
Expand Down Expand Up @@ -114,6 +122,21 @@ - (NSString *)getStopObjectName:(NSString *)lang transliterate:(BOOL)translitera
return qName.toNSString();
}

- (BOOL)isConnectedToStop:(uint64_t)stopId
{
NSString *connectedStopIds = self.localizedNames[CONNECTED_STOP_IDS];
if (connectedStopIds)
{
NSString *idString = [@(stopId) stringValue];
for (NSString *connectedStopId in [connectedStopIds componentsSeparatedByString:@","])
{
if ([idString isEqualToString:connectedStopId])
return YES;
}
}
return NO;
}

- (BOOL)isEqual:(OATransportStop *)object
{
if (self == object)
Expand Down