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 / FilledSpline3DM.java @ 47346
History | View | Annotate | Download (7.21 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.BaseSpline3DM; |
31 |
import org.gvsig.fmap.geom.jts.primitive.curve.spline.Spline3DM; |
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 FilledSpline3DM extends BaseSpline3DM implements FilledSpline { |
48 |
|
49 |
/**
|
50 |
*
|
51 |
*/
|
52 |
private static final long serialVersionUID = -1127282615744603309L; |
53 |
|
54 |
/**
|
55 |
*
|
56 |
*/
|
57 |
public FilledSpline3DM() {
|
58 |
super(Geometry.TYPES.FILLEDSPLINE);
|
59 |
} |
60 |
|
61 |
/**
|
62 |
* @param coordinates
|
63 |
*/
|
64 |
public FilledSpline3DM(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 |
FilledSpline3DM clone = new FilledSpline3DM(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 |
|
159 |
/* (non-Javadoc)
|
160 |
* @see org.gvsig.fmap.geom.Geometry#offset(double)
|
161 |
*/
|
162 |
public Geometry offset(double distance) throws GeometryOperationNotSupportedException, GeometryOperationException { |
163 |
return JTSUtils.createGeometry(this.getProjection(), getJTS().buffer(distance)); |
164 |
} |
165 |
|
166 |
public Geometry offset(int jointStyle, double distance) throws GeometryOperationNotSupportedException, GeometryOperationException { |
167 |
return JTSUtils.createGeometry(this.getProjection(), getJTS().buffer(distance, JTSUtils.calculateQuadrantSegments(jointStyle))); |
168 |
} |
169 |
|
170 |
/* (non-Javadoc)
|
171 |
* @see org.gvsig.fmap.geom.jts.primitive.curve.spline.AbstractSpline#reProject(org.cresques.cts.ICoordTrans)
|
172 |
*/
|
173 |
@Override
|
174 |
public void reProject(ICoordTrans ct) { |
175 |
super.reProject(ct);
|
176 |
if (coordinates.size()>=2 && !isClosed()) { |
177 |
closePrimitive(); |
178 |
} |
179 |
} |
180 |
|
181 |
@Override
|
182 |
public boolean equals(Object obj) { |
183 |
boolean res = super.equals(obj); |
184 |
if(res && obj instanceof FilledSpline3DM){ |
185 |
FilledSpline3DM other = (FilledSpline3DM)obj; |
186 |
if(this.getNumVertices() != other.getNumVertices()){ |
187 |
return false; |
188 |
} |
189 |
for (int i = 0; i < this.getNumVertices(); i++) { |
190 |
Coordinate coordinate = this.coordinates.get(i);
|
191 |
Coordinate otherCoordinate = other.coordinates.get(i); |
192 |
if (otherCoordinate.getOrdinate(2) != coordinate.getOrdinate(2)) { |
193 |
return false; |
194 |
} |
195 |
if (otherCoordinate.getOrdinate(3) != coordinate.getOrdinate(3)) { |
196 |
return false; |
197 |
} |
198 |
} |
199 |
return true; |
200 |
} else {
|
201 |
return false; |
202 |
} |
203 |
} |
204 |
|
205 |
@Override
|
206 |
public Geometry split(Geometry splitter) {
|
207 |
SurfaceSplitOperation op = new SurfaceSplitOperation();
|
208 |
return op.split(this, splitter); |
209 |
} |
210 |
} |