Changeset 1990 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2009-08-23T22:37:39+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/coor/LatLon.java
r1789 r1990 25 25 private static DecimalFormat cDdFormatter = new DecimalFormat("###0.0000"); 26 26 27 /**28 * Possible ways to display coordinates29 */30 public enum CoordinateFormat {31 DECIMAL_DEGREES {public String toString() {return tr("Decimal Degrees");}},32 DEGREES_MINUTES_SECONDS {public String toString() {return tr("Degrees Minutes Seconds");}};33 }34 27 35 28 public static String dms(double pCoordinate) { … … 42 35 43 36 return tDegree + "\u00B0" + cDmsMinuteFormatter.format(tMinutes) + "\'" 44 37 + cDmsSecondFormatter.format(tSeconds) + "\""; 45 38 } 46 39 … … 94 87 Bounds b = Main.proj.getWorldBoundsLatLon(); 95 88 return lat() < b.min.lat() || lat() > b.max.lat() || 96 89 lon() < b.min.lon() || lon() > b.max.lon(); 97 90 } 98 91 … … 112 105 public double greatCircleDistance(LatLon other) { 113 106 return (Math.acos( 114 Math.sin(Math.toRadians(lat())) * Math.sin(Math.toRadians(other.lat())) +115 Math.cos(Math.toRadians(lat()))*Math.cos(Math.toRadians(other.lat())) *116 107 Math.sin(Math.toRadians(lat())) * Math.sin(Math.toRadians(other.lat())) + 108 Math.cos(Math.toRadians(lat()))*Math.cos(Math.toRadians(other.lat())) * 109 Math.cos(Math.toRadians(other.lon()-lon()))) * 6378135); 117 110 } 118 111 … … 130 123 } else { 131 124 rv = Math.atan((other.lon()-lon())/(other.lat()-lat())); 132 if (rv < 0) rv += Math.PI; 133 if (other.lon() < lon()) rv += Math.PI; 125 if (rv < 0) { 126 rv += Math.PI; 127 } 128 if (other.lon() < lon()) { 129 rv += Math.PI; 130 } 134 131 } 135 132 return rv; … … 149 146 public LatLon interpolate(LatLon ll2, double proportion) { 150 147 return new LatLon(this.lat() + proportion * (ll2.lat() - this.lat()), 151 this.lon() + proportion * (ll2.lon() - this.lon()));148 this.lon() + proportion * (ll2.lon() - this.lon())); 152 149 } 153 150 -
trunk/src/org/openstreetmap/josm/data/osm/Changeset.java
r1933 r1990 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr; 5 4 6 import org.openstreetmap.josm.data.osm.visitor.Visitor; 5 import static org.openstreetmap.josm.tools.I18n.tr;6 7 7 8 /** … … 35 36 @Override 36 37 public String getName() { 38 // no translation 39 return "changeset " + id; 40 } 41 42 @Override 43 public String getLocalName(){ 37 44 return tr("Changeset {0}",id); 38 45 } 46 47 @Override 48 public String getDisplayName(NameFormatter formatter) { 49 return formatter.format(this); 50 } 39 51 } -
trunk/src/org/openstreetmap/josm/data/osm/Node.java
r1814 r1990 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import static org.openstreetmap.josm.tools.I18n.tr;4 import java.util.Locale; 5 5 6 import org.openstreetmap.josm.Main;7 6 import org.openstreetmap.josm.data.coor.CachedLatLon; 8 7 import org.openstreetmap.josm.data.coor.EastNorth; 9 8 import org.openstreetmap.josm.data.coor.LatLon; 10 import org.openstreetmap.josm.data.coor.LatLon.CoordinateFormat;11 9 import org.openstreetmap.josm.data.osm.visitor.Visitor; 10 import static org.openstreetmap.josm.tools.I18n.tr; 12 11 13 12 /** … … 50 49 } 51 50 52 private static CoordinateFormat mCord;53 51 54 static public CoordinateFormat getCoordinateFormat()55 {56 return mCord;57 }58 59 static public void setCoordinateFormat()60 {61 try {62 mCord = LatLon.CoordinateFormat.valueOf(Main.pref.get("coordinates"));63 } catch (IllegalArgumentException iae) {64 mCord = LatLon.CoordinateFormat.DECIMAL_DEGREES;65 }66 }67 68 static {69 setCoordinateFormat();70 }71 52 72 53 /** … … 127 108 128 109 @Override 110 public String getDisplayName(NameFormatter formatter) { 111 return formatter.format(this); 112 } 113 114 @Override 129 115 public String getName() { 130 String name; 131 if (incomplete) { 132 name = tr("incomplete"); 133 } else { 134 name = get("name"); 135 if (name == null) { 136 name = id == 0 ? tr("node") : ""+id; 137 } 138 name += " (" + coor.latToString(mCord) + ", " + coor.lonToString(mCord) + ")"; 139 } 140 return name; 116 String name = super.getName(); 117 if (name != null) 118 return name; 119 // no translation 120 return "node " + id; 121 } 122 123 @Override 124 public String getLocalName(){ 125 String name = super.getLocalName(); 126 if (name != null) 127 return name; 128 return tr("node {0}",id); 141 129 } 142 130 } -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r1933 r1990 10 10 import java.util.Date; 11 11 import java.util.HashMap; 12 import java.util.Locale; 12 13 import java.util.Map; 13 14 import java.util.Map.Entry; … … 358 359 return keys != null && !keys.isEmpty(); 359 360 } 360 361 /**362 * Replies the name of this primitive.363 *364 * @return the name of this primitive365 */366 public abstract String getName();367 361 368 362 /** … … 463 457 return false; 464 458 } 459 460 461 /** 462 * Replies the name of this primitive. The default implementation replies the value 463 * of the tag <tt>name</tt> or null, if this tag is not present. 464 * 465 * @return the name of this primitive 466 */ 467 public String getName() { 468 if (get("name") != null) 469 return get("name"); 470 return null; 471 } 472 473 /** 474 * Replies the a localized name for this primitive given by the value of the tags (in this order) 475 * <ul> 476 * <li>name:lang_COUNTRY_Variant of the current locale</li> 477 * <li>name:lang_COUNTRY of the current locale</li> 478 * <li>name:lang of the current locale</li> 479 * <li>name of the current locale</li> 480 * </ul> 481 * 482 * null, if no such tag exists 483 * 484 * @return the name of this primitive 485 */ 486 public String getLocalName() { 487 String key = "name:" + Locale.getDefault().toString(); 488 if (get(key) != null) 489 return get(key); 490 key = "name:" + Locale.getDefault().getLanguage() + "_" + Locale.getDefault().getCountry(); 491 if (get(key) != null) 492 return get(key); 493 key = "name:" + Locale.getDefault().getLanguage(); 494 if (get(key) != null) 495 return get(key); 496 return getName(); 497 } 498 499 /** 500 * Replies the display name of a primitive formatted by <code>formatter</code> 501 * 502 * @return the display name 503 */ 504 public abstract String getDisplayName(NameFormatter formatter); 465 505 } -
trunk/src/org/openstreetmap/josm/data/osm/Relation.java
r1951 r1990 2 2 3 3 import static org.openstreetmap.josm.tools.I18n.tr; 4 import static org.openstreetmap.josm.tools.I18n.trn;5 4 6 5 import java.util.ArrayList; 7 import java.util.Arrays;8 import java.util.Collection;9 6 import java.util.List; 10 7 11 import org.openstreetmap.josm.Main;12 8 import org.openstreetmap.josm.data.osm.visitor.Visitor; 13 9 import org.openstreetmap.josm.tools.CopyList; … … 104 100 return members.remove(index); 105 101 } 106 107 final static String[] defnames = {"name", "ref", "restriction", "note"};108 static Collection<String> names = null;109 102 110 103 @Override public void visit(Visitor visitor) { … … 164 157 } 165 158 166 @Override167 public String getName() {168 String name;169 if (incomplete) {170 name = tr("incomplete");171 } else {172 name = get("type");173 if (name == null) {174 name = tr("relation");175 }176 177 name += " (";178 if(names == null) {179 names = Main.pref.getCollection("relation.nameOrder", Arrays.asList(defnames));180 }181 String nameTag = null;182 for (String n : names) {183 nameTag = get(n);184 if (nameTag != null) {185 break;186 }187 }188 if (nameTag != null) {189 name += "\"" + nameTag + "\", ";190 }191 192 int mbno = members.size();193 name += trn("{0} member", "{0} members", mbno, mbno) + ")";194 if(errors != null) {195 name = "*"+name;196 }197 }198 return name;199 }200 201 159 // seems to be different from member "incomplete" - FIXME 202 160 public boolean isIncomplete() { … … 233 191 members.removeAll(todelete); 234 192 } 193 194 @Override 195 public String getName() { 196 String name = super.getName(); 197 if (name != null) 198 return name; 199 // no translation 200 return "relation " + id; 201 } 202 203 @Override 204 public String getLocalName(){ 205 String name = super.getLocalName(); 206 if (name != null) 207 return name; 208 return tr("relation {0}",id); 209 } 210 211 @Override 212 public String getDisplayName(NameFormatter formatter) { 213 return formatter.format(this); 214 } 235 215 } -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r1946 r1990 180 180 } 181 181 182 @Override183 public String getName() {184 String name;185 if (incomplete) {186 name = tr("incomplete");187 } else {188 name = get("name");189 if (name == null) {190 name = get("ref");191 }192 if (name == null) {193 name =194 (get("highway") != null) ? tr("highway") :195 (get("railway") != null) ? tr("railway") :196 (get("waterway") != null) ? tr("waterway") :197 (get("landuse") != null) ? tr("landuse") : "";198 }199 200 int nodesNo = new HashSet<Node>(nodes).size();201 String nodes = trn("{0} node", "{0} nodes", nodesNo, nodesNo);202 name += (name.length() > 0) ? " ("+nodes+")" : nodes;203 if(errors != null) {204 name = "*"+name;205 }206 }207 return name;208 }209 210 182 public void removeNode(Node n) { 211 183 if (incomplete) return; … … 263 235 return n == firstNode() || n == lastNode(); 264 236 } 237 238 @Override 239 public String getName() { 240 String name = super.getName(); 241 if (name != null) 242 return name; 243 // no translation 244 return "way " + id; 245 } 246 247 @Override 248 public String getLocalName(){ 249 String name = super.getLocalName(); 250 if (name != null) 251 return name; 252 return tr("way {0}",id); 253 } 254 255 @Override 256 public String getDisplayName(NameFormatter formatter) { 257 return formatter.format(this); 258 } 265 259 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r1937 r1990 34 34 import org.openstreetmap.josm.data.osm.RelationMember; 35 35 import org.openstreetmap.josm.data.osm.Way; 36 import org.openstreetmap.josm.gui.DefaultNameFormatter; 36 37 import org.openstreetmap.josm.gui.mappaint.AreaElemStyle; 37 38 import org.openstreetmap.josm.gui.mappaint.ElemStyle; … … 94 95 return (styles != null) ? styles.get(osm) : null; 95 96 96 if(osm.mappaintStyle == null && styles != null) { 97 osm.mappaintStyle = styles.get(osm); 98 if(osm instanceof Way) 99 ((Way)osm).isMappaintArea = styles.isArea(osm); 100 } 101 return osm.mappaintStyle; 97 if(osm.mappaintStyle == null && styles != null) { 98 osm.mappaintStyle = styles.get(osm); 99 if(osm instanceof Way) { 100 ((Way)osm).isMappaintArea = styles.isArea(osm); 101 } 102 } 103 return osm.mappaintStyle; 102 104 } 103 105 … … 106 108 return (styles != null) ? styles.getIcon(osm) : null; 107 109 108 if(osm.mappaintStyle == null && styles != null) 109 osm.mappaintStyle = styles.getIcon(osm); 110 111 return (IconElemStyle)osm.mappaintStyle; 110 if(osm.mappaintStyle == null && styles != null) { 111 osm.mappaintStyle = styles.getIcon(osm); 112 } 113 114 return (IconElemStyle)osm.mappaintStyle; 112 115 } 113 116 … … 129 132 * @param n The node to draw. 130 133 */ 134 @Override 131 135 public void visit(Node n) { 132 136 /* check, if the node is visible at all */ 133 137 if((n.getEastNorth().east() > maxEN.east() ) || 134 (n.getEastNorth().north() > maxEN.north()) ||135 (n.getEastNorth().east() < minEN.east() ) ||136 (n.getEastNorth().north() < minEN.north()))138 (n.getEastNorth().north() > maxEN.north()) || 139 (n.getEastNorth().east() < minEN.east() ) || 140 (n.getEastNorth().north() < minEN.north())) 137 141 { 138 142 n.mappaintVisibleCode = viewid; … … 146 150 // return; 147 151 148 if (nodeStyle != null && isZoomOk(nodeStyle) && showIcons > dist) 152 if (nodeStyle != null && isZoomOk(nodeStyle) && showIcons > dist) { 149 153 drawNode(n, nodeStyle.icon, nodeStyle.annotate, n.isSelected()); 150 else if (n.highlighted)154 } else if (n.highlighted) { 151 155 drawNode(n, highlightColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); 152 else if (n.isSelected())156 } else if (n.isSelected()) { 153 157 drawNode(n, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); 154 else if (n.isTagged())158 } else if (n.isTagged()) { 155 159 drawNode(n, nodeColor, taggedNodeSize, taggedNodeRadius, fillUnselectedNode); 156 else160 } else { 157 161 drawNode(n, nodeColor, unselectedNodeSize, unselectedNodeRadius, fillUnselectedNode); 162 } 158 163 } 159 164 … … 162 167 * @param w The way to draw. 163 168 */ 169 @Override 164 170 public void visit(Way w) { 165 171 if(w.getNodesCount() < 2) … … 177 183 for (Node n : w.getNodes()) 178 184 { 179 if(n.getEastNorth().east() > maxx) maxx = n.getEastNorth().east(); 180 if(n.getEastNorth().north() > maxy) maxy = n.getEastNorth().north(); 181 if(n.getEastNorth().east() < minx) minx = n.getEastNorth().east(); 182 if(n.getEastNorth().north() < miny) miny = n.getEastNorth().north(); 185 if(n.getEastNorth().east() > maxx) { 186 maxx = n.getEastNorth().east(); 187 } 188 if(n.getEastNorth().north() > maxy) { 189 maxy = n.getEastNorth().north(); 190 } 191 if(n.getEastNorth().east() < minx) { 192 minx = n.getEastNorth().east(); 193 } 194 if(n.getEastNorth().north() < miny) { 195 miny = n.getEastNorth().north(); 196 } 183 197 } 184 198 185 199 if ((minx > maxEN.east()) || 186 (miny > maxEN.north()) ||187 (maxx < minEN.east()) ||188 (maxy < minEN.north()))200 (miny > maxEN.north()) || 201 (maxx < minEN.east()) || 202 (maxy < minEN.north())) 189 203 { 190 204 w.mappaintVisibleCode = viewid; … … 201 215 202 216 w.mappaintVisibleCode = 0; 203 if(fillAreas > dist) 217 if(fillAreas > dist) { 204 218 w.clearErrors(); 219 } 205 220 206 221 if(wayStyle==null) … … 226 241 if (fillAreas > dist) 227 242 { 228 // profilerVisibleAreas++;243 // profilerVisibleAreas++; 229 244 drawArea(w, w.isSelected() ? selectedColor : areaStyle.color); 230 if(!w.isClosed()) 245 if(!w.isClosed()) { 231 246 w.putError(tr("Area style way is not closed."), true); 247 } 232 248 } 233 249 drawWay(w, areaStyle.line, areaStyle.color, w.isSelected()); … … 241 257 (even if the tag is negated as in oneway=false) or the way is selected */ 242 258 boolean showDirection = w.isSelected() || ((!useRealWidth) && (showDirectionArrow 243 && (!showRelevantDirectionsOnly || w.hasDirectionKeys())));259 && (!showRelevantDirectionsOnly || w.hasDirectionKeys()))); 244 260 /* head only takes over control if the option is true, 245 261 the direction should be shown at all and not only because it's selected */ … … 253 269 if(l != null) 254 270 { 255 if (l.color != null) color = l.color; 271 if (l.color != null) { 272 color = l.color; 273 } 256 274 width = l.width; 257 275 realWidth = l.realWidth; … … 259 277 dashedColor = l.dashedColor; 260 278 } 261 if(selected) 279 if(selected) { 262 280 color = selectedColor; 281 } 263 282 if (realWidth > 0 && useRealWidth && !showDirection) 264 283 { 265 284 int tmpWidth = (int) (100 / (float) (circum / realWidth)); 266 if (tmpWidth > width) width = tmpWidth; 285 if (tmpWidth > width) { 286 width = tmpWidth; 287 } 267 288 268 289 /* if we have a "width" tag, try use it */ … … 281 302 } 282 303 283 if(w.highlighted) 304 if(w.highlighted) { 284 305 color = highlightColor; 285 else if(w.isSelected())306 } else if(w.isSelected()) { 286 307 color = selectedColor; 308 } 287 309 288 310 /* draw overlays under the way */ … … 299 321 { 300 322 drawSeg(lastN, n, s.color != null && !w.isSelected() ? s.color : color, 301 false, s.getWidth(width), s.dashed, s.dashedColor);323 false, s.getWidth(width), s.dashed, s.dashedColor); 302 324 } 303 325 lastN = n; … … 313 335 { 314 336 Node n = it.next(); 315 if(lastN != null) 337 if(lastN != null) { 316 338 drawSeg(lastN, n, color, 317 showOnlyHeadArrowOnly ? !it.hasNext() : showDirection, width, dashed, dashedColor); 339 showOnlyHeadArrowOnly ? !it.hasNext() : showDirection, width, dashed, dashedColor); 340 } 318 341 lastN = n; 319 342 } … … 332 355 { 333 356 drawSeg(lastN, n, s.color != null && !w.isSelected() ? s.color : color, 334 false, s.getWidth(width), s.dashed, s.dashedColor);357 false, s.getWidth(width), s.dashed, s.dashedColor); 335 358 } 336 359 lastN = n; … … 386 409 { 387 410 nl = w.getNodesCount()-1; 388 if(w.getNode(nl) == c.getNode(0)) mode = 21; 389 else if(w.getNode(nl) == c.getNode(cl)) mode = 22; 390 else if(w.getNode(0) == c.getNode(0)) mode = 11; 391 else if(w.getNode(0) == c.getNode(cl)) mode = 12; 411 if(w.getNode(nl) == c.getNode(0)) { 412 mode = 21; 413 } else if(w.getNode(nl) == c.getNode(cl)) { 414 mode = 22; 415 } else if(w.getNode(0) == c.getNode(0)) { 416 mode = 11; 417 } else if(w.getNode(0) == c.getNode(cl)) { 418 mode = 12; 419 } 392 420 } 393 421 else 394 422 { 395 423 nl = n.size()-1; 396 if(n.get(nl) == c.getNode(0)) mode = 21; 397 else if(n.get(0) == c.getNode(cl)) mode = 12; 398 else if(n.get(0) == c.getNode(0)) mode = 11; 399 else if(n.get(nl) == c.getNode(cl)) mode = 22; 424 if(n.get(nl) == c.getNode(0)) { 425 mode = 21; 426 } else if(n.get(0) == c.getNode(cl)) { 427 mode = 12; 428 } else if(n.get(0) == c.getNode(0)) { 429 mode = 11; 430 } else if(n.get(nl) == c.getNode(cl)) { 431 mode = 22; 432 } 400 433 } 401 434 if(mode != 0) … … 403 436 joinArray[i] = null; 404 437 joined = true; 405 if(c.isSelected()) selected = true; 438 if(c.isSelected()) { 439 selected = true; 440 } 406 441 --left; 407 if(n == null) n = w.getNodes(); 442 if(n == null) { 443 n = w.getNodes(); 444 } 408 445 n.remove((mode == 21 || mode == 22) ? nl : 0); 409 if(mode == 21) 446 if(mode == 21) { 410 447 n.addAll(c.getNodes()); 411 else if(mode == 12)448 } else if(mode == 12) { 412 449 n.addAll(0, c.getNodes()); 413 else if(mode == 22)450 } else if(mode == 22) 414 451 { 415 for(Node node : c.getNodes()) 452 for(Node node : c.getNodes()) { 416 453 n.add(nl, node); 454 } 417 455 } 418 456 else /* mode == 11 */ 419 457 { 420 for(Node node : c.getNodes()) 458 for(Node node : c.getNodes()) { 421 459 n.add(0, node); 460 } 422 461 } 423 462 } … … 437 476 { 438 477 errs.putError(tr("multipolygon way ''{0}'' is not closed.", 439 w.getName()), true);478 w.getDisplayName(DefaultNameFormatter.getInstance())), true); 440 479 } 441 480 } … … 447 486 448 487 public void drawSelectedMember(OsmPrimitive osm, ElemStyle style, Boolean area, 449 Boolean areaselected)488 Boolean areaselected) 450 489 { 451 490 if(osm instanceof Way) … … 456 495 AreaElemStyle areaStyle = (AreaElemStyle)style; 457 496 drawWay(way, areaStyle.line, selectedColor, true); 458 if(area) 497 if(area) { 459 498 drawArea(way, areaselected ? selectedColor : areaStyle.color); 499 } 460 500 } 461 501 else … … 466 506 else if(osm instanceof Node) 467 507 { 468 if(style != null && isZoomOk(style)) 508 if(style != null && isZoomOk(style)) { 469 509 drawNode((Node)osm, ((IconElemStyle)style).icon, 470 ((IconElemStyle)style).annotate, true);471 else510 ((IconElemStyle)style).annotate, true); 511 } else { 472 512 drawNode((Node)osm, selectedColor, selectedNodeSize, selectedNodeRadius, fillSelectedNode); 513 } 473 514 } 474 515 osm.mappaintDrawnCode = paintid; 475 516 } 476 517 518 @Override 477 519 public void visit(Relation r) { 478 520 … … 497 539 { 498 540 if(drawMultipolygon(r)) 499 return;541 return; 500 542 } 501 543 else if (drawRestriction && "restriction".equals(r.get("type"))) … … 511 553 { 512 554 drawSelectedMember(m.getMember(), styles != null ? getPrimitiveStyle(m.getMember()) 513 : null, true, true);555 : null, true, true); 514 556 } 515 557 } … … 535 577 // System.out.println("member " + m.member + " selected " + r.selected); 536 578 537 if(m.getMember() == null) 579 if(m.getMember() == null) { 538 580 // TODO Nullable member will not be allowed after RelationMember.member is encalupsed 539 581 r.putError(tr("Empty member in relation."), true); 540 else if(m.getMember().deleted)582 } else if(m.getMember().deleted) { 541 583 r.putError(tr("Deleted member ''{0}'' in relation.", 542 m.getMember().getName()), true); 543 else if(m.getMember().incomplete) 544 { 584 m.getMember().getDisplayName(DefaultNameFormatter.getInstance())), true); 585 } else if(m.getMember().incomplete) 545 586 return; 546 }547 587 else 548 588 { … … 553 593 { 554 594 r.putError(tr("Way ''{0}'' with less than two points.", 555 w.getName()), true);595 w.getDisplayName(DefaultNameFormatter.getInstance())), true); 556 596 } 557 597 else if("from".equals(m.getRole())) { 558 if(fromWay != null) 598 if(fromWay != null) { 559 599 r.putError(tr("More than one \"from\" way found."), true); 560 else {600 } else { 561 601 fromWay = w; 562 602 } 563 603 } else if("to".equals(m.getRole())) { 564 if(toWay != null) 604 if(toWay != null) { 565 605 r.putError(tr("More than one \"to\" way found."), true); 566 else {606 } else { 567 607 toWay = w; 568 608 } 569 609 } else if("via".equals(m.getRole())) { 570 if(via != null) 610 if(via != null) { 571 611 r.putError(tr("More than one \"via\" found."), true); 572 else612 } else { 573 613 via = w; 574 }575 else614 } 615 } else { 576 616 r.putError(tr("Unknown role ''{0}''.", m.getRole()), true); 617 } 577 618 } 578 619 else if(m.isNode()) … … 581 622 if("via".equals(m.getRole())) 582 623 { 583 if(via != null) 624 if(via != null) { 584 625 r.putError(tr("More than one \"via\" found."), true); 585 else626 } else { 586 627 via = n; 587 }588 else628 } 629 } else { 589 630 r.putError(tr("Unknown role ''{0}''.", m.getRole()), true); 590 } 591 else 592 r.putError(tr("Unknown member type for ''{0}''.", m.getMember().getName()), true); 631 } 632 } else { 633 r.putError(tr("Unknown member type for ''{0}''.", m.getMember().getDisplayName(DefaultNameFormatter.getInstance())), true); 634 } 593 635 } 594 636 } … … 615 657 return; 616 658 } 617 if(!toWay.isFirstLastNode(viaNode)) 659 if(!toWay.isFirstLastNode(viaNode)) { 618 660 r.putError(tr("The \"to\" way doesn't start or end at a \"via\" node."), true); 661 } 619 662 } 620 663 else … … 623 666 Node firstNode = viaWay.firstNode(); 624 667 Node lastNode = viaWay.lastNode(); 625 if(fromWay.isFirstLastNode(firstNode)) 668 if(fromWay.isFirstLastNode(firstNode)) { 626 669 viaNode = firstNode; 627 else if(fromWay.isFirstLastNode(lastNode))670 } else if(fromWay.isFirstLastNode(lastNode)) { 628 671 viaNode = firstNode; 629 else {672 } else { 630 673 r.putError(tr("The \"from\" way doesn't start or end at the \"via\" way."), true); 631 674 return; 632 675 } 633 if(!toWay.isFirstLastNode(viaNode == firstNode ? lastNode : firstNode)) 676 if(!toWay.isFirstLastNode(viaNode == firstNode ? lastNode : firstNode)) { 634 677 r.putError(tr("The \"to\" way doesn't start or end at the \"via\" way."), true); 678 } 635 679 } 636 680 … … 675 719 (calculate the vector vx/vy with the specified length and the direction 676 720 away from the "via" node along the first segment of the "from" way) 677 */721 */ 678 722 double distanceFromVia=14; 679 723 double dx = (pFrom.x >= pVia.x) ? (pFrom.x - pVia.x) : (pVia.x - pFrom.x); … … 691 735 double vy = distanceFromVia * Math.sin(fromAngle); 692 736 693 if(pFrom.x < pVia.x) vx = -vx; 694 if(pFrom.y < pVia.y) vy = -vy; 737 if(pFrom.x < pVia.x) { 738 vx = -vx; 739 } 740 if(pFrom.y < pVia.y) { 741 vy = -vy; 742 } 695 743 696 744 //if(restrictionDebug) … … 700 748 (calculate the vx2/vy2 vector with the specified length and the direction 701 749 90degrees away from the first segment of the "from" way) 702 */750 */ 703 751 double distanceFromWay=10; 704 752 double vx2 = 0; … … 740 788 vx2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg + 180)); 741 789 vy2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg + 180)); 742 790 } else { 743 791 vx2 = distanceFromWay * Math.sin(Math.toRadians(fromAngleDeg)); 744 792 vy2 = distanceFromWay * Math.cos(Math.toRadians(fromAngleDeg)); … … 783 831 for (RelationMember m : r.getMembers()) 784 832 { 785 if(m.getMember() == null) 833 if(m.getMember() == null) { 786 834 //TODO Remove useless nullcheck when RelationMember.member is encalupsed 787 835 r.putError(tr("Empty member in relation."), true); 788 else if(m.getMember().deleted)836 } else if(m.getMember().deleted) { 789 837 r.putError(tr("Deleted member ''{0}'' in relation.", 790 m.getMember().getName()), true);791 else if(m.getMember().incomplete)838 m.getMember().getDisplayName(DefaultNameFormatter.getInstance())), true); 839 } else if(m.getMember().incomplete) { 792 840 incomplete = true; 793 else841 } else 794 842 { 795 843 if(m.isWay()) … … 799 847 { 800 848 r.putError(tr("Way ''{0}'' with less than two points.", 801 w.getName()), true);802 } 803 else if("inner".equals(m.getRole())) 849 w.getDisplayName(DefaultNameFormatter.getInstance())), true); 850 } 851 else if("inner".equals(m.getRole())) { 804 852 inner.add(w); 805 else if("outer".equals(m.getRole()))853 } else if("outer".equals(m.getRole())) { 806 854 outer.add(w); 807 else855 } else 808 856 { 809 857 r.putError(tr("No useful role ''{0}'' for Way ''{1}''.", 810 m.getRole(), w.getName()), true);811 if(!m.hasRole()) 858 m.getRole(), w.getDisplayName(DefaultNameFormatter.getInstance())), true); 859 if(!m.hasRole()) { 812 860 outer.add(w); 813 else if(r.isSelected())861 } else if(r.isSelected()) { 814 862 drawSelectedMember(m.getMember(), styles != null 815 ? getPrimitiveStyle(m.getMember()) : null, true, true); 863 ? getPrimitiveStyle(m.getMember()) : null, true, true); 864 } 816 865 } 817 866 } … … 819 868 { 820 869 r.putError(tr("Non-Way ''{0}'' in multipolygon.", 821 m.getMember().getName()), true);870 m.getMember().getDisplayName(DefaultNameFormatter.getInstance())), true); 822 871 } 823 872 } … … 829 878 for (Way w : outer) 830 879 { 831 if(wayStyle == null) 832 wayStyle = styles.getArea(w); 880 if(wayStyle == null) { 881 wayStyle = styles.getArea(w); 882 } 833 883 } 834 884 r.mappaintStyle = wayStyle; … … 844 894 for (Way w : outer) 845 895 { 846 if(w.isClosed()) outerclosed.add(w); 847 else join.add(w); 896 if(w.isClosed()) { 897 outerclosed.add(w); 898 } else { 899 join.add(w); 900 } 848 901 } 849 902 if(join.size() != 0) 850 903 { 851 for(Way w : joinWays(join, incomplete ? null : r)) 904 for(Way w : joinWays(join, incomplete ? null : r)) { 852 905 outerclosed.add(w); 906 } 853 907 } 854 908 … … 856 910 for (Way w : inner) 857 911 { 858 if(w.isClosed()) innerclosed.add(w); 859 else join.add(w); 912 if(w.isClosed()) { 913 innerclosed.add(w); 914 } else { 915 join.add(w); 916 } 860 917 } 861 918 if(join.size() != 0) 862 919 { 863 for(Way w : joinWays(join, incomplete ? null : r)) 920 for(Way w : joinWays(join, incomplete ? null : r)) { 864 921 innerclosed.add(w); 922 } 865 923 } 866 924 … … 868 926 { 869 927 r.putError(tr("No outer way for multipolygon ''{0}''.", 870 r.getName()), true);928 r.getDisplayName(DefaultNameFormatter.getInstance())), true); 871 929 visible = true; /* prevent killing remaining ways */ 872 930 } … … 892 950 for(int i = 0; i < p.npoints; ++i) 893 951 { 894 if(poly.contains(p.xpoints[i],p.ypoints[i])) 952 if(poly.contains(p.xpoints[i],p.ypoints[i])) { 895 953 --contains; 954 } 896 955 } 897 956 if(contains == 0) return 1; … … 901 960 public void addInner(Polygon p) 902 961 { 903 if(inner == null) 962 if(inner == null) { 904 963 inner = new ArrayList<Polygon>(); 964 } 905 965 inner.add(p); 906 966 } … … 908 968 { 909 969 return (poly.npoints >= 3 910 && poly.xpoints[0] == poly.xpoints[poly.npoints-1]911 && poly.ypoints[0] == poly.ypoints[poly.npoints-1]);970 && poly.xpoints[0] == poly.xpoints[poly.npoints-1] 971 && poly.ypoints[0] == poly.ypoints[poly.npoints-1]); 912 972 } 913 973 public Polygon get() … … 917 977 for (Polygon pp : inner) 918 978 { 919 for(int i = 0; i < pp.npoints; ++i) 979 for(int i = 0; i < pp.npoints; ++i) { 920 980 poly.addPoint(pp.xpoints[i],pp.ypoints[i]); 981 } 921 982 poly.addPoint(p.x,p.y); 922 983 } … … 954 1015 { 955 1016 r.putError(tr("Intersection between ways ''{0}'' and ''{1}''.", 956 pd.way.getName(), wInner.getName()), true);1017 pd.way.getDisplayName(DefaultNameFormatter.getInstance()), wInner.getDisplayName(DefaultNameFormatter.getInstance())), true); 957 1018 } 958 if(o == null || o.contains(pd.poly) > 0) 1019 if(o == null || o.contains(pd.poly) > 0) { 959 1020 o = pd; 1021 } 960 1022 } 961 1023 } … … 965 1027 { 966 1028 r.putError(tr("Inner way ''{0}'' is outside.", 967 wInner.getName()), true);1029 wInner.getDisplayName(DefaultNameFormatter.getInstance())), true); 968 1030 } 969 1031 o = poly.get(0); … … 978 1040 { 979 1041 drawAreaPolygon(p, (pd.way.isSelected() || r.isSelected()) ? selectedColor 980 : areaStyle.color);1042 : areaStyle.color); 981 1043 visible = true; 982 1044 } … … 986 1048 { 987 1049 r.mappaintVisibleCode = viewid; 988 for (Way wInner : inner) 1050 for (Way wInner : inner) { 989 1051 wInner.mappaintVisibleCode = viewid; 990 for (Way wOuter : outer) 1052 } 1053 for (Way wOuter : outer) { 991 1054 wOuter.mappaintVisibleCode = viewid; 1055 } 992 1056 return drawn; 993 1057 } … … 998 1062 { 999 1063 if(zoomok && (wInner.mappaintDrawnCode != paintid 1000 || outer.size() == 0))1064 || outer.size() == 0)) 1001 1065 { 1002 1066 drawWay(wInner, ((AreaElemStyle)wayStyle).line, 1003 ((AreaElemStyle)wayStyle).color, wInner.isSelected()1004 || r.isSelected());1067 ((AreaElemStyle)wayStyle).color, wInner.isSelected() 1068 || r.isSelected()); 1005 1069 } 1006 1070 wInner.mappaintDrawnCode = paintid; … … 1011 1075 { 1012 1076 drawSelectedMember(wInner, innerStyle, 1013 !wayStyle.equals(innerStyle), wInner.isSelected());1077 !wayStyle.equals(innerStyle), wInner.isSelected()); 1014 1078 } 1015 1079 if(wayStyle.equals(innerStyle)) 1016 1080 { 1017 1081 r.putError(tr("Style for inner way ''{0}'' equals multipolygon.", 1018 wInner.getName()), false);1019 if(!r.isSelected()) 1082 wInner.getDisplayName(DefaultNameFormatter.getInstance())), false); 1083 if(!r.isSelected()) { 1020 1084 wInner.mappaintDrawnAreaCode = paintid; 1085 } 1021 1086 } 1022 1087 } … … 1030 1095 { 1031 1096 drawWay(wOuter, ((AreaElemStyle)wayStyle).line, 1032 ((AreaElemStyle)wayStyle).color, wOuter.isSelected()1033 || r.isSelected());1097 ((AreaElemStyle)wayStyle).color, wOuter.isSelected() 1098 || r.isSelected()); 1034 1099 } 1035 1100 wOuter.mappaintDrawnCode = paintid; … … 1038 1103 { 1039 1104 if(outerStyle instanceof AreaElemStyle 1040 && !wayStyle.equals(outerStyle))1105 && !wayStyle.equals(outerStyle)) 1041 1106 { 1042 1107 r.putError(tr("Style for outer way ''{0}'' mismatches.", 1043 wOuter.getName()), true);1108 wOuter.getDisplayName(DefaultNameFormatter.getInstance())), true); 1044 1109 } 1045 1110 if(r.isSelected()) … … 1047 1112 drawSelectedMember(wOuter, outerStyle, false, false); 1048 1113 } 1049 else if(outerStyle instanceof AreaElemStyle) 1114 else if(outerStyle instanceof AreaElemStyle) { 1050 1115 wOuter.mappaintDrawnAreaCode = paintid; 1116 } 1051 1117 } 1052 1118 } … … 1115 1181 for (String rn : regionalNameOrder) { 1116 1182 name = n.get(rn); 1117 if (name != null) break; 1183 if (name != null) { 1184 break; 1185 } 1118 1186 } 1119 1187 } … … 1129 1197 Point p2 = nc.getPoint(n2); 1130 1198 1131 if (!isSegmentVisible(p1, p2)) {1199 if (!isSegmentVisible(p1, p2)) 1132 1200 return; 1133 }1134 1201 //profilerVisibleSegments++; 1135 1202 currentPath.moveTo(p1.x, p1.y); … … 1144 1211 } 1145 1212 1213 @Override 1146 1214 protected void displaySegments() { 1147 1215 displaySegments(null, 0, new float[0], null); … … 1159 1227 g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); 1160 1228 } 1161 } 1162 else 1229 } else { 1163 1230 g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); 1231 } 1164 1232 } 1165 1233 g2d.draw(currentPath); … … 1178 1246 g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); 1179 1247 } 1180 } 1181 else 1248 } else { 1182 1249 g2d.setStroke(new BasicStroke(currentWidth,BasicStroke.CAP_ROUND,BasicStroke.JOIN_ROUND)); 1250 } 1183 1251 } 1184 1252 g2d.draw(currentPath); 1185 1253 } 1186 1254 1187 if(useStrokes > dist) 1255 if(useStrokes > dist) { 1188 1256 g2d.setStroke(new BasicStroke(1)); 1257 } 1189 1258 1190 1259 currentPath = new GeneralPath(); … … 1203 1272 * @param color The color of the node. 1204 1273 */ 1274 @Override 1205 1275 public void drawNode(Node n, Color color, int size, int radius, boolean fill) { 1206 1276 if (isZoomOk(null) && size > 1) { … … 1216 1286 g.fillRect(p.x - radius, p.y - radius, size, size); 1217 1287 g.drawRect(p.x - radius, p.y - radius, size, size); 1218 } else 1288 } else { 1219 1289 g.drawRect(p.x - radius, p.y - radius, size, size); 1290 } 1220 1291 1221 1292 if(showNames > dist) … … 1234 1305 } 1235 1306 1307 @Override 1236 1308 public void getColors() 1237 1309 { … … 1242 1314 1243 1315 /* Shows areas before non-areas */ 1316 @Override 1244 1317 public void visitAll(DataSet data, Boolean virtual) { 1245 1318 … … 1303 1376 1304 1377 /*** RELATIONS ***/ 1305 // profilerN = 0;1378 // profilerN = 0; 1306 1379 for (final Relation osm : data.relations) 1307 1380 { … … 1309 1382 { 1310 1383 osm.visit(this); 1311 // profilerN++;1312 } 1313 } 1314 1315 // if(profiler)1316 // {1317 // System.out.format("Relations: %5dms, calls=%7d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);1318 // profilerLast = java.lang.System.currentTimeMillis();1319 // }1384 // profilerN++; 1385 } 1386 } 1387 1388 // if(profiler) 1389 // { 1390 // System.out.format("Relations: %5dms, calls=%7d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 1391 // profilerLast = java.lang.System.currentTimeMillis(); 1392 // } 1320 1393 1321 1394 /*** AREAS ***/ 1322 // profilerN = 0;1395 // profilerN = 0; 1323 1396 for (final Way osm : data.ways) 1324 1397 { 1325 1398 if (!osm.incomplete && !osm.deleted 1326 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid)1399 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) 1327 1400 { 1328 1401 if(isPrimitiveArea(osm) && osm.mappaintDrawnAreaCode != paintid) 1329 1402 { 1330 1403 osm.visit(this); 1331 // profilerN++;1332 } else 1404 // profilerN++; 1405 } else { 1333 1406 noAreaWays.add(osm); 1334 } 1335 } 1336 1337 // if(profiler) 1338 // { 1339 // System.out.format("Areas : %5dms, calls=%7d, visible=%d\n", 1340 // (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleAreas); 1341 // profilerLast = java.lang.System.currentTimeMillis(); 1342 // } 1407 } 1408 } 1409 } 1410 1411 // if(profiler) 1412 // { 1413 // System.out.format("Areas : %5dms, calls=%7d, visible=%d\n", 1414 // (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleAreas); 1415 // profilerLast = java.lang.System.currentTimeMillis(); 1416 // } 1343 1417 1344 1418 /*** WAYS ***/ 1345 // profilerN = 0;1419 // profilerN = 0; 1346 1420 fillAreas = 0; 1347 1421 for (final OsmPrimitive osm : noAreaWays) 1348 1422 { 1349 1423 osm.visit(this); 1350 // profilerN++;1351 } 1352 1353 // if(profiler)1354 // {1355 // System.out.format("Ways : %5dms, calls=%7d, visible=%d\n",1356 // (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleWays);1357 // profilerLast = java.lang.System.currentTimeMillis();1358 // }1424 // profilerN++; 1425 } 1426 1427 // if(profiler) 1428 // { 1429 // System.out.format("Ways : %5dms, calls=%7d, visible=%d\n", 1430 // (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleWays); 1431 // profilerLast = java.lang.System.currentTimeMillis(); 1432 // } 1359 1433 } 1360 1434 else 1361 1435 { 1362 1436 /*** WAYS (filling disabled) ***/ 1363 // profilerN = 0;1437 // profilerN = 0; 1364 1438 for (final OsmPrimitive osm : data.ways) 1365 1439 if (!osm.incomplete && !osm.deleted && !osm.isSelected() 1366 && osm.mappaintVisibleCode != viewid )1440 && osm.mappaintVisibleCode != viewid ) 1367 1441 { 1368 1442 osm.visit(this); 1369 // profilerN++;1370 } 1371 1372 // if(profiler)1373 // {1374 // System.out.format("Ways : %5dms, calls=%7d, visible=%d\n",1375 // (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleWays);1376 // profilerLast = java.lang.System.currentTimeMillis();1377 // }1443 // profilerN++; 1444 } 1445 1446 // if(profiler) 1447 // { 1448 // System.out.format("Ways : %5dms, calls=%7d, visible=%d\n", 1449 // (java.lang.System.currentTimeMillis()-profilerLast), profilerN, profilerVisibleWays); 1450 // profilerLast = java.lang.System.currentTimeMillis(); 1451 // } 1378 1452 } 1379 1453 … … 1383 1457 for (final OsmPrimitive osm : data.getSelected()) { 1384 1458 if (!osm.incomplete && !osm.deleted && !(osm instanceof Node) 1385 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid)1459 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) 1386 1460 { 1387 1461 osm.visit(this); 1388 // profilerN++;1462 // profilerN++; 1389 1463 } 1390 1464 } … … 1403 1477 for (final OsmPrimitive osm : data.nodes) 1404 1478 if (!osm.incomplete && !osm.deleted 1405 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid)1479 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) 1406 1480 { 1407 1481 osm.visit(this); 1408 // profilerN++;1482 // profilerN++; 1409 1483 } 1410 1484 … … 1419 1493 if (virtualNodeSize != 0) 1420 1494 { 1421 // profilerN = 0;1495 // profilerN = 0; 1422 1496 currentColor = nodeColor; 1423 1497 for (final OsmPrimitive osm : data.ways) 1424 1498 if (!osm.incomplete && !osm.deleted 1425 && osm.mappaintVisibleCode != viewid )1499 && osm.mappaintVisibleCode != viewid ) 1426 1500 { 1427 1501 /* TODO: move this into the SimplePaint code? */ 1428 // if(!profilerOmitDraw)1429 1430 // profilerN++;1431 } 1432 1433 // if(profiler)1434 // {1435 // System.out.format("Virtual : %5dms, calls=%7d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN);1436 // profilerLast = java.lang.System.currentTimeMillis();1437 // }1502 // if(!profilerOmitDraw) 1503 visitVirtual((Way)osm); 1504 // profilerN++; 1505 } 1506 1507 // if(profiler) 1508 // { 1509 // System.out.format("Virtual : %5dms, calls=%7d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 1510 // profilerLast = java.lang.System.currentTimeMillis(); 1511 // } 1438 1512 1439 1513 displaySegments(null);
Note:
See TracChangeset
for help on using the changeset viewer.