Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / libraries / libFMap_geometries / src / org / gvsig / fmap / geom / primitive / impl / Point2DZ.java @ 35962

History | View | Annotate | Download (3.62 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package org.gvsig.fmap.geom.primitive.impl;
42

    
43
import org.cresques.cts.IProjection;
44

    
45
import org.gvsig.fmap.geom.Geometry;
46
import org.gvsig.fmap.geom.primitive.FShape;
47
import org.gvsig.fmap.geom.primitive.Point;
48
import org.gvsig.fmap.geom.type.GeometryType;
49

    
50
/**
51
 * Punto 3D.
52
 *
53
 * @author Vicente Caballero Navarro
54
 */
55
public class Point2DZ extends Point2D implements Point{
56
        public static final String PERSISTENCE_DEFINITION_NAME = "Point2DimensionsZ";
57
        private static final long serialVersionUID = 1L;
58

    
59
        /**
60
         * The constructor with the GeometryType like and argument
61
         * is used by the {@link GeometryType}{@link #create()}
62
         * to create the geometry
63
         * @param type
64
         * The geometry type
65
         */
66
        public Point2DZ(GeometryType geomType) {
67
                super(geomType);
68
                coordinates[2] = 0;
69
        }
70

    
71
        /**
72
         * Constructor used in the {@link Geometry#cloneGeometry()} method
73
         * @param id
74
         * @param projection
75
         * @param x
76
         * @param y
77
         * @param z
78
         */
79
        Point2DZ(GeometryType geomType, String id, IProjection projection, double x, double y, double z) {
80
                super(geomType, id, projection, x, y);
81
                coordinates[2] = z;
82
        }
83

    
84
        public Point2DZ (double x, double y, double z) {
85
                super(TYPES.POINT, SUBTYPES.GEOM3D);
86
                coordinates[0] = x;
87
                coordinates[1] = y;
88
                coordinates[2] = z;
89
        }
90

    
91

    
92
        /*
93
         * (non-Javadoc)
94
         * @see org.gvsig.fmap.geom.primitive.impl.Point2D#getShapeType()
95
         */
96
        public int getShapeType() {
97
                return TYPES.POINT;
98
        }
99

    
100
        /*
101
         * (non-Javadoc)
102
         * @see org.gvsig.fmap.geom.primitive.impl.Point2D#cloneFShape()
103
         */
104
        public FShape cloneFShape() {
105
                return new Point2DZ(getGeometryType(), id, projection, coordinates[0], coordinates[1], coordinates[2]);
106
        }
107

    
108
        /*
109
         * (non-Javadoc)
110
         * @see org.gvsig.fmap.geom.primitive.impl.Point2D#getDimension()
111
         */
112
        public int getDimension() {
113
                return 3;
114
        }
115

    
116
        /*
117
         * (non-Javadoc)
118
         * @see org.gvsig.fmap.geom.primitive.impl.Point2D#equals(java.lang.Object)
119
         */
120
        public boolean equals(Object other) {
121
                if (!super.equals(other)) {
122
                        return false;
123
                }
124

    
125
                Point2DZ pother = (Point2DZ) other;
126
                if (Math.abs(this.coordinates[2] - pother.coordinates[2]) > 0.0000001) {
127
                        return false;
128
                }
129
                return true;
130
        }
131

    
132
        public void setCoordinates(double[] values) {
133
                super.setCoordinates(values);
134
                if (values.length > 2) {
135
                        coordinates[2] = values[2];
136
                }
137
        }
138
        
139
        public String toString() {
140
            StringBuffer buffer = new StringBuffer();
141
            buffer.append("Point2DZ(");
142
            toStringCoordinates(buffer);        
143
            buffer.append(")");
144
            return buffer.toString();
145
        }
146
}