Skip to content

Commit

Permalink
[GEOS-7255] Makes WMS GetFeatureInfo work with expressions dash-arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuno Oliveira committed Feb 6, 2016
1 parent e841289 commit 65c85c5
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 4 deletions.
@@ -1,4 +1,4 @@
/* (c) 2014 Open Source Geospatial Foundation - all rights reserved /* (c) 2014 - 2016 Open Source Geospatial Foundation - all rights reserved
* (c) 2013 OpenPlans * (c) 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root * This code is licensed under the GPL 2.0 license, available at the root
* application directory. * application directory.
Expand Down Expand Up @@ -283,9 +283,9 @@ private Class getTargetGeometryType(Object descriptor) {


private void addStrokeSymbolizerIfNecessary(Stroke stroke) { private void addStrokeSymbolizerIfNecessary(Stroke stroke) {
if (stroke != null) { if (stroke != null) {
float[] dashArray = stroke.getDashArray(); List<Expression> dashArray = stroke.dashArray();
Graphic graphicStroke = stroke.getGraphicStroke(); Graphic graphicStroke = stroke.getGraphicStroke();
if (graphicStroke != null || dashArray != null && dashArray.length > 0) { if (graphicStroke != null || dashArray != null && dashArray.size() > 0) {
addSolidLineSymbolier = true; addSolidLineSymbolier = true;
} }
} }
Expand Down
@@ -1,4 +1,4 @@
/* (c) 2014 - 2015 Open Source Geospatial Foundation - all rights reserved /* (c) 2014 - 2016 Open Source Geospatial Foundation - all rights reserved
* (c) 2013 OpenPlans * (c) 2013 OpenPlans
* This code is licensed under the GPL 2.0 license, available at the root * This code is licensed under the GPL 2.0 license, available at the root
* application directory. * application directory.
Expand Down Expand Up @@ -83,6 +83,7 @@ protected void onSetUp(SystemTestData testData) throws Exception {
testData.addStyle("two-rules", "two-rules.sld", this.getClass(), getCatalog()); testData.addStyle("two-rules", "two-rules.sld", this.getClass(), getCatalog());
testData.addStyle("two-fts", "two-fts.sld", this.getClass(), getCatalog()); testData.addStyle("two-fts", "two-fts.sld", this.getClass(), getCatalog());
testData.addStyle("dashed", "dashed.sld",this.getClass(), getCatalog()); testData.addStyle("dashed", "dashed.sld",this.getClass(), getCatalog());
testData.addStyle("dashed-exp", "dashed-exp.sld",this.getClass(), getCatalog());
testData.addStyle("polydash", "polydash.sld", this.getClass(), getCatalog()); testData.addStyle("polydash", "polydash.sld", this.getClass(), getCatalog());
testData.addStyle("doublepoly", "doublepoly.sld", this.getClass(), getCatalog()); testData.addStyle("doublepoly", "doublepoly.sld", this.getClass(), getCatalog());
testData.addStyle("pureLabel", "purelabel.sld", this.getClass(), getCatalog()); testData.addStyle("pureLabel", "purelabel.sld", this.getClass(), getCatalog());
Expand Down Expand Up @@ -281,6 +282,16 @@ public void testDashed() throws Exception {
assertEquals(1, result.getJSONArray("features").size()); assertEquals(1, result.getJSONArray("features").size());
} }


@Test
public void testDashedWithExpressions() throws Exception {
String layer = getLayerId(MockData.GENERICENTITY);
String request = "wms?REQUEST=GetFeatureInfo&&BBOX=0.778809%2C45.421875%2C12.021973%2C59.921875&SERVICE=WMS"
+ "&INFO_FORMAT=application/json&QUERY_LAYERS=" + layer + "&Layers=" + layer
+ "&WIDTH=397&HEIGHT=512&format=image%2Fpng&styles=dashed-exp&srs=EPSG%3A4326&version=1.1.1&x=182&y=241";
JSONObject result = (JSONObject) getAsJSON(request);
assertEquals(1, result.getJSONArray("features").size());
}

@Test @Test
public void testDoublePoly() throws Exception { public void testDoublePoly() throws Exception {
String layer = getLayerId(GRID); String layer = getLayerId(GRID);
Expand Down
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
xmlns="http://www.opengis.net/sld"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<!-- a Named Layer is the basic building block of an SLD document -->
<NamedLayer>
<Name>default_line</Name>
<UserStyle>
<!-- Styles can have names, titles and abstracts -->
<Title>Default Line</Title>
<Abstract>A sample style that draws a line</Abstract>
<!-- FeatureTypeStyles describe how to render different features -->
<!-- A FeatureTypeStyle for rendering lines -->
<FeatureTypeStyle>
<Rule>
<Name>rule1</Name>
<Title>Blue Line</Title>
<Abstract>A solid blue line with a 1 pixel width</Abstract>
<LineSymbolizer>
<Stroke>
<CssParameter name="stroke">#0000FF</CssParameter>
<CssParameter name="stroke-dasharray">
<ogc:Mul>
<ogc:Function name="strLength">
<ogc:Literal>VWXYZ</ogc:Literal>
</ogc:Function>
<ogc:Literal>4</ogc:Literal>
</ogc:Mul>
<ogc:Literal>5</ogc:Literal>
</CssParameter>
</Stroke>
</LineSymbolizer>
</Rule>
</FeatureTypeStyle>
</UserStyle>
</NamedLayer>
</StyledLayerDescriptor>

0 comments on commit 65c85c5

Please sign in to comment.