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 @ 47346

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

    
28
import org.cresques.cts.ICoordTrans;
29

    
30
import org.gvsig.fmap.geom.Geometry;
31
import org.gvsig.fmap.geom.jts.primitive.curve.spline.BaseSpline2D;
32
import org.gvsig.fmap.geom.jts.primitive.surface.split.SurfaceSplitOperation;
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
    /* (non-Javadoc)
70
     * @see org.gvsig.fmap.geom.primitive.Surface#setSurfaceAppearance(org.gvsig.fmap.geom.primitive.SurfaceAppearance)
71
     */
72
    public void setSurfaceAppearance(SurfaceAppearance app) {
73
        // TODO Auto-generated method stub
74

    
75
    }
76

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

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

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

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

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

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

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

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

    
149
    /*
150
     * (non-Javadoc)
151
     *
152
     * @see org.gvsig.fmap.geom.jts.GeometryJTS#getJTS()
153
     */
154
    public com.vividsolutions.jts.geom.Geometry getJTS() {
155
        return JTSUtils.createJTSPolygon(getSplineCoordinates());
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
    /* (non-Javadoc)
166
     * @see org.gvsig.fmap.geom.Geometry#offset(double)
167
     */
168
    public Geometry offset(int jointStyle, double distance) throws GeometryOperationNotSupportedException, GeometryOperationException {
169
        return JTSUtils.createGeometry(this.getProjection(), getJTS().buffer(distance, JTSUtils.calculateQuadrantSegments(jointStyle)));
170
    }
171

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

    
183
    @Override
184
    public Geometry split(Geometry splitter) {
185
        SurfaceSplitOperation op = new SurfaceSplitOperation();
186
        return op.split(this, splitter);
187
    }
188
}