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 / FilledSpline2DM.java @ 45762

History | View | Annotate | Download (6.62 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.BaseSpline2DM;
31
import org.gvsig.fmap.geom.jts.primitive.curve.spline.Spline2DM;
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 FilledSpline2DM extends BaseSpline2DM implements FilledSpline {
47

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

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

    
60
    /**
61
     * @param coordinates
62
     */
63
    public FilledSpline2DM(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
    public Geometry cloneGeometry() {
142
        return new FilledSpline2DM(cloneCoordinates().toCoordinateArray());
143
        }
144

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

    
154

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

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

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