Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.compat.cdc / org.gvsig.fmap.geometry / org.gvsig.fmap.geometry.jts / src / main / java / org / gvsig / fmap / geom / jts / primitive / surface / filledspline / FilledSpline3D.java @ 47346

History | View | Annotate | Download (7.01 KB)

1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2015 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.fmap.geom.jts.primitive.surface.filledspline;
24

    
25
import com.vividsolutions.jts.geom.Coordinate;
26

    
27
import org.cresques.cts.ICoordTrans;
28

    
29
import org.gvsig.fmap.geom.Geometry;
30
import org.gvsig.fmap.geom.jts.primitive.curve.spline.BaseSpline3D;
31
import org.gvsig.fmap.geom.jts.primitive.surface.split.SurfaceSplitOperation;
32
import org.gvsig.fmap.geom.jts.util.JTSUtils;
33
import org.gvsig.fmap.geom.operation.GeometryOperationException;
34
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
35
import org.gvsig.fmap.geom.primitive.FilledSpline;
36
import org.gvsig.fmap.geom.primitive.Line;
37
import org.gvsig.fmap.geom.primitive.Polygon;
38
import org.gvsig.fmap.geom.primitive.Ring;
39
import org.gvsig.fmap.geom.primitive.SurfaceAppearance;
40

    
41

    
42
/**
43
 * @author fdiaz
44
 *
45
 */
46
public class FilledSpline3D extends BaseSpline3D implements FilledSpline {
47

    
48
    /**
49
     *
50
     */
51
    private static final long serialVersionUID = -8947796452807902242L;
52

    
53
    /**
54
     *
55
     */
56
    public FilledSpline3D() {
57
        super(Geometry.TYPES.FILLEDSPLINE);
58
    }
59

    
60
    /**
61
     * @param coordinates
62
     */
63
    public FilledSpline3D(Coordinate[] coordinates) {
64
        super(Geometry.TYPES.FILLEDSPLINE, coordinates);
65
        closePrimitive();
66
    }
67

    
68
    /* (non-Javadoc)
69
     * @see org.gvsig.fmap.geom.primitive.Surface#setSurfaceAppearance(org.gvsig.fmap.geom.primitive.SurfaceAppearance)
70
     */
71
    public void setSurfaceAppearance(SurfaceAppearance app) {
72
        // TODO Auto-generated method stub
73

    
74
    }
75

    
76
    /* (non-Javadoc)
77
     * @see org.gvsig.fmap.geom.primitive.Surface#getSurfaceAppearance()
78
     */
79
    public SurfaceAppearance getSurfaceAppearance() {
80
        // TODO Auto-generated method stub
81
        return null;
82
    }
83

    
84
    /* (non-Javadoc)
85
     * @see org.gvsig.fmap.geom.primitive.Surface#getNumInteriorRings()
86
     */
87
    public int getNumInteriorRings() {
88
        String message = "Calling deprecated method getNumInteriorRings of a filled spline";
89
        notifyDeprecated(message);
90
        throw new UnsupportedOperationException(message);
91
    }
92

    
93
    /* (non-Javadoc)
94
     * @see org.gvsig.fmap.geom.primitive.Surface#getInteriorRing(int)
95
     */
96
    public Ring getInteriorRing(int index) {
97
        String message = "Calling deprecated method getInteriorRing of a filled spline";
98
        notifyDeprecated(message);
99
        throw new UnsupportedOperationException(message);
100
    }
101

    
102
    /* (non-Javadoc)
103
     * @see org.gvsig.fmap.geom.primitive.Surface#addInteriorRing(org.gvsig.fmap.geom.primitive.Ring)
104
     */
105
    public void addInteriorRing(Ring ring) {
106
        String message = "Calling deprecated method addInteriorRing of a filled spline";
107
        notifyDeprecated(message);
108
        throw new UnsupportedOperationException(message);
109
    }
110

    
111
    /* (non-Javadoc)
112
     * @see org.gvsig.fmap.geom.primitive.Surface#addInteriorRing(org.gvsig.fmap.geom.primitive.Line)
113
     */
114
    public void addInteriorRing(Line line) {
115
        String message = "Calling deprecated method addInteriorRing of a filled spline";
116
        notifyDeprecated(message);
117
        throw new UnsupportedOperationException(message);
118
    }
119

    
120
    /* (non-Javadoc)
121
     * @see org.gvsig.fmap.geom.primitive.Surface#addInteriorRing(org.gvsig.fmap.geom.primitive.Polygon)
122
     */
123
    public void addInteriorRing(Polygon polygon) {
124
        String message = "Calling deprecated method addInteriorRing of a filled spline";
125
        notifyDeprecated(message);
126
        throw new UnsupportedOperationException(message);
127
    }
128

    
129
    /* (non-Javadoc)
130
     * @see org.gvsig.fmap.geom.primitive.Surface#removeInteriorRing(int)
131
     */
132
    public void removeInteriorRing(int index) {
133
        String message = "Calling deprecated method removeInteriorRing of a circle";
134
        notifyDeprecated(message);
135
        throw new UnsupportedOperationException(message);
136
    }
137

    
138
    /* (non-Javadoc)
139
     * @see org.gvsig.fmap.geom.Geometry#cloneGeometry()
140
     */
141
    @Override
142
    public Geometry cloneGeometry() {
143
        FilledSpline3D clone = new FilledSpline3D(cloneCoordinates().toCoordinateArray());
144
        clone.setProjection(this.getProjection());
145
        return clone;
146
        }
147

    
148
    /*
149
     * (non-Javadoc)
150
     *
151
     * @see org.gvsig.fmap.geom.jts.GeometryJTS#getJTS()
152
     */
153
    public com.vividsolutions.jts.geom.Geometry getJTS() {
154
        return JTSUtils.createJTSPolygon(getSplineCoordinates());
155
    }
156

    
157

    
158
    /* (non-Javadoc)
159
     * @see org.gvsig.fmap.geom.Geometry#offset(double)
160
     */
161
    public Geometry offset(double distance) throws GeometryOperationNotSupportedException, GeometryOperationException {
162
        return JTSUtils.createGeometry(this.getProjection(), getJTS().buffer(distance));
163
    }
164

    
165
    public Geometry offset(int jointStyle, double distance) throws GeometryOperationNotSupportedException, GeometryOperationException {
166
        return JTSUtils.createGeometry(this.getProjection(), getJTS().buffer(distance, JTSUtils.calculateQuadrantSegments(jointStyle)));
167
    }
168

    
169
    /* (non-Javadoc)
170
     * @see org.gvsig.fmap.geom.jts.primitive.curve.spline.AbstractSpline#reProject(org.cresques.cts.ICoordTrans)
171
     */
172
    @Override
173
    public void reProject(ICoordTrans ct) {
174
        super.reProject(ct);
175
        if (coordinates.size()>=2 && !isClosed()) {
176
            closePrimitive();
177
        }
178
    }
179

    
180
    @Override
181
    public boolean equals(Object obj) {
182
        boolean res = super.equals(obj);
183
        if(res && obj instanceof FilledSpline3D){
184
            FilledSpline3D other = (FilledSpline3D)obj;
185
            if(this.getNumVertices() != other.getNumVertices()){
186
                return false;
187
            }
188
            for (int i = 0; i < this.getNumVertices(); i++) {
189
                Coordinate coordinate = this.coordinates.get(i);
190
                Coordinate otherCoordinate = other.coordinates.get(i);
191
                if (otherCoordinate.getOrdinate(2) != coordinate.getOrdinate(2)) {
192
                    return false;
193
                }
194
            }
195
            return true;
196
        } else {
197
            return false;
198
        }
199
    }
200

    
201
    @Override
202
    public Geometry split(Geometry splitter) {
203
        SurfaceSplitOperation op = new SurfaceSplitOperation();
204
        return op.split(this, splitter);
205
    }
206
}