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 @ 45762
History | View | Annotate | Download (6.86 KB)
1 | 42304 | fdiaz | /* 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 | 42464 | fdiaz | import org.cresques.cts.ICoordTrans; |
28 | |||
29 | 42304 | fdiaz | import org.gvsig.fmap.geom.Geometry; |
30 | import org.gvsig.fmap.geom.jts.primitive.curve.spline.BaseSpline3DM; |
||
31 | 42875 | fdiaz | import org.gvsig.fmap.geom.jts.primitive.curve.spline.Spline3DM; |
32 | 42304 | fdiaz | import org.gvsig.fmap.geom.jts.util.JTSUtils; |
33 | 42441 | fdiaz | import org.gvsig.fmap.geom.operation.GeometryOperationException; |
34 | import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
||
35 | 42304 | fdiaz | 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 FilledSpline3DM extends BaseSpline3DM implements FilledSpline { |
||
47 | |||
48 | /**
|
||
49 | *
|
||
50 | */
|
||
51 | private static final long serialVersionUID = -1127282615744603309L; |
||
52 | |||
53 | /**
|
||
54 | *
|
||
55 | */
|
||
56 | public FilledSpline3DM() {
|
||
57 | super(Geometry.TYPES.FILLEDSPLINE);
|
||
58 | } |
||
59 | |||
60 | /**
|
||
61 | * @param coordinates
|
||
62 | */
|
||
63 | public FilledSpline3DM(Coordinate[] coordinates) { |
||
64 | super(Geometry.TYPES.FILLEDSPLINE, coordinates);
|
||
65 | 42477 | fdiaz | closePrimitive(); |
66 | 42304 | fdiaz | } |
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 FilledSpline3DM(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 | 42441 | fdiaz | |
154 | |||
155 | /* (non-Javadoc)
|
||
156 | * @see org.gvsig.fmap.geom.Geometry#offset(double)
|
||
157 | */
|
||
158 | public Geometry offset(double distance) throws GeometryOperationNotSupportedException, GeometryOperationException { |
||
159 | 44099 | jjdelcerro | return JTSUtils.createGeometry(this.getProjection(), getJTS().buffer(distance)); |
160 | 42441 | fdiaz | } |
161 | 42464 | fdiaz | |
162 | 45762 | fdiaz | 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 | 42464 | fdiaz | /* (non-Javadoc)
|
167 | * @see org.gvsig.fmap.geom.jts.primitive.curve.spline.AbstractSpline#reProject(org.cresques.cts.ICoordTrans)
|
||
168 | */
|
||
169 | @Override
|
||
170 | public void reProject(ICoordTrans ct) { |
||
171 | super.reProject(ct);
|
||
172 | if (coordinates.size()>=2 && !isClosed()) { |
||
173 | closePrimitive(); |
||
174 | } |
||
175 | } |
||
176 | 42875 | fdiaz | |
177 | @Override
|
||
178 | public boolean equals(Object obj) { |
||
179 | boolean res = super.equals(obj); |
||
180 | if(res && obj instanceof FilledSpline3DM){ |
||
181 | FilledSpline3DM other = (FilledSpline3DM)obj; |
||
182 | if(this.getNumVertices() != other.getNumVertices()){ |
||
183 | return false; |
||
184 | } |
||
185 | for (int i = 0; i < this.getNumVertices(); i++) { |
||
186 | Coordinate coordinate = this.coordinates.get(i);
|
||
187 | Coordinate otherCoordinate = other.coordinates.get(i); |
||
188 | if (otherCoordinate.getOrdinate(2) != coordinate.getOrdinate(2)) { |
||
189 | return false; |
||
190 | } |
||
191 | if (otherCoordinate.getOrdinate(3) != coordinate.getOrdinate(3)) { |
||
192 | return false; |
||
193 | } |
||
194 | } |
||
195 | return true; |
||
196 | } else {
|
||
197 | return false; |
||
198 | } |
||
199 | } |
||
200 | 42304 | fdiaz | } |