01: /*
02: * GeoTools - OpenSource mapping toolkit
03: * http://geotools.org
04: * (C) 2006, GeoTools Project Managment Committee (PMC)
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation;
09: * version 2.1 of the License.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: */
16: package org.geotools.graph.util.delaunay;
17:
18: import org.geotools.feature.Feature;
19: import org.geotools.graph.structure.line.BasicXYNode;
20:
21: /**
22: *
23: * @author jfc173
24: */
25: public class DelaunayNode extends BasicXYNode {
26:
27: private Feature feature;
28:
29: /** Creates a new instance of delaunayNode */
30: public DelaunayNode() {
31: }
32:
33: public void setFeature(Feature f) {
34: feature = f;
35: }
36:
37: public Feature getFeature() {
38: return feature;
39: }
40:
41: public boolean equals(Object o) {
42: return ((o instanceof DelaunayNode)
43: && (this .getCoordinate().x == ((DelaunayNode) o)
44: .getCoordinate().x) && (this .getCoordinate().y == ((DelaunayNode) o)
45: .getCoordinate().y));
46: }
47:
48: /* waiting until we use 1.5 and Math.log10 becomes available!
49: private double roundToSigDigs(double d, int digits){
50: if (d == 0){
51: return 0;
52: } else {
53: double log = Math.log10(d);
54: int digitsLeftOfDecimal = (int) Math.ceil(log);
55: int digitsToMoveLeft = digits - digitsLeftOfDecimal;
56: double movedD = d*Math.pow(10, digitsToMoveLeft);
57: double rounded = Math.rint(movedD);
58: double ret = rounded / Math.pow(10, digitsToMoveLeft);
59: return ret;
60: }
61: }
62: */
63:
64: public String toString() {
65: // return "(" + roundToSigDigs(this.getCoordinate().x, 5) + "," + roundToSigDigs(this.getCoordinate().y, 5) + ")";
66: return "(" + this .getCoordinate().x + ","
67: + this .getCoordinate().y + ")";
68: }
69:
70: }
|