Changeset 3166 in josm for trunk/src/org/openstreetmap
- Timestamp:
- 2010-03-30T09:35:23+02:00 (15 years ago)
- Location:
- trunk/src/org/openstreetmap/josm/data/osm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r3163 r3166 19 19 20 20 import org.openstreetmap.josm.data.SelectionChangedListener; 21 import org.openstreetmap.josm.data.coor.LatLon; 21 22 import org.openstreetmap.josm.data.osm.event.AbstractDatasetChangedEvent; 22 23 import org.openstreetmap.josm.data.osm.event.ChangesetIdChangedEvent; … … 201 202 tr("Unable to add primitive {0} to the dataset because it is already included", primitive.toString())); 202 203 204 primitive.updatePosition(); // Set cached bbox for way and relation (required for reindexWay and reinexRelation to work properly) 203 205 if (primitive instanceof Node) { 204 206 nodes.add((Node) primitive); … … 209 211 } 210 212 allPrimitives.add(primitive); 211 primitive.setDataset(this); 213 primitive.setDataset(this); 212 214 firePrimitivesAdded(Collections.singletonList(primitive), false); 213 215 } … … 765 767 } 766 768 767 private void reindexNode(Node node ) {769 private void reindexNode(Node node, LatLon newCoor) { 768 770 nodes.remove(node); 769 node. updatePosition();771 node.setCoorInternal(newCoor); 770 772 nodes.add(node); 771 773 for (OsmPrimitive primitive: node.getReferrers()) { … … 868 870 } 869 871 870 void fireNodeMoved(Node node ) {871 reindexNode(node );872 void fireNodeMoved(Node node, LatLon newCoor) { 873 reindexNode(node, newCoor); 872 874 fireEvent(new NodeMovedEvent(this, node)); 873 875 } -
trunk/src/org/openstreetmap/josm/data/osm/Node.java
r3163 r3166 2 2 package org.openstreetmap.josm.data.osm; 3 3 4 import org.openstreetmap.josm.Main; 4 5 import org.openstreetmap.josm.data.coor.CachedLatLon; 5 6 import org.openstreetmap.josm.data.coor.EastNorth; … … 15 16 16 17 private CachedLatLon coor; 17 private BBox bbox;18 18 19 19 public final void setCoor(LatLon coor) { 20 20 if(coor != null){ 21 if (this.coor == null) {22 this.coor = new CachedLatLon(coor);21 if (getDataSet() != null) { 22 getDataSet().fireNodeMoved(this, coor); 23 23 } else { 24 this.coor.setCoor(coor); 25 } 26 if (getDataSet() != null) { 27 getDataSet().fireNodeMoved(this); 24 setCoorInternal(coor); 28 25 } 29 26 } … … 35 32 36 33 public final void setEastNorth(EastNorth eastNorth) { 37 if(eastNorth != null) 38 { 39 if(coor != null) { 40 coor.setEastNorth(eastNorth); 41 } else { 42 coor = new CachedLatLon(eastNorth); 43 } 44 if (getDataSet() != null) { 45 getDataSet().fireNodeMoved(this); 46 } 34 if(eastNorth != null) { 35 setCoor(Main.proj.eastNorth2latlon(eastNorth)); 47 36 } 48 37 } … … 50 39 public final EastNorth getEastNorth() { 51 40 return coor != null ? coor.getEastNorth() : null; 41 } 42 43 /** 44 * To be used only by Dataset.reindexNode 45 */ 46 protected void setCoorInternal(LatLon coor) { 47 if(this.coor == null) { 48 this.coor = new CachedLatLon(coor); 49 } else { 50 this.coor.setCoor(coor); 51 } 52 52 } 53 53 … … 187 187 @Override 188 188 public BBox getBBox() { 189 if (getDataSet() == null) 190 return new BBox(this); 191 if (bbox == null) { 192 bbox = new BBox(this); 193 } 194 return new BBox(bbox); 189 return new BBox(this); 195 190 } 196 191 197 192 @Override 198 193 public void updatePosition() { 199 bbox = new BBox(this);200 194 // TODO: replace CachedLatLon with simple doubles and update precalculated EastNorth value here 201 195 }
Note:
See TracChangeset
for help on using the changeset viewer.