Changeset 27973 in osm


Ignore:
Timestamp:
2012-03-02T16:45:35+01:00 (13 years ago)
Author:
joshdoe
Message:

utilsplugin2: add convenience replace function to ReplaceGeometry

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/utilsplugin2/src/utilsplugin2/dumbutils/ReplaceGeometryAction.java

    r27972 r27973  
    8585        }
    8686    }
     87   
     88    /**
     89     * Replace subjectObject geometry with referenceObject geometry and merge tags
     90     * and relation memberships.
     91     *
     92     * @param subjectObject
     93     * @param referenceSubject
     94     * @return
     95     */
     96    public boolean replace(OsmPrimitive subjectObject, OsmPrimitive referenceSubject) {
     97        if (subjectObject instanceof Node && referenceSubject instanceof Node) {
     98            return replaceNode((Node) subjectObject, (Node) referenceSubject);
     99        } else if (subjectObject instanceof Way && referenceSubject instanceof Way) {
     100            return replaceWay((Way) subjectObject, (Way) referenceSubject);
     101        } else if (subjectObject instanceof Node) {
     102            return upgradeNode((Node) subjectObject, referenceSubject);
     103        } else if (referenceSubject instanceof Node) {
     104            // TODO: fix this illogical reversal?
     105            return upgradeNode((Node) referenceSubject, subjectObject);
     106        } else {
     107            throw new IllegalArgumentException(tr("This tool can only replace a node, upgrade a node to a way or a multipolygon, or replace a way with a way."));
     108        }
     109    }
    87110
    88111    /**
     
    242265            return false;
    243266        }
    244         return replaceWayWithWay(subjectWay, referenceWay);
    245     }
    246    
    247     public static boolean replaceWayWithWay(Way subjectWay, Way referenceWay) {
     267        return replaceWay(subjectWay, referenceWay);
     268    }
     269   
     270    public static boolean replaceWay(Way subjectWay, Way referenceWay) {
    248271
    249272        Area a = getCurrentDataSet().getDataSourceArea();
Note: See TracChangeset for help on using the changeset viewer.