Changeset 2381 in josm
- Timestamp:
- 2009-11-02T07:51:28+01:00 (15 years ago)
- Location:
- trunk
- Files:
-
- 40 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/.classpath
r1650 r2381 5 5 <classpathentry kind="src" path="test/functional"/> 6 6 <classpathentry excluding="build/|dist/|src/|test/|test/unit/|test/functional/" including="images/|presets/|styles/" kind="src" path=""/> 7 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER "/>7 <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JDK 5"/> 8 8 <classpathentry kind="lib" path="lib/metadata-extractor-2.3.1-nosun.jar"/> 9 9 <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> -
trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java
r2356 r2381 250 250 */ 251 251 public void build(DataSet ds) { 252 for (Relation r : ds.relations) {252 for (Relation r : ds.getRelations()) { 253 253 if (!r.isUsable()) { 254 254 continue; -
trunk/src/org/openstreetmap/josm/actions/SplitWayAction.java
r2323 r2381 103 103 HashMap<Way, Integer> wayOccurenceCounter = new HashMap<Way, Integer>(); 104 104 for (Node n : selectedNodes) { 105 for (Way w : getCurrentDataSet(). ways) {105 for (Way w : getCurrentDataSet().getWays()) { 106 106 if (!w.isUsable()) { 107 107 continue; 108 108 } 109 int last = w.getNodesCount() -1;110 if (last <= 0) {109 int last = w.getNodesCount() - 1; 110 if (last <= 0) { 111 111 continue; // zero or one node ways 112 112 } … … 116 116 if ((circular || (i > 0 && i < last)) && n.equals(wn)) { 117 117 Integer old = wayOccurenceCounter.get(w); 118 wayOccurenceCounter.put(w, (old == null) ? 1 : old +1);118 wayOccurenceCounter.put(w, (old == null) ? 1 : old + 1); 119 119 break; 120 120 } … … 248 248 249 249 if (wayChunks.size() < 2) { 250 if (wayChunks.get(0).get(0) == wayChunks.get(0).get(wayChunks.get(0).size()-1)) {250 if (wayChunks.get(0).get(0) == wayChunks.get(0).get(wayChunks.get(0).size() - 1)) { 251 251 JOptionPane.showMessageDialog( 252 252 Main.parent, … … 290 290 291 291 } 292 Boolean warnmerole =false;293 Boolean warnme =false;292 Boolean warnmerole = false; 293 Boolean warnme = false; 294 294 // now copy all relations to new way also 295 295 296 for (Relation r : getCurrentDataSet(). relations) {296 for (Relation r : getCurrentDataSet().getRelations()) { 297 297 if (!r.isUsable()) { 298 298 continue; … … 307 307 for (RelationMember rm : r.getMembers()) { 308 308 if (rm.isWay()) { 309 if (rm.getMember() == selectedWay) 310 { 311 if(!("route".equals(type)) && !("multipolygon".equals(type))) { 309 if (rm.getMember() == selectedWay) { 310 if (!("route".equals(type)) && !("multipolygon".equals(type))) { 312 311 warnme = true; 313 312 } … … 318 317 int j = i; 319 318 boolean backwards = "backward".equals(rm.getRole()); 320 for(Way wayToAdd : newWays) 321 { 319 for (Way wayToAdd : newWays) { 322 320 RelationMember em = new RelationMember(rm.getRole(), wayToAdd); 323 if (em.hasRole() && !("multipolygon".equals(type))) {321 if (em.hasRole() && !("multipolygon".equals(type))) { 324 322 warnmerole = true; 325 323 } … … 342 340 } 343 341 } 344 if (warnmerole) {342 if (warnmerole) { 345 343 JOptionPane.showMessageDialog( 346 344 Main.parent, … … 348 346 tr("Warning"), 349 347 JOptionPane.WARNING_MESSAGE); 350 } else if (warnme) {348 } else if (warnme) { 351 349 JOptionPane.showMessageDialog( 352 350 Main.parent, -
trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java
r2323 r2381 67 67 if (checkSelection(selection)) { 68 68 int count = 0; 69 for (Way w : getCurrentDataSet(). ways) {69 for (Way w : getCurrentDataSet().getWays()) { 70 70 if (!w.isUsable() || w.getNodesCount() < 1) { 71 71 continue; … … 79 79 // If there aren't enough ways, maybe the user wanted to unglue the nodes 80 80 // (= copy tags to a new node) 81 if (checkForUnglueNode(selection)) {81 if (checkForUnglueNode(selection)) { 82 82 unglueNode(e); 83 83 } else { … … 92 92 for (Node n : selectedNodes) { 93 93 int count = 0; 94 for (Way w : getCurrentDataSet(). ways) {94 for (Way w : getCurrentDataSet().getWays()) { 95 95 if (w.isDeleted() || w.incomplete || w.getNodesCount() < 1) { 96 96 continue; … … 185 185 */ 186 186 private boolean checkForUnglueNode(Collection<? extends OsmPrimitive> selection) { 187 if (selection.size() != 1)187 if (selection.size() != 1) 188 188 return false; 189 189 OsmPrimitive n = (OsmPrimitive) selection.toArray()[0]; 190 if (!(n instanceof Node))190 if (!(n instanceof Node)) 191 191 return false; 192 192 boolean isPartOfWay = false; 193 for (Way w : getCurrentDataSet().ways) {194 if (w.containsNode((Node)n)) {193 for (Way w : getCurrentDataSet().getWays()) { 194 if (w.containsNode((Node) n)) { 195 195 isPartOfWay = true; 196 196 break; 197 197 } 198 198 } 199 if (!isPartOfWay)200 return false; 201 202 selectedNode = (Node) n;203 return 199 if (!isPartOfWay) 200 return false; 201 202 selectedNode = (Node) n; 203 return selectedNode.isTagged(); 204 204 } 205 205 … … 322 322 Relation newRel = null; 323 323 HashSet<String> rolesToReAdd = null; 324 for (Relation r : getCurrentDataSet(). relations) {324 for (Relation r : getCurrentDataSet().getRelations()) { 325 325 if (r.isDeleted() || r.incomplete) { 326 326 continue; … … 367 367 boolean firstway = true; 368 368 // modify all ways containing the nodes 369 for (Way w : getCurrentDataSet(). ways) {369 for (Way w : getCurrentDataSet().getWays()) { 370 370 if (w.isDeleted() || w.incomplete || w.getNodesCount() < 1) { 371 371 continue; -
trunk/src/org/openstreetmap/josm/actions/UpdateSelectionAction.java
r2323 r2381 219 219 // incomplete ways. 220 220 // 221 for (Way w : ds.ways) {221 for (Way w : ds.getWays()) { 222 222 if (w.incomplete) { 223 223 OsmServerObjectReader reader = new OsmServerObjectReader(w.getId(), OsmPrimitiveType.WAY, true /* full */); -
trunk/src/org/openstreetmap/josm/actions/UploadSelectionAction.java
r2323 r2381 68 68 protected Set<OsmPrimitive> getDeletedPrimitives(DataSet ds) { 69 69 HashSet<OsmPrimitive> ret = new HashSet<OsmPrimitive>(); 70 for (OsmPrimitive p : ds. nodes) {70 for (OsmPrimitive p : ds.getNodes()) { 71 71 if (p.isDeleted() && !p.isNew() && p.isVisible() && p.isModified()) { 72 72 ret.add(p); 73 73 } 74 74 } 75 for (OsmPrimitive p : ds. ways) {75 for (OsmPrimitive p : ds.getWays()) { 76 76 if (p.isDeleted() && !p.isNew() && p.isVisible() && p.isModified()) { 77 77 ret.add(p); 78 78 } 79 79 } 80 for (OsmPrimitive p : ds. relations) {80 for (OsmPrimitive p : ds.getRelations()) { 81 81 if (p.isDeleted() && !p.isNew() && p.isVisible() && p.isModified()) { 82 82 ret.add(p); -
trunk/src/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTaskList.java
r2336 r2381 2 2 package org.openstreetmap.josm.actions.downloadtasks; 3 3 4 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 4 5 import static org.openstreetmap.josm.tools.I18n.tr; 5 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;6 6 7 7 import java.awt.EventQueue; … … 106 106 protected Set<OsmPrimitive> getCompletePrimitives(DataSet ds) { 107 107 HashSet<OsmPrimitive> ret = new HashSet<OsmPrimitive>(); 108 for (OsmPrimitive primitive : ds. nodes) {108 for (OsmPrimitive primitive : ds.getNodes()) { 109 109 if (!primitive.incomplete && !primitive.isNew()) { 110 110 ret.add(primitive); 111 111 } 112 112 } 113 for (OsmPrimitive primitive : ds. ways) {113 for (OsmPrimitive primitive : ds.getWays()) { 114 114 if (!primitive.incomplete && !primitive.isNew()) { 115 115 ret.add(primitive); 116 116 } 117 117 } 118 for (OsmPrimitive primitive : ds. relations) {118 for (OsmPrimitive primitive : ds.getRelations()) { 119 119 if (!primitive.incomplete && !primitive.isNew()) { 120 120 ret.add(primitive); … … 155 155 ButtonSpec[] options = new ButtonSpec[] { 156 156 new ButtonSpec( 157 tr("Check on the server"), 157 tr("Check on the server"), 158 158 ImageProvider.get("ok"), 159 tr("Click to check whether objects in your local dataset are deleted on the server"), 159 tr("Click to check whether objects in your local dataset are deleted on the server"), 160 160 null /* no specific help topic */ 161 ), 161 ), 162 162 new ButtonSpec( 163 tr("Ignore"), 164 ImageProvider.get("cancel"), 165 tr("Click to abort and to resume editing"), 163 tr("Ignore"), 164 ImageProvider.get("cancel"), 165 tr("Click to abort and to resume editing"), 166 166 null /* no specific help topic */ 167 167 ), … … 172 172 + "update them the server is likely to report a<br>" + "conflict.<br>" + "<br>" 173 173 + "Click <strong>{1}</strong> to check the state of these primitives<br>" + "on the server.<br>" 174 + "Click <strong>{2}</strong> to ignore.<br>" + "</html>", 175 potentiallyDeleted.size(), 174 + "Click <strong>{2}</strong> to ignore.<br>" + "</html>", 175 potentiallyDeleted.size(), 176 176 options[0].text, 177 177 options[1].text 178 178 ); 179 179 180 180 int ret = HelpAwareOptionPane.showOptionDialog( 181 Main.parent, 182 message, 181 Main.parent, 182 message, 183 183 tr("Deleted or moved primitives"), 184 JOptionPane.WARNING_MESSAGE, 185 null, 186 options, 184 JOptionPane.WARNING_MESSAGE, 185 null, 186 options, 187 187 options[0], 188 188 ht("/Action/UpdateData#SyncPotentiallyDeletedObjects") … … 190 190 if (ret != 0 /* OK */) 191 191 return; 192 193 updatePotentiallyDeletedPrimitives(potentiallyDeleted); 192 193 updatePotentiallyDeletedPrimitives(potentiallyDeleted); 194 194 } 195 195 … … 205 205 DataSet ds = ((DownloadOsmTask) task).getDownloadedData(); 206 206 if (ds != null) { 207 ret.addAll(ds. nodes);208 ret.addAll(ds. ways);209 ret.addAll(ds. relations);207 ret.addAll(ds.getNodes()); 208 ret.addAll(ds.getWays()); 209 ret.addAll(ds.getRelations()); 210 210 } 211 211 } … … 242 242 } else if (error instanceof Exception) { 243 243 sb.append("<li>").append(ExceptionUtil.explainException((Exception) error)).append("</li>") 244 244 .append("<br>"); 245 245 } 246 246 } … … 272 272 DataSet ds = ((DownloadOsmTask) task).getDownloadedData(); 273 273 if (ds != null) { 274 myPrimitives.removeAll(ds. nodes);275 myPrimitives.removeAll(ds. ways);276 myPrimitives.removeAll(ds. relations);274 myPrimitives.removeAll(ds.getNodes()); 275 myPrimitives.removeAll(ds.getWays()); 276 myPrimitives.removeAll(ds.getRelations()); 277 277 } 278 278 } -
trunk/src/org/openstreetmap/josm/actions/mapmode/DrawAction.java
r2351 r2381 779 779 public Way getWayForNode(Node n) { 780 780 Way way = null; 781 for (Way w : getCurrentDataSet(). ways) {781 for (Way w : getCurrentDataSet().getWays()) { 782 782 if (!w.isUsable() || w.getNodesCount() < 1) { 783 783 continue; -
trunk/src/org/openstreetmap/josm/command/WayNodesConflictResolverCommand.java
r2163 r2381 69 69 // 70 70 for (Node n:mergedNodeList) { 71 if (! getLayer().data. nodes.contains(n)) {71 if (! getLayer().data.getNodes().contains(n)) { 72 72 logger.warning(tr("Main dataset does not include node {0}", n.toString())); 73 73 } -
trunk/src/org/openstreetmap/josm/corrector/ReverseWayTagCorrector.java
r1938 r2381 72 72 public Collection<Command> execute(Way oldway, Way way) throws UserCancelException { 73 73 Map<OsmPrimitive, List<TagCorrection>> tagCorrectionsMap = 74 new HashMap<OsmPrimitive, List<TagCorrection>>();74 new HashMap<OsmPrimitive, List<TagCorrection>>(); 75 75 76 76 ArrayList<OsmPrimitive> primitives = new ArrayList<OsmPrimitive>(); … … 112 112 113 113 Map<OsmPrimitive, List<RoleCorrection>> roleCorrectionMap = 114 new HashMap<OsmPrimitive, List<RoleCorrection>>();114 new HashMap<OsmPrimitive, List<RoleCorrection>>(); 115 115 roleCorrectionMap.put(way, new ArrayList<RoleCorrection>()); 116 116 117 for (Relation relation : Main.main.getCurrentDataSet(). relations) {117 for (Relation relation : Main.main.getCurrentDataSet().getRelations()) { 118 118 int position = 0; 119 119 for (RelationMember member : relation.getMembers()) { -
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 494 495 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 505 506 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 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 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 1152 1153 1154 1155 1156 1157 1158 1159 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 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 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 1219 1220 1221 1222 1223 1224 1225 1226 1227 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 1414 1415 1416 1417 1418 1419 1420 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 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 -
trunk/src/org/openstreetmap/josm/gui/NavigatableComponent.java
r2327 r2381 304 304 Node minPrimitive = null; 305 305 DataSet ds = getCurrentDataSet(); 306 if (ds == null)306 if (ds == null) 307 307 return null; 308 for (Node n : ds. nodes) {308 for (Node n : ds.getNodes()) { 309 309 if (!n.isUsable()) { 310 310 continue; … … 317 317 } 318 318 // when multiple nodes on one point, prefer new or selected nodes 319 else if (dist == minDistanceSq && minPrimitive != null319 else if (dist == minDistanceSq && minPrimitive != null 320 320 && ((n.isNew() && ds.isSelected(n)) 321 321 || (!ds.isSelected(minPrimitive) && (ds.isSelected(n) || n.isNew())))) { 322 322 minPrimitive = n; 323 323 } … … 335 335 TreeMap<Double, List<WaySegment>> nearest = new TreeMap<Double, List<WaySegment>>(); 336 336 DataSet ds = getCurrentDataSet(); 337 if (ds == null)337 if (ds == null) 338 338 return null; 339 for (Way w : ds. ways) {339 for (Way w : ds.getWays()) { 340 340 if (!w.isUsable()) { 341 341 continue; … … 358 358 double a = p.distanceSq(B); 359 359 double b = p.distanceSq(A); 360 double perDist = a -(a-b+c)*(a-b+c)/4/c; // perpendicular distance squared361 if (perDist < snapDistance && a < c +snapDistance && b < c+snapDistance) {362 if (ds.isSelected(w)) {360 double perDist = a - (a - b + c) * (a - b + c) / 4 / c; // perpendicular distance squared 361 if (perDist < snapDistance && a < c + snapDistance && b < c + snapDistance) { 362 if (ds.isSelected(w)) { 363 363 perDist -= 0.00001; 364 364 } … … 459 459 Collection<OsmPrimitive> nearest = new HashSet<OsmPrimitive>(); 460 460 DataSet ds = getCurrentDataSet(); 461 if (ds == null)461 if (ds == null) 462 462 return null; 463 for (Way w : ds. ways) {463 for (Way w : ds.getWays()) { 464 464 if (!w.isUsable()) { 465 465 continue; … … 479 479 double a = p.distanceSq(B); 480 480 double b = p.distanceSq(A); 481 double perDist = a -(a-b+c)*(a-b+c)/4/c; // perpendicular distance squared482 if (perDist < snapDistance && a < c +snapDistance && b < c+snapDistance) {481 double perDist = a - (a - b + c) * (a - b + c) / 4 / c; // perpendicular distance squared 482 if (perDist < snapDistance && a < c + snapDistance && b < c + snapDistance) { 483 483 nearest.add(w); 484 484 break; … … 487 487 } 488 488 } 489 for (Node n : ds. nodes) {489 for (Node n : ds.getNodes()) { 490 490 if (n.isUsable() 491 491 && getPoint(n).distanceSq(p) < snapDistance) { … … 507 507 Collection<Node> nearest = new HashSet<Node>(); 508 508 DataSet ds = getCurrentDataSet(); 509 if (ds == null)509 if (ds == null) 510 510 return null; 511 for (Node n : ds. nodes) {511 for (Node n : ds.getNodes()) { 512 512 if (n.isUsable() 513 513 && getPoint(n).distanceSq(p) < snapDistance) { -
trunk/src/org/openstreetmap/josm/gui/SelectionManager.java
r2120 r2381 285 285 } else { 286 286 // nodes 287 for (Node n : nc.getCurrentDataSet(). nodes) {287 for (Node n : nc.getCurrentDataSet().getNodes()) { 288 288 if (n.isUsable() && r.contains(nc.getPoint(n))) { 289 289 selection.add(n); … … 292 292 293 293 // ways 294 for (Way w : nc.getCurrentDataSet(). ways) {295 if (!w.isUsable() || w.getNodesCount() == 0) {294 for (Way w : nc.getCurrentDataSet().getWays()) { 295 if (!w.isUsable() || w.getNodesCount() == 0) { 296 296 continue; 297 297 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/PropertiesDialog.java
r2348 r2381 754 754 Map<Relation, Collection<RelationMember>> roles = new HashMap<Relation, Collection<RelationMember>>(); 755 755 if (Main.main.getCurrentDataSet() != null) { 756 for (Relation r : Main.main.getCurrentDataSet(). relations) {756 for (Relation r : Main.main.getCurrentDataSet().getRelations()) { 757 757 if (!r.isFiltered() && !r.incomplete && !r.isDeleted()) { 758 758 for (RelationMember m : r.getMembers()) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/RelationListDialog.java
r2348 r2381 147 147 protected int getNumRelations() { 148 148 if (Main.main.getCurrentDataSet() == null) return 0; 149 return Main.main.getCurrentDataSet(). relations.size();149 return Main.main.getCurrentDataSet().getRelations().size(); 150 150 } 151 151 … … 158 158 */ 159 159 protected ArrayList<Relation> getDisplayedRelationsInSortOrder(DataSet ds) { 160 ArrayList<Relation> relations = new ArrayList<Relation>(ds. relations.size());161 for (Relation r : ds.relations ){160 ArrayList<Relation> relations = new ArrayList<Relation>(ds.getRelations().size()); 161 for (Relation r : ds.getRelations()) { 162 162 if (!r.isUsable() || !r.isVisible()) { 163 163 continue; … … 170 170 new Comparator<Relation>() { 171 171 NameFormatter formatter = DefaultNameFormatter.getInstance(); 172 172 173 public int compare(Relation r1, Relation r2) { 173 174 return r1.getDisplayName(formatter).compareTo(r2.getDisplayName(formatter)); -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ChildRelationBrowser.java
r2273 r2381 258 258 return; 259 259 HashSet<Relation> relations = new HashSet<Relation>(); 260 for ( int i=0; i < selection.length;i++) {261 relations.add((Relation) selection[i].getLastPathComponent());260 for (TreePath aSelection : selection) { 261 relations.add((Relation) aSelection.getLastPathComponent()); 262 262 } 263 263 Main.worker.submit(new DownloadRelationSetTask(getParentDialog(),relations)); -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditor.java
r2378 r2381 138 138 //this.tagEditorModel.initFromPrimitive(relation); 139 139 this.memberTableModel.populate(relation); 140 if (!getLayer().data. relations.contains(relation)) {140 if (!getLayer().data.getRelations().contains(relation)) { 141 141 // treat it as a new relation if it doesn't exist in the 142 142 // data set yet. … … 597 597 ); 598 598 switch(ret) { 599 600 601 602 603 604 599 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION: return; 600 case JOptionPane.CLOSED_OPTION: return; 601 case JOptionPane.NO_OPTION: return; 602 case JOptionPane.YES_OPTION: 603 memberTableModel.removeMembersReferringTo(toCheck); 604 break; 605 605 } 606 606 } … … 633 633 ); 634 634 switch(ret) { 635 636 637 638 639 635 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION : return true; 636 case JOptionPane.YES_OPTION: return true; 637 case JOptionPane.NO_OPTION: return false; 638 case JOptionPane.CLOSED_OPTION: return false; 639 case JOptionPane.CANCEL_OPTION: throw new AddAbortException(); 640 640 } 641 641 // should not happen … … 1255 1255 ); 1256 1256 switch(ret) { 1257 1258 1259 1260 1257 case JOptionPane.YES_OPTION: return true; 1258 case ConditionalOptionPaneUtil.DIALOG_DISABLED_OPTION: return true; 1259 default: 1260 return false; 1261 1261 } 1262 1262 } -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ParentRelationLoadingTask.java
r2273 r2381 150 150 } 151 151 parents.clear(); 152 for (Relation parent : referrers. relations) {153 parents.add((Relation) getLayer().data.getPrimitiveById(parent.getId(),OsmPrimitiveType.RELATION));152 for (Relation parent : referrers.getRelations()) { 153 parents.add((Relation) getLayer().data.getPrimitiveById(parent.getId(), OsmPrimitiveType.RELATION)); 154 154 } 155 155 if (continuation != null) { -
trunk/src/org/openstreetmap/josm/gui/dialogs/relation/ReferringRelationsBrowserModel.java
r2273 r2381 79 79 return; 80 80 } 81 for (Relation parent : ds. relations) {81 for (Relation parent : ds.getRelations()) { 82 82 if (isReferringRelation(parent)) { 83 83 referrers.add(parent); -
trunk/src/org/openstreetmap/josm/gui/layer/GpxLayer.java
r2322 r2381 776 776 n.setTimestamp(DateUtils.fromString(timestr)); 777 777 } 778 ds. nodes.add(n);778 ds.addPrimitive(n); 779 779 nodes.add(n); 780 780 } 781 781 Way w = new Way(); 782 782 w.setNodes(nodes); 783 ds. ways.add(w);783 ds.addPrimitive(w); 784 784 } 785 785 } -
trunk/src/org/openstreetmap/josm/gui/layer/OsmDataLayer.java
r2327 r2381 3 3 package org.openstreetmap.josm.gui.layer; 4 4 5 import static org.openstreetmap.josm.gui.help.HelpUtil.ht; 5 6 import static org.openstreetmap.josm.tools.I18n.marktr; 6 import static org.openstreetmap.josm.gui.help.HelpUtil.ht;7 7 import static org.openstreetmap.josm.tools.I18n.tr; 8 8 import static org.openstreetmap.josm.tools.I18n.trn; … … 19 19 import java.awt.TexturePaint; 20 20 import java.awt.event.ActionEvent; 21 import java.awt.event.ActionListener;22 21 import java.awt.geom.Area; 23 22 import java.awt.image.BufferedImage; … … 32 31 import javax.swing.AbstractAction; 33 32 import javax.swing.Icon; 34 import javax.swing.JButton;35 import javax.swing.JDialog;36 33 import javax.swing.JLabel; 37 34 import javax.swing.JMenuItem; … … 68 65 import org.openstreetmap.josm.gui.dialogs.LayerListDialog; 69 66 import org.openstreetmap.josm.gui.dialogs.LayerListPopup; 70 import org.openstreetmap.josm.gui.help.HelpBrowser;71 import org.openstreetmap.josm.gui.help.HelpUtil;72 67 import org.openstreetmap.josm.tools.DateUtils; 73 68 import org.openstreetmap.josm.tools.GBC; 74 69 import org.openstreetmap.josm.tools.ImageProvider; 75 import org.openstreetmap.josm.tools.WindowGeometry;76 70 77 71 /** … … 256 250 @Override public String getToolTipText() { 257 251 String tool = ""; 258 tool += undeletedSize(data. nodes)+" "+trn("node", "nodes", undeletedSize(data.nodes))+", ";259 tool += undeletedSize(data. ways)+" "+trn("way", "ways", undeletedSize(data.ways));252 tool += undeletedSize(data.getNodes())+" "+trn("node", "nodes", undeletedSize(data.getNodes()))+", "; 253 tool += undeletedSize(data.getWays())+" "+trn("way", "ways", undeletedSize(data.getWays())); 260 254 if (data.version != null) { 261 255 tool += ", " + tr("version {0}", data.version); … … 350 344 numRemainingConflicts, 351 345 numRemainingConflicts 352 ); 353 } 354 346 ); 347 } 348 355 349 StringBuffer sb = new StringBuffer(); 356 350 sb.append("<html>").append(msg1); … … 369 363 tr("Click to close this dialog and continue editing"), 370 364 null /* no specific help */ 371 365 ) 372 366 }; 373 367 HelpAwareOptionPane.showOptionDialog( … … 380 374 options[0], 381 375 ht("/Concepts/Conflict#WarningAboutDetectedConflicts") 382 );376 ); 383 377 } 384 378 } … … 435 429 436 430 @Override public void visitBoundingBox(final BoundingXYVisitor v) { 437 for (final Node n : data.nodes)431 for (final Node n: data.getNodes()) { 438 432 if (n.isUsable()) { 439 433 v.visit(n); 440 434 } 435 } 441 436 } 442 437 … … 558 553 gpxData.storageFile = file; 559 554 HashSet<Node> doneNodes = new HashSet<Node>(); 560 for (Way w : data. ways) {555 for (Way w : data.getWays()) { 561 556 if (!w.isUsable()) { 562 557 continue; … … 583 578 } 584 579 WayPoint wpt = new WayPoint(n.getCoor()); 585 if (!n.isTimestampEmpty()) 586 { 580 if (!n.isTimestampEmpty()) { 587 581 wpt.attr.put("time", DateUtils.fromDate(n.getTimestamp())); 588 582 wpt.setTime(); … … 594 588 // what is this loop meant to do? it creates waypoints but never 595 589 // records them? 596 for (Node n : data. nodes) {590 for (Node n : data.getNodes()) { 597 591 if (n.incomplete || n.isDeleted() || doneNodes.contains(n)) { 598 592 continue; … … 607 601 wpt.attr.put("name", name); 608 602 } 603 ; 609 604 } 610 605 return gpxData; -
trunk/src/org/openstreetmap/josm/gui/layer/RawGpsLayer.java
r2179 r2381 78 78 for (GpsPoint p : c) { 79 79 Node n = new Node(p.latlon); 80 ds. nodes.add(n);80 ds.addPrimitive(n); 81 81 nodes.add(n); 82 82 } 83 83 Way w = new Way(); 84 84 w.setNodes(nodes); 85 ds. ways.add(w);85 ds.addPrimitive(w); 86 86 } 87 87 Main.main.addLayer(new OsmDataLayer(ds, tr("Converted from: {0}", RawGpsLayer.this.getName()), null)); -
trunk/src/org/openstreetmap/josm/gui/tagging/ac/AutoCompletionCache.java
r2088 r2381 150 150 cachePrimitive(primitive); 151 151 } 152 for (Relation relation : layer.data. relations) {152 for (Relation relation : layer.data.getRelations()) { 153 153 if (relation.incomplete || relation.isDeleted()) { 154 154 continue; -
trunk/src/org/openstreetmap/josm/io/OsmServerBackreferenceReader.java
r2361 r2381 221 221 progressMonitor.beginTask(null, 2); 222 222 try { 223 Collection<Way> waysToCheck = new ArrayList<Way>(ds. ways);223 Collection<Way> waysToCheck = new ArrayList<Way>(ds.getWays()); 224 224 if (isReadFull() ||primitiveType.equals(OsmPrimitiveType.NODE)) { 225 225 for (Way way: waysToCheck) { … … 233 233 } 234 234 if (isReadFull()) { 235 Collection<Relation> relationsToCheck = new ArrayList<Relation>(ds. relations);235 Collection<Relation> relationsToCheck = new ArrayList<Relation>(ds.getRelations()); 236 236 for (Relation relation: relationsToCheck) { 237 237 if (!relation.isNew() && relation.incomplete) { -
trunk/src/org/openstreetmap/josm/io/OsmWriter.java
r2327 r2381 72 72 73 73 public void writeContent(DataSet ds) { 74 for (Node n : ds. nodes)74 for (Node n : ds.getNodes()) { 75 75 if (shouldWrite(n)) { 76 76 visit(n); 77 77 } 78 for (Way w : ds.ways) 78 } 79 for (Way w : ds.getWays()) { 79 80 if (shouldWrite(w)) { 80 81 visit(w); 81 82 } 82 for (Relation e : ds.relations) 83 } 84 for (Relation e : ds.getRelations()) { 83 85 if (shouldWrite(e)) { 84 86 visit(e); 85 87 } 88 } 86 89 } 87 90 -
trunk/test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java
r2199 r2381 35 35 import org.openstreetmap.josm.data.projection.Mercator; 36 36 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 37 import org.xml.sax.SAXException;38 37 39 38 public class MultiFetchServerObjectReaderTest { … … 124 123 logger.info("creating data set on the server ..."); 125 124 ArrayList<OsmPrimitive> primitives = new ArrayList<OsmPrimitive>(); 126 primitives.addAll(testDataSet. nodes);127 primitives.addAll(testDataSet. ways);128 primitives.addAll(testDataSet. relations);125 primitives.addAll(testDataSet.getNodes()); 126 primitives.addAll(testDataSet.getWays()); 127 primitives.addAll(testDataSet.getRelations()); 129 128 130 129 OsmServerWriter writer = new OsmServerWriter(); … … 247 246 } 248 247 DataSet out = reader.parseOsm(NullProgressMonitor.INSTANCE); 249 assertEquals(10, out. nodes.size());248 assertEquals(10, out.getNodes().size()); 250 249 Iterator<Node> it = out.nodes.iterator(); 251 250 while(it.hasNext()) { … … 261 260 public void testMultiGet10Ways() throws OsmTransferException { 262 261 MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader(); 263 ArrayList<Way> ways= new ArrayList<Way>(ds. ways);262 ArrayList<Way> ways= new ArrayList<Way>(ds.getWays()); 264 263 for (int i =0; i< 10; i++) { 265 264 reader.append(ways.get(i)); 266 265 } 267 266 DataSet out = reader.parseOsm(NullProgressMonitor.INSTANCE); 268 assertEquals(10, out.ways.size()); 269 Iterator<Way> it = out.ways.iterator(); 270 while(it.hasNext()) { 271 Way w1 = it.next(); 267 assertEquals(10, out.getWays().size()); 268 for (Way w1: out.getWays()) { 272 269 Way w2 = (Way)ds.getPrimitiveById(w1.getId(), OsmPrimitiveType.WAY); 273 270 assertNotNull(w2); … … 281 278 public void testMultiGet10Relations() throws OsmTransferException { 282 279 MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader(); 283 ArrayList<Relation> relations= new ArrayList<Relation>(ds. relations);280 ArrayList<Relation> relations= new ArrayList<Relation>(ds.getRelations()); 284 281 for (int i =0; i< 10; i++) { 285 282 reader.append(relations.get(i)); 286 283 } 287 284 DataSet out = reader.parseOsm(NullProgressMonitor.INSTANCE); 288 assertEquals(10, out.relations.size()); 289 Iterator<Relation> it = out.relations.iterator(); 290 while(it.hasNext()) { 291 Relation r1 = it.next(); 285 assertEquals(10, out.getRelations().size()); 286 for (Relation r1: out.getRelations()) { 292 287 Relation r2 = (Relation)ds.getPrimitiveById(r1.getId(), OsmPrimitiveType.RELATION); 293 288 assertNotNull(r2); … … 301 296 public void testMultiGet800Nodes() throws OsmTransferException { 302 297 MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader(); 303 ArrayList<Node> nodes = new ArrayList<Node>(ds. nodes);298 ArrayList<Node> nodes = new ArrayList<Node>(ds.getNodes()); 304 299 for (int i =0; i< 812; i++) { 305 300 reader.append(nodes.get(i)); 306 301 } 307 302 DataSet out = reader.parseOsm(NullProgressMonitor.INSTANCE); 308 assertEquals(812, out. nodes.size());303 assertEquals(812, out.getNodes().size()); 309 304 Iterator<Node> it = out.nodes.iterator(); 310 305 while(it.hasNext()) { … … 320 315 public void multiGetWithNonExistingNode() throws OsmTransferException { 321 316 MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader(); 322 ArrayList<Node> nodes = new ArrayList<Node>(ds. nodes);317 ArrayList<Node> nodes = new ArrayList<Node>(ds.getNodes()); 323 318 for (int i =0; i< 10; i++) { 324 319 reader.append(nodes.get(i)); … … 327 322 reader.append(n); // doesn't exist 328 323 DataSet out = reader.parseOsm(NullProgressMonitor.INSTANCE); 329 assertEquals(10, out.nodes.size()); 330 Iterator<Node> it = out.nodes.iterator(); 331 while(it.hasNext()) { 332 Node n1 = it.next(); 324 assertEquals(10, out.getNodes().size()); 325 for (Node n1:out.getNodes()) { 333 326 Node n2 = (Node)ds.getPrimitiveById(n1.getId(), OsmPrimitiveType.NODE); 334 327 assertNotNull(n2); -
trunk/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java
r2199 r2381 34 34 import org.openstreetmap.josm.data.projection.Mercator; 35 35 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 36 import org.xml.sax.SAXException;37 36 38 37 public class OsmServerBackreferenceReaderTest { … … 40 39 41 40 protected static Node lookupNode(DataSet ds, int i) { 42 for (Node n : ds.nodes) {41 for (Node n : ds.getNodes()) { 43 42 if (("node-" + i).equals(n.get("name"))) return n; 44 43 } … … 48 47 49 48 protected static Way lookupWay(DataSet ds, int i) { 50 for (Way w : ds.ways) {49 for (Way w : ds.getWays()) { 51 50 if (("way-" + i).equals(w.get("name"))) return w; 52 51 } … … 55 54 56 55 protected static Relation lookupRelation(DataSet ds, int i) { 57 for (Relation r : ds.relations) {56 for (Relation r : ds.getRelations()) { 58 57 if (("relation-" + i).equals(r.get("name"))) return r; 59 58 } … … 103 102 } 104 103 } 105 ds. relations.add(r);104 ds.addPrimitive(r); 106 105 } 107 106 } … … 127 126 logger.info("creating data set on the server ..."); 128 127 ArrayList<OsmPrimitive> primitives = new ArrayList<OsmPrimitive>(); 129 primitives.addAll(ds. nodes);130 primitives.addAll(ds. ways);131 primitives.addAll(ds. relations);128 primitives.addAll(ds.getNodes()); 129 primitives.addAll(ds.getWays()); 130 primitives.addAll(ds.getRelations()); 132 131 OsmServerWriter writer = new OsmServerWriter(); 133 132 Changeset cs = new Changeset(); … … 253 252 reader.setReadFull(false); 254 253 DataSet referers = reader.parseOsm(NullProgressMonitor.INSTANCE); 255 assertEquals(10, referers. nodes.size());256 assertEquals(1, referers. ways.size());257 assertEquals(0, referers. relations.size());258 for (Way way : referers.ways) {254 assertEquals(10, referers.getNodes().size()); 255 assertEquals(1, referers.getWays().size()); 256 assertEquals(0, referers.getRelations().size()); 257 for (Way way : referers.getWays()) { 259 258 assertEquals(w.getId(), way.getId()); 260 259 assertEquals(false, way.incomplete); … … 272 271 reader.setReadFull(true); 273 272 DataSet referers = reader.parseOsm(NullProgressMonitor.INSTANCE); 274 assertEquals(10, referers. nodes.size());275 assertEquals(1, referers. ways.size());276 assertEquals(0, referers. relations.size());277 for (Way way : referers.ways) {273 assertEquals(10, referers.getNodes().size()); 274 assertEquals(1, referers.getWays().size()); 275 assertEquals(0, referers.getRelations().size()); 276 for (Way way : referers.getWays()) { 278 277 assertEquals(w.getId(), way.getId()); 279 278 assertEquals(false, way.incomplete); … … 292 291 reader.setReadFull(false); 293 292 DataSet referers = reader.parseOsm(NullProgressMonitor.INSTANCE); 294 assertEquals(0, referers. nodes.size()); // no nodes loaded295 assertEquals(6, referers. ways.size()); // 6 ways referred by two relations296 for (Way w1 : referers.ways) {293 assertEquals(0, referers.getNodes().size()); // no nodes loaded 294 assertEquals(6, referers.getWays().size()); // 6 ways referred by two relations 295 for (Way w1 : referers.getWays()) { 297 296 assertEquals(true, w1.incomplete); 298 297 } 299 assertEquals(2, referers. relations.size()); // two relations referring to w298 assertEquals(2, referers.getRelations().size()); // two relations referring to w 300 299 301 300 Relation r = lookupRelation(referers, 0); … … 316 315 reader.setReadFull(true); 317 316 DataSet referers = reader.parseOsm(NullProgressMonitor.INSTANCE); 318 assertEquals(6, referers. ways.size()); // 6 ways referred by two relations319 for (Way w1 : referers.ways) {317 assertEquals(6, referers.getWays().size()); // 6 ways referred by two relations 318 for (Way w1 : referers.getWays()) { 320 319 assertEquals(false, w1.incomplete); 321 320 } 322 assertEquals(2, referers. relations.size()); // two relations referring to321 assertEquals(2, referers.getRelations().size()); // two relations referring to 323 322 Set<Long> expectedNodeIds = new HashSet<Long>(); 324 for (Way way : referers.ways) {325 Way orig = (Way) ds.getPrimitiveById(way.getId(), OsmPrimitiveType.WAY);326 for (Node n: orig.getNodes()) {323 for (Way way : referers.getWays()) { 324 Way orig = (Way) ds.getPrimitiveById(way.getId(), OsmPrimitiveType.WAY); 325 for (Node n : orig.getNodes()) { 327 326 expectedNodeIds.add(n.getId()); 328 327 } 329 328 } 330 assertEquals(expectedNodeIds.size(), referers. nodes.size());331 for (Node n : referers. nodes) {329 assertEquals(expectedNodeIds.size(), referers.getNodes().size()); 330 for (Node n : referers.getNodes()) { 332 331 assertEquals(true, expectedNodeIds.contains(n.getId())); 333 332 } … … 342 341 @Test 343 342 public void testBackrefrenceForRelation() throws OsmTransferException { 344 Relation r = lookupRelation(ds, 1);343 Relation r = lookupRelation(ds, 1); 345 344 assertNotNull(r); 346 345 // way with name "relation-1" is referred to by four relations: … … 370 369 referringRelationsIds.add(r.getId()); 371 370 372 for (Relation r1 : referers.relations) {373 if (! 371 for (Relation r1 : referers.getRelations()) { 372 if (!referringRelationsIds.contains(r1.getId())) { 374 373 assertEquals(true, r1.incomplete); 375 374 } … … 401 400 } 402 401 403 assertEquals(expectedWayIds.size(), referers. ways.size());404 for (Way w1 : referers. ways) {402 assertEquals(expectedWayIds.size(), referers.getWays().size()); 403 for (Way w1 : referers.getWays()) { 405 404 assertEquals(true, expectedWayIds.contains(w1.getId())); 406 405 assertEquals(true, w1.incomplete); … … 409 408 // make sure we didn't read any nodes 410 409 // 411 assertEquals(0, referers. nodes.size());410 assertEquals(0, referers.getNodes().size()); 412 411 } 413 412 … … 438 437 @Test 439 438 public void testBackrefrenceForRelation_Full() throws OsmTransferException { 440 Relation r = lookupRelation(ds, 1);439 Relation r = lookupRelation(ds, 1); 441 440 assertNotNull(r); 442 441 // way with name "relation-1" is referred to by four relations: … … 468 467 // all relations are fully loaded 469 468 // 470 for (Relation r1 : referers.relations) {469 for (Relation r1 : referers.getRelations()) { 471 470 assertEquals(false, r1.incomplete); 472 471 } … … 497 496 } 498 497 for (long id : expectedWayIds) { 499 Way w = (Way) referers.getPrimitiveById(id, OsmPrimitiveType.WAY);498 Way w = (Way) referers.getPrimitiveById(id, OsmPrimitiveType.WAY); 500 499 assertNotNull(w); 501 500 assertEquals(false, w.incomplete); … … 503 502 504 503 Set<Long> expectedNodeIds = new HashSet<Long>(); 505 for (int i=6; i< 10;i++) {504 for (int i = 6; i < 10; i++) { 506 505 Relation r1 = lookupRelation(ds, i); 507 506 expectedNodeIds.addAll(getNodeIdsInRelation(r1)); 508 507 } 509 508 510 assertEquals(expectedNodeIds.size(), referers. nodes.size());511 for (Node n : referers.nodes) {509 assertEquals(expectedNodeIds.size(), referers.getNodes().size()); 510 for (Node n : referers.getNodes()) { 512 511 assertEquals(true, expectedNodeIds.contains(n.getId())); 513 512 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/APIDataSetTest.java
r2168 r2381 20 20 r.incomplete = false; 21 21 DataSet ds = new DataSet(); 22 ds. relations.add(r);22 ds.addPrimitive(r); 23 23 24 24 APIDataSet apiDataSet = new APIDataSet(); … … 48 48 49 49 DataSet ds = new DataSet(); 50 ds. relations.add(r1);51 ds. relations.add(r2);50 ds.addPrimitive(r1); 51 ds.addPrimitive(r2); 52 52 53 53 APIDataSet apiDataSet = new APIDataSet(); … … 88 88 89 89 DataSet ds = new DataSet(); 90 ds. relations.add(r1);91 ds. relations.add(r2);92 ds. relations.add(r3);93 ds. relations.add(r4);90 ds.addPrimitive(r1); 91 ds.addPrimitive(r2); 92 ds.addPrimitive(r3); 93 ds.addPrimitive(r4); 94 94 95 95 APIDataSet apiDataSet = new APIDataSet(); … … 130 130 131 131 DataSet ds = new DataSet(); 132 ds. relations.add(r1);133 ds. relations.add(r2);134 ds. relations.add(r3);132 ds.addPrimitive(r1); 133 ds.addPrimitive(r2); 134 ds.addPrimitive(r3); 135 135 136 136 APIDataSet apiDataSet = new APIDataSet(); … … 167 167 168 168 DataSet ds = new DataSet(); 169 ds. relations.add(r1);170 ds. relations.add(r2);171 ds. relations.add(r3);169 ds.addPrimitive(r1); 170 ds.addPrimitive(r2); 171 ds.addPrimitive(r3); 172 172 173 173 APIDataSet apiDataSet = new APIDataSet(); -
trunk/test/unit/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitorTest.java
r2077 r2381 40 40 Node n4 = new Node(new LatLon(20.0,20.0)); 41 41 n4.put("name","n4"); 42 source. nodes.add(n1);43 source. nodes.add(n2);44 source. nodes.add(n3);45 source. nodes.add(n4);42 source.addPrimitive(n1); 43 source.addPrimitive(n2); 44 source.addPrimitive(n3); 45 source.addPrimitive(n4); 46 46 source.setSelected(n1,n2); 47 47 … … 49 49 DataSet hull = builder.build(); 50 50 assertNotNull(hull); 51 assertEquals(2, hull. nodes.size());51 assertEquals(2, hull.getNodes().size()); 52 52 53 53 OsmPrimitive p = hull.getPrimitiveById(1,OsmPrimitiveType.NODE); … … 58 58 assertNull(p); 59 59 60 p = lookupByName(hull. nodes, "n2");61 assertNotNull(p); 62 63 p = lookupByName(hull. nodes, "n4");60 p = lookupByName(hull.getNodes(), "n2"); 61 assertNotNull(p); 62 63 p = lookupByName(hull.getNodes(), "n4"); 64 64 assertNull(p); 65 65 } … … 75 75 w1.addNode(n1); 76 76 w1.addNode(n2); 77 source. nodes.add(n1);78 source. nodes.add(n2);79 source. ways.add(w1);77 source.addPrimitive(n1); 78 source.addPrimitive(n2); 79 source.addPrimitive(w1); 80 80 source.setSelected(w1); 81 81 … … 83 83 DataSet hull = builder.build(); 84 84 assertNotNull(hull); 85 assertEquals(1, hull. ways.size());86 assertEquals(2, hull. nodes.size());85 assertEquals(1, hull.getWays().size()); 86 assertEquals(2, hull.getNodes().size()); 87 87 88 88 OsmPrimitive p = hull.getPrimitiveById(1,OsmPrimitiveType.NODE); … … 108 108 w1.addNode(n1); 109 109 w1.addNode(n2); 110 source. nodes.add(n1);111 source. nodes.add(n2);112 source. ways.add(w1);110 source.addPrimitive(n1); 111 source.addPrimitive(n2); 112 source.addPrimitive(w1); 113 113 source.setSelected(w1,n1,n2); 114 114 … … 116 116 DataSet hull = builder.build(); 117 117 assertNotNull(hull); 118 assertEquals(1, hull. ways.size());119 assertEquals(2, hull. nodes.size());118 assertEquals(1, hull.getWays().size()); 119 assertEquals(2, hull.getNodes().size()); 120 120 121 121 OsmPrimitive p = hull.getPrimitiveById(1,OsmPrimitiveType.NODE); … … 137 137 Way w1 = new Way(3); 138 138 w1.incomplete = true; 139 source. ways.add(w1);139 source.addPrimitive(w1); 140 140 source.setSelected(w1); 141 141 … … 143 143 DataSet hull = builder.build(); 144 144 assertNotNull(hull); 145 assertEquals(1, hull. ways.size());145 assertEquals(1, hull.getWays().size()); 146 146 147 147 OsmPrimitive p = hull.getPrimitiveById(3, OsmPrimitiveType.WAY); … … 167 167 Relation r40 = new Relation(40); 168 168 r1.addMember(new RelationMember("relation-40", r40)); 169 source. nodes.add(n20);170 source. nodes.add(n21);171 source. nodes.add(n22);172 source. ways.add(w30);173 source. relations.add(r1);174 source. relations.add(r40);169 source.addPrimitive(n20); 170 source.addPrimitive(n21); 171 source.addPrimitive(n22); 172 source.addPrimitive(w30); 173 source.addPrimitive(r1); 174 source.addPrimitive(r40); 175 175 source.setSelected(r1,n20,w30,r40); 176 176 … … 178 178 DataSet hull = builder.build(); 179 179 assertNotNull(hull); 180 assertEquals(1, hull. ways.size());181 assertEquals(3, hull. nodes.size());182 assertEquals(2, hull. relations.size());180 assertEquals(1, hull.getWays().size()); 181 assertEquals(3, hull.getNodes().size()); 182 assertEquals(2, hull.getRelations().size()); 183 183 184 184 OsmPrimitive p = hull.getPrimitiveById(1, OsmPrimitiveType.RELATION); … … 226 226 Relation r40 = new Relation(40); 227 227 r1.addMember(new RelationMember("relation-40", r40)); 228 source. nodes.add(n20);229 source. nodes.add(n21);230 source. nodes.add(n22);231 source. ways.add(w30);232 source. relations.add(r1);233 source. relations.add(r40);228 source.addPrimitive(n20); 229 source.addPrimitive(n21); 230 source.addPrimitive(n22); 231 source.addPrimitive(w30); 232 source.addPrimitive(r1); 233 source.addPrimitive(r40); 234 234 source.setSelected(r1); 235 235 … … 237 237 DataSet hull = builder.build(); 238 238 assertNotNull(hull); 239 assertEquals(1, hull. ways.size());240 assertEquals(1, hull. nodes.size());241 assertEquals(2, hull. relations.size());239 assertEquals(1, hull.getWays().size()); 240 assertEquals(1, hull.getNodes().size()); 241 assertEquals(2, hull.getRelations().size()); 242 242 243 243 OsmPrimitive p = hull.getPrimitiveById(1, OsmPrimitiveType.RELATION); … … 293 293 r1.addMember(new RelationMember("relation-40", r40)); 294 294 295 source. nodes.add(n20);296 source. nodes.add(n21);297 source. nodes.add(n22);298 source. ways.add(w30);299 source. relations.add(r1);300 source. relations.add(r40);295 source.addPrimitive(n20); 296 source.addPrimitive(n21); 297 source.addPrimitive(n22); 298 source.addPrimitive(w30); 299 source.addPrimitive(r1); 300 source.addPrimitive(r40); 301 301 source.setSelected(r1); 302 302 … … 304 304 DataSet hull = builder.build(); 305 305 assertNotNull(hull); 306 assertEquals(1, hull. ways.size());307 assertEquals(3, hull. nodes.size());308 assertEquals(2, hull. relations.size());309 310 OsmPrimitive p = lookupByName(hull. relations, "r1");306 assertEquals(1, hull.getWays().size()); 307 assertEquals(3, hull.getNodes().size()); 308 assertEquals(2, hull.getRelations().size()); 309 310 OsmPrimitive p = lookupByName(hull.getRelations(), "r1"); 311 311 assertNotNull(p); 312 312 assertEquals(p.getClass(), Relation.class); 313 313 314 Way w = (Way)lookupByName(hull. ways, "w30");314 Way w = (Way)lookupByName(hull.getWays(), "w30"); 315 315 assertNotNull(w); 316 316 assertEquals(2, w.getNodesCount()); 317 317 318 Node n = (Node)lookupByName(hull. nodes, "n21");318 Node n = (Node)lookupByName(hull.getNodes(), "n21"); 319 319 assertNotNull(n); 320 320 assertTrue(w.containsNode(n)); 321 321 322 n = (Node)lookupByName(hull. nodes, "n22");322 n = (Node)lookupByName(hull.getNodes(), "n22"); 323 323 assertNotNull(n); 324 324 assertTrue(w.containsNode(n)); 325 325 326 Relation r = (Relation)lookupByName(hull. relations, "r40");327 assertNotNull(r); 328 329 r = (Relation)lookupByName(hull. relations, "r1");326 Relation r = (Relation)lookupByName(hull.getRelations(), "r40"); 327 assertNotNull(r); 328 329 r = (Relation)lookupByName(hull.getRelations(), "r1"); 330 330 assertNotNull(r); 331 331 assertEquals(3, r.getMembersCount()); 332 RelationMember m = new RelationMember("node-20", lookupByName(hull. nodes, "n20"));332 RelationMember m = new RelationMember("node-20", lookupByName(hull.getNodes(), "n20")); 333 333 assertTrue(r.getMembers().contains(m)); 334 334 m = new RelationMember("way-30", lookupByName(hull.ways, "w30")); … … 343 343 Relation r1 = new Relation(1); 344 344 r1.addMember(new RelationMember("relation-1",r1)); 345 source. relations.add(r1);345 source.addPrimitive(r1); 346 346 source.setSelected(r1); 347 347 … … 349 349 DataSet hull = builder.build(); 350 350 assertNotNull(hull); 351 assertEquals(1, hull. relations.size());351 assertEquals(1, hull.getRelations().size()); 352 352 353 353 Relation r = (Relation)hull.getPrimitiveById(1, OsmPrimitiveType.RELATION); … … 363 363 r1.put("name", "r1"); 364 364 r1.addMember(new RelationMember("relation-1",r1)); 365 source. relations.add(r1);365 source.addPrimitive(r1); 366 366 source.setSelected(r1); 367 367 … … 369 369 DataSet hull = builder.build(); 370 370 assertNotNull(hull); 371 assertEquals(1, hull. relations.size());372 373 Relation r = (Relation)lookupByName(hull. relations, "r1");371 assertEquals(1, hull.getRelations().size()); 372 373 Relation r = (Relation)lookupByName(hull.getRelations(), "r1"); 374 374 assertNotNull(r); 375 375 assertEquals(1, r.getMembersCount()); … … 384 384 r1.addMember(new RelationMember("relation-2",r2)); 385 385 r2.addMember(new RelationMember("relation-1",r1)); 386 source. relations.add(r1);387 source. relations.add(r2);386 source.addPrimitive(r1); 387 source.addPrimitive(r2); 388 388 source.setSelected(r1,r2); 389 389 … … 391 391 DataSet hull = builder.build(); 392 392 assertNotNull(hull); 393 assertEquals(2, hull. relations.size());393 assertEquals(2, hull.getRelations().size()); 394 394 395 395 r1 = (Relation)hull.getPrimitiveById(1, OsmPrimitiveType.RELATION); -
trunk/test/unit/org/openstreetmap/josm/data/osm/visitor/MergeVisitorTest.java
r2292 r2381 8 8 9 9 import java.io.File; 10 import java.net.URLEncoder;11 10 import java.text.MessageFormat; 12 11 import java.util.Arrays; … … 358 357 Node n2 = (Node)my.getPrimitiveById(1,OsmPrimitiveType.NODE); 359 358 assertEquals(0,visitor.getConflicts().size()); 360 assertEquals(2, my.nodes.size());359 assertEquals(2, my.getNodes().size()); 361 360 assertEquals(n,n2); 362 361 } … … 402 401 visitor.merge(); 403 402 404 Node n2 = my. nodes.iterator().next();403 Node n2 = my.getNodes().iterator().next(); 405 404 assertEquals(0,visitor.getConflicts().size()); 406 405 assertEquals("value1",n2.get("key1")); … … 440 439 visitor.merge(); 441 440 442 Node n2 = my. nodes.iterator().next();441 Node n2 = my.getNodes().iterator().next(); 443 442 assertEquals(0,visitor.getConflicts().size()); 444 443 assertEquals("value1",n2.get("key1"));
Note:
See TracChangeset
for help on using the changeset viewer.