UTFGridEntries getEntries() { UTFGridMapContent mc = (UTFGridMapContent) mapContent; return mc.getEntries(); } }
@Override protected BlockingQueue<RenderingRequest> getRequestsQueue() { return new PureVectorRenderingBlockingQueue(10000); }
@Override protected StreamingRenderer buildRenderer() { // use a renderer that won't render raster or labels, not even by accident return new PureVectorRenderer(); }
public UTFGridMapContent(WMSMapContent other, UTFGridEntries entries, int downscaleFactor) { // do not copy the layers, as we need to replace them (once we have a deep layer copy // we actually might not need this) super(other, false); this.entries = entries; this.other = other; // clean up the bits we surely don't want this.setMapWidth(this.getMapWidth() / downscaleFactor); this.setMapHeight(this.getMapHeight() / downscaleFactor); this.setBgColor(Color.BLACK); this.setTransparent(false); this.setPalette(null); }
@Before public void setupVisitor() { UTFGridEntries entries = new UTFGridEntries(); colorFunction = new UTFGridColorFunction(entries); visitor = new UTFGridStyleVisitor(colorFunction); }
@Test public void testPolygonGraphicFill() throws Exception { UTFGridTester tester = getAsGridTester( "wms?service=WMS&version=1.1.0&request=GetMap&layers=cite:Forests" + "&styles=&bbox=-0.0028,-0.0028,0.0048,0.0048&width=256&height=256&srs=EPSG:4326&format=utfgrid"); // sample some pixels tester.assertGridPixel(' ', 10, 20); tester.assertGridPixel('!', 60, 20); JSONObject f = tester.getFeature('!'); assertEquals("Green Forest", f.getString("NAME")); }
@Test public void testAlternateMimetype() throws Exception { UTFGridTester tester = getAsGridTester( "wms?service=WMS&version=1.1.0&request=GetMap&layers=cite:RoadSegments&styles=line" + "&bbox=-0.0042,-0.0042,0.0042,0.0042&width=256&height=256&srs=EPSG:4326&format=application/json;type=utfgrid"); checkRoadSegments(tester); }
@Test public void testEmptyOutput() throws Exception { UTFGridTester tester = getAsGridTester( "wms?service=WMS&version=1.1.0&request=GetMap&layers=cite:Forests" + "&styles=&bbox=-10.0028,-0.0028,-9.0048,0.0048&width=256&height=256&srs=EPSG:4326&format=utfgrid"); assertEquals(1, tester.getKeyCount()); for (int i = 0; i < 32; i++) { for (int j = 0; j < 32; j++) { tester.assertGridPixel(' ', i, j); } } }
@Test public void testPolygonExtractionFromRaster() throws Exception { String url = "wms?LAYERS=" + getLayerId(MockData.TASMANIA_DEM) + "&styles=polygonExtract&" + "FORMAT=utfgrid&SERVICE=WMS&VERSION=1.1.1" + "&REQUEST=GetMap&SRS=EPSG%3A4326" + "&BBOX=145,-43,146,-41&WIDTH=100&HEIGHT=200"; UTFGridTester tester = getAsGridTester(url, 100, 200, 4); assertTrue(tester.getKeyCount() > 0); } }
private UTFGridTester getAsGridTester(String request) throws Exception { return getAsGridTester(request, 256, 256, 4); }
@Override public Object evaluate(Object object) { if (!(object instanceof Feature)) { // cannot handle this, make it "transparent" return Color.BLACK; } Feature feature = (Feature) object; int key = entries.getKeyForFeature(feature); return new Color(key, false); } }
/** * Returns the feature for the given grid code * * @param code */ JSONObject getFeature(char code) { String key = "" + (int) gridToKey(code); return data.getJSONObject(key); }
@Test public void testPolygonReproject() throws Exception { UTFGridTester tester = getAsGridTester( "wms?service=WMS&version=1.1.0&request=GetMap&layers=cite:Forests" + "&styles=polygon&bbox=-280,-280,480,480&width=256&height=256&srs=EPSG:3857&format=utfgrid"); // sample some pixels tester.assertGridPixel(' ', 10, 10); tester.assertGridPixel('!', 60, 10); JSONObject f = tester.getFeature('!'); assertEquals("Green Forest", f.getString("NAME")); }
/** * Using a color classified style. Should not make any different to UTFGrid, as long as we paint * all features */ @Test public void testLineSymbolizerClassified() throws Exception { UTFGridTester tester = getAsGridTester( "wms?service=WMS&version=1.1.0&request=GetMap&layers=cite:RoadSegments&styles=" + "&bbox=-0.0042,-0.0042,0.0042,0.0042&width=256&height=256&srs=EPSG:4326&format=utfgrid"); checkRoadSegments(tester); }
@Test public void testSolidFillAndRuleWithTextSymbolizerOnly() throws Exception { // used to blow up due to the text symbolizer alone UTFGridTester tester = getAsGridTester( "wms?LAYERS=sf%3Astates&STYLES=population&FORMAT=utfgrid" + "&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&SRS=EPSG%3A4326&BBOX=-95.8506355,24.955967,-66.969849,53.8367535&WIDTH=256&HEIGHT=256"); }
@Test public void testCircle() throws Exception { UTFGridTester tester = getAsGridTester( "wms?service=WMS&version=1.1.0&request=GetMap&layers=cite:Bridges&styles=circle&bbox=0,0.0005,0.0004,0.0009&width=256&height=256&srs=EPSG:4326&format=utfgrid"); tester.assertGridPixel(' ', 25, 30); tester.assertGridPixel('!', 32, 32); JSONObject f = tester.getFeature('!'); assertEquals("110", f.getString("FID")); assertEquals("Cam Bridge", f.getString("NAME")); }
/** Check we get a usable result even with super-thin lines */ @Test public void testThinLineSymbolizer() throws Exception { UTFGridTester tester = getAsGridTester( "wms?service=WMS&version=1.1.0&request=GetMap&layers=cite:RoadSegments&styles=thin_line" + "&bbox=-0.0042,-0.0042,0.0042,0.0042&width=256&height=256&srs=EPSG:4326&format=utfgrid"); checkRoadSegments(tester); }
@Test public void testLargeCircle() throws Exception { UTFGridTester tester = getAsGridTester( "wms?service=WMS&version=1.1.0&request=GetMap&layers=cite:Bridges&styles=circle&bbox=0,0.0005,0.0004,0.0009&width=256&height=256&srs=EPSG:4326&format=utfgrid" + "&env=radius:64"); tester.assertGridPixel('!', 25, 30); tester.assertGridPixel('!', 32, 32); JSONObject f = tester.getFeature('!'); assertEquals("110", f.getString("FID")); assertEquals("Cam Bridge", f.getString("NAME")); }
/** Check we get a correct result with graphic stroked + dash array */ @Test public void testDotted() throws Exception { UTFGridTester tester = getAsGridTester( "wms?service=WMS&version=1.1.0&request=GetMap&layers=cite:RoadSegments&styles=dotted" + "&bbox=-0.0042,-0.0042,0.0042,0.0042&width=256&height=256&srs=EPSG:4326&format=utfgrid"); checkRoadSegments(tester); }
@Test public void testLineSymbolizer() throws Exception { UTFGridTester tester = getAsGridTester( "wms?service=WMS&version=1.1.0&request=GetMap&layers=cite:RoadSegments&styles=line" + "&bbox=-0.0042,-0.0042,0.0042,0.0042&width=256&height=256&srs=EPSG:4326&format=utfgrid"); checkRoadSegments(tester); }