Changeset 2982 in josm for trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
- Timestamp:
- 2010-02-14T15:01:00+01:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
r2944 r2982 136 136 } 137 137 138 public List<Relation> searchRelations(BBox bbox) { 139 // QuadBuckets might be useful here (don't forget to do reindexing after some of rm is changed) 140 List<Relation> result = new ArrayList<Relation>(); 141 for (Relation r: relations) { 142 if (r.getBBox().intersects(bbox)) { 143 result.add(r); 144 } 145 } 146 return result; 147 } 148 138 149 /** 139 150 * All data sources of this DataSet. … … 200 211 * Adds a primitive to the dataset 201 212 * 202 * @param primitive the primitive. Ignored if null.213 * @param primitive the primitive. 203 214 */ 204 215 public void addPrimitive(OsmPrimitive primitive) { … … 779 790 } 780 791 781 /**782 * Reindex all nodes and ways after their coordinates were changed. This is a temporary solution, reindexing should783 * be automatic in the future784 * @deprecated Reindexing should be automatic785 */786 @Deprecated787 public void reindexAll() {788 List<Node> ntmp = new ArrayList<Node>(nodes);789 nodes.clear();790 nodes.addAll(ntmp);791 List<Way> wtmp = new ArrayList<Way>(ways);792 ways.clear();793 ways.addAll(wtmp);794 }795 796 792 private void reindexNode(Node node) { 797 793 nodes.remove(node); 798 794 nodes.add(node); 799 for (Way way:OsmPrimitive.getFilteredList(node.getReferrers(), Way.class)) { 800 ways.remove(way); 801 way.updatePosition(); 802 ways.add(way); 795 for (OsmPrimitive primitive: node.getReferrers()) { 796 if (primitive instanceof Way) { 797 reindexWay((Way)primitive); 798 } else { 799 reindexRelation((Relation) primitive); 800 } 803 801 } 804 802 } 805 803 806 804 private void reindexWay(Way way) { 805 BBox before = way.getBBox(); 807 806 ways.remove(way); 808 807 way.updatePosition(); 809 808 ways.add(way); 809 if (!way.getBBox().equals(before)) { 810 for (OsmPrimitive primitive: way.getReferrers()) { 811 reindexRelation((Relation)primitive); 812 } 813 } 814 } 815 816 private void reindexRelation(Relation relation) { 817 BBox before = relation.getBBox(); 818 relation.updatePosition(); 819 if (!before.equals(relation.getBBox())) { 820 for (OsmPrimitive primitive: relation.getReferrers()) { 821 reindexRelation((Relation) primitive); 822 } 823 } 810 824 } 811 825 … … 874 888 875 889 void fireRelationMembersChanged(Relation r) { 890 reindexRelation(r); 876 891 fireEvent(new RelationMembersChangedEvent(this, r)); 877 892 }
Note:
See TracChangeset
for help on using the changeset viewer.