Revision 36222 branches/v2_0_0_prep/libraries/libFMap_geometries/src/org/gvsig/fmap/geom/primitive/impl/Point2DZ.java

View differences:

Point2DZ.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
1
/* gvSIG. Geographic Information System of the Valencian Government
2 2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
5
 * 
5 6
 * This program is free software; you can redistribute it and/or
6 7
 * modify it under the terms of the GNU General Public License
7 8
 * as published by the Free Software Foundation; either version 2
8 9
 * of the License, or (at your option) any later version.
9
 *
10
 * 
10 11
 * This program is distributed in the hope that it will be useful,
11 12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 14
 * GNU General Public License for more details.
14
 *
15
 * 
15 16
 * You should have received a copy of the GNU General Public License
16 17
 * 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
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
19
 * MA  02110-1301, USA.
20
 * 
40 21
 */
41 22
package org.gvsig.fmap.geom.primitive.impl;
42 23

  
......
49 30

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

  
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
	}
38
    public static final String PERSISTENCE_DEFINITION_NAME =
39
        "Point2DimensionsZ";
40
    private static final long serialVersionUID = 1L;
70 41

  
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
	}
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
    }
83 54

  
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
	}
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
    }
90 69

  
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
    }
91 76

  
92
	/*
93
	 * (non-Javadoc)
94
	 * @see org.gvsig.fmap.geom.primitive.impl.Point2D#getShapeType()
95
	 */
96
	public int getShapeType() {
97
		return TYPES.POINT;
98
	}
77
    /*
78
     * (non-Javadoc)
79
     * 
80
     * @see org.gvsig.fmap.geom.primitive.impl.Point2D#getShapeType()
81
     */
82
    public int getShapeType() {
83
        return TYPES.POINT;
84
    }
99 85

  
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
	}
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
    }
107 95

  
108
	/*
109
	 * (non-Javadoc)
110
	 * @see org.gvsig.fmap.geom.primitive.impl.Point2D#getDimension()
111
	 */
112
	public int getDimension() {
113
		return 3;
114
	}
96
    /*
97
     * (non-Javadoc)
98
     * 
99
     * @see org.gvsig.fmap.geom.primitive.impl.Point2D#getDimension()
100
     */
101
    public int getDimension() {
102
        return 3;
103
    }
115 104

  
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
		}
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
        }
124 114

  
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
	}
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
    }
131 121

  
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
	}
122
    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
    }
146 136
}

Also available in: Unified diff