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

    x

    X coordinate on a mercator projection.

    y

    Y coordinate on a mercator projection.

    zoom

    Zoom 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

    str

    String 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

    source

    The original coordinate.

    bearing

    The map heading (bearing).

    distance

    The 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

    A

    First Coordinate.

    B

    Second Coordinate.

    C

    Third 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

    start

    First coordinate.

    end

    Second coordinate.

    Return Value

    Distance calculated in METERS.

  • Calculates the heading (bearing) between two coordinates.

    Declaration

    Swift

    + (double)headingBetweenPoint:(CLLocationCoordinate2D)p1
                         andPoint:(CLLocationCoordinate2D)p2;

    Parameters

    p1

    First coordinate.

    p2

    Second coordinate.

    Return Value

    Heading calculated in DEGREES

  • Averages the location for a list of coordinates

    Since

    1.2

    Declaration

    Swift

    + (CLLocationCoordinate2D)averageOfCoordinates:
        (NSArray<NSValue *> *)coordinates;

    Parameters

    coordinates

    the list of coordinates to average

    Return Value

    the average point

  • Check if a point falls inside of a polygon or not

    Since

    1.2

    Declaration

    Swift

    + (BOOL)point:(CLLocationCoordinate2D)point
        isInPolygon:(NSArray<NSValue *> *)vertices;

    Parameters

    point

    the point to chekc

    vertices

    the points that make up the polygon

    Return Value

    true if the given point falls within the boundaries of the polygon