Revision 44617 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/curve/spline/Spline2DM.java
Spline2DM.java | ||
---|---|---|
26 | 26 |
|
27 | 27 |
import com.vividsolutions.jts.geom.Coordinate; |
28 | 28 |
import com.vividsolutions.jts.geom.CoordinateSequence; |
29 |
import java.util.Arrays; |
|
29 | 30 |
|
30 | 31 |
import org.gvsig.fmap.geom.Geometry; |
31 | 32 |
import org.gvsig.fmap.geom.GeometryException; |
... | ... | |
44 | 45 |
import org.gvsig.fmap.geom.operation.GeometryOperationException; |
45 | 46 |
import org.gvsig.fmap.geom.operation.GeometryOperationNotSupportedException; |
46 | 47 |
import org.gvsig.fmap.geom.primitive.Line; |
48 |
import org.gvsig.fmap.geom.primitive.OrientablePrimitive; |
|
47 | 49 |
import org.gvsig.fmap.geom.primitive.Point; |
48 | 50 |
import org.gvsig.fmap.geom.primitive.Polygon; |
49 | 51 |
import org.gvsig.fmap.geom.primitive.Spline; |
... | ... | |
60 | 62 |
*/ |
61 | 63 |
private static final long serialVersionUID = 3275115053567971975L; |
62 | 64 |
|
63 |
/** |
|
64 |
* @param subtype |
|
65 |
*/ |
|
66 | 65 |
public Spline2DM() { |
67 | 66 |
super(Geometry.TYPES.SPLINE); |
68 | 67 |
} |
69 | 68 |
|
70 | 69 |
/** |
71 | 70 |
* |
71 |
* @param coordinates |
|
72 | 72 |
*/ |
73 | 73 |
public Spline2DM(Coordinate[] coordinates) { |
74 | 74 |
super(Geometry.TYPES.SPLINE, coordinates); |
75 | 75 |
} |
76 | 76 |
|
77 |
/* (non-Javadoc) |
|
78 |
* @see org.gvsig.fmap.geom.primitive.OrientablePrimitive#addVertex(double, double) |
|
79 |
*/ |
|
80 |
public void addVertex(double x, double y) { |
|
81 |
this.addVertex(new Point2DM(x, y, 0)); |
|
82 |
} |
|
77 |
@Override |
|
78 |
public OrientablePrimitive addVertex(double x, double y) { |
|
79 |
return this.addVertex(new Point2DM(x, y, 0)); |
|
80 |
} |
|
83 | 81 |
|
84 |
/* (non-Javadoc) |
|
85 |
* @see org.gvsig.fmap.geom.primitive.OrientablePrimitive#addVertex(double, double, double) |
|
86 |
*/ |
|
87 |
public void addVertex(double x, double y, double z) { |
|
82 |
@Override |
|
83 |
public OrientablePrimitive addVertex(double x, double y, double z) { |
|
88 | 84 |
String message = "Can't add x,y,z coordinate to Polygon2DM."; |
89 | 85 |
notifyDeprecated(message); |
90 | 86 |
throw new UnsupportedOperationException(message); |
91 | 87 |
} |
92 | 88 |
|
93 |
/* (non-Javadoc) |
|
94 |
* @see org.gvsig.fmap.geom.Geometry#cloneGeometry() |
|
95 |
*/ |
|
89 |
@Override |
|
96 | 90 |
public Geometry cloneGeometry() { |
97 | 91 |
return new Spline2DM(cloneCoordinates().toCoordinateArray()); |
98 | 92 |
} |
99 | 93 |
|
100 |
/* (non-Javadoc) |
|
101 |
* @see org.gvsig.fmap.geom.jts.primitive.curve.spline.AbstractSpline#fixPoint(org.gvsig.fmap.geom.primitive.Point) |
|
102 |
*/ |
|
103 | 94 |
@Override |
104 | 95 |
protected Point fixPoint(Point point) { |
105 | 96 |
if (point instanceof Point2DM) { |
... | ... | |
109 | 100 |
} |
110 | 101 |
} |
111 | 102 |
|
112 |
/* (non-Javadoc) |
|
113 |
* @see org.gvsig.fmap.geom.jts.primitive.curve.spline.AbstractSpline#getSplineCoordinates() |
|
114 |
*/ |
|
115 | 103 |
@Override |
116 | 104 |
protected ArrayListCoordinateSequence getSplineCoordinates() { |
117 | 105 |
ArrayListCoordinateSequence splineCoordinates = new ArrayListCoordinateSequence(); |
... | ... | |
149 | 137 |
return splineCoordinates; |
150 | 138 |
} |
151 | 139 |
|
152 |
/* (non-Javadoc) |
|
153 |
* @see org.gvsig.fmap.geom.primitive.Line#toPoints() |
|
154 |
*/ |
|
140 |
@Override |
|
155 | 141 |
public MultiPoint toPoints() throws GeometryException { |
156 | 142 |
MultiPoint multiPoint = new MultiPoint2DM(); |
157 |
Coordinate[] coordinates = getJTS().getCoordinates();
|
|
158 |
multiPoint.ensureCapacity(coordinates.length);
|
|
159 |
for (int i = 0; i < coordinates.length; i++) {
|
|
160 |
multiPoint.addPoint(new Point2DM(this.getProjection(), coordinates[i]));
|
|
143 |
Coordinate[] theCoordinates = getJTS().getCoordinates();
|
|
144 |
multiPoint.ensureCapacity(theCoordinates.length);
|
|
145 |
for (Coordinate theCoordinate : theCoordinates) {
|
|
146 |
multiPoint.addPoint(new Point2DM(this.getProjection(), theCoordinate));
|
|
161 | 147 |
} |
162 | 148 |
return multiPoint; |
163 | 149 |
} |
164 | 150 |
|
165 |
/* (non-Javadoc) |
|
166 |
* @see org.gvsig.fmap.geom.primitive.Line#toLines() |
|
167 |
*/ |
|
151 |
@Override |
|
168 | 152 |
public MultiLine toLines() throws GeometryException { |
169 | 153 |
MultiLine multiLine = new MultiLine2DM(); |
170 | 154 |
Line line = new Line2DM(getJTS().getCoordinates()); |
... | ... | |
172 | 156 |
return multiLine; |
173 | 157 |
} |
174 | 158 |
|
175 |
/* (non-Javadoc) |
|
176 |
* @see org.gvsig.fmap.geom.primitive.Line#toPolygons() |
|
177 |
*/ |
|
159 |
@Override |
|
178 | 160 |
public MultiPolygon toPolygons() throws GeometryException { |
179 | 161 |
MultiPolygon multiPolygon = new MultiPolygon2DM(); |
180 | 162 |
Polygon polygon = new Polygon2DM(getJTS().getCoordinates()); |
... | ... | |
183 | 165 |
} |
184 | 166 |
|
185 | 167 |
|
186 |
/* (non-Javadoc) |
|
187 |
* @see org.gvsig.fmap.geom.primitive.OrientablePrimitive#getVertex(int) |
|
188 |
*/ |
|
168 |
@Override |
|
189 | 169 |
public Point getVertex(int index) { |
190 | 170 |
Point2DM vertex = new Point2DM(this.getProjection(), this.coordinates.get(index)); |
191 | 171 |
anyVertex = vertex; |
192 | 172 |
return vertex; |
193 | 173 |
} |
194 | 174 |
|
195 |
/* (non-Javadoc) |
|
196 |
* @see org.gvsig.fmap.geom.Geometry#offset(double) |
|
197 |
*/ |
|
175 |
@Override |
|
198 | 176 |
public Geometry offset(double distance) throws GeometryOperationNotSupportedException, GeometryOperationException { |
199 | 177 |
Coordinate[] coords = getJTS().getCoordinates(); |
200 |
ArrayListCoordinateSequence listCoordSequence = new ArrayListCoordinateSequence(new ArrayList<Coordinate>()); |
|
201 |
for (int i = 0; i < coords.length; i++) { |
|
202 |
listCoordSequence.add(coords[i]); |
|
203 |
} |
|
178 |
ArrayListCoordinateSequence listCoordSequence = new ArrayListCoordinateSequence(new ArrayList<>()); |
|
179 |
listCoordSequence.addAll(Arrays.asList(coords)); |
|
204 | 180 |
if (isClosed()) { |
205 | 181 |
return JTSUtils.offsetClosedLine(this.getProjection(), listCoordSequence, distance); |
206 | 182 |
} else { |
... | ... | |
219 | 195 |
for(int i=0; i < this.getNumVertices(); i++){ |
220 | 196 |
if(other.coordinates.get(i).getOrdinate(2)!=this.coordinates.get(i).getOrdinate(2)){ |
221 | 197 |
return false; |
222 |
};
|
|
198 |
} |
|
223 | 199 |
} |
224 | 200 |
return true; |
225 | 201 |
} else { |
Also available in: Unified diff