Ignore:
Timestamp:
2008-02-14T07:06:04+01:00 (17 years ago)
Author:
jrreid
Message:

Update lakewalker plugin to automatically break ways up into sections of length as specified in preferences

Location:
applications/editors/josm/plugins/lakewalker
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/lakewalker/Lakewalker/lakewalker.py

    r6789 r6874  
    8585def download_landsat(c1, c2, width, height, fname):
    8686    layer = "global_mosaic_base"
     87    #style = "IR1"
    8788    style = options.wmslayer
    8889
     
    356357    # n lat lon - A node
    357358    # x - End of data
     359    countnodes = 0
     360   
    358361    print "s %s" % len(lakelist)
    359362    for nodelist in lakelist:
     
    361364        for node in nodelist:
    362365            print "n %.7f %.7f" % (node[0], node[1])
     366           
     367            countnodes = countnodes + 1
     368            if options.MAXLEN == countnodes:
     369              print "x"
     370              print "t %s" % len(nodelist)
     371              print "n %.7f %.7f" % (node[0], node[1])
     372              countnodes = 0
     373             
    363374    print "x"
    364375
     
    432443    parser.add_option("--threshold", "-t", type="int", default="35", metavar="VALUE", help="Maximum gray value to accept as water (based on Landsat IR-1 data). Can be in the range 0-255. Defaults to 35.")
    433444    parser.add_option("--maxnodes", type="int", default="50000", metavar="N", help="Maximum number of nodes to generate before bailing out. Defaults to 50000.")
    434     parser.add_option("--waylength", type="int", default=250, metavar="MAXLEN", help="Maximum nuber of nodes allowed in one way. Defaults to 250.")
     445    parser.add_option("--waylength", type="int", dest="MAXLEN", default=500, metavar="MAXLEN", help="Maximum nuber of nodes allowed in one way. Defaults to 250.")
    435446    parser.add_option("--landsat-res", type="int", default=4000, dest="resolution", metavar="RES", help="Resolution of Landsat tiles, measured in pixels per degree. Defaults to 4000.")
    436447    parser.add_option("--tilesize", type="int", default=2000, help="Size of one landsat tile, measured in pixels. Defaults to 2000.")
  • applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerAction.java

    r6789 r6874  
    9595    target += " --top=" + topLeft.lat();
    9696    target += " --bottom=" + botRight.lat();
     97    target += " --waylength=" + Main.pref.get(LakewalkerPreferences.PREF_MAX_SEG, "500");
    9798    target += " --maxnodes=" + Main.pref.get(LakewalkerPreferences.PREF_MAX_NODES, "50000");
    9899    target += " --threshold=" + Main.pref.get(LakewalkerPreferences.PREF_THRESHOLD, "35");
  • applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerPreferences.java

    r6789 r6874  
    7474   
    7575    pythonConfig.setValue(Main.pref.get(PREF_PYTHON, "python.exe"));
    76     maxSegsConfig.setValue(Main.pref.get(PREF_MAX_SEG, "250"));
     76    maxSegsConfig.setValue(Main.pref.get(PREF_MAX_SEG, "500"));
    7777    maxNodesConfig.setValue(Main.pref.get(PREF_MAX_NODES, "50000"));
    7878    thresholdConfig.setValue(Main.pref.get(PREF_THRESHOLD, "35"));
  • applications/editors/josm/plugins/lakewalker/src/org/openstreetmap/josm/plugins/lakewalker/LakewalkerReader.java

    r6127 r6874  
    5959    try {
    6060       
    61       Node fn = null; //new Node(new LatLon(0,0));
     61          Node n = null;  // The current node being created
     62          Node tn = null; // The last node of the previous way
     63      Node fn = null; // Node to hold the first node in the trace
    6264       
    6365      while ((line = input.readLine()) != null) {
     
    7072        case 'n':
    7173          String[] tokens = line.split(" ");
    72           try {
    73             LatLon ll = new LatLon(Double.parseDouble(tokens[1])+northOffset, Double.parseDouble(tokens[2])+eastOffset);
    74             Node n = new Node(ll);
    75             commands.add(new AddCommand(n));
    76             way.nodes.add(n);
    77             if(fn==null){
    78                 fn = n;
    79             }
     74         
     75          if(tn==null){
     76                      try {             
     77                        LatLon ll = new LatLon(Double.parseDouble(tokens[1])+northOffset, Double.parseDouble(tokens[2])+eastOffset);
     78                        n = new Node(ll);
     79                        if(fn==null){
     80                          fn = n;
     81                        }
     82                        commands.add(new AddCommand(n));
     83                      }
     84                  catch (Exception ex) {
     85                         
     86                      }
     87         
     88          } else {
     89            // If there is a last node, and this node has the same coordinates
     90            // then we substitute for the previous node
     91                n = tn;
     92                tn = null;             
    8093          }
    81           catch (Exception ex) {
    82 
    83           }
     94             
     95              way.nodes.add(n);
     96         
    8497          break;
    8598
     
    99112         
    100113          break;
     114       
     115        case 't':       
     116                way = new Way();
     117                tn = n;
     118                break;
    101119         
    102120        case 'e':
     
    107125      }
    108126      input.close();
     127
     128      // Add the start node to the end of the trace to form a closed shape
    109129      way.nodes.add(fn);
    110130    }
Note: See TracChangeset for help on using the changeset viewer.