fixing Geo
This commit is contained in:
@@ -3,9 +3,9 @@ package handler
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
routing "git.coopgo.io/coopgo-platform/routing-service"
|
||||
"github.com/paulmach/orb"
|
||||
"github.com/paulmach/orb/geojson"
|
||||
"google.golang.org/genproto/googleapis/maps/routing/v2"
|
||||
)
|
||||
|
||||
func (h *SilverMobiHandler) GeoAutocomplete(text string) (*geojson.FeatureCollection, error) {
|
||||
@@ -23,7 +23,9 @@ func (h *SilverMobiHandler) GeoRoute(locations geojson.FeatureCollection) (route
|
||||
)
|
||||
|
||||
for _, f := range locations.Features {
|
||||
|
||||
ft := f.Geometry.GeoJSONType()
|
||||
|
||||
if ft != featuresType {
|
||||
return nil, fmt.Errorf("mixing different types of geometries in"+
|
||||
" the feature collection is not allowed : %s and %s found", featuresType, ft)
|
||||
@@ -34,11 +36,15 @@ func (h *SilverMobiHandler) GeoRoute(locations geojson.FeatureCollection) (route
|
||||
if featuresType == "Point" {
|
||||
if point, ok := f.Geometry.(orb.Point); ok {
|
||||
routeLocations = append(routeLocations, point)
|
||||
} else {
|
||||
return nil, fmt.Errorf("invalid geometry type for point")
|
||||
}
|
||||
} else {
|
||||
return nil, fmt.Errorf("feature type %s not supported", featuresType)
|
||||
}
|
||||
}
|
||||
|
||||
if route, err = h.Services.Routing.Route(routeLocations); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user