MTGeoJSONParser

public struct MTGeoJSONParser : Sendable

A utility to parse GeoJSON and extract coordinates for use with offline regions or other geometry models.

  • Extracts a flat array of coordinates from a GeoJSON payload.

    This is particularly useful for generating MTOfflineRegionGeometry.route or .polygon from existing GeoJSON files containing LineString, Polygon, MultiLineString, or MultiPolygon geometries.

    Throws

    DecodingError if the GeoJSON is invalid or cannot be parsed.

    Declaration

    Swift

    public static func extractCoordinates(from data: Data) throws -> [CLLocationCoordinate2D]

    Parameters

    data

    The raw GeoJSON data.

    Return Value

    An array of CLLocationCoordinate2D extracted from the GeoJSON.

  • Extracts a flat array of coordinates from a GeoJSON string.

    Throws

    An error if the string is invalid or cannot be parsed.

    Declaration

    Swift

    public static func extractCoordinates(from string: String) throws -> [CLLocationCoordinate2D]

    Parameters

    string

    The GeoJSON string.

    Return Value

    An array of CLLocationCoordinate2D.