Mercurial > dive4elements > river
annotate backend/src/main/java/org/dive4elements/river/importer/parsers/tim/Coordinate.java @ 5844:4dd33b86dc61
Added header to river backend.
author | Sascha L. Teichmann <teichmann@intevation.de> |
---|---|
date | Fri, 26 Apr 2013 08:25:41 +0200 |
parents | 5aa05a7a34b7 |
children | 4c3ccf2b0304 |
rev | line source |
---|---|
5844
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
1 /* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde |
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
2 * Software engineering by Intevation GmbH |
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
3 * |
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
4 * This file is Free Software under the GNU AGPL (>=v3) |
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
5 * and comes with ABSOLUTELY NO WARRANTY! Check out the |
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
6 * documentation coming with Dive4Elements River for details. |
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
7 */ |
4dd33b86dc61
Added header to river backend.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5838
diff
changeset
|
8 |
5829
18619c1e7c2a
Repaired internal references.
Sascha L. Teichmann <teichmann@intevation.de>
parents:
5828
diff
changeset
|
9 package org.dive4elements.river.importer.parsers.tim; |
4732
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
10 |
4742 | 11 /** X,Y,Z- triple. */ |
4732
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
12 public class Coordinate |
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
13 { |
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
14 public double x; |
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
15 public double y; |
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
16 public double z; |
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
17 |
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
18 public Coordinate() { |
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
19 } |
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
20 |
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
21 public Coordinate(Coordinate c) { |
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
22 this(c.x, c.y, c.z); |
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
23 } |
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
24 |
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
25 public Coordinate(double x, double y) { |
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
26 this(x, y, 0d); |
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
27 } |
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
28 |
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
29 public Coordinate(double x, double y, double z) { |
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
30 this.x = x; |
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
31 this.y = y; |
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
32 this.z = z; |
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
33 } |
4748
ea8c3e6c9614
Coordinate: Introduce getters for x/y.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4742
diff
changeset
|
34 |
ea8c3e6c9614
Coordinate: Introduce getters for x/y.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4742
diff
changeset
|
35 public double getX() { |
ea8c3e6c9614
Coordinate: Introduce getters for x/y.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4742
diff
changeset
|
36 return this.x; |
ea8c3e6c9614
Coordinate: Introduce getters for x/y.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4742
diff
changeset
|
37 } |
ea8c3e6c9614
Coordinate: Introduce getters for x/y.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4742
diff
changeset
|
38 |
ea8c3e6c9614
Coordinate: Introduce getters for x/y.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4742
diff
changeset
|
39 public double getY() { |
ea8c3e6c9614
Coordinate: Introduce getters for x/y.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4742
diff
changeset
|
40 return this.y; |
ea8c3e6c9614
Coordinate: Introduce getters for x/y.
Felix Wolfsteller <felix.wolfsteller@intevation.de>
parents:
4742
diff
changeset
|
41 } |
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!?
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4748
diff
changeset
|
42 |
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!?
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4748
diff
changeset
|
43 public final double distanceSqr(double ox, double oy) { |
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!?
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4748
diff
changeset
|
44 double dx = x - ox; |
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!?
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4748
diff
changeset
|
45 double dy = y - oy; |
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!?
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4748
diff
changeset
|
46 return dx*dx + dy*dy; |
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!?
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4748
diff
changeset
|
47 } |
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!?
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4748
diff
changeset
|
48 |
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!?
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4748
diff
changeset
|
49 public final double distance(double xo, double yo) { |
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!?
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4748
diff
changeset
|
50 return Math.sqrt(distanceSqr(xo, yo)); |
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!?
Sascha L. Teichmann <teichmann@intevation.de>
parents:
4748
diff
changeset
|
51 } |
4732
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
52 } |
7fdddc6ba296
Initial version of support files for TIMParser, comments and TODOs by Felix Wolfsteller, Code by Sascha Teichmann.
Sascha Teichmann <sascha.teichmann@intevation.de>
parents:
diff
changeset
|
53 // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : |