# Routing ## Calculate a route between two points `client.Routing.Route(ctx, body) (*RouteResult, error)` **post** `/api/v1/route` Calculate a route between two points ### Parameters - `body RoutingRouteParams` - `RouteRequest param.Field[RouteRequest]` Request body for route calculation. Origin and destination are lat/lng coordinate objects. Supports optional waypoints, alternative routes, turn-by-turn steps, and EV routing parameters. ### Returns - `type RouteResult struct{…}` GeoJSON Feature representing a calculated route. The geometry is a LineString or MultiLineString of the route path. When `alternatives > 0`, the response is a FeatureCollection containing multiple route Features. - `Geometry GeoJsonGeometry` GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints. - `Coordinates GeoJsonGeometryCoordinatesUnion` Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc. - `type GeoJsonGeometryCoordinatesPoint []float64` [longitude, latitude] or [longitude, latitude, elevation] - `type GeoJsonGeometryCoordinatesLineStringOrMultiPoint [][]float64` Array of [lng, lat] positions - `type GeoJsonGeometryCoordinatesPolygonOrMultiLineString [][][]float64` Array of linear rings / line strings - `type GeoJsonGeometryCoordinatesMultiPolygon [][][][]float64` Array of polygons - `Type GeoJsonGeometryType` Geometry type - `const GeoJsonGeometryTypePoint GeoJsonGeometryType = "Point"` - `const GeoJsonGeometryTypeLineString GeoJsonGeometryType = "LineString"` - `const GeoJsonGeometryTypePolygon GeoJsonGeometryType = "Polygon"` - `const GeoJsonGeometryTypeMultiPoint GeoJsonGeometryType = "MultiPoint"` - `const GeoJsonGeometryTypeMultiLineString GeoJsonGeometryType = "MultiLineString"` - `const GeoJsonGeometryTypeMultiPolygon GeoJsonGeometryType = "MultiPolygon"` - `Properties RouteResultProperties` Route metadata - `DistanceM float64` Total route distance in meters - `DurationS float64` Estimated travel duration in seconds - `Annotations map[string, unknown]` Per-edge annotations (present when `annotations: true` in request) - `ChargeProfile [][]float64` Battery charge level at route waypoints as [distance_fraction, charge_pct] pairs (EV routes only) - `ChargingStops []map[string, unknown]` Recommended charging stops along the route (EV routes only) - `Edges []map[string, unknown]` Edge-level route details (present when `annotations: true`) - `EnergyUsedWh float64` Total energy consumed in watt-hours (EV routes only) - `Type RouteResultType` - `const RouteResultTypeFeature RouteResultType = "Feature"` ### Example ```go package main import ( "context" "fmt" "github.com/plazafyi/plaza-go" "github.com/plazafyi/plaza-go/option" ) func main() { client := githubcomplazafyiplazago.NewClient( option.WithAPIKey("My API Key"), ) routeResult, err := client.Routing.Route(context.TODO(), githubcomplazafyiplazago.RoutingRouteParams{ RouteRequest: githubcomplazafyiplazago.RouteRequestParam{ Destination: githubcomplazafyiplazago.F(githubcomplazafyiplazago.RouteRequestDestinationParam{ Lat: githubcomplazafyiplazago.F(48.858400), Lng: githubcomplazafyiplazago.F(2.294500), }), Origin: githubcomplazafyiplazago.F(githubcomplazafyiplazago.RouteRequestOriginParam{ Lat: githubcomplazafyiplazago.F(48.856600), Lng: githubcomplazafyiplazago.F(2.352200), }), }, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", routeResult.Geometry) } ``` #### Response ```json { "geometry": { "coordinates": [ 2.3522, 48.8566 ], "type": "Point" }, "properties": { "distance_m": 4523.7, "duration_s": 847.2, "annotations": { "foo": "bar" }, "charge_profile": [ [ 0 ] ], "charging_stops": [ { "foo": "bar" } ], "edges": [ { "foo": "bar" } ], "energy_used_wh": 0 }, "type": "Feature" } ``` ## Snap a coordinate to the nearest road `client.Routing.Nearest(ctx, query) (*NearestResult, error)` **get** `/api/v1/nearest` Snap a coordinate to the nearest road ### Parameters - `query RoutingNearestParams` - `Lat param.Field[float64]` Latitude - `Lng param.Field[float64]` Longitude - `OutputFields param.Field[string]` Comma-separated property fields to include - `OutputInclude param.Field[string]` Extra computed fields: bbox, distance, center - `OutputPrecision param.Field[int64]` Coordinate decimal precision (1-15, default 7) - `Radius param.Field[int64]` Search radius in meters (default 500, max 5000) ### Returns - `type NearestResult struct{…}` GeoJSON Point Feature representing the nearest point on the road network to the input coordinate. Used for snapping GPS coordinates to roads. - `Geometry GeoJsonGeometry` GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints. - `Coordinates GeoJsonGeometryCoordinatesUnion` Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc. - `type GeoJsonGeometryCoordinatesPoint []float64` [longitude, latitude] or [longitude, latitude, elevation] - `type GeoJsonGeometryCoordinatesLineStringOrMultiPoint [][]float64` Array of [lng, lat] positions - `type GeoJsonGeometryCoordinatesPolygonOrMultiLineString [][][]float64` Array of linear rings / line strings - `type GeoJsonGeometryCoordinatesMultiPolygon [][][][]float64` Array of polygons - `Type GeoJsonGeometryType` Geometry type - `const GeoJsonGeometryTypePoint GeoJsonGeometryType = "Point"` - `const GeoJsonGeometryTypeLineString GeoJsonGeometryType = "LineString"` - `const GeoJsonGeometryTypePolygon GeoJsonGeometryType = "Polygon"` - `const GeoJsonGeometryTypeMultiPoint GeoJsonGeometryType = "MultiPoint"` - `const GeoJsonGeometryTypeMultiLineString GeoJsonGeometryType = "MultiLineString"` - `const GeoJsonGeometryTypeMultiPolygon GeoJsonGeometryType = "MultiPolygon"` - `Properties NearestResultProperties` Snap result metadata - `DistanceM float64` Distance from the input coordinate to the snapped point in meters - `EdgeID int64` ID of the road network edge that was snapped to - `EdgeLengthM float64` Length of the matched road edge in meters - `Highway string` OSM highway tag value (e.g. `residential`, `primary`, `motorway`) - `OsmWayID int64` OSM way ID of the matched road segment - `Surface string` OSM surface tag value (e.g. `asphalt`, `gravel`, `paved`) - `Type NearestResultType` - `const NearestResultTypeFeature NearestResultType = "Feature"` ### Example ```go package main import ( "context" "fmt" "github.com/plazafyi/plaza-go" "github.com/plazafyi/plaza-go/option" ) func main() { client := githubcomplazafyiplazago.NewClient( option.WithAPIKey("My API Key"), ) nearestResult, err := client.Routing.Nearest(context.TODO(), githubcomplazafyiplazago.RoutingNearestParams{ Lat: githubcomplazafyiplazago.F(0.000000), Lng: githubcomplazafyiplazago.F(0.000000), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", nearestResult.Geometry) } ``` #### Response ```json { "geometry": { "coordinates": [ 2.3522, 48.8566 ], "type": "Point" }, "properties": { "distance_m": 12.4, "edge_id": 0, "edge_length_m": 0, "highway": "highway", "osm_way_id": 0, "surface": "surface" }, "type": "Feature" } ``` ## Snap a coordinate to the nearest road `client.Routing.NearestPost(ctx, body) (*NearestResult, error)` **post** `/api/v1/nearest` Snap a coordinate to the nearest road ### Parameters - `body RoutingNearestPostParams` - `Lat param.Field[float64]` Latitude - `Lng param.Field[float64]` Longitude - `OutputFields param.Field[string]` Comma-separated property fields to include - `OutputInclude param.Field[string]` Extra computed fields: bbox, distance, center - `OutputPrecision param.Field[int64]` Coordinate decimal precision (1-15, default 7) - `Radius param.Field[int64]` Search radius in meters (default 500, max 5000) ### Returns - `type NearestResult struct{…}` GeoJSON Point Feature representing the nearest point on the road network to the input coordinate. Used for snapping GPS coordinates to roads. - `Geometry GeoJsonGeometry` GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints. - `Coordinates GeoJsonGeometryCoordinatesUnion` Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc. - `type GeoJsonGeometryCoordinatesPoint []float64` [longitude, latitude] or [longitude, latitude, elevation] - `type GeoJsonGeometryCoordinatesLineStringOrMultiPoint [][]float64` Array of [lng, lat] positions - `type GeoJsonGeometryCoordinatesPolygonOrMultiLineString [][][]float64` Array of linear rings / line strings - `type GeoJsonGeometryCoordinatesMultiPolygon [][][][]float64` Array of polygons - `Type GeoJsonGeometryType` Geometry type - `const GeoJsonGeometryTypePoint GeoJsonGeometryType = "Point"` - `const GeoJsonGeometryTypeLineString GeoJsonGeometryType = "LineString"` - `const GeoJsonGeometryTypePolygon GeoJsonGeometryType = "Polygon"` - `const GeoJsonGeometryTypeMultiPoint GeoJsonGeometryType = "MultiPoint"` - `const GeoJsonGeometryTypeMultiLineString GeoJsonGeometryType = "MultiLineString"` - `const GeoJsonGeometryTypeMultiPolygon GeoJsonGeometryType = "MultiPolygon"` - `Properties NearestResultProperties` Snap result metadata - `DistanceM float64` Distance from the input coordinate to the snapped point in meters - `EdgeID int64` ID of the road network edge that was snapped to - `EdgeLengthM float64` Length of the matched road edge in meters - `Highway string` OSM highway tag value (e.g. `residential`, `primary`, `motorway`) - `OsmWayID int64` OSM way ID of the matched road segment - `Surface string` OSM surface tag value (e.g. `asphalt`, `gravel`, `paved`) - `Type NearestResultType` - `const NearestResultTypeFeature NearestResultType = "Feature"` ### Example ```go package main import ( "context" "fmt" "github.com/plazafyi/plaza-go" "github.com/plazafyi/plaza-go/option" ) func main() { client := githubcomplazafyiplazago.NewClient( option.WithAPIKey("My API Key"), ) nearestResult, err := client.Routing.NearestPost(context.TODO(), githubcomplazafyiplazago.RoutingNearestPostParams{ Lat: githubcomplazafyiplazago.F(0.000000), Lng: githubcomplazafyiplazago.F(0.000000), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", nearestResult.Geometry) } ``` #### Response ```json { "geometry": { "coordinates": [ 2.3522, 48.8566 ], "type": "Point" }, "properties": { "distance_m": 12.4, "edge_id": 0, "edge_length_m": 0, "highway": "highway", "osm_way_id": 0, "surface": "surface" }, "type": "Feature" } ``` ## Calculate an isochrone from a point `client.Routing.Isochrone(ctx, query) (*RoutingIsochroneResponse, error)` **get** `/api/v1/isochrone` Calculate an isochrone from a point ### Parameters - `query RoutingIsochroneParams` - `Lat param.Field[float64]` Latitude - `Lng param.Field[float64]` Longitude - `Time param.Field[float64]` Travel time in seconds (1-7200) - `Mode param.Field[string]` Travel mode (auto, foot, bicycle) - `OutputFields param.Field[string]` Comma-separated property fields to include - `OutputGeometry param.Field[bool]` Include geometry (default true) - `OutputInclude param.Field[string]` Extra computed fields: bbox, center - `OutputPrecision param.Field[int64]` Coordinate decimal precision (1-15, default 7) - `OutputSimplify param.Field[float64]` Simplify geometry tolerance in meters ### Returns - `type RoutingIsochroneResponse struct{…}` GeoJSON Feature or FeatureCollection representing isochrone polygons — areas reachable within the specified travel time(s). Single time value returns a Feature; comma-separated times return a FeatureCollection with one polygon per contour. - `Features []GeoJsonFeature` Array of isochrone polygon Features (multi-contour only) - `Geometry GeoJsonGeometry` GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints. - `Coordinates GeoJsonGeometryCoordinatesUnion` Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc. - `type GeoJsonGeometryCoordinatesPoint []float64` [longitude, latitude] or [longitude, latitude, elevation] - `type GeoJsonGeometryCoordinatesLineStringOrMultiPoint [][]float64` Array of [lng, lat] positions - `type GeoJsonGeometryCoordinatesPolygonOrMultiLineString [][][]float64` Array of linear rings / line strings - `type GeoJsonGeometryCoordinatesMultiPolygon [][][][]float64` Array of polygons - `Type GeoJsonGeometryType` Geometry type - `const GeoJsonGeometryTypePoint GeoJsonGeometryType = "Point"` - `const GeoJsonGeometryTypeLineString GeoJsonGeometryType = "LineString"` - `const GeoJsonGeometryTypePolygon GeoJsonGeometryType = "Polygon"` - `const GeoJsonGeometryTypeMultiPoint GeoJsonGeometryType = "MultiPoint"` - `const GeoJsonGeometryTypeMultiLineString GeoJsonGeometryType = "MultiLineString"` - `const GeoJsonGeometryTypeMultiPolygon GeoJsonGeometryType = "MultiPolygon"` - `Properties map[string, unknown]` OSM tags flattened as key-value pairs, plus `@type` (node/way/relation) and `@id` (OSM ID) metadata fields. May include `distance_m` for proximity queries. - `Type GeoJsonFeatureType` Always `Feature` - `const GeoJsonFeatureTypeFeature GeoJsonFeatureType = "Feature"` - `ID string` Compound identifier in `type/osm_id` format - `Geometry GeoJsonGeometry` GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints. - `Properties RoutingIsochroneResponseProperties` Isochrone metadata - `AreaM2 float64` Area of the isochrone polygon in square meters (multi-contour features only) - `MaxCostS float64` Maximum actual travel cost in seconds to the isochrone boundary (single contour only) - `Mode RoutingIsochroneResponsePropertiesMode` Travel mode used for the isochrone calculation - `const RoutingIsochroneResponsePropertiesModeAuto RoutingIsochroneResponsePropertiesMode = "auto"` - `const RoutingIsochroneResponsePropertiesModeFoot RoutingIsochroneResponsePropertiesMode = "foot"` - `const RoutingIsochroneResponsePropertiesModeBicycle RoutingIsochroneResponsePropertiesMode = "bicycle"` - `TimeSeconds float64` Travel time budget in seconds - `VerticesReached int64` Number of road network vertices within the isochrone - `Type RoutingIsochroneResponseType` `Feature` for single contour, `FeatureCollection` for multiple contours - `const RoutingIsochroneResponseTypeFeature RoutingIsochroneResponseType = "Feature"` - `const RoutingIsochroneResponseTypeFeatureCollection RoutingIsochroneResponseType = "FeatureCollection"` ### Example ```go package main import ( "context" "fmt" "github.com/plazafyi/plaza-go" "github.com/plazafyi/plaza-go/option" ) func main() { client := githubcomplazafyiplazago.NewClient( option.WithAPIKey("My API Key"), ) response, err := client.Routing.Isochrone(context.TODO(), githubcomplazafyiplazago.RoutingIsochroneParams{ Lat: githubcomplazafyiplazago.F(0.000000), Lng: githubcomplazafyiplazago.F(0.000000), Time: githubcomplazafyiplazago.F(0.000000), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Features) } ``` #### Response ```json { "features": [ { "geometry": { "coordinates": [ 2.3522, 48.8566 ], "type": "Point" }, "properties": { "@id": "bar", "@type": "bar", "amenity": "bar", "cuisine": "bar", "name": "bar" }, "type": "Feature", "id": "node/21154906" } ], "geometry": { "coordinates": [ 2.3522, 48.8566 ], "type": "Point" }, "properties": { "area_m2": 0, "max_cost_s": 0, "mode": "auto", "time_seconds": 0, "vertices_reached": 0 }, "type": "Feature" } ``` ## Calculate an isochrone from a point `client.Routing.IsochronePost(ctx, body) (*RoutingIsochronePostResponse, error)` **post** `/api/v1/isochrone` Calculate an isochrone from a point ### Parameters - `body RoutingIsochronePostParams` - `Lat param.Field[float64]` Latitude - `Lng param.Field[float64]` Longitude - `Time param.Field[float64]` Travel time in seconds (1-7200) - `Mode param.Field[string]` Travel mode (auto, foot, bicycle) - `OutputFields param.Field[string]` Comma-separated property fields to include - `OutputGeometry param.Field[bool]` Include geometry (default true) - `OutputInclude param.Field[string]` Extra computed fields: bbox, center - `OutputPrecision param.Field[int64]` Coordinate decimal precision (1-15, default 7) - `OutputSimplify param.Field[float64]` Simplify geometry tolerance in meters ### Returns - `type RoutingIsochronePostResponse struct{…}` GeoJSON Feature or FeatureCollection representing isochrone polygons — areas reachable within the specified travel time(s). Single time value returns a Feature; comma-separated times return a FeatureCollection with one polygon per contour. - `Features []GeoJsonFeature` Array of isochrone polygon Features (multi-contour only) - `Geometry GeoJsonGeometry` GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints. - `Coordinates GeoJsonGeometryCoordinatesUnion` Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc. - `type GeoJsonGeometryCoordinatesPoint []float64` [longitude, latitude] or [longitude, latitude, elevation] - `type GeoJsonGeometryCoordinatesLineStringOrMultiPoint [][]float64` Array of [lng, lat] positions - `type GeoJsonGeometryCoordinatesPolygonOrMultiLineString [][][]float64` Array of linear rings / line strings - `type GeoJsonGeometryCoordinatesMultiPolygon [][][][]float64` Array of polygons - `Type GeoJsonGeometryType` Geometry type - `const GeoJsonGeometryTypePoint GeoJsonGeometryType = "Point"` - `const GeoJsonGeometryTypeLineString GeoJsonGeometryType = "LineString"` - `const GeoJsonGeometryTypePolygon GeoJsonGeometryType = "Polygon"` - `const GeoJsonGeometryTypeMultiPoint GeoJsonGeometryType = "MultiPoint"` - `const GeoJsonGeometryTypeMultiLineString GeoJsonGeometryType = "MultiLineString"` - `const GeoJsonGeometryTypeMultiPolygon GeoJsonGeometryType = "MultiPolygon"` - `Properties map[string, unknown]` OSM tags flattened as key-value pairs, plus `@type` (node/way/relation) and `@id` (OSM ID) metadata fields. May include `distance_m` for proximity queries. - `Type GeoJsonFeatureType` Always `Feature` - `const GeoJsonFeatureTypeFeature GeoJsonFeatureType = "Feature"` - `ID string` Compound identifier in `type/osm_id` format - `Geometry GeoJsonGeometry` GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints. - `Properties RoutingIsochronePostResponseProperties` Isochrone metadata - `AreaM2 float64` Area of the isochrone polygon in square meters (multi-contour features only) - `MaxCostS float64` Maximum actual travel cost in seconds to the isochrone boundary (single contour only) - `Mode RoutingIsochronePostResponsePropertiesMode` Travel mode used for the isochrone calculation - `const RoutingIsochronePostResponsePropertiesModeAuto RoutingIsochronePostResponsePropertiesMode = "auto"` - `const RoutingIsochronePostResponsePropertiesModeFoot RoutingIsochronePostResponsePropertiesMode = "foot"` - `const RoutingIsochronePostResponsePropertiesModeBicycle RoutingIsochronePostResponsePropertiesMode = "bicycle"` - `TimeSeconds float64` Travel time budget in seconds - `VerticesReached int64` Number of road network vertices within the isochrone - `Type RoutingIsochronePostResponseType` `Feature` for single contour, `FeatureCollection` for multiple contours - `const RoutingIsochronePostResponseTypeFeature RoutingIsochronePostResponseType = "Feature"` - `const RoutingIsochronePostResponseTypeFeatureCollection RoutingIsochronePostResponseType = "FeatureCollection"` ### Example ```go package main import ( "context" "fmt" "github.com/plazafyi/plaza-go" "github.com/plazafyi/plaza-go/option" ) func main() { client := githubcomplazafyiplazago.NewClient( option.WithAPIKey("My API Key"), ) response, err := client.Routing.IsochronePost(context.TODO(), githubcomplazafyiplazago.RoutingIsochronePostParams{ Lat: githubcomplazafyiplazago.F(0.000000), Lng: githubcomplazafyiplazago.F(0.000000), Time: githubcomplazafyiplazago.F(0.000000), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.Features) } ``` #### Response ```json { "features": [ { "geometry": { "coordinates": [ 2.3522, 48.8566 ], "type": "Point" }, "properties": { "@id": "bar", "@type": "bar", "amenity": "bar", "cuisine": "bar", "name": "bar" }, "type": "Feature", "id": "node/21154906" } ], "geometry": { "coordinates": [ 2.3522, 48.8566 ], "type": "Point" }, "properties": { "area_m2": 0, "max_cost_s": 0, "mode": "auto", "time_seconds": 0, "vertices_reached": 0 }, "type": "Feature" } ``` ## Calculate a distance matrix between points `client.Routing.Matrix(ctx, body) (*MatrixResult, error)` **post** `/api/v1/matrix` Calculate a distance matrix between points ### Parameters - `body RoutingMatrixParams` - `MatrixRequest param.Field[MatrixRequest]` Request body for distance matrix calculation. Computes travel durations (and optionally distances) between every origin-destination pair. Maximum 2,500 pairs (origins × destinations), each list capped at 50 coordinates. ### Returns - `type MatrixResult map[string, unknown]` Distance matrix result. The exact response shape depends on the routing backend. Contains duration (and optionally distance) data for all origin-destination pairs. Null values indicate unreachable pairs. ### Example ```go package main import ( "context" "fmt" "github.com/plazafyi/plaza-go" "github.com/plazafyi/plaza-go/option" ) func main() { client := githubcomplazafyiplazago.NewClient( option.WithAPIKey("My API Key"), ) matrixResult, err := client.Routing.Matrix(context.TODO(), githubcomplazafyiplazago.RoutingMatrixParams{ MatrixRequest: githubcomplazafyiplazago.MatrixRequestParam{ Destinations: githubcomplazafyiplazago.F([]githubcomplazafyiplazago.MatrixRequestDestinationParam{githubcomplazafyiplazago.MatrixRequestDestinationParam{ Lat: githubcomplazafyiplazago.F(48.858400), Lng: githubcomplazafyiplazago.F(2.294500), }}), Origins: githubcomplazafyiplazago.F([]githubcomplazafyiplazago.MatrixRequestOriginParam{githubcomplazafyiplazago.MatrixRequestOriginParam{ Lat: githubcomplazafyiplazago.F(48.856600), Lng: githubcomplazafyiplazago.F(2.352200), }, githubcomplazafyiplazago.MatrixRequestOriginParam{ Lat: githubcomplazafyiplazago.F(48.860600), Lng: githubcomplazafyiplazago.F(2.337600), }}), }, }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", matrixResult) } ``` #### Response ```json { "foo": "bar" } ``` ## Domain Types ### Matrix Request - `type MatrixRequest struct{…}` Request body for distance matrix calculation. Computes travel durations (and optionally distances) between every origin-destination pair. Maximum 2,500 pairs (origins × destinations), each list capped at 50 coordinates. - `Destinations []MatrixRequestDestination` Array of destination coordinates (max 50) - `Lat float64` Latitude in decimal degrees (-90 to 90) - `Lng float64` Longitude in decimal degrees (-180 to 180) - `Origins []MatrixRequestOrigin` Array of origin coordinates (max 50) - `Lat float64` Latitude in decimal degrees (-90 to 90) - `Lng float64` Longitude in decimal degrees (-180 to 180) - `Annotations string` Comma-separated list of annotations to include: `duration` (always included), `distance`. Example: `duration,distance`. - `FallbackSpeed float64` Fallback speed in km/h for pairs where no route exists. When set, unreachable pairs get estimated values instead of null. - `Mode MatrixRequestMode` Travel mode (default: `auto`) - `const MatrixRequestModeAuto MatrixRequestMode = "auto"` - `const MatrixRequestModeFoot MatrixRequestMode = "foot"` - `const MatrixRequestModeBicycle MatrixRequestMode = "bicycle"` ### Matrix Result - `type MatrixResult map[string, unknown]` Distance matrix result. The exact response shape depends on the routing backend. Contains duration (and optionally distance) data for all origin-destination pairs. Null values indicate unreachable pairs. ### Nearest Result - `type NearestResult struct{…}` GeoJSON Point Feature representing the nearest point on the road network to the input coordinate. Used for snapping GPS coordinates to roads. - `Geometry GeoJsonGeometry` GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints. - `Coordinates GeoJsonGeometryCoordinatesUnion` Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc. - `type GeoJsonGeometryCoordinatesPoint []float64` [longitude, latitude] or [longitude, latitude, elevation] - `type GeoJsonGeometryCoordinatesLineStringOrMultiPoint [][]float64` Array of [lng, lat] positions - `type GeoJsonGeometryCoordinatesPolygonOrMultiLineString [][][]float64` Array of linear rings / line strings - `type GeoJsonGeometryCoordinatesMultiPolygon [][][][]float64` Array of polygons - `Type GeoJsonGeometryType` Geometry type - `const GeoJsonGeometryTypePoint GeoJsonGeometryType = "Point"` - `const GeoJsonGeometryTypeLineString GeoJsonGeometryType = "LineString"` - `const GeoJsonGeometryTypePolygon GeoJsonGeometryType = "Polygon"` - `const GeoJsonGeometryTypeMultiPoint GeoJsonGeometryType = "MultiPoint"` - `const GeoJsonGeometryTypeMultiLineString GeoJsonGeometryType = "MultiLineString"` - `const GeoJsonGeometryTypeMultiPolygon GeoJsonGeometryType = "MultiPolygon"` - `Properties NearestResultProperties` Snap result metadata - `DistanceM float64` Distance from the input coordinate to the snapped point in meters - `EdgeID int64` ID of the road network edge that was snapped to - `EdgeLengthM float64` Length of the matched road edge in meters - `Highway string` OSM highway tag value (e.g. `residential`, `primary`, `motorway`) - `OsmWayID int64` OSM way ID of the matched road segment - `Surface string` OSM surface tag value (e.g. `asphalt`, `gravel`, `paved`) - `Type NearestResultType` - `const NearestResultTypeFeature NearestResultType = "Feature"` ### Route Request - `type RouteRequest struct{…}` Request body for route calculation. Origin and destination are lat/lng coordinate objects. Supports optional waypoints, alternative routes, turn-by-turn steps, and EV routing parameters. - `Destination RouteRequestDestination` Geographic coordinate as a JSON object with `lat` and `lng` fields. - `Lat float64` Latitude in decimal degrees (-90 to 90) - `Lng float64` Longitude in decimal degrees (-180 to 180) - `Origin RouteRequestOrigin` Geographic coordinate as a JSON object with `lat` and `lng` fields. - `Lat float64` Latitude in decimal degrees (-90 to 90) - `Lng float64` Longitude in decimal degrees (-180 to 180) - `Alternatives int64` Number of alternative routes to return (0-3, default 0). When > 0, response is a FeatureCollection of route Features. - `Annotations bool` Include per-edge annotations (speed, duration) on the route (default: false) - `DepartAt Time` Departure time for traffic-aware routing (ISO 8601) - `Ev RouteRequestEv` Electric vehicle parameters for EV-aware routing - `BatteryCapacityWh float64` Total battery capacity in watt-hours (required for EV routing) - `ConnectorTypes []string` Acceptable connector types (e.g. `["ccs", "chademo"]`) - `InitialChargePct float64` Starting charge as a fraction 0-1 (default: 0.8) - `MinChargePct float64` Minimum acceptable charge at destination as a fraction 0-1 (default: 0.10) - `MinPowerKw float64` Minimum charger power in kilowatts - `Exclude string` Comma-separated road types to exclude (e.g. `toll,motorway,ferry`) - `Geometries RouteRequestGeometries` Geometry encoding format. Default: `geojson`. - `const RouteRequestGeometriesGeojson RouteRequestGeometries = "geojson"` - `const RouteRequestGeometriesPolyline RouteRequestGeometries = "polyline"` - `const RouteRequestGeometriesPolyline6 RouteRequestGeometries = "polyline6"` - `Mode RouteRequestMode` Travel mode (default: `auto`) - `const RouteRequestModeAuto RouteRequestMode = "auto"` - `const RouteRequestModeFoot RouteRequestMode = "foot"` - `const RouteRequestModeBicycle RouteRequestMode = "bicycle"` - `Overview RouteRequestOverview` Level of geometry detail: `full` (all points), `simplified` (Douglas-Peucker), `false` (no geometry). Default: `full`. - `const RouteRequestOverviewFull RouteRequestOverview = "full"` - `const RouteRequestOverviewSimplified RouteRequestOverview = "simplified"` - `const RouteRequestOverviewFalse RouteRequestOverview = "false"` - `Steps bool` Include turn-by-turn navigation steps (default: false) - `TrafficModel RouteRequestTrafficModel` Traffic prediction model (only used when `depart_at` is set) - `const RouteRequestTrafficModelBestGuess RouteRequestTrafficModel = "best_guess"` - `const RouteRequestTrafficModelOptimistic RouteRequestTrafficModel = "optimistic"` - `const RouteRequestTrafficModelPessimistic RouteRequestTrafficModel = "pessimistic"` - `Waypoints []RouteRequestWaypoint` Intermediate waypoints to visit in order (maximum 25) - `Lat float64` Latitude in decimal degrees (-90 to 90) - `Lng float64` Longitude in decimal degrees (-180 to 180) ### Route Result - `type RouteResult struct{…}` GeoJSON Feature representing a calculated route. The geometry is a LineString or MultiLineString of the route path. When `alternatives > 0`, the response is a FeatureCollection containing multiple route Features. - `Geometry GeoJsonGeometry` GeoJSON Geometry object per RFC 7946. Coordinates use [longitude, latitude] order. 3D coordinates [lng, lat, elevation] are used for elevation endpoints. - `Coordinates GeoJsonGeometryCoordinatesUnion` Coordinates array. Nesting depth varies by geometry type: Point = [lng, lat], LineString = [[lng, lat], ...], Polygon = [[[lng, lat], ...], ...], etc. - `type GeoJsonGeometryCoordinatesPoint []float64` [longitude, latitude] or [longitude, latitude, elevation] - `type GeoJsonGeometryCoordinatesLineStringOrMultiPoint [][]float64` Array of [lng, lat] positions - `type GeoJsonGeometryCoordinatesPolygonOrMultiLineString [][][]float64` Array of linear rings / line strings - `type GeoJsonGeometryCoordinatesMultiPolygon [][][][]float64` Array of polygons - `Type GeoJsonGeometryType` Geometry type - `const GeoJsonGeometryTypePoint GeoJsonGeometryType = "Point"` - `const GeoJsonGeometryTypeLineString GeoJsonGeometryType = "LineString"` - `const GeoJsonGeometryTypePolygon GeoJsonGeometryType = "Polygon"` - `const GeoJsonGeometryTypeMultiPoint GeoJsonGeometryType = "MultiPoint"` - `const GeoJsonGeometryTypeMultiLineString GeoJsonGeometryType = "MultiLineString"` - `const GeoJsonGeometryTypeMultiPolygon GeoJsonGeometryType = "MultiPolygon"` - `Properties RouteResultProperties` Route metadata - `DistanceM float64` Total route distance in meters - `DurationS float64` Estimated travel duration in seconds - `Annotations map[string, unknown]` Per-edge annotations (present when `annotations: true` in request) - `ChargeProfile [][]float64` Battery charge level at route waypoints as [distance_fraction, charge_pct] pairs (EV routes only) - `ChargingStops []map[string, unknown]` Recommended charging stops along the route (EV routes only) - `Edges []map[string, unknown]` Edge-level route details (present when `annotations: true`) - `EnergyUsedWh float64` Total energy consumed in watt-hours (EV routes only) - `Type RouteResultType` - `const RouteResultTypeFeature RouteResultType = "Feature"`