Changeset 2202 in josm for trunk


Ignore:
Timestamp:
2009-09-27T18:01:21+02:00 (15 years ago)
Author:
Gubaer
Message:

fixed #3553: Error on join overlapped areas

Location:
trunk/src/org/openstreetmap/josm/actions
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/CombineWayAction.java

    r2120 r2202  
    3131import org.openstreetmap.josm.data.osm.Tag;
    3232import org.openstreetmap.josm.data.osm.TagCollection;
     33import org.openstreetmap.josm.data.osm.TigerUtils;
    3334import org.openstreetmap.josm.data.osm.Way;
    3435import org.openstreetmap.josm.gui.ExtendedDialog;
     
    4647        super(tr("Combine Way"), "combineway", tr("Combine several ways into one."),
    4748                Shortcut.registerShortcut("tools:combineway", tr("Tool: {0}", tr("Combine Way")), KeyEvent.VK_C, Shortcut.GROUP_EDIT), true);
    48     }
    49 
    50     protected Set<OsmPrimitive> intersect(Set<? extends OsmPrimitive> s1, Set<? extends OsmPrimitive> s2) {
    51         HashSet<OsmPrimitive> ret = new HashSet<OsmPrimitive>(s1);
    52         ret.retainAll(s2);
    53         return ret;
    54     }
    55 
    56     protected boolean confirmCombiningWithConflictsInRelationMemberships() {
    57         ExtendedDialog ed = new ExtendedDialog(Main.parent,
    58                 tr("Combine ways with different memberships?"),
    59                 new String[] {tr("Combine Anyway"), tr("Cancel")});
    60         ed.setButtonIcons(new String[] {"combineway.png", "cancel.png"});
    61         ed.setContent(tr("The selected ways have differing relation memberships.  "
    62                 + "Do you still want to combine them?"));
    63         ed.showDialog();
    64 
    65         return ed.getValue() == 1;
    6649    }
    6750
     
    8265        JOptionPane.showMessageDialog(
    8366                Main.parent,
    84                 msg,  //FIXME: not sure whether this fits in a dialog
     67                msg,
    8568                tr("Information"),
    8669                JOptionPane.INFORMATION_MESSAGE
     
    120103    }
    121104
     105    /**
     106     * Combines tags from TIGER data
     107     *
     108     * @param tc the tag collection
     109     */
     110    protected static void combineTigerTags(TagCollection tc) {
     111        for (String key: tc.getKeys()) {
     112            if (TigerUtils.isTigerTag(key)) {
     113                tc.setUniqueForKey(key, TigerUtils.combineTags(key, tc.getValues(key)));
     114            }
     115        }
     116    }
     117
    122118    protected static void completeTagCollectionForEditing(TagCollection tc) {
    123119        for (String key: tc.getKeys()) {
     
    148144
    149145
    150         // try to build a new way out of the combination of ways
    151         // which are combined
     146        // try to build a new way which includes all the combined
     147        // ways
    152148        //
    153149        NodeGraph graph = NodeGraph.createDirectedGraphFromWays(ways);
     
    172168
    173169        TagCollection completeWayTags = new TagCollection(wayTags);
     170        combineTigerTags(completeWayTags);
    174171        completeTagCollectionWithMissingTags(completeWayTags, ways);
    175172        TagCollection tagsToEdit = new TagCollection(completeWayTags);
     
    216213        }
    217214    }
    218 
    219215
    220216    public void actionPerformed(ActionEvent event) {
  • trunk/src/org/openstreetmap/josm/actions/MergeNodesAction.java

    r2181 r2202  
    2525import org.openstreetmap.josm.data.osm.Tag;
    2626import org.openstreetmap.josm.data.osm.TagCollection;
     27import org.openstreetmap.josm.data.osm.TigerUtils;
    2728import org.openstreetmap.josm.data.osm.Way;
    2829import org.openstreetmap.josm.data.osm.BackreferencedDataSet.RelationToChildReference;
     
    9394
    9495    /**
     96     * Combines tags from TIGER data
     97     *
     98     * @param tc the tag collection
     99     */
     100    protected static void combineTigerTags(TagCollection tc) {
     101        for (String key: tc.getKeys()) {
     102            if (TigerUtils.isTigerTag(key)) {
     103                tc.setUniqueForKey(key, TigerUtils.combineTags(key, tc.getValues(key)));
     104            }
     105        }
     106    }
     107
     108    /**
    95109     * Selects a node out of a collection of candidate nodes. The selected
    96110     * node will become the target node the remaining nodes are merged to.
     
    153167     * Fixes the parent ways referring to one of the nodes.
    154168     *
    155      * Replies null, if the ways could not be fixed, i.e. because a way would have to be delted
     169     * Replies null, if the ways could not be fixed, i.e. because a way would have to be deleted
    156170     * which is referred to by a relation.
    157171     *
     
    159173     * @param nodesToDelete the collection of nodes to be deleted
    160174     * @param targetNode the target node the other nodes are merged to
    161      * @return a list of command; null, the ways could not be fixed
     175     * @return a list of commands; null, if the ways could not be fixed
    162176     */
    163177    protected static List<Command> fixParentWays(BackreferencedDataSet backreferences, Collection<OsmPrimitive> nodesToDelete, Node targetNode) {
     
    207221    /**
    208222     * Merges the nodes in <code>node</code> onto one of the nodes. Uses the dataset
    209      * managed by <code>layer</code> as reference. <code>backreferences</code> is precomputed
     223     * managed by <code>layer</code> as reference. <code>backreferences</code> is a precomputed
    210224     * collection of all parent/child references in the dataset.
    211225     *
    212226     * @param layer layer the reference data layer. Must not be null.
    213      * @param backreferences if null, backreferneces are first computed from layer.data; otherwise
    214      *    backreferences.getSource() == layer.data must hold
     227     * @param backreferences if null, backreferences are first computed from layer.data; otherwise
     228     *    backreferences.getSource() == layer.data must be true
    215229     * @param nodes the collection of nodes. Ignored if null.
    216230     * @param targetNode the target node the collection of nodes is merged to. Must not be null.
     
    235249        //
    236250        TagCollection nodeTags = TagCollection.unionOfAllPrimitives(nodes);
     251        combineTigerTags(nodeTags);
    237252        completeTagCollectionWithMissingTags(nodeTags, nodes);
    238253        TagCollection nodeTagsToEdit = new TagCollection(nodeTags);
     
    258273        nodesToDelete.remove(targetNode);
    259274
    260         // change the ways referring to at least one of the merge nodes
     275        // fix the ways referring to at least one of the merged nodes
    261276        //
    262277        Collection<Way> waysToDelete= new HashSet<Way>();
     
    287302
    288303    /**
    289      * Enable the "Merge Nodes" menu option if more then one node is selected
     304     * Enable the "Merge Nodes" menu option if more than one node is selected
    290305     */
    291306    @Override
Note: See TracChangeset for help on using the changeset viewer.