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 / FilledSpline2D.java @ 47432

History | View | Annotate | Download (7.17 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

    
26
import com.vividsolutions.jts.geom.Coordinate;
27
import org.cresques.cts.ICoordTrans;
28
import org.gvsig.fmap.geom.Geometry;
29
import org.gvsig.fmap.geom.jts.mgeom.MCoordinate;
30
import org.gvsig.fmap.geom.jts.primitive.curve.spline.BaseSpline2D;
31
import org.gvsig.fmap.geom.jts.primitive.surface.split.SurfaceSplitOperation;
32
import org.gvsig.fmap.geom.jts.util.ArrayListCoordinateSequence;
33
import org.gvsig.fmap.geom.jts.util.JTSUtils;
34
import org.gvsig.fmap.geom.operation.GeometryOperationException;
35
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException;
36
import org.gvsig.fmap.geom.primitive.FilledSpline;
37
import org.gvsig.fmap.geom.primitive.Line;
38
import org.gvsig.fmap.geom.primitive.Polygon;
39
import org.gvsig.fmap.geom.primitive.Ring;
40
import org.gvsig.fmap.geom.primitive.SurfaceAppearance;
41

    
42

    
43
/**
44
 * @author fdiaz
45
 *
46
 */
47
public class FilledSpline2D extends BaseSpline2D implements FilledSpline {
48

    
49
    /**
50
     *
51
     */
52
    private static final long serialVersionUID = 8857987884304738266L;
53

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

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

    
69
    public FilledSpline2D(ArrayListCoordinateSequence coordinates) {
70
        super(Geometry.TYPES.FILLEDSPLINE, coordinates);
71
        closePrimitive();
72
    }
73
    
74
    public void setSurfaceAppearance(SurfaceAppearance app) {
75
        // TODO Auto-generated method stub
76

    
77
    }
78

    
79
    public SurfaceAppearance getSurfaceAppearance() {
80
        // TODO Auto-generated method stub
81
        return null;
82
    }
83

    
84
    public int getNumInteriorRings() {
85
        String message = "Calling deprecated method getNumInteriorRings of a filled spline";
86
        notifyDeprecated(message);
87
        throw new UnsupportedOperationException(message);
88
    }
89

    
90
    public Ring getInteriorRing(int index) {
91
        String message = "Calling deprecated method getInteriorRing of a filled spline";
92
        notifyDeprecated(message);
93
        throw new UnsupportedOperationException(message);
94
    }
95

    
96
    public void addInteriorRing(Ring ring) {
97
        String message = "Calling deprecated method addInteriorRing of a filled spline";
98
        notifyDeprecated(message);
99
        throw new UnsupportedOperationException(message);
100
    }
101

    
102
    public void addInteriorRing(Line line) {
103
        String message = "Calling deprecated method addInteriorRing of a filled spline";
104
        notifyDeprecated(message);
105
        throw new UnsupportedOperationException(message);
106
    }
107

    
108
    public void addInteriorRing(Polygon polygon) {
109
        String message = "Calling deprecated method addInteriorRing of a filled spline";
110
        notifyDeprecated(message);
111
        throw new UnsupportedOperationException(message);
112
    }
113

    
114
    public void removeInteriorRing(int index) {
115
        String message = "Calling deprecated method removeInteriorRing of a circle";
116
        notifyDeprecated(message);
117
        throw new UnsupportedOperationException(message);
118
    }
119

    
120
    @Override
121
    public Geometry cloneGeometry() {
122
        FilledSpline2D clone = new FilledSpline2D(cloneCoordinates().toCoordinateArray());
123
        clone.setProjection(this.getProjection());
124
        return clone;
125
    }
126

    
127
    public com.vividsolutions.jts.geom.Geometry getJTS() {
128
        return JTSUtils.createJTSPolygon(getSplineCoordinates());
129
    }
130

    
131
    public Geometry offset(double distance) throws GeometryOperationNotSupportedException, GeometryOperationException {
132
        return JTSUtils.createGeometry(this.getProjection(), getJTS().buffer(distance));
133
    }
134

    
135
    public Geometry offset(int jointStyle, double distance) throws GeometryOperationNotSupportedException, GeometryOperationException {
136
        return JTSUtils.createGeometry(this.getProjection(), getJTS().buffer(distance, JTSUtils.calculateQuadrantSegments(jointStyle)));
137
    }
138

    
139
    @Override
140
    public void reProject(ICoordTrans ct) {
141
        super.reProject(ct);
142
        if (coordinates.size()>=2 && !isClosed()) {
143
            closePrimitive();
144
        }
145
    }
146

    
147
    @Override
148
    public Geometry split(Geometry splitter) {
149
        SurfaceSplitOperation op = new SurfaceSplitOperation();
150
        return op.split(this, splitter);
151
    }
152

    
153
    @Override
154
    public Geometry force2D() throws GeometryOperationNotSupportedException, GeometryOperationException {
155
        Geometry geom = this.cloneGeometry();
156
        return geom;
157
    }
158

    
159
    @Override
160
    public Geometry force2DM() throws GeometryOperationNotSupportedException, GeometryOperationException {
161
        ArrayListCoordinateSequence coordinates2DM = new ArrayListCoordinateSequence(coordinates.size());
162
        for (Coordinate coordinate : this.coordinates) {
163
            coordinates2DM.add(MCoordinate.create2dWithMeasure(
164
                    coordinate.x, 
165
                    coordinate.y, 
166
                    0
167
            ));
168
        }
169
        FilledSpline2DM s = new FilledSpline2DM(coordinates2DM);
170
        s.setProjection(this.getProjection());
171
        return s;
172
    }
173

    
174
    @Override
175
    public Geometry force3D() throws GeometryOperationNotSupportedException, GeometryOperationException {
176
        ArrayListCoordinateSequence coordinates3D = new ArrayListCoordinateSequence(coordinates.size());
177
        for (Coordinate coordinate : this.coordinates) {
178
            coordinates3D.add(new Coordinate(
179
                    coordinate.x, 
180
                    coordinate.y, 
181
                    0
182
            ));
183
        }
184
        FilledSpline3D s = new FilledSpline3D(coordinates3D);
185
        s.setProjection(this.getProjection());
186
        return s;
187
    }
188

    
189
    @Override
190
    public Geometry force3DM() throws GeometryOperationNotSupportedException, GeometryOperationException {
191
        ArrayListCoordinateSequence coordinates3DM = new ArrayListCoordinateSequence(coordinates.size());
192
        for (Coordinate coordinate : this.coordinates) {
193
            coordinates3DM.add(MCoordinate.create3dWithMeasure(
194
                    coordinate.x, 
195
                    coordinate.y, 
196
                    0, 
197
                    0
198
            ));
199
        }
200
        FilledSpline3DM s = new FilledSpline3DM(coordinates3DM);
201
        s.setProjection(this.getProjection());
202
        return s;
203
    }
204
    
205
}