@Test public void testBlueLake() throws IOException, IllegalFilterException, Exception { final Catalog catalog = getCatalog(); org.geoserver.catalog.FeatureTypeInfo typeInfo = catalog.getFeatureTypeByName( map.setRequest(request); addToMap(map, MockData.FORESTS); addToMap(map, MockData.LAKES); addToMap(map, MockData.STREAMS); addToMap(map, MockData.NAMED_PLACES); addToMap(map, MockData.ROAD_SEGMENTS); addToMap(map, MockData.PONDS); addToMap(map, MockData.BUILDINGS); addToMap(map, MockData.DIVIDED_ROUTES); addToMap(map, MockData.BRIDGES); addToMap(map, MockData.MAP_NEATLINE); request.setFormat(getMapFormat()); RenderedImageMap imageMap = this.rasterMapProducer.produceMap(map); BufferedImage image = (BufferedImage) imageMap.getImage(); imageMap.dispose(); assertNotBlank("testBlueLake", image);
assertNotNull(forceRenderingError(new TransformException("fake transform exception"))); assertNotNull( forceRenderingError( new NoninvertibleTransformException("fake non invertible exception"))); assertNotNull( forceRenderingError( new IllegalAttributeException("non illegal attribute exception"))); assertNotNull(forceRenderingError(new FactoryException("fake factory exception"))); forceRenderingError(new RuntimeException("fake runtime exception")); fail("Expected WMSException"); } catch (ServiceException e) { forceRenderingError(new IOException("fake IO exception")); fail("Expected WMSException"); } catch (ServiceException e) { forceRenderingError(new IllegalArgumentException("fake IAE exception")); fail("Expected WMSException"); } catch (ServiceException e) {
@Before public void setRasterMapProducer() throws Exception { Logging.getLogger("org.geotools.rendering").setLevel(Level.OFF); this.rasterMapProducer = getProducerInstance(); getTestData().addDefaultRasterLayer(SystemTestData.MULTIBAND, getCatalog()); }
@Test public void testDefaultStyle() throws Exception { List<org.geoserver.catalog.FeatureTypeInfo> typeInfos = getCatalog().getFeatureTypes(); for (org.geoserver.catalog.FeatureTypeInfo info : typeInfos) { if (info.getQualifiedName().getNamespaceURI().equals(MockData.CITE_URI) && info.getFeatureType().getGeometryDescriptor() != null) testDefaultStyle(info.getFeatureSource(null, null)); } }
@Test public void testInterpolationFromLayerConfig() throws IOException, IllegalFilterException, Exception { final Catalog catalog = getCatalog(); request.setFormat(getMapFormat()); request.setLayers(Arrays.asList(mapLayer)); WMSMapContent map = createWMSMap(env); map.setRequest(request); BufferedImage imageNearest = op.getAsBufferedImage(); imageMap.dispose(); assertNotBlank("testInterpolationsNearest", imageNearest); request.setFormat(getMapFormat()); request.setLayers(Arrays.asList(mapLayer)); map = createWMSMap(env); map.setRequest(request); BufferedImage imageBicubic = op.getAsBufferedImage(); imageMap.dispose(); assertNotBlank("testInterpolationsBicubic", imageBicubic); getPixelColor(imageNearest, 160, 160).getRGB(), getPixelColor(imageBicubic, 160, 160).getRGB()); assertNotEquals( getPixelColor(imageNearest, 300, 450).getRGB(), getPixelColor(imageBicubic, 300, 450).getRGB());
@Test public void testInterpolations() throws IOException, IllegalFilterException, Exception { final Catalog catalog = getCatalog(); CoverageInfo coverageInfo = catalog.getCoverageByName( map.setTransparent(true); map.setRequest(request); addRasterToMap(map, MockData.TASMANIA_DEM); request.setFormat(getMapFormat()); RenderedImageMap imageMap = this.rasterMapProducer.produceMap(map); RenderedOp op = (RenderedOp) imageMap.getImage(); BufferedImage imageNearest = op.getAsBufferedImage(); imageMap.dispose(); assertNotBlank("testInterpolationsNearest", imageNearest); map.setTransparent(true); map.setRequest(request); addRasterToMap(map, MockData.TASMANIA_DEM); request.setFormat(getMapFormat()); BufferedImage imageBicubic = op.getAsBufferedImage(); imageMap.dispose(); assertNotBlank("testInterpolationsBicubic", imageBicubic); getPixelColor(imageNearest, 160, 160).getRGB(), getPixelColor(imageBicubic, 160, 160).getRGB()); assertNotEquals(
@Test public void testSimpleGetMapQuery() throws Exception { Catalog catalog = getCatalog(); final FeatureSource fs = catalog.getFeatureTypeByName( MockData.BASIC_POLYGONS.getPrefix(), MockData.BASIC_POLYGONS.getLocalPart()) .getFeatureSource(null, null); final Envelope env = fs.getBounds(); LOGGER.info("about to create map ctx for BasicPolygons with bounds " + env); GetMapRequest request = new GetMapRequest(); final WMSMapContent map = new WMSMapContent(); map.getViewport().setBounds(new ReferencedEnvelope(env, DefaultGeographicCRS.WGS84)); map.setMapWidth(300); map.setMapHeight(300); map.setBgColor(Color.red); map.setTransparent(false); map.setRequest(request); StyleInfo styleByName = catalog.getStyleByName("Default"); Style basicStyle = styleByName.getStyle(); map.addLayer(new FeatureLayer(fs, basicStyle)); request.setFormat(getMapFormat()); RenderedImageMap imageMap = this.rasterMapProducer.produceMap(map); BufferedImage image = (BufferedImage) imageMap.getImage(); imageMap.dispose(); assertNotBlank("testSimpleGetMapQuery", image); }
getCatalog() .getFeatureTypeByName(STREAMS.getNamespaceURI(), STREAMS.getLocalPart()); StyleInfo someStyle = getCatalog().getStyleByName("line"); map.addLayer(new FeatureLayer(source, someStyle.getStyle())); request.setFormat(getMapFormat()); RenderedImageMap imageMap = this.rasterMapProducer.produceMap(map); BufferedImage image = (BufferedImage) imageMap.getImage();
@Override protected void onSetUp(SystemTestData testData) throws Exception { super.onSetUp(testData); testData.addDefaultRasterLayer(MockData.TASMANIA_DEM, getCatalog()); testData.addRasterLayer(TAZ_BYTE, "tazbyte.tiff", null, getCatalog()); }
private WMSMapContent createWMSMap(Envelope bounds) throws Exception { WMSMapContent map = new WMSMapContent(); int w = 400; int h = (int) Math.round((bounds.getHeight() * w) / bounds.getWidth()); map.setMapWidth(w); map.setMapHeight(h); map.setBgColor(BG_COLOR); map.setTransparent(true); addRasterToMap(map, MockData.TASMANIA_DEM); map.getViewport().setBounds(new ReferencedEnvelope(bounds, DefaultGeographicCRS.WGS84)); return map; }
private void testDefaultStyle(FeatureSource fSource) throws Exception { Catalog catalog = getCatalog(); Style style = catalog.getStyleByName("Default").getStyle(); request.setFormat(getMapFormat()); assertNotNull(image); String typeName = fSource.getSchema().getName().getLocalPart(); assertNotBlank("testDefaultStyle " + typeName, (BufferedImage) image);
@Test public void testTimeoutOption() throws Exception { Catalog catalog = getCatalog(); GetMapRequest request = new GetMapRequest(); final WMSMapContent map = new WMSMapContent(); map.setRequest(request); request.setFormat(getMapFormat()); Map formatOptions = new HashMap();
private void addToMap(final WMSMapContent map, final QName typeName) throws IOException { final FeatureTypeInfo ftInfo = getCatalog() .getFeatureTypeByName(typeName.getNamespaceURI(), typeName.getLocalPart()); List<LayerInfo> layers = getCatalog().getLayers(ftInfo); StyleInfo defaultStyle = layers.get(0).getDefaultStyle(); Style style = defaultStyle.getStyle(); map.addLayer(new FeatureLayer(ftInfo.getFeatureSource(null, null), style)); }
map.setTransparent(true); map.getViewport().setBounds(bbox); addRasterToMap(map, TAZ_BYTE); map.getViewport().setBounds(bbox);
@Test public void testCustomLabelCache() throws IOException { final Catalog catalog = getCatalog(); org.geoserver.catalog.FeatureTypeInfo typeInfo = catalog.getFeatureTypeByName( map.setRequest(request); addToMap(map, MockData.FORESTS); addToMap(map, MockData.LAKES); addToMap(map, MockData.STREAMS); addToMap(map, MockData.NAMED_PLACES); addToMap(map, MockData.ROAD_SEGMENTS); addToMap(map, MockData.PONDS); addToMap(map, MockData.BUILDINGS); addToMap(map, MockData.DIVIDED_ROUTES); addToMap(map, MockData.BRIDGES); addToMap(map, MockData.MAP_NEATLINE); request.setFormat(getMapFormat()); imageMap.dispose(); assertTrue(usedCustomLabelCache.get()); assertNotBlank("testBlueLake", image);
private void addRasterToMap(final WMSMapContent map, final QName typeName) throws IOException, FactoryRegistryException, TransformException, SchemaException { final CoverageInfo coverageInfo = getCatalog().getCoverageByName(typeName.getNamespaceURI(), typeName.getLocalPart()); List<LayerInfo> layers = getCatalog().getLayers(coverageInfo); StyleInfo defaultStyle = layers.get(0).getDefaultStyle(); Style style = defaultStyle.getStyle(); SimpleFeatureCollection fc = FeatureUtilities.wrapGridCoverageReader( (GridCoverage2DReader) coverageInfo.getGridCoverageReader(null, null), new GeneralParameterValue[] {}); map.addLayer(new FeatureLayer(fc, style)); }
@Test public void testGetMapOnByteNodataGrayScale() throws Exception { GetMapRequest request = new GetMapRequest(); CoordinateReferenceSystem crs = DefaultGeographicCRS.WGS84; ReferencedEnvelope bbox = new ReferencedEnvelope(new Envelope(145, 146, -43, -41), crs); request.setBbox(bbox); request.setHeight(768); request.setWidth(384); request.setSRS("urn:x-ogc:def:crs:EPSG:4326"); request.setFormat("image/png"); request.setTransparent(true); final WMSMapContent map = new WMSMapContent(request); map.setMapHeight(768); map.setMapWidth(384); map.setBgColor(BG_COLOR); map.setTransparent(true); map.getViewport().setBounds(bbox); addRasterToMap(map, TAZ_BYTE); map.getViewport().setBounds(bbox); RenderedImageMap imageMap = this.rasterMapProducer.produceMap(map); RenderedOp op = (RenderedOp) imageMap.getImage(); BufferedImage image = op.getAsBufferedImage(); imageMap.dispose(); // check that a pixel in nodata area is transparent assertEquals(0, image.getRaster().getSample(40, 400, 0)); assertEquals(0, image.getRaster().getSample(40, 400, 1)); }
Catalog catalog = getCatalog();
Catalog catalog = getCatalog(); CoverageInfo ci = catalog.getCoverageByName(
Catalog catalog = getCatalog();