Skip to content

Commit

Permalink
MBStyles - Perceptual tests for fill & line layer
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkrusz committed May 10, 2017
1 parent 950bf86 commit 4d9fca2
Show file tree
Hide file tree
Showing 6 changed files with 170 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ public class VisualTransformerTest {
SimpleFeatureSource gridFS;

SimpleFeatureSource lineFS;

SimpleFeatureSource lineZigFS;

SimpleFeatureSource bgFS;

Expand All @@ -98,6 +100,7 @@ public void setUp() throws Exception {
polygonFS = ds.getFeatureSource("testpolygons");
polygonsBigFS = ds.getFeatureSource("testpolygonsbig");
lineFS = ds.getFeatureSource("testlines");
lineZigFS = ds.getFeatureSource("testlinezigs");
bounds = new ReferencedEnvelope(0, 10, 0, 10, CRS.decode("EPSG:4326"));

// UNCOMMENT THE BELOW LINE TO DISPLAY VISUAL TESTS
Expand Down Expand Up @@ -131,6 +134,34 @@ public void mbFillLayerVisualTest() throws Exception {
mc.dispose();
}

/**
* Test generation of a GeoTools style from an MBFillLayer
*/
@Test
public void mbFillLayerAllPropertiesVisualTest() throws Exception {

// Read file to JSONObject
JSONObject jsonObject = MapboxTestUtils.parseTestStyle("fillStyleTestAllProperties.json");

// Get the style
MBStyle mbStyle = new MBStyle(jsonObject);
StyledLayerDescriptor sld = mbStyle.transform();
UserLayer l = (UserLayer) sld.layers().get(0);
Style style = l.getUserStyles()[0];

MapContent mc = new MapContent();
mc.addLayer(new FeatureLayer(polygonFS, style));

StreamingRenderer renderer = new StreamingRenderer();
renderer.setMapContent(mc);
renderer.setJava2DHints(new RenderingHints(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON));
BufferedImage image = MapboxTestUtils.showRender("Fill Test", renderer, DISPLAY_TIME,
new ReferencedEnvelope[] { bounds }, null);
ImageAssert.assertEquals(file("fill-test-all"), image, 50);
mc.dispose();
}


/**
* Test generation of a GeoTools style from an MBFillLayer (using a {tokenized} sprite fill pattern)
*/
Expand Down Expand Up @@ -333,6 +364,31 @@ public void mbCircleLayerOverlapVisualTest() throws Exception {
public void mbLineLayerTest() throws Exception {
JSONObject jsonObject = MapboxTestUtils.parseTestStyle("lineStyleTest.json");
testVisualizeStyleWithLineFeatures(jsonObject, "Line Style", "line-style", true);
}

@Test
public void mbLineLayerAllPropertiesTest() throws Exception {
JSONObject jsonObject = MapboxTestUtils.parseTestStyle("lineStyleTestAllProperties.json");

// Get the style
MBStyle mbStyle = new MBStyle(jsonObject);
StyledLayerDescriptor sld = mbStyle.transform();
UserLayer l = (UserLayer) sld.layers().get(0);
Style style = l.getUserStyles()[0];

MapContent mc = new MapContent();

// mc.addLayer(new FeatureLayer(lineFS, defaultLineStyle()));

mc.addLayer(new FeatureLayer(lineZigFS, style));

StreamingRenderer renderer = new StreamingRenderer();
renderer.setMapContent(mc);
renderer.setJava2DHints(new RenderingHints(KEY_ANTIALIASING, VALUE_ANTIALIAS_ON));
BufferedImage image = MapboxTestUtils.showRender("Line Style", renderer, DISPLAY_TIME,
new ReferencedEnvelope[] { bounds }, null);
ImageAssert.assertEquals(file("line-style-all-props"), image, 5000);
mc.dispose();
}


Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
{
"version": 8,
"name": "fillStyleTest",
"metadata": {
"mapbox:autocomposite": true,
"mapbox:type": "template"
},
"center": [
0,
-1.1368683772161603e-13
],
"zoom": 0.9915217327085096,
"bearing": 0,
"pitch": 0,
"sources": {
"geoserver-states": {
"url": "http://localhost:8080/geoserver/topp/states/wms",
"type": "vector"
}
},
"sprite": "mapbox://sprites/testuser/ciym62qtf005d2rnopgu725qo",
"glyphs": "mapbox://fonts/testuser/{fontstack}/{range}.pbf",
"layers": [
{
"id": "testid",
"type": "fill",
"source": "geoserver-states",
"source-layer": "states",
"layout": {
"visibility": "visible"
},
"paint": {
"fill-color": "green",
"fill-opacity": 0.84,
"fill-translate": [
20,
20
],
"fill-antialias": true,
"fill-translate-anchor": "map",
"fill-outline-color":"orangered"
}
}
],
"created": "2017-01-31T23:40:15.130Z",
"id": "ciym62qtf005d2rnopgu725qo",
"modified": "2017-01-31T23:40:52.754Z",
"owner": "testuser",
"draft": false
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{
"version": 8,
"name": "Empty",
"metadata": {
"mapbox:autocomposite": true,
"mapbox:type": "template"
},
"center": [
-106.37942820066576,
39.62499260458827
],
"zoom": 15.80212732929003,
"bearing": 0,
"pitch": 0,
"sources": {
"mapbox://mapbox.satellite": {
"url": "mapbox://mapbox.satellite",
"type": "raster",
"tileSize": 256
},
"composite": {
"url": "mapbox://test.cixwdy1nj001933p91a6wnxe0-2emxh,testuser.cixwc3qp2001l2wquza8ccz21-658xw",
"type": "vector"
}
},
"sprite": "mapbox://sprites/test/cixwe1jim001l2sp6his5j6ns",
"glyphs": "mapbox://fonts/test/{fontstack}/{range}.pbf",
"layers": [
{
"id": "test-id",
"type": "line",
"source": "test-source",
"source-layer": "test-source-layer",
"layout": {
"visibility": "visible",
"line-cap": "square",
"line-join": "round",
"line-round-limit" 1.2,
},
"paint": {
"line-color": "rebeccapurple",
"line-opacity": 0.80,
"line-translate-anchor": "viewport",
"line-dasharray": [50, 10, 20, 10],
"line-offset": 0,
"line-gap-width": 8,
"line-translate": [
0,
0
],
"line-translate-anchor": "map",
"line-width": 5,
"line-blur": 2
}
}
],
"created": "2017-01-13T22:41:15.108Z",
"id": "cixwe1jim001l2sp6his5j6ns",
"modified": "2017-02-08T16:37:48.232Z",
"owner": "test",
"draft": false
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_=geom:LineString:4326,icon:String,text:String
Line.0=LINESTRING(1 1, 4 4, 4 1, 7 2, 9 1, 9 9, 4 7, 1 2, 1 9, 7 9)|face|01

0 comments on commit 4d9fca2

Please sign in to comment.