Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.geometry / org.gvsig.fmap.geometry.impl / src / main / java / org / gvsig / fmap / geom / primitive / impl / Spline2DZ.java @ 40435

History | View | Annotate | Download (1.68 KB)

1
/**
2
 *
3
 */
4
package org.gvsig.fmap.geom.primitive.impl;
5

    
6
import java.awt.geom.Point2D;
7

    
8
import org.cresques.cts.IProjection;
9
import org.gvsig.fmap.geom.Geometry;
10
import org.gvsig.fmap.geom.primitive.Spline;
11
import org.gvsig.fmap.geom.type.GeometryType;
12

    
13
/**
14
 * @author paco
15
 *
16
 */
17
public class Spline2DZ extends Spline2D implements Spline {
18
        private static final long serialVersionUID = 8745988712085629939L;
19
        private double z;
20

    
21
        /**
22
         * The constructor with the GeometryType like and argument 
23
         * is used by the {@link GeometryType}{@link #create()}
24
         * to create the geometry
25
         * @param type
26
         * The geometry type
27
         */
28
        public Spline2DZ(GeometryType geometryType) {
29
                super(geometryType);                
30
        }
31
        
32
        /**
33
         * Constructor used in the {@link Geometry#cloneGeometry()} method
34
         * @param geometryType
35
         * @param id
36
         * @param projection
37
         * @param ps
38
         * @param z
39
         */
40
        Spline2DZ(GeometryType geometryType, String id, IProjection projection, Point2D[] ps, double z) {
41
                super(geometryType, id, projection, ps);
42
                this.z = z;
43
        }
44

    
45
        /* (non-Javadoc)
46
         * @see org.gvsig.fmap.geom.primitive.Curve2D#setCoordinateAt(int, int, double)
47
         */
48
        public void setCoordinateAt(int index, int dimension, double value) {
49
                if (dimension == 2){
50
                        z = value;
51
                }else{
52
                        super.setCoordinateAt(index, dimension, value);
53
                }
54
        }
55
        
56
    public double getCoordinateAt(int index, int dimension) {
57
        if (index > gp.getNumCoords()) {
58
            throw new ArrayIndexOutOfBoundsException();
59
        }
60
        double[] coords = gp.getPointAt(index).getCoordinates();
61
        if(dimension < coords.length)
62
                return gp.getPointAt(index).getCoordinateAt(dimension);
63
        return 0D;
64
    }
65

    
66
    public int getDimension() {
67
        return 3;
68
    }
69
}