view flys-backend/src/main/java/de/intevation/flys/importer/parsers/tim/Line.java @ 5570:91a2ddffea47

Write filename as description instead of the header meta line in flow velocity measurements.
author Raimund Renkert <rrenkert@intevation.de>
date Fri, 05 Apr 2013 11:18:16 +0200
parents ce6b9945bf8e
children
line wrap: on
line source
package de.intevation.flys.importer.parsers.tim;

/** Two coordinates and a helper. */
public class Line {

    public Coordinate a;
    public Coordinate b;

    public Line() {
    }

    public Line(Coordinate a, Coordinate b) {
        this.a = a;
        this.b = b;
    }

    /** Project coordinate to line. */
    public double distanceToFirst(Coordinate c) {

        double nx = b.x - a.x;
        double ny = b.y - a.y;

        double len = Math.sqrt(nx*nx + ny*ny);

        nx /= len;
        ny /= len;

        double px = c.x - a.x;
        double py = c.y - a.y;

        return nx*px + ny*py;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org