/*
* GeoTools - The Open Source Java GIS Toolkit
* http://geotools.org
*
* (C) 2016, Open Source Geospatial Foundation (OSGeo)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation;
* version 2.1 of the License.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*/
package org.geotools.renderer.lite;
import static java.awt.RenderingHints.KEY_ANTIALIASING;
import static java.awt.RenderingHints.VALUE_ANTIALIAS_ON;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import org.geotools.data.property.PropertyDataStore;
import org.geotools.data.simple.SimpleFeatureSource;
import org.geotools.geometry.jts.ReferencedEnvelope;
import org.geotools.image.test.ImageAssert;
import org.geotools.map.FeatureLayer;
import org.geotools.map.MapContent;
import org.geotools.referencing.CRS;
import org.geotools.styling.Style;
import org.geotools.test.TestData;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
public class QGISMarkTest {
private static final long DISPLAY_TIME = 3000;
SimpleFeatureSource pointFS;
SimpleFeatureSource lineFS;
ReferencedEnvelope bounds;
@BeforeClass
public static void setupClass() {
System.clearProperty("org.geotools.referencing.forceXY");
CRS.reset("all");
}
@Before
public void setUp() throws Exception {
File property = new File(TestData.getResource(this, "qgispoints.properties").toURI());
PropertyDataStore ds = new PropertyDataStore(property.getParentFile());
pointFS = ds.getFeatureSource("qgispoints");
lineFS = ds.getFeatureSource("qgislines");
bounds = new ReferencedEnvelope(0, 10, 0, 10, CRS.decode("EPSG:4326"));
// System.setProperty("org.geotools.test.interactive", "true");
}
File file(String name) {
return new File(
"src/test/resources/org/geotools/renderer/lite/test-data/mark/" + name + ".png");
}
/**
* Test all QGIS marks in a single image.
*/
@Test
public void testQGIS() throws Exception {
Style pStyle = RendererBaseTest.loadStyle(this, "qgis.sld");
Style lStyle = RendererBaseTest.loadStyle(this, "lineGray.sld");
MapContent mc = new MapContent();
mc.addLayer(new FeatureLayer(pointFS, pStyle));
mc.addLayer(new FeatureLayer(lineFS, lStyle));
StreamingRenderer renderer = new StreamingRenderer();
renderer.setMapContent(mc);
renderer.setJava2DHints(new RenderingHints(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON));
BufferedImage image = RendererBaseTest.showRender("QGIS Marks", renderer, DISPLAY_TIME,
bounds);
ImageAssert.assertEquals(file("qgis"), image, 50);
}
}