@Test public void testGetFeatureCountMaxFeatures() throws Exception { // check if maxFeatures doesn't affect totalFeatureCount; set Filter and maxFeatures String out3 = getAsString( "wfs?request=GetFeature&version=1.0.0&typename=sf:PrimitiveGeoFeature&maxfeatures=1&outputformat=" + JSONType.json + "&featureid=PrimitiveGeoFeature.f001,PrimitiveGeoFeature.f002"); JSONObject rootObject3 = JSONObject.fromObject(out3); assertEquals(rootObject3.get("totalFeatures"), 2); }
@Test public void testGetFeatureCountNoFilter() throws Exception { // request without filter String out = getAsString( "wfs?request=GetFeature&version=1.0.0&typename=sf:PrimitiveGeoFeature&maxfeatures=10&outputformat=" + JSONType.json); JSONObject rootObject = JSONObject.fromObject(out); assertEquals(rootObject.get("totalFeatures"), 5); }
@Test public void testGetFeatureCountMultipleFeatureTypes() throws Exception { // request with multiple featureTypes and Filter String out4 = getAsString( "wfs?request=GetFeature&version=1.0.0&typename=sf:PrimitiveGeoFeature,sf:AggregateGeoFeature&outputformat=" + JSONType.json + "&featureid=PrimitiveGeoFeature.f001,PrimitiveGeoFeature.f002,AggregateGeoFeature.f009"); JSONObject rootObject4 = JSONObject.fromObject(out4); assertEquals(rootObject4.get("totalFeatures"), 3); }
@Test public void testGetFeatureCountFilter() throws Exception { // request with filter (featureid=PrimitiveGeoFeature.f001) String out2 = getAsString( "wfs?request=GetFeature&version=1.0.0&typename=sf:PrimitiveGeoFeature&maxfeatures=10&outputformat=" + JSONType.json + "&featureid=PrimitiveGeoFeature.f001"); JSONObject rootObject2 = JSONObject.fromObject(out2); assertEquals(rootObject2.get("totalFeatures"), 1); }
getAsString( "wfs?request=GetFeature&version=2.0.0&typename=sf:PrimitiveGeoFeature&count=10&outputformat=" + JSONType.json); getAsString( "wfs?request=GetFeature&version=2.0.0&typename=sf:PrimitiveGeoFeature&count=10&outputformat=" + JSONType.json getAsString( "wfs?request=GetFeature&version=2.0.0&typename=sf:PrimitiveGeoFeature&count=1&outputformat=" + JSONType.json getAsString( "wfs?request=GetFeature&version=2.0.0&typename=sf:PrimitiveGeoFeature,sf:AggregateGeoFeature&outputformat=" + JSONType.json
@Test public void testGeometryCollection() throws Exception { String out = getAsString( "wfs?request=GetFeature&version=1.0.0&typename=sf:AggregateGeoFeature&maxfeatures=3&outputformat=" + JSONType.json); JSONObject rootObject = JSONObject.fromObject(out); assertEquals(rootObject.get("type"), "FeatureCollection"); JSONArray featureCol = rootObject.getJSONArray("features"); JSONObject aFeature = featureCol.getJSONObject(1); JSONObject aPropeties = aFeature.getJSONObject("properties"); JSONObject aGeometry = aPropeties.getJSONObject("multiCurveProperty"); assertEquals(aGeometry.getString("type"), "MultiLineString"); JSONArray geomArray = aGeometry.getJSONArray("coordinates"); geomArray = geomArray.getJSONArray(0); geomArray = geomArray.getJSONArray(0); assertEquals(geomArray.getString(0), "55.174"); CoordinateReferenceSystem expectedCrs = getCatalog() .getLayerByName(getLayerId(SystemTestData.AGGREGATEGEOFEATURE)) .getResource() .getCRS(); JSONObject aCRS = rootObject.getJSONObject("crs"); assertThat(aCRS.getString("type"), equalTo("name")); assertThat(aCRS, encodesCRS(expectedCrs)); }
getAsString( "wfs?request=GetFeature&version=1.0.0&typename=sf:AggregateGeoFeature&maxfeatures=3&outputformat=" + JSONType.json);
@Test public void getGetFeatureWithPagingFirstPage() throws Exception { // request with paging String out = getAsString( "wfs?request=GetFeature&version=2.0.0&typename=sf:PrimitiveGeoFeature" + "&startIndex=0&&count=2&outputformat=" + JSONType.json); JSONObject rootObject = JSONObject.fromObject(out); // print(rootObject); assertEquals(rootObject.get("totalFeatures"), 5); assertEquals(rootObject.get("numberMatched"), 5); assertEquals(rootObject.get("numberReturned"), 2); JSONArray links = rootObject.getJSONArray("links"); assertNotNull(links); assertEquals(1, links.size()); JSONObject link = links.getJSONObject(0); assertLink( link, "next page", "application/json", "next", "http://localhost:8080/geoserver" + "/wfs?TYPENAME=sf%3APrimitiveGeoFeature&REQUEST=GetFeature" + "&OUTPUTFORMAT=application%2Fjson&VERSION=2.0.0&COUNT=2&STARTINDEX=2"); }
@Test public void getGetFeatureWithPagingLastPage() throws Exception { // request with paging String out = getAsString( "wfs?request=GetFeature&version=2.0.0&typename=sf:PrimitiveGeoFeature" + "&startIndex=4&&count=2&outputformat=" + JSONType.json); JSONObject rootObject = JSONObject.fromObject(out); print(rootObject); assertEquals(rootObject.get("totalFeatures"), 5); assertEquals(rootObject.get("numberMatched"), 5); assertEquals(rootObject.get("numberReturned"), 1); JSONArray links = rootObject.getJSONArray("links"); assertNotNull(links); assertEquals(1, links.size()); JSONObject prev = links.getJSONObject(0); assertLink( prev, "previous page", "application/json", "previous", "http://localhost:8080/geoserver" + "/wfs?TYPENAME=sf%3APrimitiveGeoFeature&REQUEST=GetFeature" + "&OUTPUTFORMAT=application%2Fjson&VERSION=2.0.0&COUNT=2&STARTINDEX=2"); }
getAsString( "wfs?request=GetFeature&version=2.0.0&typename=sf:PrimitiveGeoFeature" + "&startIndex=2&&count=2&outputformat="