Changeset 32338 in osm


Ignore:
Timestamp:
2016-06-20T16:49:47+02:00 (8 years ago)
Author:
darya
Message:

Downloads incomplete members for all routes at once

Location:
applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/actions/IncompleteMembersDownloadThread.java

    r32277 r32338  
    22
    33import java.util.ArrayList;
     4import java.util.Collection;
    45
     6import javax.swing.JOptionPane;
     7
     8import org.openstreetmap.josm.Main;
     9import org.openstreetmap.josm.data.osm.Node;
    510import org.openstreetmap.josm.data.osm.PrimitiveId;
    611import org.openstreetmap.josm.data.osm.Relation;
    712import org.openstreetmap.josm.gui.io.DownloadPrimitivesWithReferrersTask;
     13import org.openstreetmap.josm.plugins.pt_assistant.utils.RouteUtils;
    814
    915public class IncompleteMembersDownloadThread extends Thread {
    1016
    11         private Relation relation;
     17        public IncompleteMembersDownloadThread() {
     18                super();
    1219
    13         public IncompleteMembersDownloadThread(Relation r) {
    14                 super();
    15                 relation = r;
    1620        }
    17        
     21
    1822        private void realRun() {
    19                
     23                // TODO
    2024        }
    2125
     
    2327        public void run() {
    2428
    25                  try {
    26                 synchronized (this) {
     29                try {
     30                        synchronized (this) {
    2731
    28                         ArrayList<PrimitiveId> list = new ArrayList<>(1);
    29                         list.add(relation);
     32                                ArrayList<PrimitiveId> list = new ArrayList<>();
    3033
    31                         DownloadPrimitivesWithReferrersTask task = new DownloadPrimitivesWithReferrersTask(false, list, false, true,
    32                                         null, null);
    33                         Thread t = new Thread(task);
    34                         t.start();
    35                         t.join();
     34                                // add all route relations that are of public_transport version 2:
     35                                Collection<Relation> allRelations = Main.getLayerManager().getEditDataSet().getRelations();
     36                                for (Relation currentRelation : allRelations) {
     37                                        if (RouteUtils.isTwoDirectionRoute(currentRelation)) {
     38                                                list.add(currentRelation);
     39                                        }
     40                                }
     41                               
     42                                // add all stop_positions:
     43                                Collection<Node> allNodes = Main.getLayerManager().getEditDataSet().getNodes();
     44                                for (Node currentNode: allNodes) {
     45                                        if (currentNode.hasTag("public_transport", "stop_position")) {
     46                                                list.add(currentNode);
     47                                        }
     48                                }
     49                               
     50                               
     51                                DownloadPrimitivesWithReferrersTask task = new DownloadPrimitivesWithReferrersTask(false, list, false,
     52                                                true, null, null);
     53                                Thread t = new Thread(task);
     54                                t.start();
     55                                t.join();
    3656
     57                        }
     58
     59                } catch (InterruptedException e) {
     60                        // TODO Auto-generated catch block
     61                        e.printStackTrace();
    3762
    3863                }
    3964
    40                  } catch (InterruptedException e) {
    41                  // TODO Auto-generated catch block
    42                  e.printStackTrace();
    43                
    44                  }
    45 
    4665        }
    4766}
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/gui/IncompleteMembersDownloadDialog.java

    r32330 r32338  
    2929                selectedOption = Integer.MIN_VALUE;
    3030
    31                 message = tr("The relation (id={0}) has incomplete members.\n"+
    32                     "They need to be downloaded to proceed with validation of this relation.\nDo you want to download incomplete members?", id);
     31//              message = tr("The relation (id={0}) has incomplete members.\n"+
     32//                  "They need to be downloaded to proceed with validation of this relation.\nDo you want to download incomplete members?", id);
     33                message = tr("Route relations have incomplete members.\nThey need to be downloaded to proceed with validation.\nDo you want to download them?");
    3334                checkbox = new JCheckBox(tr("Remember my choice and do not ask me again in this session"));
    3435                options = new String[2];
  • applications/editors/josm/plugins/pt_assistant/src/org/openstreetmap/josm/plugins/pt_assistant/validation/PTAssitantValidatorTest.java

    r32303 r32338  
    8383                if (userInput == JOptionPane.YES_OPTION) {
    8484
    85                         Thread t = new IncompleteMembersDownloadThread(r);
     85                        Thread t = new IncompleteMembersDownloadThread();
    8686                        t.start();
    8787                        synchronized (t) {
Note: See TracChangeset for help on using the changeset viewer.