root / branches / v2_0_0_prep / libraries / libFMap_geometries / src / org / gvsig / fmap / geom / primitive / impl / Point2DZ.java @ 38596
History | View | Annotate | Download (3.71 KB)
1 | 36222 | cordinyana | /* gvSIG. Geographic Information System of the Valencian Government
|
---|---|---|---|
2 | 20761 | jmvivo | *
|
3 | 36222 | cordinyana | * Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 | * of the Valencian Government (CIT)
|
||
5 | *
|
||
6 | 20761 | jmvivo | * This program is free software; you can redistribute it and/or
|
7 | * modify it under the terms of the GNU General Public License
|
||
8 | * as published by the Free Software Foundation; either version 2
|
||
9 | * of the License, or (at your option) any later version.
|
||
10 | 36222 | cordinyana | *
|
11 | 20761 | jmvivo | * This program 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
|
||
14 | * GNU General Public License for more details.
|
||
15 | 36222 | cordinyana | *
|
16 | 20761 | jmvivo | * You should have received a copy of the GNU General Public License
|
17 | * along with this program; if not, write to the Free Software
|
||
18 | 36222 | cordinyana | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 | * MA 02110-1301, USA.
|
||
20 | *
|
||
21 | 20761 | jmvivo | */
|
22 | 27029 | jpiera | package org.gvsig.fmap.geom.primitive.impl; |
23 | 20761 | jmvivo | |
24 | 21870 | vcaballero | import org.cresques.cts.IProjection; |
25 | 33650 | jpiera | |
26 | 29097 | jpiera | import org.gvsig.fmap.geom.Geometry; |
27 | 27029 | jpiera | import org.gvsig.fmap.geom.primitive.FShape; |
28 | import org.gvsig.fmap.geom.primitive.Point; |
||
29 | 20761 | jmvivo | import org.gvsig.fmap.geom.type.GeometryType; |
30 | |||
31 | /**
|
||
32 | * Punto 3D.
|
||
33 | 36222 | cordinyana | *
|
34 | 20761 | jmvivo | * @author Vicente Caballero Navarro
|
35 | */
|
||
36 | 36222 | cordinyana | public class Point2DZ extends Point2D implements Point { |
37 | 21731 | vcaballero | |
38 | 36222 | cordinyana | public static final String PERSISTENCE_DEFINITION_NAME = |
39 | "Point2DimensionsZ";
|
||
40 | private static final long serialVersionUID = 1L; |
||
41 | 28089 | vcaballero | |
42 | 36222 | cordinyana | /**
|
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 | } |
||
54 | 29104 | jmvivo | |
55 | 36222 | cordinyana | /**
|
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 | } |
||
69 | 20761 | jmvivo | |
70 | 36222 | cordinyana | 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 | } |
||
76 | 29097 | jpiera | |
77 | 36222 | cordinyana | /*
|
78 | * (non-Javadoc)
|
||
79 | *
|
||
80 | * @see org.gvsig.fmap.geom.primitive.impl.Point2D#getShapeType()
|
||
81 | */
|
||
82 | public int getShapeType() { |
||
83 | return TYPES.POINT;
|
||
84 | } |
||
85 | 20761 | jmvivo | |
86 | 36222 | cordinyana | /*
|
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 | } |
||
95 | 20761 | jmvivo | |
96 | 36222 | cordinyana | /*
|
97 | * (non-Javadoc)
|
||
98 | *
|
||
99 | * @see org.gvsig.fmap.geom.primitive.impl.Point2D#getDimension()
|
||
100 | */
|
||
101 | public int getDimension() { |
||
102 | return 3; |
||
103 | } |
||
104 | 21731 | vcaballero | |
105 | 36222 | cordinyana | /*
|
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 | } |
||
114 | 26289 | jmvivo | |
115 | 36222 | cordinyana | Point2DZ pother = (Point2DZ) other; |
116 | if (Math.abs(this.coordinates[2] - pother.coordinates[2]) > 0.0000001) { |
||
117 | return false; |
||
118 | } |
||
119 | return true; |
||
120 | } |
||
121 | 29104 | jmvivo | |
122 | 36222 | cordinyana | public void setCoordinates(double[] values) { |
123 | super.setCoordinates(values);
|
||
124 | if (values.length > 2) { |
||
125 | coordinates[2] = values[2]; |
||
126 | } |
||
127 | } |
||
128 | |||
129 | public String toString() { |
||
130 | StringBuffer buffer = new StringBuffer(); |
||
131 | buffer.append("Point2DZ(");
|
||
132 | toStringCoordinates(buffer); |
||
133 | buffer.append(")");
|
||
134 | return buffer.toString();
|
||
135 | } |
||
136 | 20761 | jmvivo | } |