Revision 661

View differences:

org.gvsig.raster.wcs/trunk/org.gvsig.raster.wcs/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/WCSLayerNode.java
38 38
	private String       nativeSRS             = null;
39 39
	private ArrayList    formats               = null;
40 40
	private Point2D      maxRes                = null;
41
	private int          width                 = 0;
42
	private int          height                = 0;
41 43
	private ArrayList    timePositions         = null;
42 44
	private String       description           = null;
43 45
	private ArrayList    interpolationMethods  = null;
......
212 214
        this.transparency = transparency;
213 215
    }
214 216

  
217
	public int getWidth() {
218
		return width;
219
	}
220

  
221
	public void setWidth(int width) {
222
		this.width = width;
223
	}
224

  
225
	public int getHeight() {
226
		return height;
227
	}
228

  
229
	public void setHeight(int height) {
230
		this.height = height;
231
	}
232

  
215 233
}
org.gvsig.raster.wcs/trunk/org.gvsig.raster.wcs/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/WCSConnector.java
55 55
import org.gvsig.remoteclient.wcs.WCSCoverage;
56 56
import org.gvsig.remoteclient.wcs.WCSStatus;
57 57
import org.gvsig.remoteclient.wcs.WCSCoverage.AxisDescription;
58
import org.gvsig.remoteclient.wcs.WCSCoverage.RectifiedGrid;
58 59

  
59 60
/**
60 61
 * Connector between a WCS data provider and a WCSClient. 
......
202 203

  
203 204
				// time positions
204 205
				lyr.setTimePositions(cov.getTimePositions());
205

  
206
				
207
				RectifiedGrid rf = cov.getRectifiedGrid();
208
				int w = rf.getHighGridEnvelopLimits()[0][0] - rf.getLowGridEnvelopLimits()[0][0];
209
				int h = rf.getHighGridEnvelopLimits()[0][1] - rf.getLowGridEnvelopLimits()[0][1]; 
210
				
211
				lyr.setWidth(w);
212
				lyr.setHeight(h);
213
				
206 214
				// max res
207 215
				lyr.setMaxRes(new Point2D.Double(cov.getResX(), cov.getResY()));
208 216

  
......
290 298
		}
291 299
		return null;
292 300
	}
301
	
302
	/**
303
	 * Gets the maximum width in pixels of this coverage
304
	 * @param coverageName
305
	 * @return
306
	 */
307
	public int getWidth(String coverageName) {
308
		if (coverages.containsKey(coverageName)) {
309
			return ((WCSLayerNode) coverages.get(coverageName)).getWidth();
310
		}
311
		return 0;
312
	}
293 313

  
314
	/**
315
	 * Gets the maximum height in pixels of this coverage
316
	 * @param coverageName
317
	 * @return
318
	 */
319
	public int getHeight(String coverageName) {
320
		if (coverages.containsKey(coverageName)) {
321
			return ((WCSLayerNode) coverages.get(coverageName)).getHeight();
322
		}
323
		return 0;
324
	}
294 325

  
295 326
	/**
296 327
	 * Returns an ArrayList containing a set of Strings with the coverage's SRSs.
org.gvsig.raster.wcs/trunk/org.gvsig.raster.wcs/org.gvsig.raster.wcs.io/src/main/java/org/gvsig/raster/wcs/io/WCSProvider.java
222 222
	 * @see org.gvsig.fmap.dal.coverage.dataset.RasterDataSet#getAffineTransform()
223 223
	 */
224 224
	public AffineTransform getAffineTransform() {
225
		WCSDataParametersImpl p = (WCSDataParametersImpl)parameters;
226
		Point2D resolution = null;
227
		try {
228
			resolution = getConnector().getMaxResolution(p.getCoverageName());
229
			Extent e = getExtent();
230
			ownTransformation = new AffineTransform(
231
					resolution.getX(), 
232
					0, 
233
					0, 
234
					-resolution.getY(), 
235
					e.getULX() - (resolution.getX() / 2),
236
					e.getULY() - (resolution.getY() / 2));
237
			externalTransformation = (AffineTransform) ownTransformation.clone();
238
			return ownTransformation;
239
		} catch (RemoteServiceException e1) {
240
			e1.printStackTrace();
241
		}
242
		return null;
225
		Extent e = getExtent();
226
		double resolutionX = e.width() / getWidth();
227
		double resolutionY = e.height() / getHeight();
228
		ownTransformation = new AffineTransform(
229
				resolutionX, 
230
				0, 
231
				0, 
232
				-resolutionY, 
233
				e.getULX() - (resolutionX / 2),
234
				e.getULY() - (resolutionY / 2));
235
		externalTransformation = (AffineTransform) ownTransformation.clone();
236
		return ownTransformation;
243 237
	}
244 238
	
245 239
	/**
......
332 326
	 */
333 327
	public double getWidth() {
334 328
		WCSDataParametersImpl p = (WCSDataParametersImpl)parameters;
335
		Point2D resolution = null;
336 329
		try {
337
			resolution = getConnector().getMaxResolution(p.getCoverageName());
338
			Extent e = getExtent();
339
			return e.width() / resolution.getX(); 
340
		} catch (RemoteServiceException e1) {
341
			e1.printStackTrace();
330
			return getConnector().getWidth(p.getCoverageName());
331
		} catch (RemoteServiceException e) {
332
			e.printStackTrace();
342 333
		}
343 334
		return 0;
344 335
	}
......
349 340
	 */
350 341
	public double getHeight() {
351 342
		WCSDataParametersImpl p = (WCSDataParametersImpl)parameters;
352
		Point2D resolution = null;
353 343
		try {
354
			resolution = getConnector().getMaxResolution(p.getCoverageName());
355
			Extent e = getExtent();
356
			return e.height() / resolution.getY(); 
357
		} catch (RemoteServiceException e1) {
358
			e1.printStackTrace();
344
			return getConnector().getHeight(p.getCoverageName());
345
		} catch (RemoteServiceException e) {
346
			e.printStackTrace();
359 347
		}
360 348
		return 0;
361 349
	}

Also available in: Unified diff