@Test public void testNormalSeveral() throws Exception { Envelope googleEnvelope = new Envelope(10000, 11000, 6005000, 6006000); Crs google = geoService.getCrs2(MERCATOR); Crs latlon = geoService.getCrs2(LONLAT); Envelope latlonEnvelope = geoService.transform(JTS.toGeometry(googleEnvelope), google, latlon) .getEnvelopeInternal(); double latlonScale = MAX_LEVEL_SCALE * googleEnvelope.getWidth() / latlonEnvelope.getWidth(); List<RasterTile> tiles = wms.paint(latlon, latlonEnvelope, latlonScale); Assert.assertEquals(2, tiles.size()); Assert.assertEquals("http: + "HEIGHT=512&bbox=0.0859375,47.3828125,0.09375,47.390625&format=image/jpeg&version=1.1.1&" + "srs=EPSG%3A4326&styles=&request=GetMap", tiles.get(0).getUrl()); Assert.assertEquals("http: + "HEIGHT=512&bbox=0.09375,47.3828125,0.1015625,47.390625&format=image/jpeg&version=1.1.1&" + "srs=EPSG%3A4326&styles=&request=GetMap", tiles.get(1).getUrl()); RasterTile tile = tiles.get(1); Assert.assertEquals(16, tile.getCode().getTileLevel()); Assert.assertEquals(23052, tile.getCode().getX()); Assert.assertEquals(58801, tile.getCode().getY()); Assert.assertEquals(4174.0, tile.getBounds().getX(), DELTA); Assert.assertEquals(-2110200.0, tile.getBounds().getY(), DELTA); Assert.assertEquals(348.0, tile.getBounds().getHeight(), DELTA); Assert.assertEquals(348.0, tile.getBounds().getWidth(), DELTA); }
public List<RasterTile> paint(CoordinateReferenceSystem targetCrs, Envelope bounds, double scale) throws GeomajasException { Envelope layerBounds = bounds; double layerScale = scale; CrsTransform layerToMap = null; boolean needTransform = !crs.equals(targetCrs); try { if (needTransform) { layerToMap = geoService.getCrsTransform(crs, targetCrs); CrsTransform mapToLayer = geoService.getCrsTransform(targetCrs, crs); layerBounds = geoService.transform(bounds, mapToLayer); layerScale = bounds.getWidth() * scale / layerBounds.getWidth(); } } catch (MismatchedDimensionException e) { throw new GeomajasException(e, ExceptionCode.RENDER_DIMENSION_MISMATCH); } layerBounds = clipBounds(layerBounds); if (layerBounds.isNull()) { return new ArrayList<RasterTile>(0); } Resolution bestResolution = getResolutionForScale(layerScale); RasterGrid grid = getRasterGrid(layerBounds, bestResolution.getTileWidth(), bestResolution.getTileHeight()); List<RasterTile> result = new ArrayList<RasterTile>(); for (int i = grid.getXmin(); i < grid.getXmax(); i++) { for (int j = grid.getYmin(); j < grid.getYmax(); j++) { double x = grid.getLowerLeft().x + (i - grid.getXmin()) * grid.getTileWidth(); double y = grid.getLowerLeft().y + (j - grid.getYmin()) * grid.getTileHeight(); Bbox worldBox; Bbox layerBox; if (needTransform) { layerBox = new Bbox(x, y, grid.getTileWidth(), grid.getTileHeight()); worldBox = geoService.transform(layerBox, layerToMap); } else { worldBox = new Bbox(x, y, grid.getTileWidth(), grid.getTileHeight()); layerBox = worldBox; } Bbox screenBox = new Bbox(Math.round(scale * worldBox.getX()), -Math.round(scale * worldBox.getMaxY()), Math.round(scale * worldBox.getMaxX()) - Math.round(scale * worldBox.getX()), Math.round(scale * worldBox.getMaxY()) - Math.round(scale * worldBox.getY())); RasterTile image = new RasterTile(screenBox, getId() + "." + bestResolution.getLevel() + "." + i + "," + j); image.setCode(new TileCode(bestResolution.getLevel(), i, j)); String url = formatUrl(bestResolution.getTileWidthPx(), bestResolution.getTileHeightPx(), layerBox); image.setUrl(url); result.add(image); } } return result; }
WmsLayer implements RasterLayer, LayerFeatureInfoSupport, ProxyLayerSupport { public List<RasterTile> paint(CoordinateReferenceSystem targetCrs, Envelope bounds, double scale) throws GeomajasException { Envelope layerBounds = bounds; double layerScale = scale; CrsTransform layerToMap = null; boolean needTransform = !crs.equals(targetCrs); try { if (needTransform) { layerToMap = geoService.getCrsTransform(crs, targetCrs); CrsTransform mapToLayer = geoService.getCrsTransform(targetCrs, crs); layerBounds = geoService.transform(bounds, mapToLayer); layerScale = bounds.getWidth() * scale / layerBounds.getWidth(); } } catch (MismatchedDimensionException e) { throw new GeomajasException(e, ExceptionCode.RENDER_DIMENSION_MISMATCH); } layerBounds = clipBounds(layerBounds); if (layerBounds.isNull()) { return new ArrayList<RasterTile>(0); } Resolution bestResolution = getResolutionForScale(layerScale); RasterGrid grid = getRasterGrid(layerBounds, bestResolution.getTileWidth(), bestResolution.getTileHeight()); List<RasterTile> result = new ArrayList<RasterTile>(); for (int i = grid.getXmin(); i < grid.getXmax(); i++) { for (int j = grid.getYmin(); j < grid.getYmax(); j++) { double x = grid.getLowerLeft().x + (i - grid.getXmin()) * grid.getTileWidth(); double y = grid.getLowerLeft().y + (j - grid.getYmin()) * grid.getTileHeight(); Bbox worldBox; Bbox layerBox; if (needTransform) { layerBox = new Bbox(x, y, grid.getTileWidth(), grid.getTileHeight()); worldBox = geoService.transform(layerBox, layerToMap); } else { worldBox = new Bbox(x, y, grid.getTileWidth(), grid.getTileHeight()); layerBox = worldBox; } Bbox screenBox = new Bbox(Math.round(scale * worldBox.getX()), -Math.round(scale * worldBox.getMaxY()), Math.round(scale * worldBox.getMaxX()) - Math.round(scale * worldBox.getX()), Math.round(scale * worldBox.getMaxY()) - Math.round(scale * worldBox.getY())); RasterTile image = new RasterTile(screenBox, getId() + "." + bestResolution.getLevel() + "." + i + "," + j); image.setCode(new TileCode(bestResolution.getLevel(), i, j)); String url = formatUrl(bestResolution.getTileWidthPx(), bestResolution.getTileHeightPx(), layerBox); image.setUrl(url); result.add(image); } } return result; } }
WmsLayer implements RasterLayer, LayerFeatureInfoSupport, ProxyLayerSupport { public List<RasterTile> paint(CoordinateReferenceSystem targetCrs, Envelope bounds, double scale) throws GeomajasException { Envelope layerBounds = bounds; double layerScale = scale; CrsTransform layerToMap = null; boolean needTransform = !crs.equals(targetCrs); try { if (needTransform) { layerToMap = geoService.getCrsTransform(crs, targetCrs); CrsTransform mapToLayer = geoService.getCrsTransform(targetCrs, crs); layerBounds = geoService.transform(bounds, mapToLayer); layerScale = bounds.getWidth() * scale / layerBounds.getWidth(); } } catch (MismatchedDimensionException e) { throw new GeomajasException(e, ExceptionCode.RENDER_DIMENSION_MISMATCH); } layerBounds = clipBounds(layerBounds); if (layerBounds.isNull()) { return new ArrayList<RasterTile>(0); } Resolution bestResolution = getResolutionForScale(layerScale); RasterGrid grid = getRasterGrid(layerBounds, bestResolution.getTileWidth(), bestResolution.getTileHeight()); List<RasterTile> result = new ArrayList<RasterTile>(); for (int i = grid.getXmin(); i < grid.getXmax(); i++) { for (int j = grid.getYmin(); j < grid.getYmax(); j++) { double x = grid.getLowerLeft().x + (i - grid.getXmin()) * grid.getTileWidth(); double y = grid.getLowerLeft().y + (j - grid.getYmin()) * grid.getTileHeight(); Bbox worldBox; Bbox layerBox; if (needTransform) { layerBox = new Bbox(x, y, grid.getTileWidth(), grid.getTileHeight()); worldBox = geoService.transform(layerBox, layerToMap); } else { worldBox = new Bbox(x, y, grid.getTileWidth(), grid.getTileHeight()); layerBox = worldBox; } Bbox screenBox = new Bbox(Math.round(scale * worldBox.getX()), -Math.round(scale * worldBox.getMaxY()), Math.round(scale * worldBox.getMaxX()) - Math.round(scale * worldBox.getX()), Math.round(scale * worldBox.getMaxY()) - Math.round(scale * worldBox.getY())); RasterTile image = new RasterTile(screenBox, getId() + "." + bestResolution.getLevel() + "." + i + "," + j); image.setCode(new TileCode(bestResolution.getLevel(), i, j)); String url = formatUrl(bestResolution.getTileWidthPx(), bestResolution.getTileHeightPx(), layerBox); image.setUrl(url); result.add(image); } } return result; }  }
WmsLayer implements RasterLayer, LayerFeatureInfoSupport, ProxyLayerSupport { public List<RasterTile> paint(CoordinateReferenceSystem targetCrs, Envelope bounds, double scale) throws GeomajasException { Envelope layerBounds = bounds; double layerScale = scale; CrsTransform layerToMap = null; boolean needTransform = !crs.equals(targetCrs); try { if (needTransform) { layerToMap = geoService.getCrsTransform(crs, targetCrs); CrsTransform mapToLayer = geoService.getCrsTransform(targetCrs, crs); layerBounds = geoService.transform(bounds, mapToLayer); layerScale = bounds.getWidth() * scale / layerBounds.getWidth(); } } catch (MismatchedDimensionException e) { throw new GeomajasException(e, ExceptionCode.RENDER_DIMENSION_MISMATCH); } layerBounds = clipBounds(layerBounds); if (layerBounds.isNull()) { return new ArrayList<RasterTile>(0); } Resolution bestResolution = getResolutionForScale(layerScale); RasterGrid grid = getRasterGrid(layerBounds, bestResolution.getTileWidth(), bestResolution.getTileHeight()); List<RasterTile> result = new ArrayList<RasterTile>(); for (int i = grid.getXmin(); i < grid.getXmax(); i++) { for (int j = grid.getYmin(); j < grid.getYmax(); j++) { double x = grid.getLowerLeft().x + (i - grid.getXmin()) * grid.getTileWidth(); double y = grid.getLowerLeft().y + (j - grid.getYmin()) * grid.getTileHeight(); Bbox worldBox; Bbox layerBox; if (needTransform) { layerBox = new Bbox(x, y, grid.getTileWidth(), grid.getTileHeight()); worldBox = geoService.transform(layerBox, layerToMap); } else { worldBox = new Bbox(x, y, grid.getTileWidth(), grid.getTileHeight()); layerBox = worldBox; } Bbox screenBox = new Bbox(Math.round(scale * worldBox.getX()), -Math.round(scale * worldBox.getMaxY()), Math.round(scale * worldBox.getMaxX()) - Math.round(scale * worldBox.getX()), Math.round(scale * worldBox.getMaxY()) - Math.round(scale * worldBox.getY())); RasterTile image = new RasterTile(screenBox, getId() + "." + bestResolution.getLevel() + "." + i + "," + j); image.setCode(new TileCode(bestResolution.getLevel(), i, j)); String url = formatUrl(bestResolution.getTileWidthPx(), bestResolution.getTileHeightPx(), layerBox); image.setUrl(url); result.add(image); } } return result; }  String getId(); void setId(String id); RasterLayerInfo getLayerInfo(); @Deprecated CoordinateReferenceSystem getCrs(); @Api WmsFeatureInfoFormat getFeatureInfoFormat(); @Api void setFeatureInfoFormat(WmsFeatureInfoFormat featureInfoFormat); @Api void setLayerInfo(RasterLayerInfo layerInfo); List<Feature> getFeaturesByLocation(Coordinate layerCoordinate, double layerScale, int pixelTolerance); List<RasterTile> paint(CoordinateReferenceSystem targetCrs, Envelope bounds, double scale); String getBaseWmsUrl(); @Api void setBaseWmsUrl(String baseWmsUrl); String getFormat(); @Api void setFormat(String format); @Api void setVersion(String version); @Api void setStyles(String styles); @Api void setParameters(List<Parameter> parameters); @Deprecated WmsAuthentication getAuthentication(); @Api @Deprecated void setAuthentication(WmsAuthentication authentication); ProxyAuthentication getProxyAuthentication(); @Api void setLayerAuthentication(LayerAuthentication layerAuthentication); @Api void setUseProxy(boolean useProxy); @Api void setUseCache(boolean useCache); @Api boolean isUseCache(); @Api void setEnableFeatureInfoSupport(boolean enableFeatureInfoSupport); boolean isEnableFeatureInfoSupport(); }
WmsLayer implements RasterLayer, LayerFeatureInfoSupport, ProxyLayerSupport { public List<RasterTile> paint(CoordinateReferenceSystem targetCrs, Envelope bounds, double scale) throws GeomajasException { Envelope layerBounds = bounds; double layerScale = scale; CrsTransform layerToMap = null; boolean needTransform = !crs.equals(targetCrs); try { if (needTransform) { layerToMap = geoService.getCrsTransform(crs, targetCrs); CrsTransform mapToLayer = geoService.getCrsTransform(targetCrs, crs); layerBounds = geoService.transform(bounds, mapToLayer); layerScale = bounds.getWidth() * scale / layerBounds.getWidth(); } } catch (MismatchedDimensionException e) { throw new GeomajasException(e, ExceptionCode.RENDER_DIMENSION_MISMATCH); } layerBounds = clipBounds(layerBounds); if (layerBounds.isNull()) { return new ArrayList<RasterTile>(0); } Resolution bestResolution = getResolutionForScale(layerScale); RasterGrid grid = getRasterGrid(layerBounds, bestResolution.getTileWidth(), bestResolution.getTileHeight()); List<RasterTile> result = new ArrayList<RasterTile>(); for (int i = grid.getXmin(); i < grid.getXmax(); i++) { for (int j = grid.getYmin(); j < grid.getYmax(); j++) { double x = grid.getLowerLeft().x + (i - grid.getXmin()) * grid.getTileWidth(); double y = grid.getLowerLeft().y + (j - grid.getYmin()) * grid.getTileHeight(); Bbox worldBox; Bbox layerBox; if (needTransform) { layerBox = new Bbox(x, y, grid.getTileWidth(), grid.getTileHeight()); worldBox = geoService.transform(layerBox, layerToMap); } else { worldBox = new Bbox(x, y, grid.getTileWidth(), grid.getTileHeight()); layerBox = worldBox; } Bbox screenBox = new Bbox(Math.round(scale * worldBox.getX()), -Math.round(scale * worldBox.getMaxY()), Math.round(scale * worldBox.getMaxX()) - Math.round(scale * worldBox.getX()), Math.round(scale * worldBox.getMaxY()) - Math.round(scale * worldBox.getY())); RasterTile image = new RasterTile(screenBox, getId() + "." + bestResolution.getLevel() + "." + i + "," + j); image.setCode(new TileCode(bestResolution.getLevel(), i, j)); String url = formatUrl(bestResolution.getTileWidthPx(), bestResolution.getTileHeightPx(), layerBox); image.setUrl(url); result.add(image); } } return result; }  String getId(); void setId(String id); RasterLayerInfo getLayerInfo(); @Deprecated CoordinateReferenceSystem getCrs(); @Api WmsFeatureInfoFormat getFeatureInfoFormat(); @Api void setFeatureInfoFormat(WmsFeatureInfoFormat featureInfoFormat); @Api void setLayerInfo(RasterLayerInfo layerInfo); List<Feature> getFeaturesByLocation(Coordinate layerCoordinate, double layerScale, int pixelTolerance); List<RasterTile> paint(CoordinateReferenceSystem targetCrs, Envelope bounds, double scale); String getBaseWmsUrl(); @Api void setBaseWmsUrl(String baseWmsUrl); String getFormat(); @Api void setFormat(String format); @Api void setVersion(String version); @Api void setStyles(String styles); @Api void setParameters(List<Parameter> parameters); @Deprecated WmsAuthentication getAuthentication(); @Api @Deprecated void setAuthentication(WmsAuthentication authentication); ProxyAuthentication getProxyAuthentication(); @Api void setLayerAuthentication(LayerAuthentication layerAuthentication); @Api void setUseProxy(boolean useProxy); @Api void setUseCache(boolean useCache); @Api boolean isUseCache(); @Api void setEnableFeatureInfoSupport(boolean enableFeatureInfoSupport); boolean isEnableFeatureInfoSupport();  }