- Timestamp:
- 2010-10-09T07:49:39+02:00 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java
r3554 r3595 501 501 List<AssembledMultipolygon> preparedPolygons = findPolygons(bounadries); 502 502 503 //assemble final ways503 //assemble final polygons 504 504 List<Multipolygon> polygons = new ArrayList<Multipolygon>(); 505 505 for (AssembledMultipolygon pol : preparedPolygons) { 506 polygons.add(joinPolygon(pol)); 507 } 506 507 //create the new ways 508 Multipolygon resultPol = joinPolygon(pol); 509 510 //create multipolygon relation, if necessary. 511 RelationRole ownMultipolygonRelation = addOwnMultigonRelation(resultPol.innerWays, resultPol.outerWay); 512 513 //add back the original relations, merged with our new multipolygon relation 514 fixRelations(relations, resultPol.outerWay, ownMultipolygonRelation); 515 516 //strip tags from inner ways 517 //TODO: preserve tags on existing inner ways 518 stripTags(resultPol.innerWays); 519 520 polygons.add(resultPol); 521 } 522 523 commitCommands(marktr("Assemble new polygons")); 508 524 509 525 // Delete the discarded inner ways 510 526 if (discardedWays.size() > 0) { 511 527 cmds.add(DeleteCommand.delete(Main.map.mapView.getEditLayer(), discardedWays, true)); 512 } 513 commitCommands(marktr("Delete Ways that are not part of an inner multipolygon")); 514 515 // We can attach our new multipolygon relation and pretend it has always been there 516 for (Multipolygon pol : polygons) { 517 addOwnMultigonRelation(pol.innerWays, pol.outerWay, relations); 518 fixRelations(relations, pol.outerWay); 519 } 520 521 commitCommands(marktr("Fix relations")); 522 523 for (Multipolygon pol : polygons) { 524 stripTags(pol.innerWays); 525 } 528 commitCommands(marktr("Delete Ways that are not part of an inner multipolygon")); 529 } 530 526 531 527 532 makeCommitsOneAction(marktr("Joined overlapping areas")); … … 1630 1635 * @param ArrayList<RelationRole> The list of relation with roles to add own relation to 1631 1636 */ 1632 private void addOwnMultigonRelation(Collection<Way> inner, Way outer, ArrayList<RelationRole> rels) {1633 if (inner.size() == 0) return ;1637 private RelationRole addOwnMultigonRelation(Collection<Way> inner, Way outer) { 1638 if (inner.size() == 0) return null; 1634 1639 // Create new multipolygon relation and add all inner ways to it 1635 1640 Relation newRel = new Relation(); … … 1641 1646 1642 1647 // We don't add outer to the relation because it will be handed to fixRelations() 1643 // which will then do the remaining work. Collections are passed by reference, so no 1644 // need to return it 1645 rels.add(new RelationRole(newRel, "outer")); 1646 //return rels; 1648 // which will then do the remaining work. 1649 return new RelationRole(newRel, "outer"); 1647 1650 } 1648 1651 … … 1691 1694 * @param Way The newly created outer area/way 1692 1695 */ 1693 private void fixRelations(ArrayList<RelationRole> rels, Way outer ) {1696 private void fixRelations(ArrayList<RelationRole> rels, Way outer, RelationRole ownMultipol) { 1694 1697 ArrayList<RelationRole> multiouters = new ArrayList<RelationRole>(); 1698 1699 if (ownMultipol != null){ 1700 multiouters.add(ownMultipol); 1701 } 1702 1695 1703 for (RelationRole r : rels) { 1696 1704 if (r.rel.get("type") != null &&
Note:
See TracChangeset
for help on using the changeset viewer.