@Test public void testStatesMissingHeightWidthBboxSrs() throws Exception { runGetLegendGraphics( "wms?service=WMS&version=1.1.1&request=GetLegendGraphic&format=image/png" + "&layer=" + getLayerId(SF_STATES) + "&style=Population" + "&legend_options=" + GetLegendGraphicRequest.COUNT_MATCHED_KEY + ":true"); assertEquals(1, ruleSets.size()); Rule[] rules = ruleSets.get(0); logLabels(rules); assertEquals(4, rules.length); assertLabel("2M - 4M (10)", rules[0]); assertLabel("< 2M (16)", rules[1]); assertLabel("> 4M (23)", rules[2]); // this is the rule for outline and text symbolizer, Alaska and Hawaii are not in the // map but Washington DC is and it's not a state (50 - 2 + 1) assertLabel("(49)", rules[3]); }
@Test public void testStatesMissingBbox() throws Exception { runGetLegendGraphics( "wms?service=WMS&version=1.1.1&request=GetLegendGraphic&format=image/png" + "&layer=" + getLayerId(SF_STATES) + "&style=Population" + "&width=550&height=250&srs=EPSG:4326" + "&legend_options=" + GetLegendGraphicRequest.COUNT_MATCHED_KEY + ":true"); assertEquals(1, ruleSets.size()); Rule[] rules = ruleSets.get(0); logLabels(rules); assertEquals(4, rules.length); assertLabel("2M - 4M (10)", rules[0]); assertLabel("< 2M (16)", rules[1]); assertLabel("> 4M (23)", rules[2]); // this is the rule for outline and text symbolizer, Alaska and Hawaii are not in the // map but Washington DC is and it's not a state (50 - 2 + 1) assertLabel("(49)", rules[3]); }
@Test public void testStatesMissingHeightWidthSrs() throws Exception { runGetLegendGraphics( "wms?service=WMS&version=1.1.1&request=GetLegendGraphic&format=image/png" + "&layer=" + getLayerId(SF_STATES) + "&style=Population" + "&bbox=" + "-130,24,-66,50" + "&legend_options=" + GetLegendGraphicRequest.COUNT_MATCHED_KEY + ":true"); assertEquals(1, ruleSets.size()); Rule[] rules = ruleSets.get(0); logLabels(rules); assertEquals(4, rules.length); assertLabel("2M - 4M (10)", rules[0]); assertLabel("< 2M (16)", rules[1]); assertLabel("> 4M (23)", rules[2]); // this is the rule for outline and text symbolizer, Alaska and Hawaii are not in the // map but Washington DC is and it's not a state (50 - 2 + 1) assertLabel("(49)", rules[3]); }
@Test public void testStatesMissingHeightWidth() throws Exception { runGetLegendGraphics( "wms?service=WMS&version=1.1.1&request=GetLegendGraphic&format=image/png" + "&layer=" + getLayerId(SF_STATES) + "&style=Population" + "&srs=EPSG:4326&bbox=" + "-130,24,-66,50" + "&legend_options=" + GetLegendGraphicRequest.COUNT_MATCHED_KEY + ":true"); assertEquals(1, ruleSets.size()); Rule[] rules = ruleSets.get(0); logLabels(rules); assertEquals(4, rules.length); assertLabel("2M - 4M (10)", rules[0]); assertLabel("< 2M (16)", rules[1]); assertLabel("> 4M (23)", rules[2]); // this is the rule for outline and text symbolizer, Alaska and Hawaii are not in the // map but Washington DC is and it's not a state (50 - 2 + 1) assertLabel("(49)", rules[3]); }
@Test public void testStatesMissingHeightWidthBboxSrsOnWMS13() throws Exception { runGetLegendGraphics( "wms?service=WMS&version=1.3.0&request=GetLegendGraphic&format=image/png" + "&layer=" + getLayerId(SF_STATES) + "&style=Population" + "&legend_options=" + GetLegendGraphicRequest.COUNT_MATCHED_KEY + ":true"); assertEquals(1, ruleSets.size()); Rule[] rules = ruleSets.get(0); logLabels(rules); assertEquals(4, rules.length); assertLabel("2M - 4M (10)", rules[0]); assertLabel("< 2M (16)", rules[1]); assertLabel("> 4M (23)", rules[2]); // this is the rule for outline and text symbolizer, Alaska and Hawaii are not in the // map but Washington DC is and it's not a state (50 - 2 + 1) assertLabel("(49)", rules[3]); }
@Test public void testStatesMissingBboxSrs() throws Exception { runGetLegendGraphics( "wms?service=WMS&version=1.1.1&request=GetLegendGraphic&format=image/png" + "&layer=" + getLayerId(SF_STATES) + "&style=Population" + "&width=550&height=250" + "&legend_options=" + GetLegendGraphicRequest.COUNT_MATCHED_KEY + ":true"); assertEquals(1, ruleSets.size()); Rule[] rules = ruleSets.get(0); logLabels(rules); assertEquals(4, rules.length); assertLabel("2M - 4M (10)", rules[0]); assertLabel("< 2M (16)", rules[1]); assertLabel("> 4M (23)", rules[2]); // this is the rule for outline and text symbolizer, Alaska and Hawaii are not in the // map but Washington DC is and it's not a state (50 - 2 + 1) assertLabel("(49)", rules[3]); }
@Test public void testStatesCqlFilter() throws Exception { runGetLegendGraphics( "wms?service=WMS&version=1.1.1&request=GetLegendGraphic&format=image/png" + "&layer=" + getLayerId(SF_STATES) + "&style=Population&width=550&height=250&srs=EPSG:4326" // + "&bbox=" + "-130,24,-66,50" + "&legend_options=" + GetLegendGraphicRequest.COUNT_MATCHED_KEY + ":true" + "&CQL_FILTER=PERSONS < 2000000"); assertEquals(1, ruleSets.size()); Rule[] rules = ruleSets.get(0); logLabels(rules); assertEquals(4, rules.length); assertLabel("2M - 4M (0)", rules[0]); assertLabel("< 2M (16)", rules[1]); assertLabel("> 4M (0)", rules[2]); assertLabel("(16)", rules[3]); }
@Test public void testStatesFull() throws Exception { runGetLegendGraphics( "wms?service=WMS&version=1.1.1&request=GetLegendGraphic&format=image/png" + "&layer=" + getLayerId(SF_STATES) + "&style=Population&width=550&height=250&srs=EPSG:4326" // + "&bbox=" + "-130,24,-66,50" + "&legend_options=" + GetLegendGraphicRequest.COUNT_MATCHED_KEY + ":true"); assertEquals(1, ruleSets.size()); Rule[] rules = ruleSets.get(0); logLabels(rules); assertEquals(4, rules.length); assertLabel("2M - 4M (10)", rules[0]); assertLabel("< 2M (16)", rules[1]); assertLabel("> 4M (23)", rules[2]); // this is the rule for outline and text symbolizer, Alaska and Hawaii are not in the // map but Washington DC is and it's not a state (50 - 2 + 1) assertLabel("(49)", rules[3]); }
@Test public void testStatesElse() throws Exception { runGetLegendGraphics( "wms?service=WMS&version=1.1.1&request=GetLegendGraphic&format=image/png" + "&layer=" + getLayerId(SF_STATES) + "&style=PopulationElse&width=550&height=250&srs=EPSG:4326" // + "&bbox=" + "-130,24,-66,50" + "&legend_options=" + GetLegendGraphicRequest.COUNT_MATCHED_KEY + ":true"); assertEquals(1, ruleSets.size()); Rule[] rules = ruleSets.get(0); logLabels(rules); assertEquals(3, rules.length); assertLabel("2M - 4M (10)", rules[0]); assertLabel("< 2M (16)", rules[1]); assertLabel("Others (23)", rules[2]); }
@Test public void testCountOnGroup() throws Exception { String url = "wms?service=WMS&version=1.1.1&request=GetLegendGraphic&format=image/png" + "&layer=nature&width=100&height=100" + "&srs=epsg:4326&bbox=-0.002,-0.003,0.005,0.002" + "&legend_options=" + GetLegendGraphicRequest.COUNT_MATCHED_KEY + ":true"; runGetLegendGraphics(url); for (Rule[] rules : ruleSets) { logLabels(rules); } // two layers, one rule each assertEquals(2, ruleSets.size()); assertEquals(1, ruleSets.get(0).length); assertEquals(1, ruleSets.get(1).length); // boring case, the title is just title assertLabel("title (1)", ruleSets.get(0)[0]); assertLabel("title (1)", ruleSets.get(1)[0]); }
@Test public void testBasicPolygonsNoFeatures() throws Exception { runGetLegendGraphics( "wms?service=WMS&version=1.1.1&request=GetLegendGraphic" + "&layer=" + getLayerId(MockData.BASIC_POLYGONS) + "&style=" + "&format=image/png&SRS=EPSG%3A4326&WIDTH=256&HEIGHT=256&BBOX=30,0,40,10" + "&legend_options=" + GetLegendGraphicRequest.COUNT_MATCHED_KEY + ":true"); assertEquals(1, ruleSets.size()); Rule[] rules = ruleSets.get(0); assertEquals(1, rules.length); assertLabel("(0)", rules[0]); }
@Test public void testBasicPolygonsTwoFeatures() throws Exception { runGetLegendGraphics( "wms?service=WMS&version=1.1.1&request=GetLegendGraphic" + "&layer=" + getLayerId(MockData.BASIC_POLYGONS) + "&style=" + "&format=image/png&SRS=EPSG%3A4326&WIDTH=256&HEIGHT=256&BBOX=-2.4,1.4,0.4,4.2" + "&legend_options=" + GetLegendGraphicRequest.COUNT_MATCHED_KEY + ":true"); assertEquals(1, ruleSets.size()); Rule[] rules = ruleSets.get(0); assertEquals(1, rules.length); assertLabel("(2)", rules[0]); }
@Test public void testBasicPolygonsTwoFeaturesWms13() throws Exception { runGetLegendGraphics( "wms?service=WMS&version=1.3.0&request=GetLegendGraphic" + "&layer=" + getLayerId(MockData.BASIC_POLYGONS) + "&style=" + "&format=image/png&CRS=EPSG%3A4326&WIDTH=256&HEIGHT=256&BBOX=1.4,-2.4,4.2,0.4" + "&legend_options=" + GetLegendGraphicRequest.COUNT_MATCHED_KEY + ":true"); assertEquals(1, ruleSets.size()); Rule[] rules = ruleSets.get(0); assertEquals(1, rules.length); assertLabel("(2)", rules[0]); }
@Test public void testBasicPolygonsAllFeatures() throws Exception { runGetLegendGraphics( "wms?service=WMS&version=1.1.1&request=GetLegendGraphic&format=image/png" + "&layer=" + getLayerId(MockData.BASIC_POLYGONS) + "&style=" + "&SRS=EPSG%3A4326&WIDTH=256&HEIGHT=256&BBOX=-180,-90,180,90" + "&legend_options=" + GetLegendGraphicRequest.COUNT_MATCHED_KEY + ":true"); assertEquals(1, ruleSets.size()); Rule[] rules = ruleSets.get(0); assertEquals(1, rules.length); assertLabel("(3)", rules[0]); }
logLabels(rules); assertEquals(4, rules.length); assertLabel("2M - 4M (0)", rules[0]); assertLabel("< 2M (16)", rules[1]); assertLabel("> 4M (0)", rules[2]); assertLabel("(0)", rules[3]);
public void testScaleDependent(String bboxSpecification, String expectedLabel) throws Exception { // around 4k String requestURL = "wms?service=WMS&version=1.1.1&request=GetLegendGraphic&format=image/png" + "&layer=" + getLayerId(SF_STATES) + "&style=scaleDependent&width=20&height=20&srs=EPSG:4326" // + "&bbox=" + bboxSpecification + "&legend_options=" + GetLegendGraphicRequest.COUNT_MATCHED_KEY + ":true" + "&srcwidht=768&srcheight=300"; Map rawKvp = (Map) caseInsensitiveKvp(KvpUtils.parseQueryString(requestURL)); Map kvp = parseKvp(rawKvp); GetLegendGraphicKvpReader reader = new GetLegendGraphicKvpReader(getWMS()); GetLegendGraphicRequest request = reader.read(reader.createRequest(), kvp, rawKvp); // run legendProducer.buildLegendGraphic(request); this.lastRequest = request; assertEquals(1, ruleSets.size()); Rule[] rules = ruleSets.get(0); logLabels(rules); assertEquals(1, rules.length); assertLabel(expectedLabel, rules[0]); }