hello sir,
i'm working on a arcgis runtime application in java using arcgis runtime samples for java . sir, if you know that how to import any .gpx format file ,then please guide me. and provide code if available...
We don't directly support GPX data, but its pretty easy to write your own importer. If you look at the file format / specification you will see all the data is XML.
https://wiki.openstreetmap.org/wiki/GPX
So if you can read a track as shown in the link above you will set a set of points which make up a track.
<trk><name>Example gpx</name><number>1</number><trkseg>
<trkpt lat="46.57608333" lon="8.89241667"><ele>2376</ele><time>2007-10-14T10:09:57Z</time></trkpt>
<trkpt lat="46.57619444" lon="8.89252778"><ele>2375</ele><time>2007-10-14T10:10:52Z</time></trkpt>
<trkpt lat="46.57641667" lon="8.89266667"><ele>2372</ele><time>2007-10-14T10:12:39Z</time></trkpt>
<trkpt lat="46.57650000" lon="8.89280556"><ele>2373</ele><time>2007-10-14T10:13:12Z</time></trkpt>
<trkpt lat="46.57638889" lon="8.89302778"><ele>2374</ele><time>2007-10-14T10:13:20Z</time></trkpt>
<trkpt lat="46.57652778" lon="8.89322222"><ele>2375</ele><time>2007-10-14T10:13:48Z</time></trkpt>
<trkpt lat="46.57661111" lon="8.89344444"><ele>2376</ele><time>2007-10-14T10:14:08Z</time></trkpt>
</trkseg></trk>
I've hard coded the points into a polyline as shown:
// points for the track (remember that longitute is X and latitude is Y!
Point pt1 = new Point(8.89241667, 46.57608333, 2376, SpatialReferences.getWgs84());
Point pt2 = new Point(8.89252778, 46.57619444, 2375, SpatialReferences.getWgs84());
Point pt3 = new Point(8.89266667, 46.57641667, 2372, SpatialReferences.getWgs84());
Point pt4 = new Point(8.89280556, 46.57650000, 2373, SpatialReferences.getWgs84());
Point pt5 = new Point(8.89302778, 46.57638889, 2374, SpatialReferences.getWgs84());
Point pt6 = new Point(8.89322222, 46.57652778, 2375, SpatialReferences.getWgs84());
Point pt7 = new Point(8.89344444, 46.57661111, 2376, SpatialReferences.getWgs84());
// collection for the points
PointCollection points = new PointCollection(SpatialReferences.getWgs84());
points.add(pt1);
points.add(pt2);
points.add(pt3);
points.add(pt4);
points.add(pt5);
points.add(pt6);
points.add(pt7);
// create polyline from the points in the collection
Polyline trackGeometrty = new Polyline(points);
// graphic overlay in a map view (could be a scene view for 3D)
graphicsOverlay = new GraphicsOverlay();
mapView.getGraphicsOverlays().add(graphicsOverlay);
// symbol for line
SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, 0xFF00FF00,5);
// graphic from style and polyline
Graphic graphic = new Graphic(trackGeometrty, lineSymbol);
// finally add graphic to graphic overlay
graphicsOverlay.getGraphics().add(graphic);
The end result is this:
So all you need to do is read the xml file remembering that longitude is X and latitude is Y as they are often mixed up.
Does this help?
can you provide any sample code if available...