Ignore:
Timestamp:
2014-08-16T20:14:24+02:00 (5 years ago)
Author:
Don-vip
Message:

see #9680, see #4626 - multithreaded multipolygon creation

File:
1 edited

Legend:

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

    r7392 r7423  
    4343 * Create multipolygon from selected ways automatically.
    4444 *
    45  * New relation with type=multipolygon is created
     45 * New relation with type=multipolygon is created.
    4646 *
    4747 * If one or more of ways is already in relation with type=multipolygon or the
    48  * way is not closed, then error is reported and no relation is created
     48 * way is not closed, then error is reported and no relation is created.
    4949 *
    5050 * The "inner" and "outer" roles are guessed automatically. First, bbox is
     
    9393            final Relation relation = commandAndRelation.b;
    9494
    95 
    9695            // to avoid EDT violations
    9796            SwingUtilities.invokeLater(new Runnable() {
     
    103102                    // knows about the new relation before we try to select it.
    104103                    // (Yes, we are already in event dispatch thread. But DatasetEventManager
    105                     // uses 'SwingUtilities.invokeLater' to fire events so we have to do
    106                     // the same.)
     104                    // uses 'SwingUtilities.invokeLater' to fire events so we have to do the same.)
    107105                    SwingUtilities.invokeLater(new Runnable() {
    108106                        @Override
     
    123121    }
    124122
    125     /**
    126      * The action button has been clicked
    127      *
    128      * @param e Action Event
    129      */
    130123    @Override
    131124    public void actionPerformed(ActionEvent e) {
     
    239232
    240233    /** Enable this action only if something is selected */
    241     @Override protected void updateEnabledState() {
     234    @Override
     235    protected void updateEnabledState() {
    242236        if (getCurrentDataSet() == null) {
    243237            setEnabled(false);
     
    252246      * @param selection the current selection, gets tested for emptyness
    253247      */
    254     @Override protected void updateEnabledState(Collection < ? extends OsmPrimitive > selection) {
     248    @Override
     249    protected void updateEnabledState(Collection<? extends OsmPrimitive> selection) {
    255250        if (update) {
    256251            setEnabled(getSelectedMultipolygonRelation() != null);
     
    265260     * @return <code>null</code>, if there was a problem with the ways.
    266261     */
    267     private static MultipolygonBuilder analyzeWays(Collection < Way > selectedWays, boolean showNotif) {
     262    private static MultipolygonBuilder analyzeWays(Collection<Way> selectedWays, boolean showNotif) {
    268263
    269264        MultipolygonBuilder pol = new MultipolygonBuilder();
     
    324319     * @return a list of commands to execute
    325320     */
    326     public static List<Command> removeTagsFromWaysIfNeeded( Relation relation ) {
     321    public static List<Command> removeTagsFromWaysIfNeeded(Relation relation) {
    327322        Map<String, String> values = new HashMap<>(relation.getKeys());
    328323
     
    342337                outerWays.add(way);
    343338
    344                 for( String key : way.keySet() ) {
    345                     if( !values.containsKey(key) ) { //relation values take precedence
     339                for (String key : way.keySet()) {
     340                    if (!values.containsKey(key)) { //relation values take precedence
    346341                        values.put(key, way.get(key));
    347                     } else if( !relation.hasKey(key) && !values.get(key).equals(way.get(key)) ) {
     342                    } else if (!relation.hasKey(key) && !values.get(key).equals(way.get(key))) {
    348343                        conflictingKeys.add(key);
    349344                    }
     
    353348
    354349        // filter out empty key conflicts - we need second iteration
    355         if( !Main.pref.getBoolean("multipoly.alltags", false) )
    356             for( RelationMember m : relation.getMembers() )
    357                 if( m.hasRole() && "outer".equals(m.getRole()) && m.isWay() )
    358                     for( String key : values.keySet() )
    359                         if( !m.getWay().hasKey(key) && !relation.hasKey(key) )
     350        if (!Main.pref.getBoolean("multipoly.alltags", false))
     351            for (RelationMember m : relation.getMembers())
     352                if (m.hasRole() && "outer".equals(m.getRole()) && m.isWay())
     353                    for (String key : values.keySet())
     354                        if (!m.getWay().hasKey(key) && !relation.hasKey(key))
    360355                            conflictingKeys.add(key);
    361356
    362         for( String key : conflictingKeys )
     357        for (String key : conflictingKeys)
    363358            values.remove(key);
    364359
    365         for( String linearTag : Main.pref.getCollection("multipoly.lineartagstokeep", DEFAULT_LINEAR_TAGS) )
     360        for (String linearTag : Main.pref.getCollection("multipoly.lineartagstokeep", DEFAULT_LINEAR_TAGS))
    366361            values.remove(linearTag);
    367362
     
    402397        if (moveTags) {
    403398            // add those tag values to the relation
    404 
    405399            boolean fixed = false;
    406400            Relation r2 = new Relation(relation);
Note: See TracChangeset for help on using the changeset viewer.