Changeset 16319 in osm for applications/editors/josm/plugins/validator/src/org
- Timestamp:
- 2009-07-05T11:20:49+02:00 (15 years ago)
- Location:
- applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/TagChecker.java
r14121 r16319 66 66 /** The default data files */ 67 67 public static final String DATA_FILE = "http://svn.openstreetmap.org/applications/editors/josm/plugins/validator/tagchecker.cfg"; 68 public static final String IGNORE_FILE = "http://svn.openstreetmap.org/applications/editors/josm/plugins/validator/ignoretags.cfg"; 68 69 public static final String SPELL_FILE = "http://svn.openstreetmap.org/applications/utils/planet.osm/java/speller/words.cfg"; 69 70 … … 74 75 /** The TagChecker data */ 75 76 protected static List<CheckerData> checkerData = new ArrayList<CheckerData>(); 77 protected static ArrayList<String> ignoreDataStartsWith = new ArrayList<String>(); 78 protected static ArrayList<String> ignoreDataEquals = new ArrayList<String>(); 79 protected static ArrayList<String> ignoreDataEndsWith = new ArrayList<String>(); 80 protected static ArrayList<IgnoreKeyPair> ignoreDataKeyPair = new ArrayList<IgnoreKeyPair>(); 76 81 77 82 /** The preferences prefix */ … … 86 91 public static final String PREF_SOURCES = PREFIX + ".sources"; 87 92 public static final String PREF_USE_DATA_FILE = PREFIX + ".usedatafile"; 93 public static final String PREF_USE_IGNORE_FILE = PREFIX + ".useignorefile"; 88 94 public static final String PREF_USE_SPELL_FILE = PREFIX + ".usespellfile"; 89 95 … … 113 119 114 120 protected JCheckBox prefUseDataFile; 121 protected JCheckBox prefUseIgnoreFile; 115 122 protected JCheckBox prefUseSpellFile; 116 123 … … 169 176 sources = DATA_FILE + ";" + sources; 170 177 } 178 if(Main.pref.getBoolean(PREF_USE_IGNORE_FILE, true)) 179 { 180 if( sources == null || sources.length() == 0) 181 sources = IGNORE_FILE; 182 else 183 sources = IGNORE_FILE + ";" + sources; 184 } 171 185 if(Main.pref.getBoolean(PREF_USE_SPELL_FILE, true)) 172 186 { … … 198 212 String okValue = null; 199 213 Boolean tagcheckerfile = false; 214 Boolean ignorefile = false; 200 215 String line; 201 216 while((line = reader.readLine()) != null && (tagcheckerfile || line.length() != 0)) … … 205 220 if(line.startsWith("# JOSM TagChecker")) 206 221 tagcheckerfile = true; 222 if(line.startsWith("# JOSM IgnoreTags")) 223 ignorefile = true; 224 continue; 225 } 226 else if(ignorefile) 227 { 228 line = line.trim(); 229 if(line.length() < 4) 230 continue; 231 232 String key = line.substring(0, 2); 233 line = line.substring(2); 234 235 if(key.equals("S:")) 236 { 237 ignoreDataStartsWith.add(line); 238 } 239 else if(key.equals("E:")) 240 { 241 ignoreDataEquals.add(line); 242 } 243 else if(key.equals("F:")) 244 { 245 ignoreDataEndsWith.add(line); 246 } 247 else if(key.equals("K:")) 248 { 249 IgnoreKeyPair tmp = new IgnoreKeyPair(); 250 int mid = line.indexOf("="); 251 tmp.key = line.substring(0, mid); 252 tmp.value = line.substring(mid+1); 253 ignoreDataKeyPair.add(tmp); 254 } 255 continue; 207 256 } 208 257 else if(tagcheckerfile) … … 391 440 { 392 441 Boolean ignore = false; 393 for(String a : Main.pref.getCollection(PreferenceEditor.PREFIX + ".startswithkeys", 394 Arrays.asList(new String[]{"opengeodb","openGeoDB","name:","note:"}))) 442 for(String a : ignoreDataStartsWith) 395 443 { 396 444 if(key.startsWith(a)) 397 445 ignore = true; 398 446 } 399 for(String a : Main.pref.getCollection(PreferenceEditor.PREFIX + ".endswithkeys", 400 Arrays.asList(new String[]{":forward",":backward",":left",":right"}))) 447 for(String a : ignoreDataEquals) 448 { 449 if(key.equals(a)) 450 ignore = true; 451 } 452 for(String a : ignoreDataEndsWith) 401 453 { 402 454 if(key.endsWith(a)) … … 413 465 else if(values.size() > 0 && !values.contains(prop.getValue())) 414 466 { 415 String i = marktr("Value ''{0}'' for key ''{1}'' not in presets."); 416 errors.add( new TestError(this, Severity.OTHER, tr("Presets do not contain property value"), 417 tr(i, prop.getValue(), key), MessageFormat.format(i, prop.getValue(), key), INVALID_VALUE, p) ); 418 withErrors.add(p, "UPV"); 467 boolean ignore = false; 468 for(IgnoreKeyPair a : ignoreDataKeyPair) 469 { 470 if(key.equals(a.key) && value.equals(a.value)) 471 ignore = true; 472 } 473 474 if(!ignore) 475 { 476 String i = marktr("Value ''{0}'' for key ''{1}'' not in presets."); 477 errors.add( new TestError(this, Severity.OTHER, tr("Presets do not contain property value"), 478 tr(i, prop.getValue(), key), MessageFormat.format(i, prop.getValue(), key), INVALID_VALUE, p) ); 479 withErrors.add(p, "UPV"); 480 } 419 481 } 420 482 } … … 601 663 prefUseDataFile.setToolTipText(tr("Use the default data file (recommended).")); 602 664 testPanel.add(prefUseDataFile, GBC.eol().insets(20,0,0,0)); 665 666 prefUseIgnoreFile = new JCheckBox(tr("Use default tag ignore file."), Main.pref.getBoolean(PREF_USE_IGNORE_FILE, true)); 667 prefUseIgnoreFile.setToolTipText(tr("Use the default tag ignore file (recommended).")); 668 testPanel.add(prefUseIgnoreFile, GBC.eol().insets(20,0,0,0)); 603 669 604 670 prefUseSpellFile = new JCheckBox(tr("Use default spellcheck file."), Main.pref.getBoolean(PREF_USE_SPELL_FILE, true)); … … 635 701 Main.pref.put(PREF_CHECK_PAINT_BEFORE_UPLOAD, prefCheckPaintBeforeUpload.isSelected()); 636 702 Main.pref.put(PREF_USE_DATA_FILE, prefUseDataFile.isSelected()); 703 Main.pref.put(PREF_USE_IGNORE_FILE, prefUseIgnoreFile.isSelected()); 637 704 Main.pref.put(PREF_USE_SPELL_FILE, prefUseSpellFile.isSelected()); 638 705 String sources = ""; … … 709 776 710 777 return false; 778 } 779 780 private static class IgnoreKeyPair { 781 public String key; 782 public String value; 711 783 } 712 784 -
applications/editors/josm/plugins/validator/src/org/openstreetmap/josm/plugins/validator/tests/UnconnectedWays.java
r16159 r16319 12 12 13 13 import org.openstreetmap.josm.data.osm.Node; 14 import org.openstreetmap.josm.data.osm.OsmUtils; 14 15 import org.openstreetmap.josm.data.osm.Way; 15 16 import org.openstreetmap.josm.Main; … … 65 66 for(Node en : endnodes_highway) 66 67 { 68 if("turning_circle".equals(en.get("highway")) || 69 OsmUtils.getOsmBoolean(en.get("noexit")) || en.get("barrier") != null) 70 continue; 67 71 for(MyWaySegment s : ways) 68 72 { 69 if( s.highway && s.nearby(en, mindist) && (a == null || a.contains(en.getCoor())))73 if(!s.isBoundary && !s.isAbandoned && s.highway && s.nearby(en, mindist) && (a == null || a.contains(en.getCoor()))) 70 74 map.put(en, s.w); 71 75 } … … 85 89 for(MyWaySegment s : ways) 86 90 { 87 if(!s. highway && s.nearby(en, mindist) && !s.isArea() && (a == null || a.contains(en.getCoor())))91 if(!s.isBoundary && !s.isAbandoned && !s.highway && s.nearby(en, mindist) && !s.isArea() && (a == null || a.contains(en.getCoor()))) 88 92 map.put(en, s.w); 89 93 } … … 93 97 for(MyWaySegment s : ways) 94 98 { 95 if( s.nearby(en, mindist) && !s.isArea() && (a == null || a.contains(en.getCoor())))99 if(!s.isBoundary && !s.isAbandoned && s.nearby(en, mindist) && !s.isArea() && (a == null || a.contains(en.getCoor()))) 96 100 map.put(en, s.w); 97 101 } … … 114 118 for(MyWaySegment s : ways) 115 119 { 116 if( s.nearby(en, minmiddledist) && (a == null || a.contains(en.getCoor())))120 if(!s.isBoundary && !s.isAbandoned && s.nearby(en, minmiddledist) && (a == null || a.contains(en.getCoor()))) 117 121 map.put(en, s.w); 118 122 } … … 132 136 for(MyWaySegment s : ways) 133 137 { 134 if( s.nearby(en, minmiddledist) && (a == null || a.contains(en.getCoor())))138 if(!s.isBoundary && !s.isAbandoned && s.nearby(en, minmiddledist) && (a == null || a.contains(en.getCoor()))) 135 139 map.put(en, s.w); 136 140 } … … 154 158 private Line2D line; 155 159 public Way w; 160 public Boolean isAbandoned = false; 161 public Boolean isBoundary = false; 156 162 public Boolean highway; 157 163 … … 159 165 { 160 166 this.w = w; 161 this.highway = w.get("highway") != null || w.get("railway") != null; 167 String railway = w.get("railway"); 168 this.isAbandoned = railway != null && railway.equals("abandoned"); 169 this.highway = w.get("highway") != null || (railway != null && !isAbandoned); 170 this.isBoundary = w.get("boundary") != null && w.get("boundary").equals("administrative") && !this.highway; 162 171 line = new Line2D.Double(n1.getEastNorth().east(), n1.getEastNorth().north(), 163 172 n2.getEastNorth().east(), n2.getEastNorth().north()); … … 169 178 && line.ptSegDist(n.getEastNorth().east(), n.getEastNorth().north()) < dist; 170 179 } 171 180 172 181 public boolean isArea() { 173 182 return w.get("landuse") != null
Note:
See TracChangeset
for help on using the changeset viewer.