Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
cedarmaps-sdk-ios-public
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Cedar Studios
cedarmaps-sdk-ios-public
Commits
90be2393
Commit
90be2393
authored
Jan 13, 2018
by
Deployer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added instructions to routings
parent
a8b17c71
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
120 additions
and
4 deletions
+120
-4
CSMapKit.h
CedarMaps/Classes/CSMapKit.h
+12
-0
CSMapKit.m
CedarMaps/Classes/CSMapKit.m
+10
-3
CSRoute.h
CedarMaps/Classes/CSRoute.h
+6
-0
CSRoute.m
CedarMaps/Classes/CSRoute.m
+4
-0
CSRouteInstruction.h
CedarMaps/Classes/CSRouteInstruction.h
+63
-0
CSRouteInstruction.m
CedarMaps/Classes/CSRouteInstruction.m
+24
-0
CSAppDelegate.m
Example/CedarMaps/CSAppDelegate.m
+1
-1
No files found.
CedarMaps/Classes/CSMapKit.h
View file @
90be2393
...
...
@@ -166,6 +166,18 @@
*/
-
(
void
)
calculateDirections
:(
nonnull
NSArray
<
CSRoutePair
*>
*
)
routePairs
withCompletionHandler
:(
nonnull
CSDirectionCompletionHandler
)
completionHandler
;
/**
* This method calculates directions with verbal instructions using car profile between a source and a destination.
*
* Up to 100 pairs of source and destionation points can be provided to calculate a multiple step routing.
@param routePairs An array of CSRoutePair consisting of source and destination points.
@param locale The locale for instruction. Currently supports "en" and "fa"
@param completionHandler This handler is called when the process of fetching direction
* results is completed. The block will be called on the main_queue.
@see CSRoutePair.h
*/
-
(
void
)
calculateDirectionsWithInstructionsForRoutePairs
:(
nonnull
NSArray
<
CSRoutePair
*>
*
)
routePairs
locale
:(
nonnull
NSLocale
*
)
locale
withCompletionHandler
:(
nonnull
CSDirectionCompletionHandler
)
completionHandler
;
/**
* This method calculates distance using car profile between a source and a destination.
...
...
CedarMaps/Classes/CSMapKit.m
View file @
90be2393
...
...
@@ -302,11 +302,15 @@ typedef void (^CSNetworkResponseCompletionHandler)(NSData * _Nullable data, NSUR
-
(
void
)
calculateDirections
:
(
NSArray
<
CSRoutePair
*>
*
)
routePairs
withCompletionHandler
:
(
CSDirectionCompletionHandler
)
completionHandler
{
[
self
fetchDirectionOrDistance
:
kDirection
forRoutePairs
:
routePairs
withCompletionHandler
:
completionHandler
];
[
self
fetchDirectionOrDistance
:
kDirection
forRoutePairs
:
routePairs
withInstructions
:
NO
locale
:
nil
withCompletionHandler
:
completionHandler
];
}
-
(
void
)
calculateDirectionsWithInstructionsForRoutePairs
:
(
NSArray
<
CSRoutePair
*>
*
)
routePairs
locale
:
(
NSLocale
*
)
locale
withCompletionHandler
:
(
CSDirectionCompletionHandler
)
completionHandler
{
[
self
fetchDirectionOrDistance
:
kDirection
forRoutePairs
:
routePairs
withInstructions
:
YES
locale
:
locale
withCompletionHandler
:
completionHandler
];
}
-
(
void
)
calculateDistance
:
(
NSArray
<
CSRoutePair
*>
*
)
routePairs
withCompletionHandler
:
(
CSDirectionCompletionHandler
)
completionHandler
{
[
self
fetchDirectionOrDistance
:
kDistance
forRoutePairs
:
routePairs
withCompletionHandler
:
completionHandler
];
[
self
fetchDirectionOrDistance
:
kDistance
forRoutePairs
:
routePairs
with
Instructions
:
NO
locale
:
nil
with
CompletionHandler
:
completionHandler
];
}
typedef
enum
{
...
...
@@ -314,7 +318,7 @@ typedef enum {
kDistance
}
DirectionOrDistance
;
-
(
void
)
fetchDirectionOrDistance
:(
DirectionOrDistance
)
option
forRoutePairs
:(
NSArray
<
CSRoutePair
*>
*
)
routePairs
withCompletionHandler
:(
CSDirectionCompletionHandler
)
completionHandler
{
-
(
void
)
fetchDirectionOrDistance
:(
DirectionOrDistance
)
option
forRoutePairs
:(
NSArray
<
CSRoutePair
*>
*
)
routePairs
with
Instructions
:(
BOOL
)
shouldGetInstructions
locale
:(
NSLocale
*
)
locale
with
CompletionHandler
:(
CSDirectionCompletionHandler
)
completionHandler
{
NSString
*
pointsStr
=
@""
;
for
(
int
i
=
0
;
i
<
MIN
(
routePairs
.
count
,
100
);
i
++
)
{
...
...
@@ -335,6 +339,9 @@ typedef enum {
if
(
pointsStr
.
length
>
0
)
{
urlStr
=
[
urlStr
stringByAppendingString
:
pointsStr
];
}
if
(
locale
.
languageCode
)
{
urlStr
=
[
urlStr
stringByAppendingFormat
:
@"?instructions=%@&locale=%@"
,
shouldGetInstructions
?
@"true"
:
@"false"
,
locale
.
languageCode
];
}
__weak
CSMapKit
*
weakSelf
=
self
;
[
self
responseFromURLString
:
urlStr
completionHandler
:
^
(
NSData
*
_Nullable
data
,
NSURLResponse
*
_Nullable
response
,
NSError
*
_Nullable
error
)
{
...
...
CedarMaps/Classes/CSRoute.h
View file @
90be2393
...
...
@@ -7,6 +7,7 @@
#import <JSONModel/JSONModel.h>
#import "CSBoundingBox.h"
#import "CSRouteInstruction.h"
@protocol
CSRoute
;
...
...
@@ -39,6 +40,11 @@
*/
@property
(
nonatomic
,
strong
,
nullable
)
NSArray
<
CLLocation
*>
<
Optional
>
*
points
;
/**
* Verbal representation of the route.
*/
@property
(
nonatomic
,
strong
,
nullable
)
NSArray
<
CSRouteInstruction
*>
<
Optional
,
CSRouteInstruction
>
*
instructions
;
@end
typedef
void
(
^
CSDirectionCompletionHandler
)(
NSArray
<
CSRoute
*>
*
__nullable
routes
,
NSError
*
__nullable
error
);
...
...
CedarMaps/Classes/CSRoute.m
View file @
90be2393
...
...
@@ -9,6 +9,10 @@
@implementation
CSRoute
-
(
NSTimeInterval
)
time
{
return
_time
/
1000
;
}
-
(
void
)
setBoundingBoxWithNSArray
:
(
NSArray
*
)
array
{
if
(
array
&&
array
.
count
==
4
)
{
CLLocationCoordinate2D
ne
=
CLLocationCoordinate2DMake
([
array
[
3
]
doubleValue
],
[
array
[
2
]
doubleValue
]);
...
...
CedarMaps/Classes/CSRouteInstruction.h
0 → 100644
View file @
90be2393
//
// CSRouteInstruction.h
// CedarMaps
//
// Created by Saeed Taheri on 1/13/18.
//
#import <JSONModel/JSONModel.h>
@import
CoreLocation
;
@protocol
CSRouteInstruction
;
typedef
NS_ENUM
(
NSUInteger
,
CSInstructionSign
)
{
CSInstructionSignKeepLeft
=
-
7
,
CSInstructionSignTurnSharpLeft
=
-
3
,
CSInstructionSignTurnLeft
=
-
2
,
CSInstructionSignTurnSlightLeft
=
-
1
,
CSInstructionSignContinue
=
0
,
CSInstructionSignTurnSlightRight
=
1
,
CSInstructionSignTurnRight
=
2
,
CSInstructionSignTurnSharpRight
=
3
,
CSInstructionSignFinish
=
4
,
CSInstructionSignReachedVia
=
5
,
CSInstructionSignUseRoundabout
=
6
,
CSInstructionSignKeepRight
=
7
};
/**
* Verbal representation of a route section in routing.
*/
@interface
CSRouteInstruction
:
JSONModel
/**
Distance in a route section in meters using car profile.
*/
@property
(
nonatomic
,
assign
)
CLLocationDistance
distance
;
/**
ETA for a route in seconds using car profile.
*/
@property
(
nonatomic
,
assign
)
NSTimeInterval
time
;
/**
Main street name in the route section.
*/
@property
(
nonatomic
,
strong
)
NSString
*
streetName
;
/**
Textual instruction of route section.
*/
@property
(
nonatomic
,
strong
)
NSString
*
text
;
/**
An array of indeces; these indeces can be looked up in CSRoute `points` property. It shows locations included in this section.
*/
@property
(
nonatomic
,
strong
)
NSArray
<
NSNumber
*>
*
interval
;
/**
Traffic sign of current section.
*/
@property
(
nonatomic
,
assign
)
CSInstructionSign
sign
;
@end
CedarMaps/Classes/CSRouteInstruction.m
0 → 100644
View file @
90be2393
//
// CSRouteInstruction.m
// CedarMaps
//
// Created by Saeed Taheri on 1/13/18.
//
#import "CSRouteInstruction.h"
@implementation
CSRouteInstruction
-
(
NSTimeInterval
)
time
{
return
_time
/
1000
;
}
+
(
JSONKeyMapper
*
)
keyMapper
{
NSDictionary
*
map
=
@{
@"streetName"
:
@"street_name"
};
return
[[
JSONKeyMapper
alloc
]
initWithModelToJSONDictionary
:
map
];
}
@end
Example/CedarMaps/CSAppDelegate.m
View file @
90be2393
...
...
@@ -15,7 +15,7 @@
{
[[
CSMapKit
sharedMapKit
]
setCredentialsWithClientID
:
@"YOUR_CLIENT_ID"
clientSecret
:
@"YOUR_CLIENT_SECRET"
];
[[
CSMapKit
sharedMapKit
]
prepareMapTiles
:
^
(
BOOL
isReady
,
NSError
*
_Nullable
error
)
{
}];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment