go-mapbox icon indicating copy to clipboard operation
go-mapbox copied to clipboard

directions: doesn't support returning Geojson

Open d4l3k opened this issue 6 years ago • 2 comments

Hi, I ran into an issue when trying to get directions via this library. It doesn't seem to support getting Geojson from mapbox.

		geometry := directions.GeometryGeojson
		overview := directions.OverviewFull
		directions, err := mbox.Directions.GetDirections([]base.Location{
			{Latitude: bm.Latitude, Longitude: bm.Longitude},
			{Latitude: b.Latitude, Longitude: b.Longitude},
		}, directions.RoutingCycling, &directions.RequestOpts{
			Geometries: &geometry,
			Overview:   &overview,
		})
json: cannot unmarshal object into Go struct field Route.Geometry of type string

d4l3k avatar Sep 19 '18 04:09 d4l3k

Hey, thanks for the issue and sorry you've run into trouble! It looks like we haven't got support for GeoJSON Geometry in the directions api yet.

We did add support for GeoJSON Geometry types for the map matching API here, but that really needs to be refactored to the types package and added to the other components where relevant.

I'd be happy to accept a PR if you're interested in opening one! Otherwise I'll put it on my list of things to fix ^_^

ryankurte avatar Sep 21 '18 15:09 ryankurte

I ended up just using the default type and parsing then manually manipulating it into geojson format.

https://github.com/d4l3k/dropbike-visualizer/blob/master/process.go#L112

On Fri, Sep 21, 2018, 08:48 Ryan [email protected] wrote:

Hey, thanks for the issue and sorry you've run into trouble! It looks like we haven't got support for GeoJSON Geometry in the directions api yet.

We did add support for GeoJSON Geometry types for the map matching API here https://github.com/ryankurte/go-mapbox/commit/eaf7747d61aaa7fba9de4b18ec9117dd3d318fe0, but that really needs to be refactored to the types https://github.com/ryankurte/go-mapbox/blob/master/lib/directions/types.go package and added to the other components where relevant.

I'd be happy to accept a PR if you're interested in opening one! Otherwise I'll put it on my list of things to fix ^_^

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/ryankurte/go-mapbox/issues/25#issuecomment-423581046, or mute the thread https://github.com/notifications/unsubscribe-auth/AA3fMNH5PjNPGDl1_XoE9-_1pcg8v-Eeks5udQo1gaJpZM4WvX4y .

d4l3k avatar Sep 21 '18 17:09 d4l3k