Mercurial > dive4elements > river
comparison 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 |
comparison
equal
deleted
inserted
replaced
4767:03246a8b3869 | 4768:99f9e371371b |
---|---|
29 } | 29 } |
30 | 30 |
31 public double getY() { | 31 public double getY() { |
32 return this.y; | 32 return this.y; |
33 } | 33 } |
34 | |
35 public final double distanceSqr(double ox, double oy) { | |
36 double dx = x - ox; | |
37 double dy = y - oy; | |
38 return dx*dx + dy*dy; | |
39 } | |
40 | |
41 public final double distance(double xo, double yo) { | |
42 return Math.sqrt(distanceSqr(xo, yo)); | |
43 } | |
34 } | 44 } |
35 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : | 45 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |