Changeset 18988 in josm for trunk


Ignore:
Timestamp:
2024-02-16T11:13:51+01:00 (9 months ago)
Author:
GerdP
Message:

fix #23305: conflict detection not working for combine way with one null and one tag set
(23305-alt.patch)

  • adds code to check if a conflict exists where one or more tagged ways don't have the same tag value and - if so - show the conflict dialog.
  • adds a preference combine-conflict-precise . If set to false the old behaviour is restored.
  • changes the preference for the non-expert relation member ship warning popup from combine_tags to combine_relation_member, so that both dialogs have separate settings
Location:
trunk/src/org/openstreetmap/josm/gui/conflict/tags
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/CombinePrimitiveResolverDialog.java

    r18298 r18988  
    1717import java.beans.PropertyChangeListener;
    1818import java.util.Collection;
     19import java.util.HashSet;
    1920import java.util.LinkedList;
    2021import java.util.List;
     
    4647import org.openstreetmap.josm.gui.util.WindowGeometry;
    4748import org.openstreetmap.josm.gui.widgets.AutoAdjustingSplitPane;
     49import org.openstreetmap.josm.spi.preferences.Config;
    4850import org.openstreetmap.josm.tools.CheckParameterUtil;
    4951import org.openstreetmap.josm.tools.ImageProvider;
     
    517519        tagModel.populate(tagsToEdit, completeWayTags.getKeysWithMultipleValues(), false);
    518520        relModel.populate(parentRelations, primitives, false);
    519         tagModel.prepareDefaultTagDecisions(false);
     521        if (Config.getPref().getBoolean("combine-conflict-precise", true)) {
     522            tagModel.prepareDefaultTagDecisions(getResolvableKeys(tagsOfPrimitives.getKeys(), primitives));
     523        } else {
     524            tagModel.prepareDefaultTagDecisions(false);
     525        }
    520526        relModel.prepareDefaultRelationDecisions(false);
    521527
     
    590596
    591597        if (!ConditionalOptionPaneUtil.showConfirmationDialog(
    592                 "combine_tags",
     598                "combine_relation_member",
    593599                MainApplication.getMainFrame(),
    594600                "<html>" + msg + "</html>",
     
    643649    }
    644650
     651    /**
     652     * See #23305: Find those tag keys for which no conflict exists.
     653     * @param keysToDecide the keys of tags which might be shown in the conflict dialog
     654     * @param primitives the collection of primitives
     655     * @return the keys which can be resolved using the only available value
     656     */
     657    private static Set<String> getResolvableKeys(Set<String> keysToDecide, Collection<? extends OsmPrimitive> primitives) {
     658        Set<String> easyKeys = new HashSet<>();
     659        // determine the number of objects which have any of the tags which require a decision
     660        int countTagged = 0;
     661        for (OsmPrimitive p : primitives) {
     662            for (String key : keysToDecide) {
     663                if (p.hasTag(key)) {
     664                    ++countTagged;
     665                    break;
     666                }
     667            }
     668        }
     669        for (String key : keysToDecide) {
     670            Set<String> values = new HashSet<>();
     671            int num = 0;
     672            for (OsmPrimitive p : primitives) {
     673                String val = p.get(key);
     674                if (val != null) {
     675                    num++;
     676                    values.add(val);
     677                }
     678            }
     679            if (values.size() == 1 && num == countTagged) {
     680                // there is only one value and all tagged objects have that value -> easy to solve
     681                easyKeys.add(key);
     682            }
     683        }
     684        return easyKeys;
     685    }
     686
    645687    @Override
    646688    public void dispose() {
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/TagConflictResolverModel.java

    r18072 r18988  
    276276     * Prepare the default decisions for the current model
    277277     * @param fireEvent {@code true} to call {@code fireTableDataChanged} (can be a slow operation)
    278      * @since 11626
     278     * @since 11627
    279279     */
    280280    void prepareDefaultTagDecisions(boolean fireEvent) {
     
    293293
    294294    /**
     295     * Prepare the default decisions for the current model.
     296     * @param decidedKeys set of tag keys for which the first value should be used
     297     * @since xxx
     298     */
     299    public void prepareDefaultTagDecisions(Set<String> decidedKeys) {
     300        for (MultiValueResolutionDecision decision : decisions.values()) {
     301            if (!decidedKeys.contains(decision.getKey()))
     302                continue;
     303            List<String> values = decision.getValues();
     304            if (!values.isEmpty()) {
     305                decision.keepOne(values.iterator().next());
     306            }
     307        }
     308        rebuild(false);
     309    }
     310
     311    /**
    295312     * Returns the set of keys in conflict.
    296313     * @return the set of keys in conflict.
Note: See TracChangeset for help on using the changeset viewer.