Hi!
I'm working on an app that display nautical charts; i'm using a polyline to represent a "route". This route can be save in the phone as json file. To do this, i use pathRoute.getGeometry().toJson().
As you can seee in the video, the route has 4 points, however, when i save the "route", it saves a lots of points in the json file. Why this's happening?
The nautical charts that i'm using is in 2 million scale.
Thanks for your support.
Ma Eugenia
Solved! Go to Solution.
Hi Nicholas.
I just changed GeometryEngine.densifyGeodetic for GeometryEngine.densify, and for a 4 point route it save in the json file 7 point...
I assume the route is being drawn using your own custom code and stored as a Graphic (the pathRoute above looks like a GeoElement of some sort - can you confirm if it's a Graphic or a Feature, though it shouldn't make a difference).
It looks like sometime between tapping the 4 points and writing it out to JSON, it is being densified somehow. Do you have any code that calls GeometryEngine.densify() or .densifyGeodetic()?
Hi Nicholas!
Yes, the route it's a graphic. I'm not using those method when i drawing the route; this how i do it.
Regards!
public Geometry drawRoute(ArrayList<Point> addPoint, int value) {
Geometry pathGeometry = GeometryEngine.densifyGeodetic(new Polyline(new PointCollection(addPoint, SpatialReferences.getWgs84())), 1.0d, this.mLinearUnit, GeodeticCurveType.GEODESIC);
pathRoute.setGeometry(pathGeometry);
return pathGeometry;
}
Hi Nicholas.
I just changed GeometryEngine.densifyGeodetic for GeometryEngine.densify, and for a 4 point route it save in the json file 7 point...
Glad that improves things, but I'm curious why you're using densify at all. For straight-line segments you shouldn't need to. I could be missing a nuance of your use case though.
Hi Nicholas.
Now everything works fine. I set 5.0d to maxSegmentLength and, now the amount of point in the json file is equal to the amount of point of the route.
Geometry pathGeometry = GeometryEngine.densify(new Polyline(new PointCollection(addPoint)), 5.0d);