Ignore:
Timestamp:
2011-08-11T16:54:57+02:00 (13 years ago)
Author:
akks
Message:

'FastDraw: I = drawn line info'

Location:
applications/editors/josm/plugins/FastDraw
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/FastDraw/build.xml

    r26520 r26522  
    3030<project name="FastDraw" default="dist" basedir=".">
    3131    <!-- enter the SVN commit message -->
    32     <property name="commit.message" value="FastDraw: snapping fixed, do not save degenerate lines"/>
     32    <property name="commit.message" value="FastDraw: I = drawn line info"/>
    3333    <!-- enter the *lowest* JOSM version this plugin is currently compatible with -->
    3434    <property name="plugin.main.version" value="4201"/>
  • applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/DrawnPolyLine.java

    r26501 r26522  
    3232    boolean isFixed(LatLon pp2) {
    3333        return fixed.contains(pp2);
     34    }
     35   
     36    double getLength() {
     37        List<LatLon> pts = getPoints();
     38        Iterator<LatLon> it1,it2;
     39        LatLon pp1,pp2;
     40        if (pts.size()<2) return 0;
     41        it1=pts.listIterator(0);
     42        it2=pts.listIterator(1);
     43        double len=0;
     44        for (int i = 0; i < pts.size() - 1; i++) {
     45                pp1 = it1.next();
     46                pp2 = it2.next();
     47                len+=pp1.greatCircleDistance(pp2);
     48        }
     49        return len;
    3450    }
    3551
     
    348364        double pkm=0,maxpkm=0;
    349365        double len=0;
     366        int seg=0; // averaged segments counts
    350367        for (int i = 1; i < n; i++) {
    351368                len+=lens[i-1]; // add next next point
    352369                // remove old segment
    353                 if (i>k) len-=lens[i-k-1];
    354                 if (i>=k) {
     370                if (i>k) {seg=k; len-=lens[i-k-1];} else seg=i;
     371                if (i>=k || i==n-1) {
    355372                    // len is length of points[i-windowSize] .. points[i]
    356                     if (len>0) pkm = k / len * 1000;
     373                    if (len>0) pkm = seg / len * 1000;
    357374                    //System.out.println("i="+i+" pkm="+len+" pkm="+pkm);
    358375                    if (pkm > maxpkm) maxpkm=pkm;
  • applications/editors/josm/plugins/FastDraw/src/org/openstreetmap/josm/plugins/fastdraw/FastDrawingMode.java

    r26520 r26522  
    498498            tryToLoadWay();
    499499        break;
     500        case KeyEvent.VK_I:
     501           JOptionPane.showMessageDialog(Main.parent,
     502                        tr("{0} m - length of the line\n{1} nodes\n{2} points per km (maximum)\n{3} points per km (average)",
     503                        line.getLength(),line.getPoints().size(),line.getNodesPerKm(settings.pkmBlockSize),
     504                        line.getNodesPerKm(1000000)),
     505                        tr("Line information"),JOptionPane.INFORMATION_MESSAGE);
     506        break;           
    500507        case KeyEvent.VK_Q:
    501508            // less details
Note: See TracChangeset for help on using the changeset viewer.