Revision 2614 org.gvsig.raster.wmts/trunk/org.gvsig.raster.wmts/org.gvsig.raster.wmts.ogc/org.gvsig.raster.wmts.ogc.impl/src/main/java/org/gvsig/raster/wmts/ogc/impl/struct/WMTSLayerImpl.java
WMTSLayerImpl.java | ||
---|---|---|
23 | 23 |
|
24 | 24 |
import java.awt.geom.Rectangle2D; |
25 | 25 |
import java.util.ArrayList; |
26 |
import java.util.HashMap; |
|
26 | 27 |
import java.util.List; |
27 | 28 |
|
28 | 29 |
import org.cresques.cts.ICoordTrans; |
... | ... | |
48 | 49 |
* @author Nacho Brodin (nachobrodin@gmail.com) |
49 | 50 |
*/ |
50 | 51 |
public abstract class WMTSLayerImpl extends WMTSBaseStruct implements WMTSLayer { |
51 |
protected WMTSBoundingBox wgs84bbox = null; |
|
52 |
protected WMTSBoundingBox bbox = null; |
|
53 |
private List<WMTSStyle> style = null; |
|
54 |
private List<String> imageFormat = null; |
|
55 |
private List<String> infoFormat = null; |
|
56 |
private List<String> keywords = null; |
|
57 |
private List<WMTSDimension> dimension = null; |
|
58 |
private String metadata = null; |
|
59 |
private List<WMTSTileMatrixSetLink> tileMatrixSetLinkList = null; |
|
60 |
private List<WMTSResourceURL> resourceURL = null; |
|
61 |
protected WMTSServerDescription status = null; |
|
62 |
private Logger log = LoggerFactory.getLogger(WMTSLayerImpl.class); |
|
63 |
protected boolean forceChangeAxisOrder = false; |
|
52 |
protected WMTSBoundingBox wgs84bbox = null; |
|
53 |
protected WMTSBoundingBox bbox = null; |
|
54 |
private List<WMTSStyle> style = null; |
|
55 |
private List<String> imageFormat = null; |
|
56 |
private List<String> infoFormat = null; |
|
57 |
private List<String> keywords = null; |
|
58 |
private List<WMTSDimension> dimension = null; |
|
59 |
private String metadata = null; |
|
60 |
private List<WMTSTileMatrixSetLink> tileMatrixSetLinkList = null; |
|
61 |
private List<WMTSResourceURL> resourceURL = null; |
|
62 |
protected WMTSServerDescription status = null; |
|
63 |
private Logger log = LoggerFactory.getLogger(WMTSLayerImpl.class); |
|
64 |
protected boolean forceChangeAxisOrder = false; |
|
65 |
private HashMap<String, Rectangle2D> transformations = new HashMap<String, Rectangle2D>(); |
|
64 | 66 |
|
65 | 67 |
/** |
66 | 68 |
* Sets longitude first in the axis order read from the capabilities file |
... | ... | |
107 | 109 |
} |
108 | 110 |
|
109 | 111 |
public Rectangle2D getWGS84BBoxTransformed(String epsg) { |
112 |
Rectangle2D r = transformations.get(epsg); |
|
113 |
if(r != null) { |
|
114 |
return r; |
|
115 |
} |
|
116 |
|
|
110 | 117 |
IProjection projSrc = CRSFactory.getCRS("EPSG:4326"); |
111 | 118 |
try { |
112 | 119 |
IProjection projDst = CRSFactory.getCRS(epsg); |
113 | 120 |
if(projDst != null) { |
114 | 121 |
try { |
115 | 122 |
ICoordTrans t = projSrc.getCT(projDst); |
116 |
return t.convert(wgs84bbox.toRectangle2D()); |
|
123 |
r = t.convert(wgs84bbox.toRectangle2D()); |
|
124 |
if(isBoundingBoxValid(r)) { |
|
125 |
transformations.put(epsg, r); |
|
126 |
return r; |
|
127 |
} |
|
117 | 128 |
} catch (Exception e) { |
118 | 129 |
log.info("I cannot get the transformation between EPSG:4326 and " + epsg, e); |
119 | 130 |
} |
... | ... | |
124 | 135 |
return null; |
125 | 136 |
} |
126 | 137 |
|
138 |
private boolean isBoundingBoxValid(Rectangle2D bbox) { |
|
139 |
if(Double.isInfinite(bbox.getX()) || |
|
140 |
Double.isNaN(bbox.getX()) || |
|
141 |
Double.isInfinite(bbox.getY()) || |
|
142 |
Double.isNaN(bbox.getY())) { |
|
143 |
return false; |
|
144 |
} |
|
145 |
return true; |
|
146 |
} |
|
147 |
|
|
127 | 148 |
public WMTSBoundingBox getBBox() { |
128 | 149 |
return bbox; |
129 | 150 |
} |
Also available in: Unified diff