Revision 38599 branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/impl/Point2DZ.java
Point2DZ.java | ||
---|---|---|
22 | 22 |
package org.gvsig.fmap.geom.primitive.impl; |
23 | 23 |
|
24 | 24 |
import org.cresques.cts.IProjection; |
25 |
|
|
26 | 25 |
import org.gvsig.fmap.geom.Geometry; |
27 | 26 |
import org.gvsig.fmap.geom.primitive.FShape; |
28 | 27 |
import org.gvsig.fmap.geom.primitive.Point; |
29 | 28 |
import org.gvsig.fmap.geom.type.GeometryType; |
30 | 29 |
|
31 | 30 |
/** |
32 |
* Punto 3D.
|
|
31 |
* 3D point implementation.
|
|
33 | 32 |
* |
34 | 33 |
* @author Vicente Caballero Navarro |
34 |
* @author gvSIG team |
|
35 | 35 |
*/ |
36 | 36 |
public class Point2DZ extends Point2D implements Point { |
37 | 37 |
|
38 |
public static final String PERSISTENCE_DEFINITION_NAME = |
|
39 |
"Point2DimensionsZ"; |
|
40 |
private static final long serialVersionUID = 1L; |
|
38 |
private static final long serialVersionUID = 3113070237182638858L; |
|
41 | 39 |
|
42 |
/** |
|
43 |
* The constructor with the GeometryType like and argument |
|
44 |
* is used by the {@link GeometryType}{@link #create()} to create the |
|
45 |
* geometry |
|
46 |
* |
|
47 |
* @param type |
|
48 |
* The geometry type |
|
49 |
*/ |
|
50 |
public Point2DZ(GeometryType geomType) { |
|
51 |
super(geomType); |
|
52 |
coordinates[2] = 0; |
|
53 |
} |
|
40 |
public static final String PERSISTENCE_DEFINITION_NAME = "Point2DimensionsZ"; |
|
41 |
private double z = 0.0d; |
|
54 | 42 |
|
55 |
/** |
|
56 |
* Constructor used in the {@link Geometry#cloneGeometry()} method |
|
57 |
* |
|
58 |
* @param id |
|
59 |
* @param projection |
|
60 |
* @param x |
|
61 |
* @param y |
|
62 |
* @param z |
|
63 |
*/ |
|
64 |
Point2DZ(GeometryType geomType, String id, IProjection projection, |
|
65 |
double x, double y, double z) { |
|
66 |
super(geomType, id, projection, x, y); |
|
67 |
coordinates[2] = z; |
|
68 |
} |
|
43 |
/** |
|
44 |
* The constructor with the GeometryType like and argument is used by the |
|
45 |
* {@link GeometryType}{@link #create()} to create the geometry |
|
46 |
* |
|
47 |
* @param type |
|
48 |
* The geometry type |
|
49 |
*/ |
|
50 |
public Point2DZ(GeometryType geomType) { |
|
51 |
super(geomType); |
|
52 |
} |
|
69 | 53 |
|
70 |
public Point2DZ(double x, double y, double z) { |
|
71 |
super(TYPES.POINT, SUBTYPES.GEOM3D); |
|
72 |
coordinates[0] = x; |
|
73 |
coordinates[1] = y; |
|
74 |
coordinates[2] = z; |
|
75 |
} |
|
54 |
/** |
|
55 |
* Constructor used in the {@link Geometry#cloneGeometry()} method |
|
56 |
* |
|
57 |
* @param id |
|
58 |
* @param projection |
|
59 |
* @param x |
|
60 |
* @param y |
|
61 |
* @param z |
|
62 |
*/ |
|
63 |
Point2DZ(GeometryType geomType, String id, IProjection projection, |
|
64 |
double x, double y, double z) { |
|
65 |
super(geomType, id, projection, x, y); |
|
66 |
this.z = z; |
|
67 |
} |
|
76 | 68 |
|
77 |
/* |
|
78 |
* (non-Javadoc) |
|
79 |
* |
|
80 |
* @see org.gvsig.fmap.geom.primitive.impl.Point2D#getShapeType() |
|
81 |
*/ |
|
82 |
public int getShapeType() { |
|
83 |
return TYPES.POINT; |
|
69 |
public Point2DZ(double x, double y, double z, GeometryType geometryType) { |
|
70 |
super(geometryType); |
|
71 |
this.x = x; |
|
72 |
this.y = y; |
|
73 |
this.z = z; |
|
84 | 74 |
} |
85 | 75 |
|
86 |
/* |
|
87 |
* (non-Javadoc) |
|
88 |
* |
|
89 |
* @see org.gvsig.fmap.geom.primitive.impl.Point2D#cloneFShape() |
|
90 |
*/ |
|
91 |
public FShape cloneFShape() { |
|
92 |
return new Point2DZ(getGeometryType(), id, projection, coordinates[0], |
|
93 |
coordinates[1], coordinates[2]); |
|
94 |
} |
|
76 |
public Point2DZ(double x, double y, double z) { |
|
77 |
super(TYPES.POINT, SUBTYPES.GEOM3D); |
|
78 |
this.x = x; |
|
79 |
this.y = y; |
|
80 |
this.z = z; |
|
81 |
} |
|
95 | 82 |
|
96 |
/* |
|
97 |
* (non-Javadoc) |
|
98 |
* |
|
99 |
* @see org.gvsig.fmap.geom.primitive.impl.Point2D#getDimension() |
|
100 |
*/ |
|
101 |
public int getDimension() { |
|
102 |
return 3; |
|
103 |
} |
|
83 |
public int getShapeType() { |
|
84 |
return TYPES.POINT; |
|
85 |
} |
|
104 | 86 |
|
105 |
/* |
|
106 |
* (non-Javadoc) |
|
107 |
* |
|
108 |
* @see org.gvsig.fmap.geom.primitive.impl.Point2D#equals(java.lang.Object) |
|
109 |
*/ |
|
110 |
public boolean equals(Object other) { |
|
111 |
if (!super.equals(other)) { |
|
112 |
return false; |
|
113 |
} |
|
87 |
public FShape cloneFShape() { |
|
88 |
return new Point2DZ(getGeometryType(), id, projection, x, y, z); |
|
89 |
} |
|
114 | 90 |
|
115 |
Point2DZ pother = (Point2DZ) other; |
|
116 |
if (Math.abs(this.coordinates[2] - pother.coordinates[2]) > 0.0000001) { |
|
117 |
return false; |
|
118 |
} |
|
119 |
return true; |
|
120 |
} |
|
91 |
public int getDimension() { |
|
92 |
return 3; |
|
93 |
} |
|
121 | 94 |
|
122 |
public void setCoordinates(double[] values) { |
|
123 |
super.setCoordinates(values); |
|
124 |
if (values.length > 2) { |
|
125 |
coordinates[2] = values[2]; |
|
126 |
} |
|
127 |
} |
|
95 |
public boolean equals(Object other) { |
|
96 |
if (!super.equals(other)) { |
|
97 |
return false; |
|
98 |
} |
|
128 | 99 |
|
129 |
public String toString() { |
|
130 |
StringBuffer buffer = new StringBuffer(); |
|
131 |
buffer.append("Point2DZ("); |
|
132 |
toStringCoordinates(buffer); |
|
133 |
buffer.append(")"); |
|
134 |
return buffer.toString(); |
|
135 |
} |
|
100 |
Point2DZ pother = (Point2DZ) other; |
|
101 |
if (Math.abs(this.z - pother.z) > 0.0000001) { |
|
102 |
return false; |
|
103 |
} |
|
104 |
return true; |
|
105 |
} |
|
106 |
|
|
107 |
public void setCoordinates(double[] values) { |
|
108 |
super.setCoordinates(values); |
|
109 |
if (values.length > 2) { |
|
110 |
z = values[2]; |
|
111 |
} |
|
112 |
} |
|
113 |
|
|
114 |
public void setCoordinateAt(int dimension, double value) { |
|
115 |
if (dimension == Geometry.DIMENSIONS.Z) { |
|
116 |
this.z = value; |
|
117 |
} else { |
|
118 |
super.setCoordinateAt(dimension, value); |
|
119 |
} |
|
120 |
} |
|
121 |
|
|
122 |
public double getCoordinateAt(int dimension) { |
|
123 |
return (dimension == Geometry.DIMENSIONS.Z) ? this.z : super |
|
124 |
.getCoordinateAt(dimension); |
|
125 |
} |
|
126 |
|
|
127 |
public double getOrdinate(int dimension) { |
|
128 |
return (dimension == Geometry.DIMENSIONS.Z) ? this.z : super |
|
129 |
.getCoordinateAt(dimension); |
|
130 |
} |
|
131 |
|
|
132 |
public double[] getCoordinates() { |
|
133 |
return new double[] { getX(), getY(), this.z }; |
|
134 |
} |
|
135 |
|
|
136 |
protected String getFullTypeName() { |
|
137 |
return "Point2DZ"; |
|
138 |
} |
|
139 |
|
|
136 | 140 |
} |
Also available in: Unified diff