Changeset 30796 in osm for applications/editors/josm/plugins/opendata/src
- Timestamp:
- 2014-11-12T02:37:22+01:00 (10 years ago)
- Location:
- applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GeographicReader.java
r30795 r30796 9 9 import java.util.ArrayList; 10 10 import java.util.Arrays; 11 import java.util.Collections; 11 12 import java.util.HashMap; 12 13 import java.util.List; … … 43 44 import org.openstreetmap.josm.data.osm.RelationMember; 44 45 import org.openstreetmap.josm.data.osm.Way; 46 import org.openstreetmap.josm.data.validation.tests.DuplicateWay; 45 47 import org.openstreetmap.josm.gui.ExtendedDialog; 46 48 import org.openstreetmap.josm.io.AbstractReader; … … 116 118 } 117 119 118 119 120 121 122 if(n != null && n.hasKeys()) {123 124 125 126 127 128 129 130 131 132 133 134 135 136 120 protected Node createOrGetEmptyNode(Point p) throws MismatchedDimensionException, TransformException { 121 Point p2 = (Point) JTS.transform(p, transform); 122 LatLon key = new LatLon(p2.getY(), p2.getX()); 123 Node n = getNode(p2, key); 124 if (n != null && n.hasKeys()) { 125 n = null; 126 } 127 if (n == null) { 128 n = new Node(key); 129 if (handler == null || handler.useNodeMap()) { 130 nodes.put(key, n); 131 } 132 ds.addPrimitive(n); 133 } else if (n.getDataSet() == null) { 134 // handler may have removed the node from DataSet (see Paris public light handler for example) 135 ds.addPrimitive(n); 136 } 137 return n; 138 } 137 139 138 140 protected <T extends OsmPrimitive> T addOsmPrimitive(T p) { … … 145 147 } 146 148 147 protected final Way createWay(LineString ls) { 148 Way w = createWay(); 149 protected final Way createOrGetWay(LineString ls) { 150 Way w = null; 151 Way tempWay = new Way(); 149 152 if (ls != null) { 153 // Build list of nodes 150 154 for (int i=0; i<ls.getNumPoints(); i++) { 151 155 try { 152 w.addNode(createOrGetNode(ls.getPointN(i)));156 tempWay.addNode(createOrGetNode(ls.getPointN(i))); 153 157 } catch (Exception e) { 154 158 Main.error(e.getMessage()); 155 159 } 156 160 } 161 // Find possible duplicated ways 162 if (tempWay.getNodesCount() > 0) { 163 List<Way> candidates = OsmPrimitive.getFilteredList(tempWay.firstNode().getReferrers(), Way.class); 164 candidates.remove(tempWay); 165 List<LatLon> tempNodes = DuplicateWay.getOrderedNodes(tempWay); 166 for (Way candidate : candidates) { 167 List<LatLon> candNodesA = DuplicateWay.getOrderedNodes(candidate); 168 List<LatLon> candNodesB = new ArrayList<>(candNodesA); 169 Collections.reverse(candNodesB); 170 if (tempNodes.equals(candNodesA) || tempNodes.equals(candNodesB)) { 171 w = candidate; 172 break; 173 } 174 } 175 } 176 } 177 // If no duplicate way found, create new one 178 if (w == null) { 179 w = createWay(); 180 w.setNodes(tempWay.getNodes()); 157 181 } 158 182 return w; -
applications/editors/josm/plugins/opendata/src/org/openstreetmap/josm/plugins/opendata/core/io/geographic/ShpReader.java
r30795 r30796 138 138 r = createMultipolygon(); 139 139 } 140 w = create Way(p.getExteriorRing());140 w = createOrGetWay(p.getExteriorRing()); 141 141 if (r != null) { 142 142 addWayToMp(r, "outer", w); 143 143 for (int j=0; j<p.getNumInteriorRing(); j++) { 144 addWayToMp(r, "inner", create Way(p.getInteriorRingN(j)));144 addWayToMp(r, "inner", createOrGetWay(p.getInteriorRingN(j))); 145 145 } 146 146 } 147 147 } else if (g instanceof LineString) { 148 w = create Way((LineString) g);148 w = createOrGetWay((LineString) g); 149 149 } else if (g instanceof Point) { 150 150 // Some belgian data sets hold points into collections ?!
Note:
See TracChangeset
for help on using the changeset viewer.