graphhopper / map-matching

The map matching functionality is now located in the main repository https://github.com/graphhopper/graphhopper#map-matching
https://www.graphhopper.com/open-source/
Apache License 2.0
785 stars 274 forks source link

extended_json & GeoJson #43

Closed harksin closed 8 years ago

harksin commented 8 years ago

Hi , when i use extanded_json as output with webServer, MapMatching create invalid GeoJson Object with only one point in LineString.

could you confirm this is an issue ?

{ "geometry": "{\"coordinates\":[[3.89894,43.609859]],\"type\":\"LineString\"}", "id": 78938, "wpts": [] }, { "geometry": "{\"coordinates\":[[3.898914,43.609945]],\"type\":\"LineString\"}", "id": 471587, "wpts": [] }, { "geometry": "{\"coordinates\":[[3.898889,43.61003],[3.898851,43.610155],[3.898824,43.610272]],\"type\":\"LineString\"}", "id": 471588, "wpts": [] }

karussell commented 8 years ago

Could be an issue as we currently always export as LineString

harksin commented 8 years ago

ok, you can fix just by patch class MatchResultToJson with :

      if(pointList.size() >=2)  {
                geometry.put("coordinates", pointList.toGeoJson());
                geometry.put("type", "LineString");
            }
            if(pointList.size() < 2) {
                geometry.put("coordinates", pointList.toGeoJson().get(0));
                geometry.put("type", "Point");
            }