@Test @Category(UnitTest.class) public void testRootResourceXml() { final String response = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?><Services><TileMapService href=\"http: try { Document doc = tms.rootResourceXml("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 generate root resource xml", ex); } }
Document rootResourceXml(final String url) throws ParserConfigurationException { final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); final DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); final Document doc = docBuilder.newDocument(); final Element rootElement = doc.createElement("Services"); doc.appendChild(rootElement); final Element tms = doc.createElement("TileMapService"); rootElement.appendChild(tms); final Attr title = doc.createAttribute("title"); title.setValue("MrGeo Tile Map Service"); tms.setAttributeNode(title); final Attr v = doc.createAttribute("version"); v.setValue(VERSION); tms.setAttributeNode(v); final Attr href = doc.createAttribute("href"); href.setValue(normalizeUrl(url) + "/" + VERSION); tms.setAttributeNode(href); return doc; }
TileMapServiceResource { Document rootResourceXml(final String url) throws ParserConfigurationException { final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); final DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); final Document doc = docBuilder.newDocument(); final Element rootElement = doc.createElement("Services"); doc.appendChild(rootElement); final Element tms = doc.createElement("TileMapService"); rootElement.appendChild(tms); final Attr title = doc.createAttribute("title"); title.setValue("MrGeo Tile Map Service"); tms.setAttributeNode(title); final Attr v = doc.createAttribute("version"); v.setValue(VERSION); tms.setAttributeNode(v); final Attr href = doc.createAttribute("href"); href.setValue(normalizeUrl(url) + "/" + VERSION); tms.setAttributeNode(href); return doc; } }
TileMapServiceResource { Document rootResourceXml(final String url) throws ParserConfigurationException { final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); final DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); final Document doc = docBuilder.newDocument(); final Element rootElement = doc.createElement("Services"); doc.appendChild(rootElement); final Element tms = doc.createElement("TileMapService"); rootElement.appendChild(tms); final Attr title = doc.createAttribute("title"); title.setValue("MrGeo Tile Map Service"); tms.setAttributeNode(title); final Attr v = doc.createAttribute("version"); v.setValue(VERSION); tms.setAttributeNode(v); final Attr href = doc.createAttribute("href"); href.setValue(normalizeUrl(url) + "/" + VERSION); tms.setAttributeNode(href); return doc; }  }
TileMapServiceResource { Document rootResourceXml(final String url) throws ParserConfigurationException { final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); final DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); final Document doc = docBuilder.newDocument(); final Element rootElement = doc.createElement("Services"); doc.appendChild(rootElement); final Element tms = doc.createElement("TileMapService"); rootElement.appendChild(tms); final Attr title = doc.createAttribute("title"); title.setValue("MrGeo Tile Map Service"); tms.setAttributeNode(title); final Attr v = doc.createAttribute("version"); v.setValue(VERSION); tms.setAttributeNode(v); final Attr href = doc.createAttribute("href"); href.setValue(normalizeUrl(url) + "/" + VERSION); tms.setAttributeNode(href); 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 rootResourceXml(final String url) throws ParserConfigurationException { final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); final DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); final Document doc = docBuilder.newDocument(); final Element rootElement = doc.createElement("Services"); doc.appendChild(rootElement); final Element tms = doc.createElement("TileMapService"); rootElement.appendChild(tms); final Attr title = doc.createAttribute("title"); title.setValue("MrGeo Tile Map Service"); tms.setAttributeNode(title); final Attr v = doc.createAttribute("version"); v.setValue(VERSION); tms.setAttributeNode(v); final Attr href = doc.createAttribute("href"); href.setValue(normalizeUrl(url) + "/" + VERSION); tms.setAttributeNode(href); 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);  }