Revision 2860 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

View differences:

WMTSLayerImpl.java
63 63
	private Logger                        log                          = LoggerFactory.getLogger(WMTSLayerImpl.class);
64 64
	protected boolean                     forceChangeAxisOrder         = false;
65 65
	private HashMap<String, Rectangle2D>  transformations = new HashMap<String, Rectangle2D>();
66
	
66

  
67 67
	/**
68 68
	 * Sets longitude first in the axis order read from the capabilities file
69 69
	 * @param force
......
71 71
	public void setForceChangeAxisOrder(boolean force) {
72 72
		this.forceChangeAxisOrder = force;
73 73
	}
74
	
74

  
75 75
	public WMTSLayerImpl(WMTSServerDescription status) {
76 76
		this.status = status;
77 77
	}
78
	
78

  
79 79
	public String getMetadata() {
80 80
		return metadata;
81 81
	}
82
	
82

  
83 83
	public void setMetadata(String metadata) {
84 84
		this.metadata = metadata;
85 85
	}
86
	
86

  
87 87
	public List<String> getFormat() {
88 88
		if(imageFormat == null)
89 89
			imageFormat = new ArrayList<String>();
90 90
		return imageFormat;
91 91
	}
92
	
92

  
93 93
	public List<String> getInfoFormat() {
94 94
		if(infoFormat == null)
95 95
			infoFormat = new ArrayList<String>();
96 96
		return infoFormat;
97 97
	}
98
	
98

  
99 99
	public List<String> getKeywords() {
100 100
		return keywords;
101 101
	}
102
	
102

  
103 103
	public void setKeywords(List<String> k) {
104 104
		this.keywords = k;
105 105
	}
106
	
106

  
107 107
	public WMTSBoundingBox getWGS84BBox() {
108 108
		return wgs84bbox;
109 109
	}
110
	
110

  
111 111
	public Rectangle2D getWGS84BBoxTransformed(String epsg) {
112 112
		Rectangle2D r = transformations.get(epsg);
113 113
		if(r != null) {
114 114
			return r;
115 115
		}
116
		
116

  
117 117
		IProjection projSrc = CRSFactory.getCRS("EPSG:4326");
118 118
		try {
119 119
			IProjection projDst = CRSFactory.getCRS(epsg);
120 120
			if(projDst != null) {
121 121
				try {
122 122
					ICoordTrans t = projSrc.getCT(projDst);
123
					r = t.convert(wgs84bbox.toRectangle2D());
123
					if (t!=null){
124
						r = t.convert(wgs84bbox.toRectangle2D());
125
					} else {
126
						r = wgs84bbox.toRectangle2D();
127
					}
124 128
					if(isBoundingBoxValid(r)) {
125 129
						transformations.put(epsg, r);
126 130
						return r;
......
134 138
		}
135 139
		return null;
136 140
	}
137
	
141

  
138 142
	private boolean isBoundingBoxValid(Rectangle2D bbox) {
139
		if(Double.isInfinite(bbox.getX()) || 
140
			Double.isNaN(bbox.getX()) || 
141
			Double.isInfinite(bbox.getY()) || 
143
		if(Double.isInfinite(bbox.getX()) ||
144
			Double.isNaN(bbox.getX()) ||
145
			Double.isInfinite(bbox.getY()) ||
142 146
			Double.isNaN(bbox.getY())) {
143 147
			return false;
144 148
		}
145 149
		return true;
146 150
	}
147
	
151

  
148 152
	public WMTSBoundingBox getBBox() {
149 153
		return bbox;
150 154
	}
151
	
155

  
152 156
	public void setWGS84BBox(WMTSBoundingBox wgs84bbox) {
153 157
		this.wgs84bbox = wgs84bbox;
154 158
	}
155
	
159

  
156 160
	public void setBBox(WMTSBoundingBox bbox) {
157 161
		this.bbox = bbox;
158 162
	}
159
	
163

  
160 164
	public List<WMTSResourceURL> getResourceURL() {
161 165
		if(resourceURL == null)
162 166
			resourceURL = new ArrayList<WMTSResourceURL>();//resourceURL = (WMTSResourceURL)status.createVersionObject("WMTSResourceURL");
......
180 184
			tileMatrixSetLinkList = new ArrayList<WMTSTileMatrixSetLink>();
181 185
		return tileMatrixSetLinkList;
182 186
	}
183
	
187

  
184 188
	/**
185
	 * Returns the initial level of this layer inside the matrix set. 
189
	 * Returns the initial level of this layer inside the matrix set.
186 190
	 * @return
187 191
	 */
188 192
	public int getInitialLevel(String tileMatrixSetId) {
......
206 210
		}
207 211
		return initialLevel;
208 212
	}
209
	
213

  
210 214
	/**
211 215
	 * Links the TileMatrixSet with the limits inside the layer structure
212 216
	 * @param tileMatrixSetList
......
230 234
			}
231 235
		}
232 236
	}
233
	
237

  
234 238
	/**
235 239
	 * Gets the list of srs's supported
236 240
	 * @return
......
244 248
		}
245 249
		return list;
246 250
	}
247
	
251

  
248 252
	/**
249 253
	 * Builds the list of URL whether the capabilities file uses templates.
250 254
	 */
......
252 256
		TemplateSupport templateSupport = new TemplateSupport(getDimensions(), getResourceURL());
253 257
		templateSupport.buildResourceURLListFromTemplate(status);
254 258
	}
255
	
259

  
256 260
	public void print() {
257 261
		System.out.println("*****WMTSLayer******");
258 262
		System.out.println("Abstract:" + getAbstract());
......
271 275
		((WMTSBoundingBoxImpl)getBBox()).print();
272 276
		((WMTSBoundingBoxImpl)getWGS84BBox()).print();
273 277
		for (int i = 0; i < getDimensions().size(); i++) {
274
			((WMTSDimensionImpl)getDimensions().get(i)).print();			
278
			((WMTSDimensionImpl)getDimensions().get(i)).print();
275 279
		}
276 280
		System.out.println("Metadata:" + getMetadata());
277 281
		for (int i = 0; i < getTileMatrixSetLink().size(); i++) {

Also available in: Unified diff