Changeset 22445 in osm for applications
- Timestamp:
- 2010-07-27T03:34:06+02:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/DuplicateNode.java
r21177 r22445 2 2 package org.openstreetmap.josm.plugins.validator.tests; 3 3 4 import static org.openstreetmap.josm.tools.I18n.marktr; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 6 … … 8 9 import java.util.ArrayList; 9 10 import java.util.Collection; 11 import java.util.HashMap; 10 12 import java.util.Iterator; 11 13 import java.util.LinkedHashSet; … … 25 27 import org.openstreetmap.josm.data.osm.Node; 26 28 import org.openstreetmap.josm.data.osm.OsmPrimitive; 29 import org.openstreetmap.josm.data.osm.OsmPrimitiveType; 27 30 import org.openstreetmap.josm.data.osm.Storage; 31 import org.openstreetmap.josm.data.osm.Way; 28 32 import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil; 29 33 import org.openstreetmap.josm.gui.progress.ProgressMonitor; … … 63 67 64 68 protected static int DUPLICATE_NODE = 1; 69 protected static int DUPLICATE_NODE_MIXED = 2; 70 protected static int DUPLICATE_NODE_HIGHWAY = 3; 71 protected static int DUPLICATE_NODE_RAILWAY = 3; 72 protected static int DUPLICATE_NODE_WATERWAY = 4; 73 protected static int DUPLICATE_NODE_BOUNDARY = 5; 74 protected static int DUPLICATE_NODE_POWER = 6; 65 75 66 76 /** The map of potential duplicates. … … 114 124 bag.add(n.getKeys(), n); 115 125 } 126 127 Map<String,Boolean> typeMap=new HashMap<String,Boolean>(); 128 String[] types = {"none", "highway", "railway", "waterway", "boundary", "power"}; 129 130 116 131 // check whether we have multiple nodes at the same position with 117 132 // the same tag set … … 120 135 Map<String,String> tagSet = it.next(); 121 136 if (bag.get(tagSet).size() > 1) { 122 errors.add(new TestError( 123 parentTest, 124 Severity.ERROR, 125 tr("Duplicated nodes"), 126 DUPLICATE_NODE, 127 bag.get(tagSet) 128 )); 137 138 for (String type: types) { 139 typeMap.put(type, false); 140 } 141 142 for (OsmPrimitive p : bag.get(tagSet)) { 143 if (p.getType()==OsmPrimitiveType.NODE) { 144 Node n = (Node) p; 145 List<OsmPrimitive> lp=n.getReferrers(); 146 for (OsmPrimitive sp: lp) { 147 if (sp.getType()==OsmPrimitiveType.WAY) { 148 boolean typed = false; 149 Way w=(Way) sp; 150 Map<String, String> keys = w.getKeys(); 151 for (String type: typeMap.keySet()) { 152 if (keys.containsKey(type)) { 153 typeMap.put(type, true); 154 typed=true; 155 } 156 } 157 if (!typed) typeMap.put("none", true); 158 } 159 } 160 161 } 162 } 163 164 int nbType=0; 165 for (String type: typeMap.keySet()) { 166 if (typeMap.get(type)) nbType++; 167 } 168 169 if (nbType>1) { 170 String msg = marktr("Mixed type duplicated nodes"); 171 errors.add(new TestError( 172 parentTest, 173 Severity.ERROR, 174 tr("Duplicated nodes"), 175 tr(msg), 176 msg, 177 DUPLICATE_NODE_MIXED, 178 bag.get(tagSet) 179 )); 180 } else if (typeMap.get("highway")) { 181 String msg = marktr("Highway duplicated nodes"); 182 errors.add(new TestError( 183 parentTest, 184 Severity.ERROR, 185 tr("Duplicated nodes"), 186 tr(msg), 187 msg, 188 DUPLICATE_NODE_HIGHWAY, 189 bag.get(tagSet) 190 )); 191 } else if (typeMap.get("railway")) { 192 String msg = marktr("Railway duplicated nodes"); 193 errors.add(new TestError( 194 parentTest, 195 Severity.ERROR, 196 tr("Duplicated nodes"), 197 tr(msg), 198 msg, 199 DUPLICATE_NODE_RAILWAY, 200 bag.get(tagSet) 201 )); 202 } else if (typeMap.get("waterway")) { 203 String msg = marktr("Waterway duplicated nodes"); 204 errors.add(new TestError( 205 parentTest, 206 Severity.ERROR, 207 tr("Duplicated nodes"), 208 tr(msg), 209 msg, 210 DUPLICATE_NODE_WATERWAY, 211 bag.get(tagSet) 212 )); 213 } else if (typeMap.get("boundary")) { 214 String msg = marktr("Boundary duplicated nodes"); 215 errors.add(new TestError( 216 parentTest, 217 Severity.ERROR, 218 tr("Duplicated nodes"), 219 tr(msg), 220 msg, 221 DUPLICATE_NODE_BOUNDARY, 222 bag.get(tagSet) 223 )); 224 } else if (typeMap.get("power")) { 225 String msg = marktr("Power duplicated nodes"); 226 errors.add(new TestError( 227 parentTest, 228 Severity.ERROR, 229 tr("Duplicated nodes"), 230 tr(msg), 231 msg, 232 DUPLICATE_NODE_POWER, 233 bag.get(tagSet) 234 )); 235 } else { 236 errors.add(new TestError( 237 parentTest, 238 Severity.ERROR, 239 tr("Duplicated nodes"), 240 DUPLICATE_NODE, 241 bag.get(tagSet) 242 )); 243 244 } 129 245 it.remove(); 130 246 }
Note:
See TracChangeset
for help on using the changeset viewer.