Changeset 2450 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2009-11-14T18:47:09+01:00 (16 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm
- Files:
-
- 1 added
- 8 edited
-
BBox.java (added)
-
DataSet.java (modified) (1 diff)
-
Node.java (modified) (1 diff)
-
OsmPrimitive.java (modified) (2 diffs)
-
QuadBuckets.java (modified) (6 diffs)
-
Relation.java (modified) (1 diff)
-
Way.java (modified) (1 diff)
-
visitor/MapPaintVisitor.java (modified) (6 diffs)
-
visitor/SimplePaintVisitor.java (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r2439 r2450 20 20 21 21 import org.openstreetmap.josm.data.SelectionChangedListener; 22 import org.openstreetmap.josm.data.osm.QuadBuckets.BBox;23 22 24 23 /** -
trunk/src/org/openstreetmap/josm/data/osm/Node.java
r2437 r2450 5 5 import org.openstreetmap.josm.data.coor.EastNorth; 6 6 import org.openstreetmap.josm.data.coor.LatLon; 7 import org.openstreetmap.josm.data.osm.QuadBuckets.BBox;8 7 import org.openstreetmap.josm.data.osm.visitor.Visitor; 9 8 -
trunk/src/org/openstreetmap/josm/data/osm/OsmPrimitive.java
r2448 r2450 19 19 20 20 import org.openstreetmap.josm.Main; 21 import org.openstreetmap.josm.data.osm.QuadBuckets.BBox;22 21 import org.openstreetmap.josm.data.osm.visitor.Visitor; 23 22 import org.openstreetmap.josm.gui.mappaint.ElemStyle; … … 219 218 * @param disabled true, if this primitive is disabled; false, otherwise 220 219 */ 221 publicvoid setDisabled(boolean disabled) {220 void setDisabled(boolean disabled) { 222 221 if (disabled) { 223 222 flags |= FLAG_DISABLED; -
trunk/src/org/openstreetmap/josm/data/osm/QuadBuckets.java
r2449 r2450 58 58 public static double WORLD_PARTS = (1 << NR_LEVELS); 59 59 60 public static int MAX_OBJECTS_PER_LEVEL = 16; 61 // has to be a power of 2 62 public static int TILES_PER_LEVEL_SHIFT = 2; 63 public static int TILES_PER_LEVEL = 1<<TILES_PER_LEVEL_SHIFT; 64 // Maybe this should just be a Rectangle?? 65 public static class BBox 66 { 67 private double xmin = Double.POSITIVE_INFINITY; 68 private double xmax = Double.NEGATIVE_INFINITY; 69 private double ymin = Double.POSITIVE_INFINITY; 70 private double ymax = Double.NEGATIVE_INFINITY; 71 void sanity() 72 { 73 if (xmin < -180.0) { 74 xmin = -180.0; 75 } 76 if (xmax > 180.0) { 77 xmax = 180.0; 78 } 79 if (ymin < -90.0) { 80 ymin = -90.0; 81 } 82 if (ymax > 90.0) { 83 ymax = 90.0; 84 } 85 if ((xmin < -180.0) || 86 (xmax > 180.0) || 87 (ymin < -90.0) || 88 (ymax > 90.0)) 89 throw new IllegalArgumentException("bad BBox: " + this); 90 } 91 @Override 92 public String toString() 93 { 94 return "[ x: " + xmin + " -> " + xmax + 95 ", y: " + ymin + " -> " + ymax + " ]"; 96 } 97 double min(double a, double b) 98 { 99 if (a < b) 100 return a; 101 return b; 102 } 103 double max(double a, double b) 104 { 105 if (a > b) 106 return a; 107 return b; 108 } 109 private void add(LatLon c) 110 { 111 xmin = min(xmin, c.lon()); 112 xmax = max(xmax, c.lon()); 113 ymin = min(ymin, c.lat()); 114 ymax = max(ymax, c.lat()); 115 } 116 public BBox(LatLon a, LatLon b) 117 { 118 add(a); 119 add(b); 120 sanity(); 121 } 122 public BBox(double a_x, double a_y, double b_x, double b_y) 123 { 124 xmin = min(a_x, b_x); 125 xmax = max(a_x, b_x); 126 ymin = min(a_y, b_y); 127 ymax = max(a_y, b_y); 128 sanity(); 129 } 130 public BBox(Way w) 131 { 132 for (Node n : w.getNodes()) { 133 LatLon coor = n.getCoor(); 134 if (coor == null) { 135 continue; 136 } 137 add(coor); 138 } 139 this.sanity(); 140 } 141 public double height() 142 { 143 return ymax-ymin; 144 } 145 public double width() 146 { 147 return xmax-xmin; 148 } 149 boolean bounds(BBox b) 150 { 151 if (!(xmin <= b.xmin) || 152 !(xmax >= b.xmax) || 153 !(ymin <= b.ymin) || 154 !(ymax >= b.ymax)) 155 return false; 156 return true; 157 } 158 boolean bounds(LatLon c) 159 { 160 if ((xmin <= c.lon()) && 161 (xmax >= c.lon()) && 162 (ymin <= c.lat()) && 163 (ymax >= c.lat())) 164 return true; 165 return false; 166 } 167 boolean inside(BBox b) 168 { 169 if (xmin >= b.xmax) 170 return false; 171 if (xmax <= b.xmin) 172 return false; 173 if (ymin >= b.ymax) 174 return false; 175 if (ymax <= b.ymin) 176 return false; 177 return true; 178 } 179 boolean intersects(BBox b) 180 { 181 return this.inside(b) || b.inside(this); 182 } 183 List<LatLon> points() 184 { 185 LatLon p1 = new LatLon(ymin, xmin); 186 LatLon p2 = new LatLon(ymin, xmax); 187 LatLon p3 = new LatLon(ymax, xmin); 188 LatLon p4 = new LatLon(ymax, xmax); 189 List<LatLon> ret = new ArrayList<LatLon>(); 190 ret.add(p1); 191 ret.add(p2); 192 ret.add(p3); 193 ret.add(p4); 194 return ret; 195 } 196 } 60 public static int MAX_OBJECTS_PER_LEVEL = 2; 197 61 class QBLevel 198 62 { … … 294 158 continue; 295 159 } 296 if (children == null) 160 if (children == null) { 297 161 children = newChildren(); 162 } 298 163 if (children[new_index] == null) { 299 164 children[new_index] = new QBLevel(this, new_index); … … 725 590 public BBox bbox() 726 591 { 727 if (bbox != null) { 728 bbox.sanity(); 592 if (bbox != null) 729 593 return bbox; 730 }731 594 if (level == 0) { 732 595 bbox = new BBox(-180, 90, 180, -90); … … 738 601 bbox = new BBox(bottom_left, top_right); 739 602 } 740 bbox.sanity();741 603 return bbox; 742 604 } … … 1100 962 out("search bbox before sanity: " + bbox); 1101 963 } 1102 bbox.sanity();1103 964 if (debug) { 1104 965 out("search bbox after sanity: " + bbox); … … 1124 985 { 1125 986 BBox bbox = new BBox(b1.lon(), b1.lat(), b2.lon(), b2.lat()); 1126 bbox.sanity();1127 987 return this.search(bbox); 1128 988 } -
trunk/src/org/openstreetmap/josm/data/osm/Relation.java
r2439 r2450 7 7 import java.util.Set; 8 8 9 import org.openstreetmap.josm.data.osm.QuadBuckets.BBox;10 9 import org.openstreetmap.josm.data.osm.visitor.Visitor; 11 10 import org.openstreetmap.josm.tools.CopyList; -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r2437 r2450 9 9 import java.util.List; 10 10 11 import org.openstreetmap.josm.data.osm.QuadBuckets.BBox;12 11 import org.openstreetmap.josm.data.osm.visitor.Visitor; 13 12 import org.openstreetmap.josm.tools.CopyList; -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r2392 r2450 32 32 33 33 import org.openstreetmap.josm.Main; 34 import org.openstreetmap.josm.data.Bounds; 34 35 import org.openstreetmap.josm.data.coor.EastNorth; 35 36 import org.openstreetmap.josm.data.coor.LatLon; 37 import org.openstreetmap.josm.data.osm.BBox; 36 38 import org.openstreetmap.josm.data.osm.DataSet; 37 39 import org.openstreetmap.josm.data.osm.Node; … … 114 116 return (styles != null) ? styles.getIcon(osm) : null; 115 117 116 if(osm.mappaintStyle == null && styles != null) { 117 osm.mappaintStyle = styles.getIcon(osm); 118 } 119 120 return (IconElemStyle)osm.mappaintStyle; 118 if(osm.mappaintStyle == null && styles != null) { 119 osm.mappaintStyle = styles.getIcon(osm); 120 } 121 122 return (IconElemStyle)osm.mappaintStyle; 121 123 } 122 124 … … 1445 1447 /* Shows areas before non-areas */ 1446 1448 @Override 1447 public void visitAll(DataSet data, Boolean virtual) { 1449 public void visitAll(DataSet data, boolean virtual, Bounds bounds) { 1450 BBox bbox = new BBox(bounds); 1448 1451 this.data = data; 1449 1452 //boolean profiler = Main.pref.getBoolean("mappaint.profiler",false); … … 1521 1524 /*** AREAS ***/ 1522 1525 // profilerN = 0; 1523 for (final Way osm : selectedLast(data, data. getWays())) {1526 for (final Way osm : selectedLast(data, data.searchWays(bbox))) { 1524 1527 if (drawable(osm) 1525 1528 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) { … … 1614 1617 /*** NODES ***/ 1615 1618 //profilerN = 0; 1616 for (final Node osm: data. getNodes()) {1619 for (final Node osm: data.searchNodes(bbox)) { 1617 1620 if (!osm.incomplete && !osm.isDeleted() && (data.isSelected(osm) || !osm.isFiltered()) 1618 1621 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) … … 1634 1637 // profilerN = 0; 1635 1638 currentColor = nodeColor; 1636 for (final OsmPrimitive osm: data. getWays()) {1639 for (final OsmPrimitive osm: data.searchWays(bbox)) { 1637 1640 if (osm.isUsable() && !osm.isFiltered() 1638 1641 && osm.mappaintVisibleCode != viewid ) -
trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
r2381 r2450 19 19 20 20 import org.openstreetmap.josm.Main; 21 import org.openstreetmap.josm.data.Bounds; 21 22 import org.openstreetmap.josm.data.osm.DataSet; 22 23 import org.openstreetmap.josm.data.osm.Node; … … 129 130 130 131 DataSet ds; 131 public void visitAll(DataSet data, Boolean virtual) {132 public void visitAll(DataSet data, boolean virtual, Bounds bounds) { 132 133 this.ds = data; 133 134 //boolean profiler = Main.pref.getBoolean("simplepaint.profiler",false);
Note:
See TracChangeset
for help on using the changeset viewer.
