Revision 44040 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/DefaultEnvelope.java
DefaultEnvelope.java | ||
---|---|---|
44 | 44 |
import org.gvsig.fmap.geom.jts.util.JTSUtils; |
45 | 45 |
import org.gvsig.fmap.geom.primitive.Envelope; |
46 | 46 |
import org.gvsig.fmap.geom.primitive.EnvelopeNotInitializedException; |
47 |
import org.gvsig.fmap.geom.primitive.Line; |
|
47 | 48 |
import org.gvsig.fmap.geom.primitive.Point; |
49 |
import org.gvsig.fmap.geom.primitive.Polygon; |
|
48 | 50 |
import org.gvsig.fmap.geom.primitive.Surface; |
49 | 51 |
import org.gvsig.tools.ToolsLocator; |
50 | 52 |
import org.gvsig.tools.dynobject.DynStruct; |
... | ... | |
63 | 65 |
|
64 | 66 |
* @author Vicente Caballero Navarro |
65 | 67 |
*/ |
68 |
@SuppressWarnings("UseSpecificCatch") |
|
66 | 69 |
public abstract class DefaultEnvelope implements Envelope, org.gvsig.tools.lang.Cloneable{ |
67 | 70 |
private static final Logger LOG = |
68 | 71 |
LoggerFactory.getLogger(DefaultEnvelope.class); |
... | ... | |
212 | 215 |
throw new EnvelopeNotInitializedException(); |
213 | 216 |
} |
214 | 217 |
try { |
215 |
Surface surface = (Surface)manager.create(TYPES.SURFACE, SUBTYPES.GEOM2D); |
|
216 |
surface.addVertex((Point)min.cloneGeometry()); |
|
217 |
surface.addVertex(manager.createPoint(getMaximum(0),getMinimum(1), SUBTYPES.GEOM2D)); |
|
218 |
surface.addVertex((Point)max.cloneGeometry()); |
|
219 |
surface.addVertex(manager.createPoint(getMinimum(0),getMaximum(1), SUBTYPES.GEOM2D)); |
|
220 |
surface.addVertex((Point)min.cloneGeometry()); |
|
221 |
surface.setProjection(projection); |
|
222 |
return surface; |
|
223 |
} catch (CreateGeometryException e) { |
|
224 |
LOG.error("Error creting the surface", e); |
|
218 |
// point? |
|
219 |
if (this.min.getX() == this.max.getX() && this.min.getY() == this.max.getY()) { |
|
220 |
Point point = this.min.clone(); |
|
221 |
point.setProjection(projection); |
|
222 |
return point; |
|
223 |
} |
|
224 |
// vertical or horizontal line? |
|
225 |
if (this.min.getX() == this.max.getX() || |
|
226 |
this.min.getY() == this.max.getY()) { |
|
227 |
Line line = manager.createLine(SUBTYPES.GEOM2D); |
|
228 |
line.addVertex(min.clone()); |
|
229 |
line.addVertex(max.clone()); |
|
230 |
line.setProjection(projection); |
|
231 |
return line; |
|
232 |
} |
|
233 |
Polygon polygon = manager.createPolygon(SUBTYPES.GEOM2D); |
|
234 |
polygon.addVertex(min.clone()); |
|
235 |
polygon.addVertex(manager.createPoint(getMaximum(0),getMinimum(1), SUBTYPES.GEOM2D)); |
|
236 |
polygon.addVertex(max.clone()); |
|
237 |
polygon.addVertex(manager.createPoint(getMinimum(0),getMaximum(1), SUBTYPES.GEOM2D)); |
|
238 |
polygon.addVertex(min.clone()); |
|
239 |
polygon.setProjection(projection); |
|
240 |
return polygon; |
|
241 |
} catch (Exception e) { |
|
242 |
LOG.warn("Error creting the geometry from envelope", e); |
|
225 | 243 |
} |
226 | 244 |
return null; |
227 | 245 |
} |
Also available in: Unified diff