Changeset 22427 in osm for applications


Ignore:
Timestamp:
2010-07-23T02:03:47+02:00 (14 years ago)
Author:
nakor
Message:

Make sure all data along long segments is correctly downloaded

File:
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/download_along/src/org/openstreetmap/josm/plugin/download_along/DownloadAlong.java

    r22295 r22427  
    160160        for (Node p : way.getNodes()) {
    161161          LatLon c = p.getCoor();
    162           if (previous == null || c.greatCircleDistance(previous) > buffer_dist) {
    163             // we add a buffer around the point.
    164             r.setRect(c.lon() - buffer_x, c.lat() - buffer_y, 2 * buffer_x,
    165                 2 * buffer_y);
    166             a.add(new Area(r));
    167             previous = c;
     162          ArrayList<LatLon> intermediateNodes = new ArrayList<LatLon>();
     163          if (previous != null
     164              && c.greatCircleDistance(previous) > buffer_dist) {
     165            Double d = c.greatCircleDistance(previous) / buffer_dist;
     166            int nbNodes = d.intValue();
     167            System.out.println(tr("{0} intermediate nodes to download.", nbNodes));
     168            System.out.println(tr("between {0} {1} and {2} {3}", c.lat(), c.lon(), previous.lat(), previous.lon()));
     169            for (i = 1; i < nbNodes; i++) {
     170              intermediateNodes.add(new LatLon(previous.lat()+(i * (c.lat() - previous.lat())
     171                  / (nbNodes+1)), previous.lon()+(i * (c.lon() - previous.lon()) / (nbNodes+1))));
     172              System.out.println(tr("  adding {0} {1}", previous.lat()+(i * (c.lat() - previous.lat())
     173                  / (nbNodes+1)), previous.lon()+(i * (c.lon() - previous.lon()) / (nbNodes+1))));
     174           }
    168175          }
     176          intermediateNodes.add(c);
     177          for (LatLon d : intermediateNodes) {
     178            if (previous == null
     179                || d.greatCircleDistance(previous) > buffer_dist) {
     180              // we add a buffer around the point.
     181              r.setRect(d.lon() - buffer_x, d.lat() - buffer_y, 2 * buffer_x,
     182                  2 * buffer_y);
     183              a.add(new Area(r));
     184              previous = d;
     185            }
     186          }
     187          previous = c;
    169188        }
    170189      }
Note: See TracChangeset for help on using the changeset viewer.