Changeset 21423 in osm for applications/editors/josm/plugins
- Timestamp:
- 2010-05-23T21:12:42+02:00 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/osmarender/src/org/openstreetmap/josm/plugins/osmarender/OsmarenderPlugin.java
r19419 r21423 26 26 import org.openstreetmap.josm.data.Bounds; 27 27 import org.openstreetmap.josm.data.coor.LatLon; 28 import org.openstreetmap.josm.data.osm.DataSet;29 28 import org.openstreetmap.josm.data.osm.Node; 30 29 import org.openstreetmap.josm.data.osm.OsmPrimitive; 30 import org.openstreetmap.josm.data.osm.Relation; 31 31 import org.openstreetmap.josm.data.osm.Way; 32 32 import org.openstreetmap.josm.gui.MainMenu; … … 59 59 } 60 60 61 Set<OsmPrimitive> parents = new HashSet<OsmPrimitive>();62 DataSet fromDataSet = new DataSet();63 for (Node n : Main.main.getCurrentDataSet().getNodes()) {64 if (n.isUsable() && n.getCoor().isWithin(b)) {65 fromDataSet.addPrimitive(n);66 parents.addAll(n.getReferrers());67 }68 }69 for (OsmPrimitive p : new HashSet<OsmPrimitive>(parents)) {70 if (p instanceof Way) {71 for (Node n : ((Way) p).getNodes()) {72 if (n.getCoor().isWithin(b))73 parents.add(n);74 }75 }76 }77 for (OsmPrimitive p : parents)78 fromDataSet.addPrimitive(p);79 61 80 62 String firefox = Main.pref.get("osmarender.firefox", "firefox"); 81 63 try { 82 64 // write to plugin dir 83 OsmWriter w = new OsmWriter(new PrintWriter(new FileOutputStream(getPluginDir()+File.separator+"data.osm")), false, fromDataSet.getVersion());65 OsmWriter w = new OsmWriter(new PrintWriter(new FileOutputStream(getPluginDir()+File.separator+"data.osm")), false, "0.6"); 84 66 w.header(); 85 w.writeDataSources(fromDataSet); 86 w.writeContent(fromDataSet); 67 68 // Write nodes, make list of ways and relations 69 Set<OsmPrimitive> parents = new HashSet<OsmPrimitive>(); 70 for (Node n : Main.main.getCurrentDataSet().getNodes()) { 71 if (n.isUsable() && n.getCoor().isWithin(b)) { 72 parents.addAll(n.getReferrers()); 73 w.visit(n); 74 } 75 } 76 77 // I'm not sure why (if) is this usefull 78 for (OsmPrimitive p : new HashSet<OsmPrimitive>(parents)) { 79 if (p instanceof Way) { 80 for (Node n : ((Way) p).getNodes()) { 81 if (n.getCoor().isWithin(b)) 82 parents.add(n); 83 } 84 } 85 } 86 87 // Write ways 88 for (OsmPrimitive p: parents) { 89 if (p instanceof Way) { 90 w.visit((Way)p); 91 } 92 } 93 94 // Write relations (should be parent relation also written?) 95 for (OsmPrimitive p: parents) { 96 if (p instanceof Relation) { 97 w.visit((Relation)p); 98 } 99 } 100 87 101 w.footer(); 88 102 w.close();
Note:
See TracChangeset
for help on using the changeset viewer.