[ios] Support geo-navigation URL

Signed-off-by: Yannik Bloscheck <git@yannikbloscheck.com>
This commit is contained in:
Yannik Bloscheck
2025-09-27 10:48:33 +02:00
parent 74122e2fae
commit f5b68183c9
10 changed files with 49 additions and 9 deletions

View File

@@ -24,8 +24,12 @@ static inline DeeplinkUrlType deeplinkUrlType(url_scheme::ParsedMapApi::UrlType
+ (DeeplinkUrlType)parseAndSetApiURL:(NSURL *)url {
Framework &f = GetFramework();
if ([url.scheme isEqual: @"geo-navigation"]) {
return deeplinkUrlType(f.ParseGeoNav(url.absoluteString.UTF8String, f));
} else {
return deeplinkUrlType(f.ParseAndSetApiURL(url.absoluteString.UTF8String));
}
}
+ (void)executeMapApiRequest {
GetFramework().ExecuteMapApiRequest();

View File

@@ -19,6 +19,8 @@
<string>CloudDocuments</string>
<string>CloudKit</string>
</array>
<key>com.apple.developer.navigation-app</key>
<true/>
<key>com.apple.developer.ubiquity-container-identifiers</key>
<array>
<string>iCloud.app.comaps.debug</string>

View File

@@ -19,6 +19,8 @@
<string>CloudDocuments</string>
<string>CloudKit</string>
</array>
<key>com.apple.developer.navigation-app</key>
<true/>
<key>com.apple.developer.ubiquity-container-identifiers</key>
<array>
<string>iCloud.app.comaps</string>

View File

@@ -65,6 +65,7 @@
<string>mapsme</string>
<string>ge0</string>
<string>geo</string>
<string>geo-navigation</string>
<string>om</string>
<string>mapswithmepro</string>
</array>
@@ -89,7 +90,7 @@
<true/>
<key>NSExceptionDomains</key>
<dict>
<key>comaps.at</key>
<key>comaps.app</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>
@@ -98,7 +99,7 @@
<key>NSThirdPartyExceptionRequiresForwardSecrecy</key>
<false/>
</dict>
<key>comaps.app</key>
<key>comaps.at</key>
<dict>
<key>NSExceptionAllowsInsecureHTTPLoads</key>
<true/>

View File

@@ -91,7 +91,7 @@
switch urlType {
case .route:
if let adapter = DeepLinkRouteStrategyAdapter(url) {
MWMRouter.buildApiRoute(with: adapter.type, start: adapter.p1, finish: adapter.p2)
MWMRouter.buildApiRoute(with: adapter.type, start: adapter.pStart, intermediatePoint: adapter.pIntermediate, finish: adapter.pFinish)
MapsAppDelegate.theApp().showMap()
return true
}

View File

@@ -6,8 +6,9 @@ NS_ASSUME_NONNULL_BEGIN
@class MWMRoutePoint;
@interface DeepLinkRouteStrategyAdapter : NSObject
@property(nonatomic, readonly) MWMRoutePoint* p1;
@property(nonatomic, readonly) MWMRoutePoint* p2;
@property(nonatomic, readonly) MWMRoutePoint* pStart;
@property(nonatomic, readonly) MWMRoutePoint* pIntermediate;
@property(nonatomic, readonly) MWMRoutePoint* pFinish;
@property(nonatomic, readonly) MWMRouterType type;
- (nullable instancetype)init:(NSURL*)url;

View File

@@ -11,11 +11,29 @@
auto const parsedData = GetFramework().GetParsedRoutingData();
auto const points = parsedData.m_points;
if (points.size() == 2) {
_p1 = [[MWMRoutePoint alloc] initWithURLSchemeRoutePoint:points.front()
for (auto point: points) {
if (point.m_type == RouteMarkType::Start) {
_pStart = [[MWMRoutePoint alloc] initWithURLSchemeRoutePoint:point
type:MWMRoutePointTypeStart
intermediateIndex:0];
_p2 = [[MWMRoutePoint alloc] initWithURLSchemeRoutePoint:points.back()
} else if (point.m_type == RouteMarkType::Finish) {
_pFinish = [[MWMRoutePoint alloc] initWithURLSchemeRoutePoint:point
type:MWMRoutePointTypeFinish
intermediateIndex:0];
} else if (point.m_type == RouteMarkType::Intermediate) {
_pIntermediate = [[MWMRoutePoint alloc] initWithURLSchemeRoutePoint:point
type:MWMRoutePointTypeIntermediate
intermediateIndex:0];
}
}
if (_pStart && _pFinish) {
_type = routerType(parsedData.m_type);
} else if (points.size() == 2) {
_pStart = [[MWMRoutePoint alloc] initWithURLSchemeRoutePoint:points.front()
type:MWMRoutePointTypeStart
intermediateIndex:0];
_pFinish = [[MWMRoutePoint alloc] initWithURLSchemeRoutePoint:points.back()
type:MWMRoutePointTypeFinish
intermediateIndex:0];
_type = routerType(parsedData.m_type);

View File

@@ -56,6 +56,7 @@ typedef void (^MWMImageHeightBlock)(UIImage *, NSString *, NSString *);
+ (void)buildToPoint:(MWMRoutePoint *)finish bestRouter:(BOOL)bestRouter;
+ (void)buildApiRouteWithType:(MWMRouterType)type
startPoint:(MWMRoutePoint *)startPoint
intermediatePoint:(MWMRoutePoint *)intermediatePoint
finishPoint:(MWMRoutePoint *)finishPoint;
+ (void)rebuildWithBestRouter:(BOOL)bestRouter;

View File

@@ -255,6 +255,7 @@ char const *kRenderAltitudeImagesQueueLabel = "mapsme.mwmrouter.renderAltitudeIm
+ (void)buildApiRouteWithType:(MWMRouterType)type
startPoint:(MWMRoutePoint *)startPoint
intermediatePoint:(MWMRoutePoint *)intermediatePoint
finishPoint:(MWMRoutePoint *)finishPoint {
if (!startPoint || !finishPoint)
return;
@@ -264,6 +265,9 @@ char const *kRenderAltitudeImagesQueueLabel = "mapsme.mwmrouter.renderAltitudeIm
auto router = [MWMRouter router];
router.isAPICall = YES;
[self addPoint:startPoint];
if (intermediatePoint) {
[self addPoint:intermediatePoint];
}
[self addPoint:finishPoint];
router.isAPICall = NO;

View File

@@ -585,6 +585,13 @@ public:
return m_parsedMapApi.SetUrlAndParse(url);
}
#if defined(OMIM_OS_MAC) || defined(OMIM_OS_IPHONE)
url_scheme::ParsedMapApi::UrlType ParseGeoNav(std::string const & raw, Framework & fm)
{
return m_parsedMapApi.ParseGeoNav(raw, fm);
}
#endif
struct ParsedRoutingData
{
ParsedRoutingData(std::vector<url_scheme::RoutePoint> const & points, routing::RouterType type)