Changeset 6485 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2013-12-17T19:13:35+01:00 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/io/GeoJSONWriter.java
r6484 r6485 2 2 package org.openstreetmap.josm.io; 3 3 4 import java.util.Iterator; 4 5 import java.util.Map; 5 6 import java.util.Map.Entry; 6 7 7 8 import org.json.JSONStringer; 9 import org.openstreetmap.josm.data.Bounds; 8 10 import org.openstreetmap.josm.data.coor.LatLon; 9 11 import org.openstreetmap.josm.data.osm.Changeset; … … 28 30 out = new JSONStringer(); 29 31 out.object().key("type").value("FeatureCollection"); 32 out.key("generator").value("JOSM"); 33 appendLayerBounds(); 30 34 out.key("features").array(); 31 35 for (Node n : layer.data.getNodes()) { … … 62 66 } 63 67 64 protected String escape(String s) {65 return s.replace("\"", "\\\"").replace("\\", "\\\\").replace("\n", "\\n");66 }67 68 68 protected void appendPrimitive(OsmPrimitive p) { 69 69 if (p.isIncomplete()) { … … 91 91 } 92 92 } 93 94 protected void appendLayerBounds() { 95 Iterator<Bounds> it = layer.data.getDataSourceBounds().iterator(); 96 if (it.hasNext()) { 97 Bounds b = new Bounds(it.next()); 98 while (it.hasNext()) { 99 b.extend(it.next()); 100 } 101 appendBounds(b); 102 } 103 } 104 105 protected void appendBounds(Bounds b) { 106 if (b != null) { 107 out.key("bbox").array() 108 .value(b.getMinLon()).value(b.getMinLat()) 109 .value(b.getMaxLon()).value(b.getMaxLat()).endArray(); 110 } 111 } 93 112 }
Note:
See TracChangeset
for help on using the changeset viewer.