view flys-backend/src/main/java/de/intevation/flys/importer/parsers/tim/Coordinate.java @ 4768:99f9e371371b

Move distance calculation to Coordinate class. Use inheritance instead of composition in Anchor class. Made Anchor class static. Use epsilon equal comparision when checking for same station: Boy, do you ever learn that sharp equal comparison of doubles is not a clever idea!?
author Sascha L. Teichmann <teichmann@intevation.de>
date Fri, 04 Jan 2013 15:35:51 +0100
parents ea8c3e6c9614
children
line wrap: on
line source
package de.intevation.flys.importer.parsers.tim;

/** X,Y,Z- triple. */
public class Coordinate
{
    public double x;
    public double y;
    public double z;

    public Coordinate() {
    }

    public Coordinate(Coordinate c) {
        this(c.x, c.y, c.z);
    }

    public Coordinate(double x, double y) {
        this(x, y, 0d);
    }

    public Coordinate(double x, double y, double z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    public double getX() {
        return this.x;
    }

    public double getY() {
        return this.y;
    }

    public final double distanceSqr(double ox, double oy) {
        double dx = x - ox;
        double dy = y - oy;
        return dx*dx + dy*dy;
    }

    public final double distance(double xo, double yo) {
        return Math.sqrt(distanceSqr(xo, yo));
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org