view flys-backend/src/main/java/de/intevation/flys/importer/parsers/tim/Line.java @ 4732:7fdddc6ba296

Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
author Sascha Teichmann <sascha.teichmann@intevation.de>
date Fri, 28 Dec 2012 15:01:12 +0100
parents
children ce6b9945bf8e
line wrap: on
line source
package de.intevation.flys.importer.parsers.tim;

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