Revision 2613 org.gvsig.raster.wmts/trunk/org.gvsig.raster.wmts/org.gvsig.raster.wmts.io/src/main/java/org/gvsig/raster/wmts/io/WMTSProvider.java

View differences:

WMTSProvider.java
96 96
import org.gvsig.raster.wmts.ogc.exception.DownloadException;
97 97
import org.gvsig.raster.wmts.ogc.exception.ServerErrorException;
98 98
import org.gvsig.raster.wmts.ogc.exception.WMTSException;
99
import org.gvsig.raster.wmts.ogc.struct.WMTSBoundingBox;
100 99
import org.gvsig.raster.wmts.ogc.struct.WMTSLayer;
101 100
import org.gvsig.raster.wmts.ogc.struct.WMTSTile;
102 101
import org.gvsig.raster.wmts.ogc.struct.WMTSTileMatrix;
......
432 431
	}
433 432
	
434 433
	/**
435
	 * Gets the bounding box in world coordinates. If the layer has grid subsets (TileMatrixLimits) then
434
	 * <p>
435
	 * Gets the bounding box in world coordinates. 
436
	 * If the layer has defined the BoundingBox tag, we will take this bounding box as entire 
437
	 * extension of this layer, else we'll see if the tag WGS84BoundingBox is defined (it can be approximated).
438
	 * In this case we'll take WGS84BoundingBox as entire extension.
439
	 * </p>
440
	 * <br>
441
	 * Note: 
442
	 * <br>
443
	 * <p>
444
	 * If the layer has grid subsets (TileMatrixLimits) then
436 445
	 * this will have a only extent but if the layer doesn't have grid subsets then this will have a different
437 446
	 * extent in each level resolution. In this case we need to know the extent for each level.
447
	 * </p>
438 448
	 * @return Extent
439 449
	 */
440 450
	public Extent getExtent() {
441 451
		WMTSDataParameters p = (WMTSDataParameters)parameters;
442
		if(gridSubsets) {
443
			WMTSLayer layer = p.getLayer();
452
		WMTSLayer layer = p.getLayer();
453

  
454
		if(layer.getBBox() != null)
455
			return new ExtentImpl(layer.getBBox().toRectangle2D());
456
		
457
		if(layer.getWGS84BBox() != null) {
458
			String crsCode = p.getSRSCode();
459
			Rectangle2D r = layer.getWGS84BBoxTransformed(crsCode);
460
			if(r != null)
461
				return new ExtentImpl(r);
462
		}
463
			
464
		if(bbox == null)
465
			getExtentByResolutionLevel();
466
		return bbox;
467
		
468
		/*if(gridSubsets) {
444 469
			WMTSBoundingBox bbox = layer.getWGS84BBox();
445 470
			return new ExtentImpl(bbox.toRectangle2D());
446 471
		} else {
447
			/*WMTSTileMatrixSet tileMatrixSet = getTileMatrixSetLink().getTileMatrixSet();
448
			
449
			//Si ya se han calculado los niveles es q el extent es v?lido sino el nivel ser? el 0
450
			double scale = 0D;
451
			int level = 0;
452
			if(extentByLevel != null && p.getExtent() != null) {
453
				scale = getScale(p.getExtent(), p.getWidth());
454
				try {
455
					level = getLevelFromScale(scale, tileMatrixSet);
456
				} catch (RasterDriverException e) {
457
					e.printStackTrace();
458
				}				
459
			}
460
			
461
			Extent[] ext = getExtentByResolutionLevel();
462
			
463
			if(ext != null && level >= 0 && level < ext.length)
464
				return ext[level];*/
465 472
			if(bbox == null)
466 473
				getExtentByResolutionLevel();
467 474
			return bbox;
468
		}
475
		}*/
469 476
	}
470 477
	
471 478
	/**
......
524 531
				WMTSTileMatrix tileMatrix = (WMTSTileMatrix)tileMatrixList.get(i);
525 532
		    	if(!p.isProjected()) {
526 533
		    		widthMtsTile = (tileMatrix.getScaleDenominator() * tileMatrix.getTileWidth() * 0.28) / (MTS_X_GRADO * 1000);
527
		    		heightMtsTile = (tileMatrix.getScaleDenominator() * tileMatrix.getTileWidth() * 0.28) / (MTS_X_GRADO * 1000);
534
		    		heightMtsTile = (tileMatrix.getScaleDenominator() * tileMatrix.getTileHeight() * 0.28) / (MTS_X_GRADO * 1000);
528 535
		    	} else {
529 536
		    		widthMtsTile = (tileMatrix.getScaleDenominator() * tileMatrix.getTileWidth() * 0.28) / 1000;
530
		    		heightMtsTile = (tileMatrix.getScaleDenominator() * tileMatrix.getTileWidth() * 0.28) / 1000;
537
		    		heightMtsTile = (tileMatrix.getScaleDenominator() * tileMatrix.getTileHeight() * 0.28) / 1000;
531 538
		    	}
532 539
		    	
533
		    	double h = Math.abs(tileMatrix.getTopLeftCorner()[0] - (tileMatrix.getTopLeftCorner()[0] - (tileMatrix.getMatrixHeight() * heightMtsTile)));
540
		    	//TODO: Revisar!!! Creo que el top left sale al rev?s en el de la nasa
541
		    	
542
		    	double h = Math.abs(tileMatrix.getTopLeftCorner()[1] - (tileMatrix.getTopLeftCorner()[1] - (tileMatrix.getMatrixHeight() * heightMtsTile)));
534 543
		    	Rectangle2D r = new Rectangle2D.Double(
535
		    			tileMatrix.getTopLeftCorner()[1], 
536
		    			tileMatrix.getTopLeftCorner()[0] - h,
537
		    			Math.abs(tileMatrix.getTopLeftCorner()[1] - (tileMatrix.getTopLeftCorner()[1] + (tileMatrix.getMatrixWidth() * widthMtsTile))),
544
		    			tileMatrix.getTopLeftCorner()[0], 
545
		    			tileMatrix.getTopLeftCorner()[1] - h,
546
		    			Math.abs(tileMatrix.getTopLeftCorner()[0] - (tileMatrix.getTopLeftCorner()[0] + (tileMatrix.getMatrixWidth() * widthMtsTile))),
538 547
		    			h);
539 548
		    	extentByLevel[i] = new ExtentImpl(r);
540 549
		    	if(i == 0) {
......
981 990
		status.setTileMatrixSet(tileMatrixSet.getIdentifier());
982 991
		status.setTileMatrix(tileMatrix.getIdentifier());
983 992
		status.setLevel(level - dif);
993
		status.setDimension(p.getDimension());
994
		status.setValueForDimension(p.getDimensionSelectedValue());
984 995
		
985
		wmtsLayer.buildResourceURLListFromTemplate(status, null);
996
		wmtsLayer.buildResourceURLListFromTemplate(status);
986 997
		this.lastStatus = status;
987 998
		
988 999
		return status;

Also available in: Unified diff