@Test public void testBuildQueryToStream() throws Exception { GeoServerProxyService service = new GeoServerProxyService(); final String lon = "4551585.429555906"; final String lat = "3273782.647749871"; final int zoom = 11; final String layerId = "67"; final String uuid = "abc-123"; final String srs = "EPSG:3035"; ByteArrayOutputStream outs = new ByteArrayOutputStream(); service.buildQueryToStream(GeoServerProxyService.MY_PLACE_FEATURE_FILTER_XML, lon + " " + lat, zoom, layerId, uuid, outs, srs); String xml = outs.toString(); outs.close(); String expectedResult = ResourceHelper.readStringResource("GetFeatureInfoMyPlaces-expected.xml", this); Diff xmlDiff = new Diff(expectedResult, xml); assertTrue("Should get expected query for myplaces GFI " + xmlDiff, xmlDiff.similar()); }
protected String buildQueryToStream(String resourceName, String lon_lat, int zoomLevel, String categoryId, String uuid, OutputStream outs, final String srs) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException, TransformerException { DocumentBuilderFactory factory = XmlHelper.newDocumentBuilderFactory(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); InputStream inp = this.getClass().getResourceAsStream(resourceName); Document doc = builder.parse(inp); inp.close(); XPathFactory xFactory = XPathFactory.newInstance(); XPath xpath = xFactory.newXPath(); xpath.setNamespaceContext(new MyPlacesNamespaceContext()); setupTemplateValue(doc, xpath, " setupTemplateValue(doc, xpath, " setupTemplateValue(doc, xpath, " final String distanceForZoom = String.valueOf(DISTANCE_FACTOR * Math.pow(2, (MAX_ZOOM_LEVEL - zoomLevel))); setupTemplateValue(doc, xpath, " setupSrsAttribute(doc, xpath, " setupSrsAttribute(doc, xpath, " TransformerFactory tFactory = XmlHelper.newTransformerFactory(); Transformer transformer = tFactory.newTransformer(); DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(outs); transformer.transform(source, result); return outs.toString(); }
GeoServerProxyService { protected String buildQueryToStream(String resourceName, String lon_lat, int zoomLevel, String categoryId, String uuid, OutputStream outs, final String srs) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException, TransformerException { DocumentBuilderFactory factory = XmlHelper.newDocumentBuilderFactory(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); InputStream inp = this.getClass().getResourceAsStream(resourceName); Document doc = builder.parse(inp); inp.close(); XPathFactory xFactory = XPathFactory.newInstance(); XPath xpath = xFactory.newXPath(); xpath.setNamespaceContext(new MyPlacesNamespaceContext()); setupTemplateValue(doc, xpath, " setupTemplateValue(doc, xpath, " setupTemplateValue(doc, xpath, " final String distanceForZoom = String.valueOf(DISTANCE_FACTOR * Math.pow(2, (MAX_ZOOM_LEVEL - zoomLevel))); setupTemplateValue(doc, xpath, " setupSrsAttribute(doc, xpath, " setupSrsAttribute(doc, xpath, " TransformerFactory tFactory = XmlHelper.newTransformerFactory(); Transformer transformer = tFactory.newTransformer(); DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(outs); transformer.transform(source, result); return outs.toString(); } }
GeoServerProxyService { protected String buildQueryToStream(String resourceName, String lon_lat, int zoomLevel, String categoryId, String uuid, OutputStream outs, final String srs) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException, TransformerException { DocumentBuilderFactory factory = XmlHelper.newDocumentBuilderFactory(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); InputStream inp = this.getClass().getResourceAsStream(resourceName); Document doc = builder.parse(inp); inp.close(); XPathFactory xFactory = XPathFactory.newInstance(); XPath xpath = xFactory.newXPath(); xpath.setNamespaceContext(new MyPlacesNamespaceContext()); setupTemplateValue(doc, xpath, " setupTemplateValue(doc, xpath, " setupTemplateValue(doc, xpath, " final String distanceForZoom = String.valueOf(DISTANCE_FACTOR * Math.pow(2, (MAX_ZOOM_LEVEL - zoomLevel))); setupTemplateValue(doc, xpath, " setupSrsAttribute(doc, xpath, " setupSrsAttribute(doc, xpath, " TransformerFactory tFactory = XmlHelper.newTransformerFactory(); Transformer transformer = tFactory.newTransformer(); DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(outs); transformer.transform(source, result); return outs.toString(); }  }
GeoServerProxyService { protected String buildQueryToStream(String resourceName, String lon_lat, int zoomLevel, String categoryId, String uuid, OutputStream outs, final String srs) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException, TransformerException { DocumentBuilderFactory factory = XmlHelper.newDocumentBuilderFactory(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); InputStream inp = this.getClass().getResourceAsStream(resourceName); Document doc = builder.parse(inp); inp.close(); XPathFactory xFactory = XPathFactory.newInstance(); XPath xpath = xFactory.newXPath(); xpath.setNamespaceContext(new MyPlacesNamespaceContext()); setupTemplateValue(doc, xpath, " setupTemplateValue(doc, xpath, " setupTemplateValue(doc, xpath, " final String distanceForZoom = String.valueOf(DISTANCE_FACTOR * Math.pow(2, (MAX_ZOOM_LEVEL - zoomLevel))); setupTemplateValue(doc, xpath, " setupSrsAttribute(doc, xpath, " setupSrsAttribute(doc, xpath, " TransformerFactory tFactory = XmlHelper.newTransformerFactory(); Transformer transformer = tFactory.newTransformer(); DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(outs); transformer.transform(source, result); return outs.toString(); }  String proxy(final ProxyRequest request); JSONObject getFeatureInfo(final double lat, final double lon, final int zoom, final String id, final String uuid, final String srs); }
GeoServerProxyService { protected String buildQueryToStream(String resourceName, String lon_lat, int zoomLevel, String categoryId, String uuid, OutputStream outs, final String srs) throws ParserConfigurationException, SAXException, IOException, XPathExpressionException, TransformerException { DocumentBuilderFactory factory = XmlHelper.newDocumentBuilderFactory(); factory.setNamespaceAware(true); DocumentBuilder builder = factory.newDocumentBuilder(); InputStream inp = this.getClass().getResourceAsStream(resourceName); Document doc = builder.parse(inp); inp.close(); XPathFactory xFactory = XPathFactory.newInstance(); XPath xpath = xFactory.newXPath(); xpath.setNamespaceContext(new MyPlacesNamespaceContext()); setupTemplateValue(doc, xpath, " setupTemplateValue(doc, xpath, " setupTemplateValue(doc, xpath, " final String distanceForZoom = String.valueOf(DISTANCE_FACTOR * Math.pow(2, (MAX_ZOOM_LEVEL - zoomLevel))); setupTemplateValue(doc, xpath, " setupSrsAttribute(doc, xpath, " setupSrsAttribute(doc, xpath, " TransformerFactory tFactory = XmlHelper.newTransformerFactory(); Transformer transformer = tFactory.newTransformer(); DOMSource source = new DOMSource(doc); StreamResult result = new StreamResult(outs); transformer.transform(source, result); return outs.toString(); }  String proxy(final ProxyRequest request); JSONObject getFeatureInfo(final double lat, final double lon, final int zoom, final String id, final String uuid, final String srs);  }