fixing Geo
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
|
||||
grpcproto "git.coopgo.io/coopgo-apps/silvermobi/servers/grpcapi/proto"
|
||||
"git.coopgo.io/coopgo-platform/routing-service"
|
||||
"github.com/google/uuid"
|
||||
"github.com/paulmach/orb/geojson"
|
||||
"github.com/rs/zerolog/log"
|
||||
@@ -52,6 +53,8 @@ func (s SilvermobiGRPCService) GeoRoute(ctx context.Context,
|
||||
req *grpcproto.GeoRouteRequest) (*grpcproto.GeoRouteResponse, error) {
|
||||
locationsRaw, ok := req.Locations.(*grpcproto.GeoRouteRequest_LocationsRaw)
|
||||
|
||||
var route *routing.Route
|
||||
|
||||
if !ok {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "could not read departure")
|
||||
}
|
||||
@@ -61,20 +64,22 @@ func (s SilvermobiGRPCService) GeoRoute(ctx context.Context,
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
if _, err = s.Handler.GeoRoute(*locations); err != nil {
|
||||
if route, err = s.Handler.GeoRoute(*locations); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
route, _ := s.Handler.GeoRoute(*locations)
|
||||
|
||||
return &grpcproto.GeoRouteResponse{
|
||||
Polyline: route.Polyline.String(),
|
||||
Polyline: route.Summary.Polyline,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s SilvermobiGRPCService) GeoRouteWithReturn(ctx context.Context,
|
||||
req *grpcproto.GeoRouteWithReturnRequest) (*grpcproto.GeoRouteWithReturnResponse, error) {
|
||||
|
||||
var (
|
||||
route, returnRoute *routing.Route
|
||||
)
|
||||
|
||||
locationsRaw, ok := req.Locations.(*grpcproto.GeoRouteWithReturnRequest_LocationsRaw)
|
||||
|
||||
if !ok {
|
||||
@@ -86,20 +91,16 @@ func (s SilvermobiGRPCService) GeoRouteWithReturn(ctx context.Context,
|
||||
return nil, status.Error(codes.Internal, err.Error())
|
||||
}
|
||||
|
||||
if _, err = s.Handler.GeoRoute(*locations); err != nil {
|
||||
if route, err = s.Handler.GeoRoute(*locations); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
route, _ := s.Handler.GeoRoute(*locations)
|
||||
|
||||
if _, err = s.Handler.GeoReturnRoute(*locations); err != nil {
|
||||
if returnRoute, err = s.Handler.GeoReturnRoute(*locations); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
returnRoute, _ := s.Handler.GeoReturnRoute(*locations)
|
||||
|
||||
return &grpcproto.GeoRouteWithReturnResponse{
|
||||
Polyline: route.Polyline.String(),
|
||||
ReturnPolyline: returnRoute.Polyline.String(),
|
||||
Polyline: route.Summary.Polyline,
|
||||
ReturnPolyline: returnRoute.Summary.Polyline,
|
||||
}, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user