You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by am...@apache.org on 2021/05/27 14:15:16 UTC

[sis] branch geoapi-4.0 updated: chore(Feature): add a test for BBOX filter. Ensure usage of a CRS for whom no matching authority factory exists does not cause failure.

This is an automated email from the ASF dual-hosted git repository.

amanin pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new 23acea5  chore(Feature): add a test for BBOX filter. Ensure usage of a CRS for whom no matching authority factory exists does not cause failure.
23acea5 is described below

commit 23acea527ccab114ef6cbebf6ed408262fcc167f
Author: Alexis Manin <al...@geomatys.com>
AuthorDate: Thu May 27 16:15:02 2021 +0200

    chore(Feature): add a test for BBOX filter. Ensure usage of a CRS for whom no matching authority factory exists does not cause failure.
    
    This test has been added, because this kind of error has been seen on previous BBOX implementation in Geotoolkit project.
---
 .../org/apache/sis/filter/SpatialFunctionTest.java | 38 ++++++++++++++++++++++
 .../src/test/resources/io/wkt/extra_ESRI_CRS.txt   | 18 ++++++++++
 2 files changed, 56 insertions(+)

diff --git a/core/sis-feature/src/test/java/org/apache/sis/filter/SpatialFunctionTest.java b/core/sis-feature/src/test/java/org/apache/sis/filter/SpatialFunctionTest.java
index 2921b66..381086c 100644
--- a/core/sis-feature/src/test/java/org/apache/sis/filter/SpatialFunctionTest.java
+++ b/core/sis-feature/src/test/java/org/apache/sis/filter/SpatialFunctionTest.java
@@ -16,6 +16,15 @@
  */
 package org.apache.sis.filter;
 
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
+import java.util.stream.Collectors;
+import org.apache.sis.geometry.Envelope2D;
+import org.apache.sis.referencing.CRS;
+import org.apache.sis.referencing.IdentifiedObjects;
+import org.apache.sis.referencing.crs.HardCodedCRS;
 import org.opengis.filter.FilterFactory2;
 import org.opengis.filter.spatial.BBOX;
 import org.opengis.filter.spatial.Beyond;
@@ -36,6 +45,7 @@ import org.locationtech.jts.geom.Coordinate;
 import org.locationtech.jts.geom.Geometry;
 import org.locationtech.jts.geom.GeometryFactory;
 import org.locationtech.jts.geom.LinearRing;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
 
 import static org.apache.sis.test.Assert.assertFalse;
 import static org.apache.sis.test.Assert.assertSerializedEquals;
@@ -143,6 +153,34 @@ public final strictfp class SpatialFunctionTest extends TestCase {
     }
 
     @Test
+    public void bbox_filter_does_not_fail_on_esri_crs() throws Exception {
+        final Coordinate[] coords = new Coordinate[3];
+        coords[0] = new Coordinate(4, 2);
+        coords[1] = new Coordinate(7, 5);
+        coords[2] = new Coordinate(9, 3);
+        final Geometry esriGeom = GF.createLineString(coords);
+        final String crsWkt;
+        try (
+                InputStream is = SpatialFunctionTest.class.getResourceAsStream("/io/wkt/extra_ESRI_CRS.txt");
+                BufferedReader reader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))
+        ) {
+            crsWkt = reader.lines().collect(Collectors.joining(System.lineSeparator()));
+        }
+        final CoordinateReferenceSystem esriCRS = CRS.fromWKT(crsWkt);
+        esriGeom.setUserData(esriCRS);
+        esriGeom.setSRID(Integer.parseInt(esriCRS.getIdentifiers().iterator().next().getCode()));
+
+        Envelope2D envelope = new Envelope2D(esriCRS, 0, 0, 10, 10);
+        BBOX filter = FF.bbox(FF.literal(esriGeom), envelope);
+        assertTrue(filter.evaluate(null));
+
+        // Ensure no error is raised, even if a reprojection is involved
+        envelope = new Envelope2D(HardCodedCRS.WGS84, 0, 0, 10, 10);
+        filter = FF.bbox(FF.literal(esriGeom), envelope);
+        filter.evaluate(null);
+    }
+
+    @Test
     public void testBeyond() {
         //we can not test units while using jts geometries
 
diff --git a/core/sis-feature/src/test/resources/io/wkt/extra_ESRI_CRS.txt b/core/sis-feature/src/test/resources/io/wkt/extra_ESRI_CRS.txt
new file mode 100644
index 0000000..69e744c
--- /dev/null
+++ b/core/sis-feature/src/test/resources/io/wkt/extra_ESRI_CRS.txt
@@ -0,0 +1,18 @@
+ProjectedCRS["RGF_1993_Lambert_93 (deprecated)",
+  BaseGeodCRS["RGF93",
+    Datum["Reseau_Geodesique_Francais_1993",
+      Ellipsoid["GRS 1980", 6378137.0, 298.257222101]],
+    Unit["degree", 0.017453292519943295]],
+  Conversion["Lambert_Conformal_Conic_2SP",
+    Method["Lambert Conic Conformal (2SP)"],
+    Parameter["Latitude of false origin", 46.5],
+    Parameter["Longitude of false origin", 3.0],
+    Parameter["Latitude of 1st standard parallel", 44.0],
+    Parameter["Latitude of 2nd standard parallel", 49.0],
+    Parameter["Easting at false origin", 700000.0],
+    Parameter["Northing at false origin", 6600000.0]],
+  CS[Cartesian, 2],
+    Axis["Easting (E)", east],
+    Axis["Northing (N)", north],
+    Unit["metre", 1],
+  Id["ESRI", 102110, Citation["ESRI:ArcGIS"]]]
\ No newline at end of file