VMMSMapUtil
@interface VMMSMapUtil : NSObject
This is a utility class that performs various calculations related to maps. All methods are class methods so an instance of this class is not needed.
Since
1.0-
Calculates the tile bounds on a mercator projection given an x, y, and zoom.
Declaration
Swift
+ (VMMSCoordinateBounds *)tileBoundsForX:(NSUInteger)x y:(NSUInteger)y zoom:(NSUInteger)zoom;Parameters
xX coordinate on a mercator projection.
yY coordinate on a mercator projection.
zoomZoom of the map.
Return Value
A VMMSCoordinateBounds instance containing the northeast and southwest coordinates.
-
Retrieves the latitude and longitude from a string. Expected format: 99.99, 99.99
Declaration
Swift
+ (CLLocationCoordinate2D)locationFromString:(NSString *)str;Parameters
strString representation of a coordinate.
Return Value
The coordinate found in the string.
-
Calculates offset location given source location, heading (bearing), and distance.
Declaration
Swift
+ (CLLocationCoordinate2D)locationWithOffset:(CLLocationCoordinate2D)source withHeading:(double)bearing andDistance:(double)distance;Parameters
sourceThe original coordinate.
bearingThe map heading (bearing).
distanceThe offset distance in METERS.
Return Value
Offset Coordinate.
-
Calculates the angle and direction between 3 coordinates. A direction value larger than 0 indicates a left turn. A direction value smaller than 0 indicates a right turn. A direction value equal to 0 indicates no turn i.e. the 3 points are colinear.
Declaration
Swift
+ (NSDictionary<NSString *, NSNumber *> *) angleAndDirectionBetweenLocationA:(CLLocationCoordinate2D)A andLocationB:(CLLocationCoordinate2D)B andLocationC:(CLLocationCoordinate2D)C;Parameters
AFirst Coordinate.
BSecond Coordinate.
CThird Coordinate.
Return Value
A dictionary containing the angle and direction. Keys: [
angle
,direction
] -
Calculates the distance between two coordinates.
Declaration
Swift
+ (double)distanceBetweenPoint:(CLLocationCoordinate2D)start andPoint:(CLLocationCoordinate2D)end;Parameters
startFirst coordinate.
endSecond coordinate.
Return Value
Distance calculated in METERS.
-
Calculates the heading (bearing) between two coordinates.
Declaration
Swift
+ (double)headingBetweenPoint:(CLLocationCoordinate2D)p1 andPoint:(CLLocationCoordinate2D)p2;Parameters
p1First coordinate.
p2Second coordinate.
Return Value
Heading calculated in DEGREES
-
Averages the location for a list of coordinates
Since
1.2Declaration
Swift
+ (CLLocationCoordinate2D)averageOfCoordinates: (NSArray<NSValue *> *)coordinates;Parameters
coordinatesthe list of coordinates to average
Return Value
the average point
-
Check if a point falls inside of a polygon or not
Since
1.2Declaration
Swift
+ (BOOL)point:(CLLocationCoordinate2D)point isInPolygon:(NSArray<NSValue *> *)vertices;Parameters
pointthe point to chekc
verticesthe points that make up the polygon
Return Value
true if the given point falls within the boundaries of the polygon
VMMSMapUtil Class Reference