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.routeor.polygonfrom existing GeoJSON files containingLineString,Polygon,MultiLineString, orMultiPolygongeometries.Throws
DecodingErrorif the GeoJSON is invalid or cannot be parsed.Declaration
Swift
public static func extractCoordinates(from data: Data) throws -> [CLLocationCoordinate2D]Parameters
dataThe raw GeoJSON data.
Return Value
An array of
CLLocationCoordinate2Dextracted 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
stringThe GeoJSON string.
Return Value
An array of
CLLocationCoordinate2D.