@Test @Category(UnitTest.class) public void testMrsPyramidMetadataToTileMapXml() { final String raster = "CostDistanceHumveeV2"; final String response = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><TileMap tilemapservice=\"http: MrsPyramidMetadata mpm = new MrsPyramidMetadata(); mpm.setBounds(new Bounds(68, 33, 72, 35)); mpm.setMaxZoomLevel(10); mpm.setTilesize(MrGeoConstants.MRGEO_MRS_TILESIZE_DEFAULT_INT); try { Document doc = tms.mrsPyramidMetadataToTileMapXml(raster, "global-geodetic", "http: TransformerFactory tf = TransformerFactory.newInstance(); Transformer transformer = tf.newTransformer(); StringWriter writer = new StringWriter(); transformer.transform(new DOMSource(doc), new StreamResult(writer)); String output = writer.getBuffer().toString(); assertEquals(response, output); } catch (ParserConfigurationException | TransformerException ex) { log.error("Failed to convert metadata to TileMap xml", ex); } }
Document mrsPyramidMetadataToTileMapXml(final String raster, final String profilename, final String url, final MrsPyramidMetadata mpm) throws ParserConfigurationException { int index = -1; for (int i = 0; i < profiles.length; i++) { if (profilename.equals(profiles[i])) { index = i; break; } } if (index < 0) { throw new ParserConfigurationException("Bad profile name: " + profilename); } double maxPixelsize = TMSUtils.resolution(1, mpm.getTilesize()); Bounds bounds = mpm.getBounds(); WritablePoint origin = GeometryFactory.createPoint(Bounds.WORLD.w, Bounds.WORLD.s); if (index != WGS84) { String srs = SRSs[index]; bounds = RequestUtils.reprojectBounds(bounds, srs); Reprojector reprojector = Reprojector.createFromCode(SRSs[WGS84], srs); origin = GeometryFactory.createPoint(limits[index].w, limits[index].s); reprojector.filter(origin); WritablePoint pt = GeometryFactory.createPoint(maxPixelsize, 0); reprojector.filter(pt); maxPixelsize = pt.getX(); } final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); final DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); final Document doc = docBuilder.newDocument(); final Element rootElement = doc.createElement("TileMap"); doc.appendChild(rootElement); final Attr v = doc.createAttribute("version"); v.setValue(VERSION); rootElement.setAttributeNode(v); final Attr tilemapservice = doc.createAttribute("tilemapservice"); String root = url.substring(0, url.lastIndexOf("/" + raster)); tilemapservice.setValue(normalizeUrl(root)); rootElement.setAttributeNode(tilemapservice); final Element title = doc.createElement("Title"); title.setTextContent(raster); rootElement.appendChild(title); final Element abst = doc.createElement("Abstract"); abst.setTextContent(""); rootElement.appendChild(abst); final Element srs = doc.createElement("SRS"); srs.setTextContent(SRSs[index]); rootElement.appendChild(srs); final Element bbox = doc.createElement("BoundingBox"); rootElement.appendChild(bbox); final Attr minx = doc.createAttribute("minx"); minx.setValue(String.valueOf(bounds.w)); bbox.setAttributeNode(minx); final Attr miny = doc.createAttribute("miny"); miny.setValue(String.valueOf(bounds.s)); bbox.setAttributeNode(miny); final Attr maxx = doc.createAttribute("maxx"); maxx.setValue(String.valueOf(bounds.e)); bbox.setAttributeNode(maxx); final Attr maxy = doc.createAttribute("maxy"); maxy.setValue(String.valueOf(bounds.n)); bbox.setAttributeNode(maxy); final Element orign = doc.createElement("Origin"); rootElement.appendChild(orign); final Attr x = doc.createAttribute("x"); x.setValue(String.valueOf(origin.getX())); orign.setAttributeNode(x); final Attr y = doc.createAttribute("y"); y.setValue(String.valueOf(origin.getY())); orign.setAttributeNode(y); final Element tileformat = doc.createElement("TileFormat"); rootElement.appendChild(tileformat); final Attr w = doc.createAttribute("width"); w.setValue(String.valueOf(mpm.getTilesize())); tileformat.setAttributeNode(w); final Attr h = doc.createAttribute("height"); h.setValue(String.valueOf(mpm.getTilesize())); tileformat.setAttributeNode(h); final Attr mt = doc.createAttribute("mime-type"); mt.setValue("image/tiff"); tileformat.setAttributeNode(mt); final Attr ext = doc.createAttribute("extension"); ext.setValue("tif"); tileformat.setAttributeNode(ext); final Element tilesets = doc.createElement("TileSets"); rootElement.appendChild(tilesets); final Attr profile = doc.createAttribute("profile"); profile.setValue(profiles[index]); tilesets.setAttributeNode(profile); for (int i = 0; i < mpm.getMaxZoomLevel(); i++) { final Element tileset = doc.createElement("TileSet"); tilesets.appendChild(tileset); final Attr href = doc.createAttribute("href"); href.setValue(normalizeUrl(normalizeUrl(url)) + "/" + (i + 1)); tileset.setAttributeNode(href); final Attr upp = doc.createAttribute("units-per-pixel"); upp.setValue(String.valueOf(maxPixelsize / Math.pow(2, i))); tileset.setAttributeNode(upp); final Attr order = doc.createAttribute("order"); order.setValue(String.valueOf(i)); tileset.setAttributeNode(order); } return doc; }
TileMapServiceResource { Document mrsPyramidMetadataToTileMapXml(final String raster, final String profilename, final String url, final MrsPyramidMetadata mpm) throws ParserConfigurationException { int index = -1; for (int i = 0; i < profiles.length; i++) { if (profilename.equals(profiles[i])) { index = i; break; } } if (index < 0) { throw new ParserConfigurationException("Bad profile name: " + profilename); } double maxPixelsize = TMSUtils.resolution(1, mpm.getTilesize()); Bounds bounds = mpm.getBounds(); WritablePoint origin = GeometryFactory.createPoint(Bounds.WORLD.w, Bounds.WORLD.s); if (index != WGS84) { String srs = SRSs[index]; bounds = RequestUtils.reprojectBounds(bounds, srs); Reprojector reprojector = Reprojector.createFromCode(SRSs[WGS84], srs); origin = GeometryFactory.createPoint(limits[index].w, limits[index].s); reprojector.filter(origin); WritablePoint pt = GeometryFactory.createPoint(maxPixelsize, 0); reprojector.filter(pt); maxPixelsize = pt.getX(); } final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); final DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); final Document doc = docBuilder.newDocument(); final Element rootElement = doc.createElement("TileMap"); doc.appendChild(rootElement); final Attr v = doc.createAttribute("version"); v.setValue(VERSION); rootElement.setAttributeNode(v); final Attr tilemapservice = doc.createAttribute("tilemapservice"); String root = url.substring(0, url.lastIndexOf("/" + raster)); tilemapservice.setValue(normalizeUrl(root)); rootElement.setAttributeNode(tilemapservice); final Element title = doc.createElement("Title"); title.setTextContent(raster); rootElement.appendChild(title); final Element abst = doc.createElement("Abstract"); abst.setTextContent(""); rootElement.appendChild(abst); final Element srs = doc.createElement("SRS"); srs.setTextContent(SRSs[index]); rootElement.appendChild(srs); final Element bbox = doc.createElement("BoundingBox"); rootElement.appendChild(bbox); final Attr minx = doc.createAttribute("minx"); minx.setValue(String.valueOf(bounds.w)); bbox.setAttributeNode(minx); final Attr miny = doc.createAttribute("miny"); miny.setValue(String.valueOf(bounds.s)); bbox.setAttributeNode(miny); final Attr maxx = doc.createAttribute("maxx"); maxx.setValue(String.valueOf(bounds.e)); bbox.setAttributeNode(maxx); final Attr maxy = doc.createAttribute("maxy"); maxy.setValue(String.valueOf(bounds.n)); bbox.setAttributeNode(maxy); final Element orign = doc.createElement("Origin"); rootElement.appendChild(orign); final Attr x = doc.createAttribute("x"); x.setValue(String.valueOf(origin.getX())); orign.setAttributeNode(x); final Attr y = doc.createAttribute("y"); y.setValue(String.valueOf(origin.getY())); orign.setAttributeNode(y); final Element tileformat = doc.createElement("TileFormat"); rootElement.appendChild(tileformat); final Attr w = doc.createAttribute("width"); w.setValue(String.valueOf(mpm.getTilesize())); tileformat.setAttributeNode(w); final Attr h = doc.createAttribute("height"); h.setValue(String.valueOf(mpm.getTilesize())); tileformat.setAttributeNode(h); final Attr mt = doc.createAttribute("mime-type"); mt.setValue("image/tiff"); tileformat.setAttributeNode(mt); final Attr ext = doc.createAttribute("extension"); ext.setValue("tif"); tileformat.setAttributeNode(ext); final Element tilesets = doc.createElement("TileSets"); rootElement.appendChild(tilesets); final Attr profile = doc.createAttribute("profile"); profile.setValue(profiles[index]); tilesets.setAttributeNode(profile); for (int i = 0; i < mpm.getMaxZoomLevel(); i++) { final Element tileset = doc.createElement("TileSet"); tilesets.appendChild(tileset); final Attr href = doc.createAttribute("href"); href.setValue(normalizeUrl(normalizeUrl(url)) + "/" + (i + 1)); tileset.setAttributeNode(href); final Attr upp = doc.createAttribute("units-per-pixel"); upp.setValue(String.valueOf(maxPixelsize / Math.pow(2, i))); tileset.setAttributeNode(upp); final Attr order = doc.createAttribute("order"); order.setValue(String.valueOf(i)); tileset.setAttributeNode(order); } return doc; } }
TileMapServiceResource { Document mrsPyramidMetadataToTileMapXml(final String raster, final String profilename, final String url, final MrsPyramidMetadata mpm) throws ParserConfigurationException { int index = -1; for (int i = 0; i < profiles.length; i++) { if (profilename.equals(profiles[i])) { index = i; break; } } if (index < 0) { throw new ParserConfigurationException("Bad profile name: " + profilename); } double maxPixelsize = TMSUtils.resolution(1, mpm.getTilesize()); Bounds bounds = mpm.getBounds(); WritablePoint origin = GeometryFactory.createPoint(Bounds.WORLD.w, Bounds.WORLD.s); if (index != WGS84) { String srs = SRSs[index]; bounds = RequestUtils.reprojectBounds(bounds, srs); Reprojector reprojector = Reprojector.createFromCode(SRSs[WGS84], srs); origin = GeometryFactory.createPoint(limits[index].w, limits[index].s); reprojector.filter(origin); WritablePoint pt = GeometryFactory.createPoint(maxPixelsize, 0); reprojector.filter(pt); maxPixelsize = pt.getX(); } final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); final DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); final Document doc = docBuilder.newDocument(); final Element rootElement = doc.createElement("TileMap"); doc.appendChild(rootElement); final Attr v = doc.createAttribute("version"); v.setValue(VERSION); rootElement.setAttributeNode(v); final Attr tilemapservice = doc.createAttribute("tilemapservice"); String root = url.substring(0, url.lastIndexOf("/" + raster)); tilemapservice.setValue(normalizeUrl(root)); rootElement.setAttributeNode(tilemapservice); final Element title = doc.createElement("Title"); title.setTextContent(raster); rootElement.appendChild(title); final Element abst = doc.createElement("Abstract"); abst.setTextContent(""); rootElement.appendChild(abst); final Element srs = doc.createElement("SRS"); srs.setTextContent(SRSs[index]); rootElement.appendChild(srs); final Element bbox = doc.createElement("BoundingBox"); rootElement.appendChild(bbox); final Attr minx = doc.createAttribute("minx"); minx.setValue(String.valueOf(bounds.w)); bbox.setAttributeNode(minx); final Attr miny = doc.createAttribute("miny"); miny.setValue(String.valueOf(bounds.s)); bbox.setAttributeNode(miny); final Attr maxx = doc.createAttribute("maxx"); maxx.setValue(String.valueOf(bounds.e)); bbox.setAttributeNode(maxx); final Attr maxy = doc.createAttribute("maxy"); maxy.setValue(String.valueOf(bounds.n)); bbox.setAttributeNode(maxy); final Element orign = doc.createElement("Origin"); rootElement.appendChild(orign); final Attr x = doc.createAttribute("x"); x.setValue(String.valueOf(origin.getX())); orign.setAttributeNode(x); final Attr y = doc.createAttribute("y"); y.setValue(String.valueOf(origin.getY())); orign.setAttributeNode(y); final Element tileformat = doc.createElement("TileFormat"); rootElement.appendChild(tileformat); final Attr w = doc.createAttribute("width"); w.setValue(String.valueOf(mpm.getTilesize())); tileformat.setAttributeNode(w); final Attr h = doc.createAttribute("height"); h.setValue(String.valueOf(mpm.getTilesize())); tileformat.setAttributeNode(h); final Attr mt = doc.createAttribute("mime-type"); mt.setValue("image/tiff"); tileformat.setAttributeNode(mt); final Attr ext = doc.createAttribute("extension"); ext.setValue("tif"); tileformat.setAttributeNode(ext); final Element tilesets = doc.createElement("TileSets"); rootElement.appendChild(tilesets); final Attr profile = doc.createAttribute("profile"); profile.setValue(profiles[index]); tilesets.setAttributeNode(profile); for (int i = 0; i < mpm.getMaxZoomLevel(); i++) { final Element tileset = doc.createElement("TileSet"); tilesets.appendChild(tileset); final Attr href = doc.createAttribute("href"); href.setValue(normalizeUrl(normalizeUrl(url)) + "/" + (i + 1)); tileset.setAttributeNode(href); final Attr upp = doc.createAttribute("units-per-pixel"); upp.setValue(String.valueOf(maxPixelsize / Math.pow(2, i))); tileset.setAttributeNode(upp); final Attr order = doc.createAttribute("order"); order.setValue(String.valueOf(i)); tileset.setAttributeNode(order); } return doc; }  }
TileMapServiceResource { Document mrsPyramidMetadataToTileMapXml(final String raster, final String profilename, final String url, final MrsPyramidMetadata mpm) throws ParserConfigurationException { int index = -1; for (int i = 0; i < profiles.length; i++) { if (profilename.equals(profiles[i])) { index = i; break; } } if (index < 0) { throw new ParserConfigurationException("Bad profile name: " + profilename); } double maxPixelsize = TMSUtils.resolution(1, mpm.getTilesize()); Bounds bounds = mpm.getBounds(); WritablePoint origin = GeometryFactory.createPoint(Bounds.WORLD.w, Bounds.WORLD.s); if (index != WGS84) { String srs = SRSs[index]; bounds = RequestUtils.reprojectBounds(bounds, srs); Reprojector reprojector = Reprojector.createFromCode(SRSs[WGS84], srs); origin = GeometryFactory.createPoint(limits[index].w, limits[index].s); reprojector.filter(origin); WritablePoint pt = GeometryFactory.createPoint(maxPixelsize, 0); reprojector.filter(pt); maxPixelsize = pt.getX(); } final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); final DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); final Document doc = docBuilder.newDocument(); final Element rootElement = doc.createElement("TileMap"); doc.appendChild(rootElement); final Attr v = doc.createAttribute("version"); v.setValue(VERSION); rootElement.setAttributeNode(v); final Attr tilemapservice = doc.createAttribute("tilemapservice"); String root = url.substring(0, url.lastIndexOf("/" + raster)); tilemapservice.setValue(normalizeUrl(root)); rootElement.setAttributeNode(tilemapservice); final Element title = doc.createElement("Title"); title.setTextContent(raster); rootElement.appendChild(title); final Element abst = doc.createElement("Abstract"); abst.setTextContent(""); rootElement.appendChild(abst); final Element srs = doc.createElement("SRS"); srs.setTextContent(SRSs[index]); rootElement.appendChild(srs); final Element bbox = doc.createElement("BoundingBox"); rootElement.appendChild(bbox); final Attr minx = doc.createAttribute("minx"); minx.setValue(String.valueOf(bounds.w)); bbox.setAttributeNode(minx); final Attr miny = doc.createAttribute("miny"); miny.setValue(String.valueOf(bounds.s)); bbox.setAttributeNode(miny); final Attr maxx = doc.createAttribute("maxx"); maxx.setValue(String.valueOf(bounds.e)); bbox.setAttributeNode(maxx); final Attr maxy = doc.createAttribute("maxy"); maxy.setValue(String.valueOf(bounds.n)); bbox.setAttributeNode(maxy); final Element orign = doc.createElement("Origin"); rootElement.appendChild(orign); final Attr x = doc.createAttribute("x"); x.setValue(String.valueOf(origin.getX())); orign.setAttributeNode(x); final Attr y = doc.createAttribute("y"); y.setValue(String.valueOf(origin.getY())); orign.setAttributeNode(y); final Element tileformat = doc.createElement("TileFormat"); rootElement.appendChild(tileformat); final Attr w = doc.createAttribute("width"); w.setValue(String.valueOf(mpm.getTilesize())); tileformat.setAttributeNode(w); final Attr h = doc.createAttribute("height"); h.setValue(String.valueOf(mpm.getTilesize())); tileformat.setAttributeNode(h); final Attr mt = doc.createAttribute("mime-type"); mt.setValue("image/tiff"); tileformat.setAttributeNode(mt); final Attr ext = doc.createAttribute("extension"); ext.setValue("tif"); tileformat.setAttributeNode(ext); final Element tilesets = doc.createElement("TileSets"); rootElement.appendChild(tilesets); final Attr profile = doc.createAttribute("profile"); profile.setValue(profiles[index]); tilesets.setAttributeNode(profile); for (int i = 0; i < mpm.getMaxZoomLevel(); i++) { final Element tileset = doc.createElement("TileSet"); tilesets.appendChild(tileset); final Attr href = doc.createAttribute("href"); href.setValue(normalizeUrl(normalizeUrl(url)) + "/" + (i + 1)); tileset.setAttributeNode(href); final Attr upp = doc.createAttribute("units-per-pixel"); upp.setValue(String.valueOf(maxPixelsize / Math.pow(2, i))); tileset.setAttributeNode(upp); final Attr order = doc.createAttribute("order"); order.setValue(String.valueOf(i)); tileset.setAttributeNode(order); } return doc; }  @GET @Produces("text/xml") Response getRootResource(@Context final HttpServletRequest hsr); @SuppressWarnings("squid:S1166") // TileNotFoundException (only) caught and handled @SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces("image/*") @Path("mapproxy/{version}/{raster}/{profile}/{z}/{x}/{y}.{format}") /** * Mapproxy starts at zoom level 0 for some reason rather 1. The mapproxy code * does not seem to use the capabilities docs returned by a TMS server. They * compute zoom, resolution and tiles based on the grid configured in mapproxy * for the source. It appears they incorrectly compute the resolution based on * a single tile at the world level, but strangely, they make TMS requests using * two tiles at the world level. */ Response getTileForMapproxy(@PathParam("version") final String version,
                        @PathParam("raster") String pyramid,
                        @PathParam("profile") String profile,
                        @PathParam("z") final Integer z,
                        @PathParam("x") final Integer x,
                        @PathParam("y") final Integer y,
                        @PathParam("format") final String format,
                        @QueryParam("color-scale-name") final String colorScaleName,
                        @QueryParam("color-scale") final String colorScale,
                        @QueryParam("min") final Double min,
                        @QueryParam("max") final Double max,
                        @DefaultValue("1") @QueryParam("maskMax") final Double maskMax,
                        @QueryParam("mask") final String mask); @SuppressWarnings("squid:S1166") // TileNotFoundException (only) caught and handled @SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces("image/*") @Path("{version}/{raster}/{profile}/{z}/{x}/{y}.{format}") Response getTile(@PathParam("version") final String version,
    @PathParam("raster") String pyramid,
    @PathParam("profile") String profile,
    @PathParam("z") final Integer z,
    @PathParam("x") final Integer x,
    @PathParam("y") final Integer y,
    @PathParam("format") final String format,
    @QueryParam("color-scale-name") final String colorScaleName,
    @QueryParam("color-scale") final String colorScale,
    @QueryParam("min") final Double min,
    @QueryParam("max") final Double max,
    @DefaultValue("1") @QueryParam("maskMax") final Double maskMax,
    @QueryParam("mask") final String mask); @SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces("text/xml") @Path("/{version}/{raster}/{profile}") Response getTileMap(@PathParam("version") final String version,
    @PathParam("raster") String raster, @PathParam("profile") String profile, @Context final HttpServletRequest hsr); @SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces("text/xml") @Path("/{version}") Response getTileMapService(@PathParam("version") final String version,
    @Context final HttpServletRequest hsr); }
TileMapServiceResource { Document mrsPyramidMetadataToTileMapXml(final String raster, final String profilename, final String url, final MrsPyramidMetadata mpm) throws ParserConfigurationException { int index = -1; for (int i = 0; i < profiles.length; i++) { if (profilename.equals(profiles[i])) { index = i; break; } } if (index < 0) { throw new ParserConfigurationException("Bad profile name: " + profilename); } double maxPixelsize = TMSUtils.resolution(1, mpm.getTilesize()); Bounds bounds = mpm.getBounds(); WritablePoint origin = GeometryFactory.createPoint(Bounds.WORLD.w, Bounds.WORLD.s); if (index != WGS84) { String srs = SRSs[index]; bounds = RequestUtils.reprojectBounds(bounds, srs); Reprojector reprojector = Reprojector.createFromCode(SRSs[WGS84], srs); origin = GeometryFactory.createPoint(limits[index].w, limits[index].s); reprojector.filter(origin); WritablePoint pt = GeometryFactory.createPoint(maxPixelsize, 0); reprojector.filter(pt); maxPixelsize = pt.getX(); } final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); final DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); final Document doc = docBuilder.newDocument(); final Element rootElement = doc.createElement("TileMap"); doc.appendChild(rootElement); final Attr v = doc.createAttribute("version"); v.setValue(VERSION); rootElement.setAttributeNode(v); final Attr tilemapservice = doc.createAttribute("tilemapservice"); String root = url.substring(0, url.lastIndexOf("/" + raster)); tilemapservice.setValue(normalizeUrl(root)); rootElement.setAttributeNode(tilemapservice); final Element title = doc.createElement("Title"); title.setTextContent(raster); rootElement.appendChild(title); final Element abst = doc.createElement("Abstract"); abst.setTextContent(""); rootElement.appendChild(abst); final Element srs = doc.createElement("SRS"); srs.setTextContent(SRSs[index]); rootElement.appendChild(srs); final Element bbox = doc.createElement("BoundingBox"); rootElement.appendChild(bbox); final Attr minx = doc.createAttribute("minx"); minx.setValue(String.valueOf(bounds.w)); bbox.setAttributeNode(minx); final Attr miny = doc.createAttribute("miny"); miny.setValue(String.valueOf(bounds.s)); bbox.setAttributeNode(miny); final Attr maxx = doc.createAttribute("maxx"); maxx.setValue(String.valueOf(bounds.e)); bbox.setAttributeNode(maxx); final Attr maxy = doc.createAttribute("maxy"); maxy.setValue(String.valueOf(bounds.n)); bbox.setAttributeNode(maxy); final Element orign = doc.createElement("Origin"); rootElement.appendChild(orign); final Attr x = doc.createAttribute("x"); x.setValue(String.valueOf(origin.getX())); orign.setAttributeNode(x); final Attr y = doc.createAttribute("y"); y.setValue(String.valueOf(origin.getY())); orign.setAttributeNode(y); final Element tileformat = doc.createElement("TileFormat"); rootElement.appendChild(tileformat); final Attr w = doc.createAttribute("width"); w.setValue(String.valueOf(mpm.getTilesize())); tileformat.setAttributeNode(w); final Attr h = doc.createAttribute("height"); h.setValue(String.valueOf(mpm.getTilesize())); tileformat.setAttributeNode(h); final Attr mt = doc.createAttribute("mime-type"); mt.setValue("image/tiff"); tileformat.setAttributeNode(mt); final Attr ext = doc.createAttribute("extension"); ext.setValue("tif"); tileformat.setAttributeNode(ext); final Element tilesets = doc.createElement("TileSets"); rootElement.appendChild(tilesets); final Attr profile = doc.createAttribute("profile"); profile.setValue(profiles[index]); tilesets.setAttributeNode(profile); for (int i = 0; i < mpm.getMaxZoomLevel(); i++) { final Element tileset = doc.createElement("TileSet"); tilesets.appendChild(tileset); final Attr href = doc.createAttribute("href"); href.setValue(normalizeUrl(normalizeUrl(url)) + "/" + (i + 1)); tileset.setAttributeNode(href); final Attr upp = doc.createAttribute("units-per-pixel"); upp.setValue(String.valueOf(maxPixelsize / Math.pow(2, i))); tileset.setAttributeNode(upp); final Attr order = doc.createAttribute("order"); order.setValue(String.valueOf(i)); tileset.setAttributeNode(order); } return doc; }  @GET @Produces("text/xml") Response getRootResource(@Context final HttpServletRequest hsr); @SuppressWarnings("squid:S1166") // TileNotFoundException (only) caught and handled @SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces("image/*") @Path("mapproxy/{version}/{raster}/{profile}/{z}/{x}/{y}.{format}") /** * Mapproxy starts at zoom level 0 for some reason rather 1. The mapproxy code * does not seem to use the capabilities docs returned by a TMS server. They * compute zoom, resolution and tiles based on the grid configured in mapproxy * for the source. It appears they incorrectly compute the resolution based on * a single tile at the world level, but strangely, they make TMS requests using * two tiles at the world level. */ Response getTileForMapproxy(@PathParam("version") final String version,
                        @PathParam("raster") String pyramid,
                        @PathParam("profile") String profile,
                        @PathParam("z") final Integer z,
                        @PathParam("x") final Integer x,
                        @PathParam("y") final Integer y,
                        @PathParam("format") final String format,
                        @QueryParam("color-scale-name") final String colorScaleName,
                        @QueryParam("color-scale") final String colorScale,
                        @QueryParam("min") final Double min,
                        @QueryParam("max") final Double max,
                        @DefaultValue("1") @QueryParam("maskMax") final Double maskMax,
                        @QueryParam("mask") final String mask); @SuppressWarnings("squid:S1166") // TileNotFoundException (only) caught and handled @SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces("image/*") @Path("{version}/{raster}/{profile}/{z}/{x}/{y}.{format}") Response getTile(@PathParam("version") final String version,
    @PathParam("raster") String pyramid,
    @PathParam("profile") String profile,
    @PathParam("z") final Integer z,
    @PathParam("x") final Integer x,
    @PathParam("y") final Integer y,
    @PathParam("format") final String format,
    @QueryParam("color-scale-name") final String colorScaleName,
    @QueryParam("color-scale") final String colorScale,
    @QueryParam("min") final Double min,
    @QueryParam("max") final Double max,
    @DefaultValue("1") @QueryParam("maskMax") final Double maskMax,
    @QueryParam("mask") final String mask); @SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces("text/xml") @Path("/{version}/{raster}/{profile}") Response getTileMap(@PathParam("version") final String version,
    @PathParam("raster") String raster, @PathParam("profile") String profile, @Context final HttpServletRequest hsr); @SuppressFBWarnings(value = "JAXRS_ENDPOINT", justification = "verified") @GET @Produces("text/xml") @Path("/{version}") Response getTileMapService(@PathParam("version") final String version,
    @Context final HttpServletRequest hsr);  }