Changeset 2381 in josm for trunk/src/org/openstreetmap/josm/data
- Timestamp:
- 2009-11-02T07:51:28+01:00 (17 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data
- Files:
-
- 11 edited
-
conflict/ConflictCollection.java (modified) (1 diff)
-
osm/BackreferencedDataSet.java (modified) (2 diffs)
-
osm/DataSet.java (modified) (8 diffs)
-
osm/Relation.java (modified) (3 diffs)
-
osm/TagCollection.java (modified) (1 diff)
-
osm/Way.java (modified) (2 diffs)
-
osm/visitor/CollectBackReferencesVisitor.java (modified) (1 diff)
-
osm/visitor/MapPaintVisitor.java (modified) (20 diffs)
-
osm/visitor/MergeSourceBuildingVisitor.java (modified) (1 diff)
-
osm/visitor/MergeVisitor.java (modified) (3 diffs)
-
osm/visitor/SimplePaintVisitor.java (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/conflict/ConflictCollection.java
r2181 r2381 54 54 55 55 protected void fireConflictAdded() { 56 Iterator<IConflictListener> it = listeners.iterator(); 57 while(it.hasNext()) { 58 it.next().onConflictsAdded(this); 56 for (IConflictListener listener : listeners) { 57 listener.onConflictsAdded(this); 59 58 } 60 59 } -
trunk/src/org/openstreetmap/josm/data/osm/BackreferencedDataSet.java
r2181 r2381 105 105 throw new IllegalArgumentException(tr("Parameter ''{0}'' must not be null.")); 106 106 this.source = source; 107 int size = source. ways.size() + source.relations.size();107 int size = source.getWays().size() + source.getRelations().size(); 108 108 referers = new HashMap<OsmPrimitive, Set<OsmPrimitive>>(size, 0.75f); 109 109 } … … 131 131 */ 132 132 public void build() { 133 for (Way w: source. ways) {134 for (Node n: w.getNodes()) { 135 remember(w,n); 136 } 137 } 138 for (Relation r: source. relations) {139 for (RelationMember m: r.getMembers()) { 133 for (Way w : source.getWays()) { 134 for (Node n : w.getNodes()) { 135 remember(w, n); 136 } 137 } 138 for (Relation r : source.getRelations()) { 139 for (RelationMember m : r.getMembers()) { 140 140 remember(r, m.getMember()); 141 141 } -
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r2352 r2381 1 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import java.awt.geom.Area; 4 5 import java.util.ArrayList; 5 6 import java.util.Arrays; 6 7 import java.util.Collection; 8 import java.util.Collections; 7 9 import java.util.Comparator; 8 10 import java.util.HashMap; … … 26 28 */ 27 29 public class DataSet implements Cloneable { 28 30 29 31 /** 30 32 * A list of listeners to selection changed events. The list is static, as listeners register … … 33 35 */ 34 36 public static Collection<SelectionChangedListener> selListeners = new LinkedList<SelectionChangedListener>(); 35 37 36 38 /** 37 39 * notifies all registered selection change listeners about the current selection of … … 54 56 * All nodes goes here, even when included in other data (ways etc). This enables the instant 55 57 * conversion of the whole DataSet by iterating over this data structure. 56 */ 58 * @deprecated Use getNodes() for read-only operations, addPrimitive() and removePrimitive() for modifications 59 */ 60 @Deprecated 57 61 public QuadBuckets<Node> nodes = new QuadBuckets<Node>(); 58 62 63 public Collection<Node> getNodes() { 64 return Collections.unmodifiableCollection(nodes); 65 } 66 59 67 /** 60 68 * All ways (Streets etc.) in the DataSet. 61 69 * 62 70 * The way nodes are stored only in the way list. 63 */ 71 * @deprecated Use getWays() for read-only operations, addPrimitive() and removePrimitive() for modifications 72 */ 73 @Deprecated 64 74 public QuadBuckets<Way> ways = new QuadBuckets<Way>(); 65 75 76 public Collection<Way> getWays() { 77 return Collections.unmodifiableCollection(ways); 78 } 79 66 80 /** 67 81 * All relations/relationships 68 */ 82 * @deprecated Use getRelations() for read-only operations, addPrimitive() and removePrimitive() for modifications 83 */ 84 @Deprecated 69 85 public Collection<Relation> relations = new LinkedList<Relation>(); 70 86 87 public Collection<Relation> getRelations() { 88 return Collections.unmodifiableCollection(relations); 89 } 90 71 91 /** 72 92 * All data sources of this DataSet. 73 93 */ 74 94 public Collection<DataSource> dataSources = new LinkedList<DataSource>(); 75 95 76 96 /** 77 97 * @return A collection containing all primitives of the dataset. The data is ordered after: … … 255 275 256 276 public boolean toggleSelected(Collection<OsmPrimitive> osm) { 257 for (OsmPrimitive o : osm) 277 for (OsmPrimitive o : osm) { 258 278 this.__toggleSelected(o); 279 } 259 280 fireSelectionChanged(); 260 281 return true; … … 405 426 406 427 /** 407 * Notifies all registered {@see SelectionChangedListener} about the current selection in 428 * Notifies all registered {@see SelectionChangedListener} about the current selection in 408 429 * this dataset. 409 430 * … … 491 512 Collection<? extends OsmPrimitive> primitives = null; 492 513 switch(type) { 493 case NODE: primitives = nodes; break;494 case WAY: primitives = ways; break;495 case RELATION: primitives = relations; break;514 case NODE: primitives = nodes; break; 515 case WAY: primitives = ways; break; 516 case RELATION: primitives = relations; break; 496 517 } 497 518 for (OsmPrimitive primitive : primitives) { … … 502 523 OsmPrimitive result = null; 503 524 switch (type) { 504 case NODE: result = new Node(id, true); break;505 case WAY: result = new Way(id, true); break;506 case RELATION: result = new Relation(id, true); break;525 case NODE: result = new Node(id, true); break; 526 case WAY: result = new Way(id, true); break; 527 case RELATION: result = new Relation(id, true); break; 507 528 } 508 529 addPrimitive(result); -
trunk/src/org/openstreetmap/josm/data/osm/Relation.java
r2363 r2381 158 158 super.load(data, dataSet); 159 159 160 RelationData relationData = (RelationData)data; 160 RelationData relationData = (RelationData) data; 161 161 162 162 // TODO Make this faster … … 169 169 Map<Long, Relation> relations = new HashMap<Long, Relation>(); 170 170 171 for (RelationMemberData member :relationData.getMembers()) {171 for (RelationMemberData member : relationData.getMembers()) { 172 172 switch (member.getMemberType()) { 173 case NODE: 174 nodes.put(member.getMemberId(), nodeMarker); 175 break; 176 case WAY: 177 ways.put(member.getMemberId(), wayMarker); 178 break; 179 case RELATION: 180 relations.put(member.getMemberId(), relationMarker); 181 break; 182 } 183 } 184 185 for (Node node :dataSet.nodes) {173 case NODE: 174 nodes.put(member.getMemberId(), nodeMarker); 175 break; 176 case WAY: 177 ways.put(member.getMemberId(), wayMarker); 178 break; 179 case RELATION: 180 relations.put(member.getMemberId(), relationMarker); 181 break; 182 } 183 } 184 185 for (Node node : dataSet.getNodes()) { 186 186 if (nodes.get(node.getUniqueId()) == nodeMarker) { 187 187 nodes.put(node.getUniqueId(), node); 188 188 } 189 189 } 190 for (Way way :dataSet.ways) {190 for (Way way : dataSet.getWays()) { 191 191 if (ways.get(way.getUniqueId()) == wayMarker) { 192 192 ways.put(way.getUniqueId(), way); 193 193 } 194 194 } 195 for (Relation relation :dataSet.relations) {195 for (Relation relation : dataSet.getRelations()) { 196 196 if (relations.get(relation.getUniqueId()) == relationMarker) { 197 197 relations.put(relation.getUniqueId(), relation); … … 200 200 201 201 List<RelationMember> newMembers = new ArrayList<RelationMember>(); 202 for (RelationMemberData member :relationData.getMembers()) {202 for (RelationMemberData member : relationData.getMembers()) { 203 203 OsmPrimitive foundMember = null; 204 204 switch (member.getMemberType()) { 205 case NODE: 206 foundMember = nodes.get(member.getMemberId()); 207 if (foundMember == nodeMarker) 208 throw new AssertionError("Data consistency problem - relation with missing member detected"); 209 break; 210 case WAY: 211 foundMember = ways.get(member.getMemberId()); 212 if (foundMember == wayMarker) 213 throw new AssertionError("Data consistency problem - relation with missing member detected"); 214 break; 215 case RELATION: 216 foundMember = relations.get(member.getMemberId()); 217 if (foundMember == relationMarker) 218 throw new AssertionError("Data consistency problem - relation with missing member detected"); 219 break; 205 case NODE: 206 foundMember = nodes.get(member.getMemberId()); 207 if (foundMember == nodeMarker) 208 throw new AssertionError("Data consistency problem - relation with missing member detected"); 209 break; 210 case WAY: 211 foundMember = ways.get(member.getMemberId()); 212 if (foundMember == wayMarker) 213 throw new AssertionError("Data consistency problem - relation with missing member detected"); 214 break; 215 case RELATION: 216 foundMember = relations.get(member.getMemberId()); 217 if (foundMember == relationMarker) 218 throw new AssertionError("Data consistency problem - relation with missing member detected"); 219 break; 220 220 } 221 221 newMembers.add(new RelationMember(member.getRole(), foundMember)); -
trunk/src/org/openstreetmap/josm/data/osm/TagCollection.java
r2305 r2381 111 111 TagCollection tags = new TagCollection(); 112 112 if (ds == null) return tags; 113 tags.add(TagCollection.unionOfAllPrimitives(ds. nodes));114 tags.add(TagCollection.unionOfAllPrimitives(ds. ways));115 tags.add(TagCollection.unionOfAllPrimitives(ds. relations));113 tags.add(TagCollection.unionOfAllPrimitives(ds.getNodes())); 114 tags.add(TagCollection.unionOfAllPrimitives(ds.getWays())); 115 tags.add(TagCollection.unionOfAllPrimitives(ds.getRelations())); 116 116 return tags; 117 117 } -
trunk/src/org/openstreetmap/josm/data/osm/Way.java
r2363 r2381 177 177 super.load(data, dataSet); 178 178 179 WayData wayData = (WayData)data; 179 WayData wayData = (WayData) data; 180 180 181 181 // TODO We should have some lookup by id mechanism in future to speed this up 182 182 Node marker = new Node(0); 183 183 Map<Long, Node> foundNodes = new HashMap<Long, Node>(); 184 for (Long nodeId :wayData.getNodes()) {184 for (Long nodeId : wayData.getNodes()) { 185 185 foundNodes.put(nodeId, marker); 186 186 } 187 for (Node node :dataSet.nodes) {187 for (Node node : dataSet.getNodes()) { 188 188 if (foundNodes.get(node.getUniqueId()) == marker) { 189 189 foundNodes.put(node.getUniqueId(), node); … … 192 192 193 193 List<Node> newNodes = new ArrayList<Node>(wayData.getNodes().size()); 194 for (Long nodeId :wayData.getNodes()) {194 for (Long nodeId : wayData.getNodes()) { 195 195 Node node = foundNodes.get(nodeId); 196 196 if (node != marker) { -
trunk/src/org/openstreetmap/josm/data/osm/visitor/CollectBackReferencesVisitor.java
r2166 r2381 52 52 } 53 53 54 private void makeLookupTable(){ 55 for (Way w : ds. ways) {56 for (Node n : w.getNodes()) { 57 if(!lookupTable.containsKey(n)) lookupTable.put(n, new HashSet<OsmPrimitive>());58 lookupTable.get(n).add(w); 59 } 60 } 61 for (Relation r : ds. relations) {62 for (RelationMember m : r.getMembers()) { 63 OsmPrimitive o = m.getMember(); 64 if(!lookupTable.containsKey(o)) lookupTable.put(o, new HashSet<OsmPrimitive>());65 lookupTable.get(o).add(r); 66 } 67 } 54 private void makeLookupTable() { 55 for (Way w : ds.getWays()) { 56 for (Node n : w.getNodes()) { 57 if (!lookupTable.containsKey(n)) lookupTable.put(n, new HashSet<OsmPrimitive>()); 58 lookupTable.get(n).add(w); 59 } 60 } 61 for (Relation r : ds.getRelations()) { 62 for (RelationMember m : r.getMembers()) { 63 OsmPrimitive o = m.getMember(); 64 if (!lookupTable.containsKey(o)) lookupTable.put(o, new HashSet<OsmPrimitive>()); 65 lookupTable.get(o).add(r); 66 } 67 } 68 68 } 69 69 -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MapPaintVisitor.java
r2354 r2381 24 24 import java.util.Collection; 25 25 import java.util.Collections; 26 import java.util.Comparator; 26 27 import java.util.Iterator; 27 28 import java.util.LinkedList; 28 29 import java.util.List; 29 import java.util.TreeSet;30 import java.util.Comparator;31 30 32 31 import javax.swing.ImageIcon; … … 532 531 } 533 532 533 @Override 534 534 public void visit(Relation r) {}; 535 535 public void paintUnselectedRelation(Relation r) { … … 1031 1031 for (PolyData pd : outerPoly) { 1032 1032 Polygon p = pd.get(); 1033 if(!isPolygonVisible(p)) 1033 if(!isPolygonVisible(p)) { 1034 1034 continue; 1035 } 1035 1036 1036 1037 boolean selected = pd.selected || data.isSelected(pd.way) || data.isSelected(r); … … 1055 1056 if(innerStyle == null) 1056 1057 { 1057 if (data.isSelected(wInner)) 1058 if (data.isSelected(wInner)) { 1058 1059 continue; 1060 } 1059 1061 if(zoomok && (wInner.mappaintDrawnCode != paintid 1060 1062 || outer.size() == 0)) … … 1089 1091 { 1090 1092 // Selected ways are drawn at the very end 1091 if (data.isSelected(wOuter)) 1093 if (data.isSelected(wOuter)) { 1092 1094 continue; 1095 } 1093 1096 if(zoomok) 1094 1097 { … … 1134 1137 protected Point2D getCentroid(Polygon p) 1135 1138 { 1136 double cx = 0.0, cy = 0.0, a = 0.0;1137 1138 // usually requires points[0] == points[npoints] and can then use i+1 instead of j.1139 // Faked it slowly using j. If this is really gets used, this should be fixed.1140 for (int i = 0; i < p.npoints; i++) {1141 int j = i+1 == p.npoints ? 0 : i+1;1142 a += (p.xpoints[i] * p.ypoints[j]) - (p.ypoints[i] * p.xpoints[j]);1143 cx += (p.xpoints[i] + p.xpoints[j]) * (p.xpoints[i] * p.ypoints[j] - p.ypoints[i] * p.xpoints[j]);1144 cy += (p.ypoints[i] + p.ypoints[j]) * (p.xpoints[i] * p.ypoints[j] - p.ypoints[i] * p.xpoints[j]);1145 }1146 return new Point2D.Double(cx / (3.0*a), cy / (3.0*a));1139 double cx = 0.0, cy = 0.0, a = 0.0; 1140 1141 // usually requires points[0] == points[npoints] and can then use i+1 instead of j. 1142 // Faked it slowly using j. If this is really gets used, this should be fixed. 1143 for (int i = 0; i < p.npoints; i++) { 1144 int j = i+1 == p.npoints ? 0 : i+1; 1145 a += (p.xpoints[i] * p.ypoints[j]) - (p.ypoints[i] * p.xpoints[j]); 1146 cx += (p.xpoints[i] + p.xpoints[j]) * (p.xpoints[i] * p.ypoints[j] - p.ypoints[i] * p.xpoints[j]); 1147 cy += (p.ypoints[i] + p.ypoints[j]) * (p.xpoints[i] * p.ypoints[j] - p.ypoints[i] * p.xpoints[j]); 1148 } 1149 return new Point2D.Double(cx / (3.0*a), cy / (3.0*a)); 1147 1150 } 1148 1151 1149 1152 protected double getArea(Polygon p) 1150 1153 { 1151 double sum = 0.0;1152 1153 // usually requires points[0] == points[npoints] and can then use i+1 instead of j.1154 // Faked it slowly using j. If this is really gets used, this should be fixed.1155 for (int i = 0; i < p.npoints; i++) {1156 int j = i+1 == p.npoints ? 0 : i+1;1157 sum = sum + (p.xpoints[i] * p.ypoints[j]) - (p.ypoints[i] * p.xpoints[j]);1158 }1159 return Math.abs(sum/2.0);1154 double sum = 0.0; 1155 1156 // usually requires points[0] == points[npoints] and can then use i+1 instead of j. 1157 // Faked it slowly using j. If this is really gets used, this should be fixed. 1158 for (int i = 0; i < p.npoints; i++) { 1159 int j = i+1 == p.npoints ? 0 : i+1; 1160 sum = sum + (p.xpoints[i] * p.ypoints[j]) - (p.ypoints[i] * p.xpoints[j]); 1161 } 1162 return Math.abs(sum/2.0); 1160 1163 } 1161 1164 … … 1168 1171 g.fillPolygon(polygon); 1169 1172 1170 if (showNames > dist) {1171 String name = getWayName(w);1172 if (name!=null /* && annotate */) {1173 Rectangle pb = polygon.getBounds();1174 FontMetrics fontMetrics = g.getFontMetrics(orderFont); // if slow, use cache1175 Rectangle2D nb = fontMetrics.getStringBounds(name, g); // if slow, approximate by strlen()*maxcharbounds(font)1176 1177 // Point2D c = getCentroid(polygon);1178 // Using the Centroid is Nicer for buildings like: +--------+1179 // but this needs to be fast. As most houses are | 42 |1180 // boxes anyway, the center of the bounding box +---++---+1181 // will have to do. ++1182 // Centroids are not optimal either, just imagine a U-shaped house.1183 // Point2D c = new Point2D.Double(pb.x + pb.width / 2.0, pb.y + pb.height / 2.0);1184 // Rectangle2D.Double centeredNBounds =1185 // new Rectangle2D.Double(c.getX() - nb.getWidth()/2,1186 // c.getY() - nb.getHeight()/2,1187 // nb.getWidth(),1188 // nb.getHeight());1189 1190 Rectangle centeredNBounds = new Rectangle(pb.x + (int)((pb.width - nb.getWidth())/2.0),1191 pb.y + (int)((pb.height - nb.getHeight())/2.0),1192 (int)nb.getWidth(),1193 (int)nb.getHeight());1194 1195 //// Draw name bounding box for debugging:1196 // g.setColor(new Color(255,255,0,128));1197 // g.drawRect((int)centeredNBounds.getMinX(),1198 // (int)centeredNBounds.getMinY(),1199 // (int)centeredNBounds.getWidth(),1200 // (int)centeredNBounds.getHeight());1201 1202 if ((pb.width >= nb.getWidth() && pb.height >= nb.getHeight()) && // quick check1203 polygon.contains(centeredNBounds) // slow but nice1204 ) {1205 g.setColor(areaTextColor);1206 Font defaultFont = g.getFont();1207 g.setFont (orderFont);1208 g.drawString (name,1209 (int)(centeredNBounds.getMinX() - nb.getMinX()),1210 (int)(centeredNBounds.getMinY() - nb.getMinY()));1211 g.setFont(defaultFont);1212 }1213 }1214 }1173 if (showNames > dist) { 1174 String name = getWayName(w); 1175 if (name!=null /* && annotate */) { 1176 Rectangle pb = polygon.getBounds(); 1177 FontMetrics fontMetrics = g.getFontMetrics(orderFont); // if slow, use cache 1178 Rectangle2D nb = fontMetrics.getStringBounds(name, g); // if slow, approximate by strlen()*maxcharbounds(font) 1179 1180 // Point2D c = getCentroid(polygon); 1181 // Using the Centroid is Nicer for buildings like: +--------+ 1182 // but this needs to be fast. As most houses are | 42 | 1183 // boxes anyway, the center of the bounding box +---++---+ 1184 // will have to do. ++ 1185 // Centroids are not optimal either, just imagine a U-shaped house. 1186 // Point2D c = new Point2D.Double(pb.x + pb.width / 2.0, pb.y + pb.height / 2.0); 1187 // Rectangle2D.Double centeredNBounds = 1188 // new Rectangle2D.Double(c.getX() - nb.getWidth()/2, 1189 // c.getY() - nb.getHeight()/2, 1190 // nb.getWidth(), 1191 // nb.getHeight()); 1192 1193 Rectangle centeredNBounds = new Rectangle(pb.x + (int)((pb.width - nb.getWidth())/2.0), 1194 pb.y + (int)((pb.height - nb.getHeight())/2.0), 1195 (int)nb.getWidth(), 1196 (int)nb.getHeight()); 1197 1198 //// Draw name bounding box for debugging: 1199 // g.setColor(new Color(255,255,0,128)); 1200 // g.drawRect((int)centeredNBounds.getMinX(), 1201 // (int)centeredNBounds.getMinY(), 1202 // (int)centeredNBounds.getWidth(), 1203 // (int)centeredNBounds.getHeight()); 1204 1205 if ((pb.width >= nb.getWidth() && pb.height >= nb.getHeight()) && // quick check 1206 polygon.contains(centeredNBounds) // slow but nice 1207 ) { 1208 g.setColor(areaTextColor); 1209 Font defaultFont = g.getFont(); 1210 g.setFont (orderFont); 1211 g.drawString (name, 1212 (int)(centeredNBounds.getMinX() - nb.getMinX()), 1213 (int)(centeredNBounds.getMinY() - nb.getMinY())); 1214 g.setFont(defaultFont); 1215 } 1216 } 1217 } 1215 1218 } 1216 1219 1217 1220 protected String getWayName(Way w) { 1218 String name = null;1219 if (w.hasKeys()) {1220 for (String rn : regionalNameOrder) {1221 name = w.get(rn);1222 if (name != null) {1223 break;1224 }1225 }1226 }1227 return name;1221 String name = null; 1222 if (w.hasKeys()) { 1223 for (String rn : regionalNameOrder) { 1224 name = w.get(rn); 1225 if (name != null) { 1226 break; 1227 } 1228 } 1229 } 1230 return name; 1228 1231 } 1229 1232 … … 1410 1413 ArrayList<T> sorted = new ArrayList<T>(prims); 1411 1414 Collections.sort(sorted, 1412 new Comparator<T>() { 1413 public int compare(T o1, T o2) {1414 boolean s1 = data.isSelected(o1);1415 boolean s2 = data.isSelected(o2);1416 if (s1 && !s2)1417 return 1;1418 if (!s1 && s2)1419 return -1;1420 return o1.compareTo(o2);1421 }1422 });1415 new Comparator<T>() { 1416 public int compare(T o1, T o2) { 1417 boolean s1 = data.isSelected(o1); 1418 boolean s2 = data.isSelected(o2); 1419 if (s1 && !s2) 1420 return 1; 1421 if (!s1 && s2) 1422 return -1; 1423 return o1.compareTo(o2); 1424 } 1425 }); 1423 1426 return sorted; 1424 1427 } … … 1431 1434 //profilerOmitDraw = Main.pref.getBoolean("mappaint.profiler.omitdraw",false); 1432 1435 1433 useStyleCache = Main.pref.getBoolean("mappaint.cache",true); 1436 useStyleCache = Main.pref.getBoolean("mappaint.cache", true); 1434 1437 int fillAreas = Main.pref.getInteger("mappaint.fillareas", 10000000); 1435 1438 fillAlpha = Math.min(255, Math.max(0, Integer.valueOf(Main.pref.getInteger("mappaint.fillalpha", 50)))); … … 1437 1440 showIcons = Main.pref.getInteger("mappaint.showicons", 10000000); 1438 1441 useStrokes = Main.pref.getInteger("mappaint.strokes", 10000000); 1439 LatLon ll1 = nc.getLatLon(0,0); 1440 LatLon ll2 = nc.getLatLon(100,0); 1442 LatLon ll1 = nc.getLatLon(0, 0); 1443 LatLon ll2 = nc.getLatLon(100, 0); 1441 1444 dist = ll1.greatCircleDistance(ll2); 1442 1445 … … 1452 1455 1453 1456 getSettings(virtual); 1454 useRealWidth = Main.pref.getBoolean("mappaint.useRealWidth",false); 1455 zoomLevelDisplay = Main.pref.getBoolean("mappaint.zoomLevelDisplay",false); 1457 useRealWidth = Main.pref.getBoolean("mappaint.useRealWidth", false); 1458 zoomLevelDisplay = Main.pref.getBoolean("mappaint.zoomLevelDisplay", false); 1456 1459 circum = Main.map.mapView.getDist100Pixel(); 1457 1460 styles = MapPaintStyles.getStyles().getStyleSet(); 1458 drawMultipolygon = Main.pref.getBoolean("mappaint.multipolygon",true); 1459 drawRestriction = Main.pref.getBoolean("mappaint.restriction",true); 1461 drawMultipolygon = Main.pref.getBoolean("mappaint.multipolygon", true); 1462 drawRestriction = Main.pref.getBoolean("mappaint.restriction", true); 1460 1463 //restrictionDebug = Main.pref.getBoolean("mappaint.restriction.debug",false); 1461 leftHandTraffic = Main.pref.getBoolean("mappaint.lefthandtraffic",false); 1462 orderFont = new Font(Main.pref.get("mappaint.font","Helvetica"), Font.PLAIN, Main.pref.getInteger("mappaint.fontsize", 8)); 1463 String[] names = {"name:" +LanguageInfo.getJOSMLocaleCode(), "name", "int_name", "ref", "operator", "brand","addr:housenumber"};1464 leftHandTraffic = Main.pref.getBoolean("mappaint.lefthandtraffic", false); 1465 orderFont = new Font(Main.pref.get("mappaint.font", "Helvetica"), Font.PLAIN, Main.pref.getInteger("mappaint.fontsize", 8)); 1466 String[] names = {"name:" + LanguageInfo.getJOSMLocaleCode(), "name", "int_name", "ref", "operator", "brand", "addr:housenumber"}; 1464 1467 regionalNameOrder = Main.pref.getCollection("mappaint.nameOrder", Arrays.asList(names)); 1465 minEN = nc.getEastNorth(0,nc.getHeight() -1);1466 maxEN = nc.getEastNorth(nc.getWidth() -1,0);1468 minEN = nc.getEastNorth(0, nc.getHeight() - 1); 1469 maxEN = nc.getEastNorth(nc.getWidth() - 1, 0); 1467 1470 1468 1471 … … 1487 1490 /*** RELATIONS ***/ 1488 1491 // profilerN = 0; 1489 for (final Relation osm : data.relations) 1490 { 1491 if(drawable(osm) && osm.mappaintVisibleCode != viewid) 1492 { 1492 for (final Relation osm: data.getRelations()) { 1493 if (drawable(osm) && osm.mappaintVisibleCode != viewid) { 1493 1494 paintUnselectedRelation(osm); 1494 1495 // profilerN++; … … 1504 1505 /*** AREAS ***/ 1505 1506 // profilerN = 0; 1506 for (final Way osm : selectedLast(data, data. ways)) {1507 for (final Way osm : selectedLast(data, data.getWays())) { 1507 1508 if (drawable(osm) 1508 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) 1509 { 1510 if(isPrimitiveArea(osm) && osm.mappaintDrawnAreaCode != paintid) 1511 { 1509 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) { 1510 if (isPrimitiveArea(osm) && osm.mappaintDrawnAreaCode != paintid) { 1512 1511 drawWay(osm, fillAreas); 1513 1512 // profilerN++; 1514 1513 }// else { 1515 noAreaWays.add(osm);1514 noAreaWays.add(osm); 1516 1515 //} 1517 1516 } … … 1527 1526 /*** WAYS ***/ 1528 1527 // profilerN = 0; 1529 for (final Way osm : noAreaWays) 1530 { 1528 for (final Way osm : noAreaWays) { 1531 1529 drawWay(osm, 0); 1532 1530 // profilerN++; … … 1539 1537 // profilerLast = java.lang.System.currentTimeMillis(); 1540 1538 // } 1541 } 1542 else 1543 { 1539 } else { 1544 1540 /*** WAYS (filling disabled) ***/ 1545 1541 // profilerN = 0; 1546 for (final Way way : data.ways)1542 for (final Way way: data.getWays()) { 1547 1543 if (drawable(way) && !data.isSelected(way) 1548 && way.mappaintVisibleCode != viewid ) 1549 { 1544 && way.mappaintVisibleCode != viewid) { 1550 1545 drawWay(way, 0); 1551 1546 // profilerN++; 1552 1547 } 1548 } 1553 1549 1554 1550 // if(profiler) … … 1565 1561 if (!osm.incomplete && !osm.isDeleted() && !(osm instanceof Node) 1566 1562 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid 1567 ) 1568 { 1563 ) { 1569 1564 osm.visit(new AbstractVisitor() { 1570 1565 public void visit(Way w) { 1571 1566 drawWay(w, 0); 1572 1567 } 1568 1573 1569 public void visit(Node n) { 1574 1570 drawNode(n); 1575 1571 } 1572 1576 1573 public void visit(Relation r) { 1577 1574 /* TODO: is it possible to do this like the nodes/ways code? */ … … 1601 1598 /*** NODES ***/ 1602 1599 //profilerN = 0; 1603 for (final Node osm : data.nodes)1600 for (final Node osm: data.getNodes()) { 1604 1601 if (!osm.incomplete && !osm.isDeleted() && (data.isSelected(osm) || !osm.isFiltered()) 1605 1602 && osm.mappaintVisibleCode != viewid && osm.mappaintDrawnCode != paintid) … … 1608 1605 // profilerN++; 1609 1606 } 1607 } 1610 1608 1611 1609 //if(profiler) … … 1617 1615 1618 1616 /*** VIRTUAL ***/ 1619 if (virtualNodeSize != 0) 1620 { 1617 if (virtualNodeSize != 0) { 1621 1618 // profilerN = 0; 1622 1619 currentColor = nodeColor; 1623 for (final OsmPrimitive osm : data.ways)1620 for (final OsmPrimitive osm: data.getWays()) { 1624 1621 if (osm.isUsable() && !osm.isFiltered() 1625 1622 && osm.mappaintVisibleCode != viewid ) … … 1630 1627 // profilerN++; 1631 1628 } 1629 } 1632 1630 1633 1631 // if(profiler) -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitor.java
r2273 r2381 228 228 for (OsmPrimitive primitive : mappedPrimitives.keySet()) { 229 229 OsmPrimitive clone = mappedPrimitives.get(primitive); 230 if (clone instanceof Node) { 231 hull.nodes.add((Node)clone); 232 } else if (clone instanceof Way) { 233 hull.ways.add((Way)clone); 234 } else if (clone instanceof Relation) { 235 hull.relations.add((Relation)clone); 236 } 230 hull.addPrimitive(clone); 237 231 } 238 232 } -
trunk/src/org/openstreetmap/josm/data/osm/visitor/MergeVisitor.java
r2303 r2381 1 // License: GPL. Copyright 2007 by Immanuel Scholz and others2 1 package org.openstreetmap.josm.data.osm.visitor; 3 2 … … 60 59 this.theirDataSet = theirDataSet; 61 60 62 for (Node n : myDataSet.nodes) if (!n.isNew()) { 63 nodeshash.put(n.getId(), n); 64 } 65 for (Way w : myDataSet.ways) if (!w.isNew()) { 66 wayshash.put(w.getId(), w); 67 } 68 for (Relation r : myDataSet.relations) if (!r.isNew()) { 69 relshash.put(r.getId(), r); 61 for (Node n : myDataSet.getNodes()) { 62 if (!n.isNew()) { 63 nodeshash.put(n.getId(), n); 64 } 65 } 66 for (Way w : myDataSet.getWays()) { 67 if (!w.isNew()) { 68 wayshash.put(w.getId(), w); 69 } 70 } 71 for (Relation r : myDataSet.getRelations()) { 72 if (!r.isNew()) { 73 relshash.put(r.getId(), r); 74 } 70 75 } 71 76 conflicts = new ConflictCollection(); … … 162 167 */ 163 168 public void fixReferences() { 164 for (Way w : myDataSet. ways) {169 for (Way w : myDataSet.getWays()) { 165 170 fixWay(w); 166 171 fixIncomplete(w); 167 172 } 168 for (Relation r : myDataSet. relations) {173 for (Relation r : myDataSet.getRelations()) { 169 174 fixRelation(r); 170 175 } 171 176 for (OsmPrimitive osm : conflicts.getMyConflictParties()) 172 177 if (osm instanceof Way) { 173 fixWay((Way)osm); 178 fixWay((Way) osm); 174 179 } else if (osm instanceof Relation) { 175 180 fixRelation((Relation) osm); -
trunk/src/org/openstreetmap/josm/data/osm/visitor/SimplePaintVisitor.java
r2264 r2381 150 150 require changing the colour while painting... */ 151 151 //profilerN = 0; 152 for (final OsmPrimitive osm : data.relations) 152 for (final OsmPrimitive osm: data.getRelations()) { 153 if (!osm.isDeleted() && !ds.isSelected(osm) && !osm.isFiltered()) { 154 osm.visit(this); 155 // profilerN++; 156 } 157 } 158 159 //if(profiler) 160 //{ 161 // System.out.format("Relations: %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 162 // profilerLast = java.lang.System.currentTimeMillis(); 163 //} 164 165 //profilerN = 0; 166 for (final OsmPrimitive osm:data.getWays()){ 167 if (!osm.isDeleted() && !ds.isSelected(osm) && !osm.isFiltered() && osm.isTagged()) { 168 osm.visit(this); 169 // profilerN++; 170 } 171 } 172 displaySegments(); 173 174 for (final OsmPrimitive osm:data.getWays()){ 175 if (!osm.isDeleted() && !ds.isSelected(osm) && !osm.isFiltered() && !osm.isTagged()) { 176 osm.visit(this); 177 // profilerN++; 178 } 179 } 180 displaySegments(); 181 182 //if(profiler) 183 //{ 184 // System.out.format("Ways : %4dms, n=%5d\n", 185 // (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 186 // profilerLast = java.lang.System.currentTimeMillis(); 187 //} 188 189 //profilerN = 0; 190 for (final OsmPrimitive osm : data.getSelected()) 191 if (!osm.isDeleted()) { 192 osm.visit(this); 193 // profilerN++; 194 } 195 displaySegments(); 196 197 //if(profiler) 198 //{ 199 // System.out.format("Selected : %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 200 // profilerLast = java.lang.System.currentTimeMillis(); 201 //} 202 203 //profilerN = 0; 204 for (final OsmPrimitive osm: data.getNodes()) { 153 205 if (!osm.isDeleted() && !ds.isSelected(osm) && !osm.isFiltered()) 154 206 { … … 156 208 // profilerN++; 157 209 } 158 159 //if(profiler) 160 //{ 161 // System.out.format("Relations: %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 162 // profilerLast = java.lang.System.currentTimeMillis(); 163 //} 164 165 //profilerN = 0; 166 for (final OsmPrimitive osm : data.ways) 167 if (!osm.isDeleted() && !ds.isSelected(osm) && !osm.isFiltered() && osm.isTagged()) 168 { 169 osm.visit(this); 170 // profilerN++; 171 } 172 displaySegments(); 173 174 for (final OsmPrimitive osm : data.ways) 175 if (!osm.isDeleted() && !ds.isSelected(osm) && !osm.isFiltered() && !osm.isTagged()) 176 { 177 osm.visit(this); 178 // profilerN++; 179 } 180 displaySegments(); 181 182 //if(profiler) 183 //{ 184 // System.out.format("Ways : %4dms, n=%5d\n", 185 // (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 186 // profilerLast = java.lang.System.currentTimeMillis(); 187 //} 188 189 //profilerN = 0; 190 for (final OsmPrimitive osm : data.getSelected()) 191 if (!osm.isDeleted()) 192 { 193 osm.visit(this); 194 // profilerN++; 195 } 196 displaySegments(); 197 198 //if(profiler) 199 //{ 200 // System.out.format("Selected : %4dms, n=%5d\n", (java.lang.System.currentTimeMillis()-profilerLast), profilerN); 201 // profilerLast = java.lang.System.currentTimeMillis(); 202 //} 203 204 //profilerN = 0; 205 for (final OsmPrimitive osm : data.nodes) 206 if (!osm.isDeleted() && !ds.isSelected(osm) && !osm.isFiltered()) 207 { 208 osm.visit(this); 209 // profilerN++; 210 } 210 } 211 211 212 212 //if(profiler) … … 217 217 //} 218 218 219 if(virtualNodeSize != 0) 220 { 219 if (virtualNodeSize != 0) { 221 220 // profilerN = 0; 222 221 currentColor = nodeColor; 223 for (final OsmPrimitive osm : data.ways) 224 if (!osm.isDeleted() && !osm.isDisabled() && !osm.isFiltered()) 225 { 226 visitVirtual((Way)osm); 222 for (final OsmPrimitive osm:data.getWays()){ 223 if (!osm.isDeleted() && !osm.isDisabled() && !osm.isFiltered()) { 224 visitVirtual((Way) osm); 227 225 // profilerN++; 228 226 } 227 } 229 228 displaySegments(); 230 229
Note:
See TracChangeset
for help on using the changeset viewer.
