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

Polyline won't show up #8

Open pariterre opened 2 years ago

pariterre commented 2 years ago

Hello!

Thanks for this routing interface! Really useful stuff :)

I am not sure if I am not using the API properly but ot seems that only Geometries.geojson returns roads in the polyline attribute. The other (polyline and polyline6) always return null (in both getRoad and getTrip). I had a quick look and it seems that in road.dart, the route["geometry"] variable is indeed empty for the polyline. I am unsure if it is intended or a change in the API, but since polyline is the default value, one would expect that it actually fills the polyline attribute.

If no easy fix can be find, I would suggest to use Geometries.geojson as default!

liodali commented 2 years ago

can provide me the parameter used to get that result because Geometries.geojson has different output than Geometries. polyline|polyline6

pariterre commented 2 years ago

Here is an example that always fails (in the sense that road.polyline is always null), while if Geometries.geojson is used, then road.polyline is actually filled

  Future<List<LngLat>> getRoadPolyline() async {
    List<LngLat> waypoints = [
      LngLat(lng: 13.388860, lat: 52.517037),
      LngLat(lng: 13.397634, lat: 52.529407),
      LngLat(lng: 13.428555, lat: 52.523219),
    ];

    final manager = OSRMManager();
    final road = await manager.getRoad(
        waypoints: waypoints, geometrie: Geometries.polyline);

    if (road.polyline == null) return []; // With polyline, this is always null
    return road.polyline!;
  }
liodali commented 2 years ago

thnx i will check why thats happen sorry for late reply

liodali commented 2 years ago

ah yeah because polyline get values only when geometries are geojson and check if you check polylineEncoded when that geometries is polyline you find it not null and used to share polyline easly but since this make confusion but I will fix it for all geometries types