Revision 5462 org.gvsig.raster/trunk/org.gvsig.raster/org.gvsig.raster.lib/org.gvsig.raster.lib.impl/src/main/java/org/gvsig/raster/impl/datastruct/ExtentImpl.java
ExtentImpl.java | ||
---|---|---|
28 | 28 |
import java.text.DecimalFormat; |
29 | 29 |
|
30 | 30 |
import org.cresques.cts.ICoordTrans; |
31 |
import org.gvsig.fmap.dal.coverage.RasterLocator; |
|
31 | 32 |
import org.gvsig.fmap.dal.coverage.datastruct.Extent; |
32 | 33 |
import org.gvsig.fmap.dal.coverage.datastruct.GridExtent; |
34 |
import org.gvsig.fmap.geom.GeometryLocator; |
|
35 |
import org.gvsig.fmap.geom.Geometry.SUBTYPES; |
|
36 |
import org.gvsig.fmap.geom.exception.CreateEnvelopeException; |
|
37 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
33 | 38 |
import org.gvsig.raster.impl.grid.GridExtentImpl; |
34 | 39 |
import org.gvsig.tools.ToolsLocator; |
35 | 40 |
import org.gvsig.tools.dynobject.DynStruct; |
41 |
import org.gvsig.tools.locator.LocatorException; |
|
36 | 42 |
import org.gvsig.tools.persistence.PersistenceManager; |
37 | 43 |
import org.gvsig.tools.persistence.PersistentState; |
38 | 44 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
45 |
import org.slf4j.Logger; |
|
46 |
import org.slf4j.LoggerFactory; |
|
39 | 47 |
|
40 | 48 |
/** |
41 | 49 |
* Clase que getiona el extent de una imagen |
... | ... | |
43 | 51 |
* @author Luis W.Sevilla (sevilla_lui@gva.es) |
44 | 52 |
*/ |
45 | 53 |
public class ExtentImpl implements Extent { |
54 |
|
|
55 |
private static final Logger LOG = LoggerFactory.getLogger(ExtentImpl.class); |
|
56 |
|
|
46 | 57 |
public static final String PERSISTENT_NAME = "Extent_Persistent"; |
47 | 58 |
public static final String PERSISTENT_DESCRIPTION = "Extent Persistent"; |
48 | 59 |
|
... | ... | |
482 | 493 |
} |
483 | 494 |
|
484 | 495 |
public Extent convert(ICoordTrans trans) { |
485 |
Rectangle2D rect = new Rectangle2D.Double(getURX(), getLRY(), width(), height()); |
|
486 |
Rectangle2D rectDest = trans.convert(rect); |
|
487 |
if (rectDest == null){ |
|
488 |
return null; |
|
489 |
} |
|
490 |
|
|
491 |
return new ExtentImpl( |
|
492 |
rectDest.getMinX(), |
|
493 |
rectDest.getMaxY(), |
|
494 |
rectDest.getMaxX(), |
|
495 |
rectDest.getMinY()); |
|
496 |
try { |
|
497 |
Envelope envelope = GeometryLocator.getGeometryManager().createEnvelope(getMin().getX(), |
|
498 |
getMin().getY(), getMax().getX(), getMax().getY(), SUBTYPES.GEOM2D); |
|
499 |
envelope = envelope.convert(trans); |
|
500 |
|
|
501 |
Point2D ul = new Point2D.Double(envelope.getMinimum(0), envelope.getMaximum(1)); |
|
502 |
Point2D lr = new Point2D.Double(envelope.getMaximum(0), envelope.getMinimum(1)); |
|
503 |
|
|
504 |
return RasterLocator.getManager().getDataStructFactory().createExtent(ul, lr); |
|
505 |
} catch (LocatorException | CreateEnvelopeException e) { |
|
506 |
LOG.error("Can not convert data extent. []"); |
|
507 |
return null; |
|
508 |
} |
|
496 | 509 |
} |
497 | 510 |
|
498 | 511 |
public boolean equals(Object obj) { |
Also available in: Unified diff