liodali / OSM-Routing-Client-Dart

flutter package for osrm client api and open source routing service
https://pub.dev/packages/routing_client_dart
MIT License
18 stars 12 forks source link

Hi, i'm not understand why the return is equals in three parameter. Can you help-me #5

Closed AlysonTrizotto closed 2 years ago

AlysonTrizotto commented 2 years ago

I'm getting the coordinates passed by 'manager.getTrip(...)' and collecting the return of the following parameter 'List result = decodePolyline(road.polylineEncoded.toString());' However, the return only gives me 3 coordinates. And my goal is to create a route with polylines, can you tell me why I'm trying to return the same coordinates?

//Here's an example of how I'm collecting the coordinates. ` Future routeHelper() async { late List ponto = []; double latPoint = 0.0; double longPoint = 0.0;

points.clear();

List<LngLat> waypoints = [
  LngLat(lat: latLng.latitude, lng: latLng.longitude),
  LngLat(lat: currentCenter.latitude, lng: currentCenter.longitude),
];
print('WAYPOINTS');
print(waypoints);

final manager = OSRMManager();
final road = await manager.getTrip(
  waypoints: waypoints,
  roundTrip:true,
  destination: DestinationGeoPointOption.last,
  source: SourceGeoPointOption.first,
  geometry: Geometries.polyline,
  steps: true,
  languageCode: "en",
);

List resultado = decodePolyline(road.polylineEncoded.toString());
await Future.delayed(Duration(seconds: 1));

setState(() {
  print(resultado);
  for (int x = 0; x < resultado.length; x++) {
    List passagem = resultado[x];
    print(passagem);
    points.add(LatLng(passagem[0], passagem[1]));
  }
  print('points');
  print(points);
});

}`

//Debugger output follows

I/flutter (31741): [LatLng(latitude:-25.51185, longitude:-49.16439), LatLng(latitude:-25.51185, longitude:-49.16439)] I/flutter (31741): WAYPOINTS I/flutter (31741): [-49.1645689,-25.5120383, -49.1645689,-25.5120383] I/flutter (31741): [[-25.51185, -49.16439], [-25.51185, -49.16439], [-25.51185, -49.16439]] I/flutter (31741): [-25.51185, -49.16439] I/chatty (31741): uid=10289(alysontrizotto.github.io.localiza_favoritos) 1.ui identical 1 line I/flutter (31741): [-25.51185, -49.16439] I/flutter (31741): points I/flutter (31741): [LatLng(latitude:-25.51185, longitude:-49.16439), LatLng(latitude:-25.51185, longitude:-49.16439), LatLng(latitude:-25.51185, longitude:-49.16439)]

liodali commented 2 years ago

I will check and i will told you what is the problem

AlysonTrizotto commented 2 years ago

It's ok

AlysonTrizotto commented 2 years ago

Do you have any news about the problem?

liodali commented 2 years ago

you're putting the same starting point, If you want to get back to the start point just make roundTrip true and destination:DestinationGeoPointOption.any and change the last point to another point

AlysonTrizotto commented 2 years ago

Right, I had put this issue aside and focused on solving other things, when I decided to go back to work I found the problem lol... It worked