/** * Disposes any resource held by this Map. * * <p>This method is meant to be called right after the map is no longer needed. That generally * happens at the end of a {@link Response#write} operation, and is meant to free any resource * the map implementation might be holding, specially if it contains a refrerence to {@link * WMSMapContent}, in which case it's mandatory that the map context's {@link * WMSMapContent#dispose()} method is called. */ public final void dispose() { if (mapContent != null) { mapContent.dispose(); } disposeInternal(); }
@After public void tearDown() { ImageUtilities.disposeImage(this.op); this.map.dispose(); this.map = null; this.image = null; this.op = null; }
@Test public void testChannelDescription() throws Exception { WMSMapContent map = new WMSMapContent(createGetMapRequest(MockData.BASIC_POLYGONS)); map.addLayer(createMapLayer(MockData.BASIC_POLYGONS)); map.layers().get(0).getUserData().put("abstract", "Test Abstract"); Document document; try { document = getRSSResponse(map, AtomGeoRSSTransformer.GeometryEncoding.LATLONG); } finally { map.dispose(); } Element element = document.getDocumentElement(); assertEquals("rss", element.getNodeName()); Element channel = (Element) element.getElementsByTagName("channel").item(0); NodeList description = channel.getElementsByTagName("description"); assertEquals("Test Abstract", description.item(0).getChildNodes().item(0).getNodeValue()); }
imageMap = pngProducer.produceMap(subContext); } finally { subContext.dispose();
document = getRSSResponse(map, AtomGeoRSSTransformer.GeometryEncoding.LATLONG); } finally { map.dispose();
@Test public void testLatLongInternal() throws Exception { WMSMapContent map = new WMSMapContent(createGetMapRequest(MockData.BASIC_POLYGONS)); map.addLayer(createMapLayer(MockData.BASIC_POLYGONS)); Document document; try { document = getRSSResponse(map, AtomGeoRSSTransformer.GeometryEncoding.LATLONG); } finally { map.dispose(); } Element element = document.getDocumentElement(); assertEquals("rss", element.getNodeName()); NodeList items = element.getElementsByTagName("item"); int n = getFeatureSource(MockData.BASIC_POLYGONS).getCount(Query.ALL); assertEquals(n, items.getLength()); for (int i = 0; i < items.getLength(); i++) { Element item = (Element) items.item(i); assertEquals(1, item.getElementsByTagName("geo:lat").getLength()); assertEquals(1, item.getElementsByTagName("geo:long").getLength()); } }
@Test public void testSimpleInternal() throws Exception { WMSMapContent map = new WMSMapContent(createGetMapRequest(MockData.BASIC_POLYGONS)); map.addLayer(createMapLayer(MockData.BASIC_POLYGONS)); Document document; try { // print(document); document = getRSSResponse(map, GeoRSSTransformerBase.GeometryEncoding.SIMPLE); } finally { map.dispose(); } Element element = document.getDocumentElement(); assertEquals("rss", element.getNodeName()); NodeList entries = element.getElementsByTagName("item"); int n = getFeatureSource(MockData.BASIC_POLYGONS).getCount(Query.ALL); assertEquals(n, entries.getLength()); for (int i = 0; i < entries.getLength(); i++) { Element entry = (Element) entries.item(i); assertEquals(1, entry.getElementsByTagName("georss:polygon").getLength()); } }
@Test public void testReproject() throws Exception { // Set up a map context with a projected layer WMSMapContent map = new WMSMapContent(createGetMapRequest(MockData.LINES)); map.addLayer(createMapLayer(MockData.LINES)); Document document; try { document = getRSSResponse(map, AtomGeoRSSTransformer.GeometryEncoding.LATLONG); } finally { map.dispose(); } NodeList items = document.getDocumentElement().getElementsByTagName("item"); // check all items are there assertEquals(1, items.getLength()); // check coordinates are in wgs84, originals aren't for (int i = 0; i < items.getLength(); i++) { Element item = (Element) items.item(i); double lat = Double.parseDouble(getOrdinate(item, "geo:lat")); double lon = Double.parseDouble(getOrdinate(item, "geo:long")); assertTrue("Expected valid latitude value: " + lat, lat >= -90 && lat <= 90); assertTrue("Expected valid longitude value: " + lon, lon >= -180 && lon <= 180); } }
return map; } catch (Throwable t) { mapContent.dispose(); fireFailed(t); if (t instanceof RuntimeException) {
@Test public void testFilter() throws Exception { // Set up a map context with a filtered layer WMSMapContent map = new WMSMapContent(createGetMapRequest(MockData.BUILDINGS)); Document document; try { FeatureLayer layer = (FeatureLayer) createMapLayer(MockData.BUILDINGS); Filter f = ff.equals(ff.property("ADDRESS"), ff.literal("215 Main Street")); layer.setQuery(new Query(MockData.BUILDINGS.getLocalPart(), f)); map.addLayer(layer); document = getRSSResponse(map, AtomGeoRSSTransformer.GeometryEncoding.LATLONG); } finally { map.dispose(); } NodeList items = document.getDocumentElement().getElementsByTagName("item"); assertEquals(1, items.getLength()); }
mapContent.dispose();
dstImageMap.dispose(); map.dispose();
dstImageMap.dispose(); map.dispose();