use of io.arlas.server.core.model.request.MultiValueFilter in project ARLAS-server by gisaia.
the class AbstractFilteredTest method testMixedFilter.
@Test
public void testMixedFilter() throws Exception {
// valid bbox from WFS OGC SPEC = lower longitude , lower latitude , upper longitude , upper latitude
// valid bbox for ARLAS classic bbox = lat top, long left, lat bottom, long right
request.filter.f = // "job:eq:Architect"
Arrays.asList(// "job:eq:Architect"
new MultiValueFilter<>(new Expression("params.job", OperatorEnum.eq, "Architect")), new MultiValueFilter<>(new Expression("params.startdate", OperatorEnum.range, "[1009799<2000000]")), new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.within, "-50,-50,50,50")), new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.within, "-30,-30,30,30")), new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "POLYGON((-20 20, 20 20, 20 -20, -20 -20, -20 20))")));
Filter filterHeader = new Filter();
filterHeader.f = Arrays.asList(new MultiValueFilter<>(new Expression("params.startdate", OperatorEnum.range, "[0<1009801]")), new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.notwithin, "20,-50,60,50")), new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.notwithin, "POLYGON((-50 50,-20 50, -20 -50, -50 -50,-50 50))")), new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.notintersects, "POLYGON((-30 -10,30 10, 30 -30, -30 -30,-30 -10))")));
handleComplexFilter(givenFilterableRequestParams().header("partition-filter", objectMapper.writeValueAsString(filterHeader)).header("column-filter", "params.job,params.city,params.country").param("f", new Expression("params.job", OperatorEnum.eq, "Architect").toString()).param("f", new Expression("params.startdate", OperatorEnum.range, "[1009799<2000000]").toString()).param("f", request.filter.f.get(2).get(0).toString()).param("f", request.filter.f.get(3).get(0).toString()).param("f", request.filter.f.get(4).get(0).toString()).when().get(getUrlPath("geodata")).then());
handleComplexFilter(post(request, "partition-filter", objectMapper.writeValueAsString(filterHeader), "column-filter", "params.job,params.city,params.country"));
filterHeader.f = Arrays.asList(new MultiValueFilter<>(new Expression("params.job", OperatorEnum.eq, "Actor")));
handleNotMatchingRequest(givenFilterableRequestParams().header("partition-filter", objectMapper.writeValueAsString(filterHeader)).header("column-filter", // an empty column filter is not considered
"").param("f", (new Expression("params.job", OperatorEnum.eq, "Architect")).toString()).when().get(getUrlPath("geodata")).then());
handleNotMatchingRequest(givenFilterableRequestBody().body(request).header("partition-filter", objectMapper.writeValueAsString(filterHeader)).header("column-filter", // an empty column filter is not considered
"").when().post(getUrlPath("geodata")).then());
request.filter = new Filter();
}
use of io.arlas.server.core.model.request.MultiValueFilter in project ARLAS-server by gisaia.
the class AbstractFilteredTest method testGintersectFilter.
@Test
public void testGintersectFilter() throws Exception {
/**
* west < east bbox
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "-2,-2,2,2")));
handleMatchingGeometryFilter(post(request), 1, everyItem(equalTo("0,0")));
handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 1, everyItem(equalTo("0,0")));
handleMatchingGeometryFilter(header(request.filter), 1, everyItem(equalTo("0,0")));
/**
* west < east bbox
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "-170,-2,170,2")));
handleMatchingGeometryFilter(post(request), 35, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 35, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(header(request.filter), 35, everyItem(startsWith("0,")));
/**
* west > east bbox
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "2,-2,-2,2")));
handleMatchingGeometryFilter(post(request), 34, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 34, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(header(request.filter), 34, everyItem(startsWith("0,")));
/**
* west > east bbox
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "170,-2,-170,2")));
handleMatchingGeometryFilter(post(request), 2, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 2, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(header(request.filter), 2, everyItem(startsWith("0,")));
/**
* clock-wise WKT
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "POLYGON((-2 -2, -2 2, 2 2, 2 -2, -2 -2))")));
handleMatchingGeometryFilter(post(request), 1, everyItem(equalTo("0,0")));
handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 1, everyItem(equalTo("0,0")));
handleMatchingGeometryFilter(header(request.filter), 1, everyItem(equalTo("0,0")));
/**
* clock-wise WKT
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "POLYGON((-170 -2, -170 2, 170 2, 170 -2, -170 -2))")));
handleMatchingGeometryFilter(post(request), 35, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 35, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(header(request.filter), 35, everyItem(startsWith("0,")));
/**
* counter clock-wise WKT
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "POLYGON((-170 -2, 170 -2, 170 2, -170 2, -170 -2))")));
handleMatchingGeometryFilter(post(request), 2, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 2, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(header(request.filter), 2, everyItem(startsWith("0,")));
/**
* counter clock-wise WKT
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "POLYGON((-2 -2, 2 -2, 2 2,-2 2, -2 -2))")));
handleMatchingGeometryFilter(post(request), 34, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 34, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(header(request.filter), 34, everyItem(startsWith("0,")));
/**
* clock-wise WKT
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "POLYGON((-330 -2, -330 -1, -290 -1, -290 2, -15 2, -15 1, -40 1, -40 -2, -330 -2))")));
handleMatchingGeometryFilter(post(request), 31, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 31, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(header(request.filter), 31, everyItem(startsWith("0,")));
/**
* counter clock-wise WKT
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "POLYGON((-330 -2, -40 -2, -40 1, -15 1, -15 2, -290 2, -290 -1, -330 -1, -330 -2))")));
handleMatchingGeometryFilter(post(request), 12, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 12, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(header(request.filter), 12, everyItem(startsWith("0,")));
/**
* clock-wise WKT
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "POLYGON((10 -2, 10 2, 350 2, 350 0, 300 0, 350 -2, 10 -2))")));
handleMatchingGeometryFilter(post(request), 34, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 34, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(header(request.filter), 34, everyItem(startsWith("0,")));
/**
* counter clock-wise WKT
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "POLYGON((10 -2, 350 -2, 300 0, 350 0, 350 2, 10 2, 10 -2))")));
handleMatchingGeometryFilter(post(request), 8, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 8, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(header(request.filter), 8, everyItem(startsWith("0,")));
/**
* clock-wise WKT with with a point longitude > 180
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "POLYGON((-130 -2, -130 2, 220 2, 220 -2, -130 -2))")));
handleMatchingGeometryFilter(post(request), 35, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 35, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(header(request.filter), 35, everyItem(startsWith("0,")));
/**
* counter clock-wise WKT with a point longitude > 180
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "POLYGON((-130 -2, 220 -2, 220 2, -130 2, -130 -2))")));
handleMatchingGeometryFilter(post(request), 2, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 2, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(header(request.filter), 2, everyItem(startsWith("0,")));
/**
* clock-wise WKT
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "POLYGON((0 1,1 1,1 -1,0 -1,0 1))")));
handleMatchingGeometryFilter(post(request), 1, everyItem(equalTo("0,0")));
handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 1, everyItem(equalTo("0,0")));
handleMatchingGeometryFilter(header(request.filter), 1, everyItem(equalTo("0,0")));
/**
* clock-wise WKT
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "POLYGON((2 2,2 3,3 3,3 2,2 2))")));
handleNotMatchingGintersectFilter(post(request));
handleNotMatchingGintersectFilter(get("f", request.filter.f.get(0).get(0).toString()));
handleNotMatchingGintersectFilter(header(request.filter));
/**
* WKT Linestring that crosses the dateline
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "LINESTRING(50 0, 340 0)")));
handleMatchingGeometryFilter(post(request), 29, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 29, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(header(request.filter), 29, everyItem(startsWith("0,")));
/**
* WKT Linestring that doesn't cross the dateline
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "LINESTRING(50 0, -20 0)")));
handleMatchingGeometryFilter(post(request), 8, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 8, everyItem(startsWith("0,")));
handleMatchingGeometryFilter(header(request.filter), 8, everyItem(startsWith("0,")));
/**
* west < east bbox
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "-12,-12,12,12")), new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "0,-1,1,1")));
handleMatchingGeometryFilter(post(request), 1, everyItem(equalTo("0,0")));
handleMatchingGeometryFilter(get(Arrays.asList(new ImmutablePair<>("f", request.filter.f.get(0).get(0).toString()), new ImmutablePair<>("f", request.filter.f.get(1).get(0).toString()))), 1, everyItem(equalTo("0,0")));
handleMatchingGeometryFilter(header(request.filter), 1, everyItem(equalTo("0,0")));
/**
* west < east bbox along with a clock-wise WKT
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(Arrays.asList(new Expression("geo_params.geometry", OperatorEnum.intersects, "-12,-12,12,12"), new Expression("geo_params.geometry", OperatorEnum.intersects, "POLYGON((0 1,1 1,1 -1,0 -1,0 1))"))));
handleMatchingGeometryFilter(post(request), 9, everyItem(notNullValue()));
handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString() + ";" + request.filter.f.get(0).get(1).toString()), 9, everyItem(notNullValue()));
handleMatchingGeometryFilter(header(request.filter), 9, everyItem(notNullValue()));
/**
* clock-wise wkt
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.notintersects, "POLYGON((180 90, 180 -70, 160 -70, 160 -90,-180 -90,-180 90,180 90))")));
handleMatchingGeometryFilter(post(request), 1, everyItem(equalTo("-80,170")));
handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 1, everyItem(equalTo("-80,170")));
handleMatchingGeometryFilter(header(request.filter), 1, everyItem(equalTo("-80,170")));
/**
* counter clock-wise WKT
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.notintersects, "POLYGON((-2 -2, 2 -2, 2 2,-2 2, -2 -2))")));
handleMatchingGeometryFilter(post(request), 561, everyItem(notNullValue()));
handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 561, everyItem(notNullValue()));
handleMatchingGeometryFilter(header(request.filter), 561, everyItem(notNullValue()));
/**
* clock-wise wkt
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.notintersects, "POLYGON((180 90,180 -90,-180 -90,-180 90,180 90))")));
handleNotMatchingNotGintersectFilter(post(request));
handleNotMatchingNotGintersectFilter(get("f", request.filter.f.get(0).get(0).toString()));
handleNotMatchingNotGintersectFilter(header(request.filter));
/**
* counter clock-wise WKT
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.notintersects, "POLYGON((160 -2, 160 2, -160 2, -160 -2, 160 -2))")));
handleMatchingGeometryFilter(post(request), 591, everyItem(notNullValue()));
handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString()), 591, notNullValue());
handleMatchingGeometryFilter(header(request.filter), 591, everyItem(notNullValue()));
/**
* west < east bbox along with a clock-wise WKT
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.notintersects, "-12,-12,12,12")), new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.notintersects, "POLYGON((180 90, 180 -70, 160 -70, 160 -90,-180 -90,-180 90,180 90))")));
handleMatchingGeometryFilter(post(request), 1, everyItem(equalTo("-80,170")));
handleMatchingGeometryFilter(get(Arrays.asList(new ImmutablePair<>("notintersects", request.filter.f.get(0).get(0).toString()), new ImmutablePair<>("f", request.filter.f.get(1).get(0).toString()))), 1, everyItem(equalTo("-80,170")));
handleMatchingGeometryFilter(header(request.filter), 1, everyItem(equalTo("-80,170")));
/**
* clock-wise wkts
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(Arrays.asList(new Expression("geo_params.geometry", OperatorEnum.notintersects, "POLYGON((12 12,12 -12,-12 -12,-12 12,12 12))"), new Expression("geo_params.geometry", OperatorEnum.notintersects, "POLYGON((180 90, 180 -70, 160 -70, 160 -90,-180 -90,-180 90,180 90))"))));
handleMatchingGeometryFilter(post(request), 586, everyItem(notNullValue()));
handleMatchingGeometryFilter(get("f", request.filter.f.get(0).get(0).toString() + ";" + request.filter.f.get(0).get(1).toString()), 586, everyItem(notNullValue()));
handleMatchingGeometryFilter(header(request.filter), 586, everyItem(notNullValue()));
/**
* clock-wise wkts
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "POLYGON((10 10,10 -10,-10 -10,-10 10,10 10))")), new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.notintersects, "POLYGON((10 10,10 -10,0 -10,0 10,10 10))")));
handleMatchingGeometryFilter(post(request), 3, hasItems("10,-10", "0,-10", "-10,-10"));
handleMatchingGeometryFilter(givenFilterableRequestParams().param("f", request.filter.f.get(0).get(0).toString()).param("f", request.filter.f.get(1).get(0).toString()).when().get(getUrlPath("geodata")).then(), 3, hasItems("10,-10", "0,-10", "-10,-10"));
handleMatchingGeometryFilter(header(request.filter), 3, hasItems("10,-10", "0,-10", "-10,-10"));
/**
* clock-wise wkts
*/
request.filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.intersects, "POLYGON((10 10,10 -10,-10 -10,-10 10,10 10))")), new MultiValueFilter<>(new Expression("geo_params.geometry", OperatorEnum.notintersects, "POLYGON((11 11,11 -11,-11 -11,-11 11,11 11))")));
handleNotMatchingGintersectComboFilter(post(request));
handleNotMatchingGintersectComboFilter(givenFilterableRequestParams().param("f", request.filter.f.get(0).get(0).toString()).param("f", request.filter.f.get(1).get(0).toString()).when().get(getUrlPath("geodata")).then());
handleNotMatchingGintersectComboFilter(header(request.filter));
request.filter.f = null;
}
use of io.arlas.server.core.model.request.MultiValueFilter in project ARLAS-server by gisaia.
the class AbstractFilteredTest method testNotFoundCollection.
// ----------------------------------------------------------------
// ------------------------- ERROR TESTS --------------------------
// ----------------------------------------------------------------
@Test
public void testNotFoundCollection() throws Exception {
request.filter.f = // "job:eq:" + DataSetTool.jobs[0]
Arrays.asList(// "job:eq:" + DataSetTool.jobs[0]
new MultiValueFilter<>(new Expression("params.job", OperatorEnum.eq, DataSetTool.jobs[0])), new MultiValueFilter<>(new Expression("params.startdate", OperatorEnum.range, "[1000000<2000000]")), new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.within, "10,10,-10,-10")), new MultiValueFilter<>(new Expression("geo_params.centroid", OperatorEnum.notwithin, "5,5,-5,-5")));
handleNotFoundCollection(givenFilterableRequestBody().body(request).when().post(getUrlPath("unknowncollection")).then());
handleNotFoundCollection(givenFilterableRequestParams().param("f", request.filter.f).when().get(getUrlPath("unknowncollection")).then());
request.filter.f = null;
}
use of io.arlas.server.core.model.request.MultiValueFilter in project ARLAS-server by gisaia.
the class WFSServiceIT method testGetFeatureHeaderFilter.
@Test
public void testGetFeatureHeaderFilter() throws Exception {
Filter filter = new Filter();
filter.f = // "job:eq:Architect"
Arrays.asList(// "job:eq:Architect"
new MultiValueFilter<>(new Expression("params.job", OperatorEnum.like, "Architect")), new MultiValueFilter<>(new Expression("params.startdate", OperatorEnum.range, "[1009799<1009801]")));
handleGetFeatureHeaderFilter(get(Arrays.asList(new ImmutablePair<>("SERVICE", "WFS"), new ImmutablePair<>("VERSION", "2.0.0"), new ImmutablePair<>("COUNT", "1000"), new ImmutablePair<>("REQUEST", "GetFeature")), filter));
}
use of io.arlas.server.core.model.request.MultiValueFilter in project ARLAS-server by gisaia.
the class WFSServiceIT method testGetPropertyValueHeaderFilter.
@Test
public void testGetPropertyValueHeaderFilter() throws Exception {
Filter filter = new Filter();
filter.f = Arrays.asList(new MultiValueFilter<>(new Expression("params.job", OperatorEnum.like, "Architect")), new MultiValueFilter<>(new Expression("params.startdate", OperatorEnum.range, "[1009799<1009801]")));
handleGetPropertyValueHeaderFilter(get(Arrays.asList(new ImmutablePair<>("SERVICE", "WFS"), new ImmutablePair<>("VERSION", "2.0.0"), new ImmutablePair<>("COUNT", "1000"), new ImmutablePair<>("REQUEST", "GetPropertyValue"), new ImmutablePair<>("valuereference", "params.job")), filter));
}
Aggregations