You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2019/05/08 11:51:28 UTC
[jena] 07/08: JENA-664: Java line endings
This is an automated email from the ASF dual-hosted git repository.
andy pushed a commit to branch geosparql
in repository https://gitbox.apache.org/repos/asf/jena.git
commit 0df9471d48f9d2d0396175ab8a8fc1af1725b9bc
Author: Andy Seaborne <an...@apache.org>
AuthorDate: Wed May 8 12:44:40 2019 +0100
JENA-664: Java line endings
---
.../org/apache/jena/fuseki/geosparql/Main.java | 144 +-
.../org/apache/jena/fuseki/geosparql/MainTest.java | 248 +-
.../fuseki/geosparql/cli/RDFFileParameterTest.java | 202 +-
.../fuseki/geosparql/cli/TabFileParameterTest.java | 200 +-
.../geosparql/configuration/GeoSPARQLConfig.java | 554 ++---
.../geo/topological/GenericPropertyFunction.java | 654 ++---
.../geof/topological/GenericFilterFunction.java | 162 +-
.../filter_functions/egenhofer/EhContainsFF.java | 108 +-
.../filter_functions/egenhofer/EhCoveredByFF.java | 106 +-
.../filter_functions/egenhofer/EhCoversFF.java | 106 +-
.../filter_functions/egenhofer/EhDisjointFF.java | 106 +-
.../filter_functions/egenhofer/EhEqualsFF.java | 106 +-
.../filter_functions/egenhofer/EhInsideFF.java | 106 +-
.../filter_functions/egenhofer/EhMeetFF.java | 106 +-
.../filter_functions/egenhofer/EhOverlapFF.java | 106 +-
.../filter_functions/rcc8/RccDisconnectedFF.java | 106 +-
.../filter_functions/rcc8/RccEqualsFF.java | 106 +-
.../rcc8/RccExternallyConnectedFF.java | 106 +-
.../rcc8/RccNonTangentialProperPartFF.java | 106 +-
.../rcc8/RccNonTangentialProperPartInverseFF.java | 106 +-
.../rcc8/RccPartiallyOverlappingFF.java | 108 +-
.../rcc8/RccTangentialProperPartFF.java | 106 +-
.../rcc8/RccTangentialProperPartInverseFF.java | 106 +-
.../simple_features/SfContainsFF.java | 106 +-
.../simple_features/SfCrossesFF.java | 104 +-
.../simple_features/SfDisjointFF.java | 104 +-
.../simple_features/SfEqualsFF.java | 108 +-
.../simple_features/SfIntersectsFF.java | 104 +-
.../simple_features/SfOverlapsFF.java | 104 +-
.../simple_features/SfTouchesFF.java | 104 +-
.../simple_features/SfWithinFF.java | 104 +-
.../geosparql/implementation/DimensionInfo.java | 432 ++--
.../geosparql/implementation/GeometryReverse.java | 452 ++--
.../geosparql/implementation/GeometryWrapper.java | 2496 ++++++++++----------
.../geosparql/implementation/UnitsOfMeasure.java | 448 ++--
.../implementation/index/GeometryLiteralIndex.java | 324 +--
.../index/GeometryTransformIndex.java | 318 +--
.../implementation/index/QueryRewriteIndex.java | 602 ++---
.../EgenhoferIntersectionPattern.java | 94 +-
.../RCC8IntersectionPattern.java | 84 +-
.../SimpleFeaturesIntersectionPattern.java | 56 +-
.../jts/CustomCoordinateSequence.java | 1138 ++++-----
.../jts/CustomCoordinateSequenceFactory.java | 114 +-
.../implementation/parsers/wkt/WKTReader.java | 728 +++---
.../implementation/parsers/wkt/WKTWriter.java | 580 ++---
.../implementation/registry/SRSRegistry.java | 280 +--
.../geosparql/implementation/vocabulary/Geo.java | 348 +--
.../geosparql/implementation/vocabulary/Geof.java | 164 +-
.../jena/geosparql/spatial/CardinalDirection.java | 52 +-
.../spatial/filter_functions/EqualsFF.java | 108 +-
.../GenericGeometryPropertyFunctionTest.java | 280 +--
.../topological/GenericPropertyFunctionTest.java | 1172 ++++-----
.../egenhofer/EhContainsPFTest.java | 278 +--
.../egenhofer/EhCoveredByPFTest.java | 282 +--
.../egenhofer/EhCoversPFTest.java | 226 +-
.../egenhofer/EhDisjointPFTest.java | 278 +--
.../egenhofer/EhEqualsPFTest.java | 404 ++--
.../egenhofer/EhInsidePFTest.java | 338 +--
.../property_functions/egenhofer/EhMeetPFTest.java | 282 +--
.../egenhofer/EhOverlapPFTest.java | 260 +-
.../CoordinateDimensionPFTest.java | 214 +-
.../geometry_property/DimensionPFTest.java | 188 +-
.../geometry_property/IsEmptyPFTest.java | 162 +-
.../geometry_property/IsSimplePFTest.java | 162 +-
.../geometry_property/IsValidPFTest.java | 162 +-
.../geometry_property/SpatialDimensionPFTest.java | 214 +-
.../rcc8/RccDisconnectedPFTest.java | 168 +-
.../property_functions/rcc8/RccEqualsPFTest.java | 236 +-
.../rcc8/RccExternallyConnectedPFTest.java | 166 +-
.../RccNonTangentialProperPartInversePFTest.java | 166 +-
.../rcc8/RccNonTangentialProperPartPFTest.java | 166 +-
.../rcc8/RccPartiallyOverlappingPFTest.java | 164 +-
.../rcc8/RccTangentialProperPartInversePFTest.java | 168 +-
.../rcc8/RccTangentialProperPartPFTest.java | 168 +-
.../simple_features/SfContainsPFTest.java | 278 +--
.../simple_features/SfCrossesPFTest.java | 344 +--
.../simple_features/SfDisjointPFTest.java | 278 +--
.../simple_features/SfEqualsPFTest.java | 404 ++--
.../simple_features/SfIntersectsPFTest.java | 278 +--
.../simple_features/SfOverlapsPFTest.java | 282 +--
.../simple_features/SfTouchesPFTest.java | 280 +--
.../simple_features/SfWithinPFTest.java | 278 +--
.../filter_functions/BoundaryFFTest.java | 164 +-
.../filter_functions/BufferFFTest.java | 360 +--
.../filter_functions/ConvexHullFFTest.java | 160 +-
.../filter_functions/DifferenceFFTest.java | 136 +-
.../filter_functions/DistanceFFTest.java | 172 +-
.../filter_functions/EnvelopFFTest.java | 186 +-
.../filter_functions/GetSRIDFFTest.java | 162 +-
.../filter_functions/IntersectionFFTest.java | 192 +-
.../SymmetricDifferenceFFTest.java | 136 +-
.../filter_functions/UnionFFTest.java | 136 +-
.../egenhofer/EhContainsFFTest.java | 586 ++---
.../egenhofer/EhCoveredByFFTest.java | 590 ++---
.../filter_functions/egenhofer/EhCoversFFTest.java | 532 ++---
.../egenhofer/EhDisjointFFTest.java | 584 ++---
.../filter_functions/egenhofer/EhEqualsFFTest.java | 640 ++---
.../filter_functions/egenhofer/EhInsideFFTest.java | 644 ++---
.../filter_functions/egenhofer/EhMeetFFTest.java | 588 ++---
.../egenhofer/EhOverlapFFTest.java | 566 ++---
.../CoordinateDimensionFFTest.java | 212 +-
.../geometry_property/DimensionFFTest.java | 186 +-
.../geometry_property/IsEmptyFFTest.java | 160 +-
.../geometry_property/IsSimpleFFTest.java | 160 +-
.../geometry_property/IsValidFFTest.java | 160 +-
.../geometry_property/SpatialDimensionFFTest.java | 212 +-
.../rcc8/RccDisconnectedFFTest.java | 476 ++--
.../filter_functions/rcc8/RccEqualsFFTest.java | 474 ++--
.../rcc8/RccExternallyConnectedFFTest.java | 472 ++--
.../rcc8/RccNonTangentialProperPartFFTest.java | 472 ++--
.../RccNonTangentialProperPartInverseFFTest.java | 492 ++--
.../rcc8/RccPartiallyOverlappingFFTest.java | 472 ++--
.../rcc8/RccTangentialProperPartFFTest.java | 474 ++--
.../rcc8/RccTangentialProperPartInverseFFTest.java | 492 ++--
.../simple_features/SfContainsFFTest.java | 586 ++---
.../simple_features/SfCrossesFFTest.java | 650 ++---
.../simple_features/SfDisjointFFTest.java | 584 ++---
.../simple_features/SfEqualsFFTest.java | 640 ++---
.../simple_features/SfIntersectsFFTest.java | 584 ++---
.../simple_features/SfOverlapsFFTest.java | 588 ++---
.../simple_features/SfTouchesFFTest.java | 586 ++---
.../simple_features/SfWithinFFTest.java | 584 ++---
.../implementation/GeometryReverseTest.java | 586 ++---
.../implementation/UnitsOfMeasureTest.java | 606 ++---
.../datatype/GeometryDatatypeTest.java | 280 +--
.../implementation/jts/GeometryTransformTest.java | 220 +-
.../implementation/parsers/gml/GMLReaderTest.java | 1486 ++++++------
.../implementation/parsers/wkt/WKTReaderTest.java | 994 ++++----
.../implementation/parsers/wkt/WKTWriterTest.java | 836 +++----
.../implementation/registry/SRSRegistryTest.java | 278 +--
.../jena/geosparql/spatial/SearchEnvelopeTest.java | 756 +++---
.../geosparql/spatial/SpatialIndexTestData.java | 224 +-
.../filter_functions/ConvertLatLonFFTest.java | 286 +--
.../spatial/filter_functions/EqualsFFTest.java | 640 ++---
.../spatial/property_functions/EqualsPFTest.java | 404 ++--
.../nearby/NearbyGeomPFTest.java | 896 +++----
.../property_functions/nearby/NearbyPFTest.java | 812 +++----
137 files changed, 23900 insertions(+), 23900 deletions(-)
diff --git a/jena-fuseki-geosparql/src/main/java/org/apache/jena/fuseki/geosparql/Main.java b/jena-fuseki-geosparql/src/main/java/org/apache/jena/fuseki/geosparql/Main.java
index 5ba4ea4..68dcd95 100644
--- a/jena-fuseki-geosparql/src/main/java/org/apache/jena/fuseki/geosparql/Main.java
+++ b/jena-fuseki-geosparql/src/main/java/org/apache/jena/fuseki/geosparql/Main.java
@@ -1,72 +1,72 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.fuseki.geosparql;
-
-import com.beust.jcommander.JCommander;
-import java.lang.invoke.MethodHandles;
-import java.util.Arrays;
-import org.apache.jena.geosparql.configuration.SrsException;
-import org.apache.jena.geosparql.spatial.SpatialIndexException;
-import org.apache.jena.fuseki.geosparql.cli.ArgsConfig;
-import org.apache.jena.query.Dataset;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.slf4j.bridge.SLF4JBridgeHandler;
-
-public class Main {
-
- private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
-
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
-
- //Apache SIS j.u.l logging redirection.
- SLF4JBridgeHandler.removeHandlersForRootLogger();
- SLF4JBridgeHandler.install();
-
- LOGGER.info("Arguments Received: {}", Arrays.asList(args));
-
- ArgsConfig argsConfig = new ArgsConfig();
-
- JCommander jCommander = JCommander.newBuilder()
- .addObject(argsConfig)
- .build();
-
- jCommander.setProgramName("GeoSPARQL Fuseki");
- jCommander.parse(args);
- if (argsConfig.isHelp()) {
- jCommander.usage();
- return;
- }
-
- //Setup dataset
- try {
- Dataset dataset = DatasetOperations.setup(argsConfig);
-
- //Configure server
- GeosparqlServer server = new GeosparqlServer(argsConfig.getPort(), argsConfig.getDatsetName(), argsConfig.isLoopbackOnly(), dataset, argsConfig.isUpdateAllowed());
- server.start();
- } catch (SrsException | DatasetException | SpatialIndexException ex) {
- LOGGER.error("GeoSPARQL Server: Exiting - {}: {}", ex.getMessage(), argsConfig.getDatsetName());
- }
-
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.fuseki.geosparql;
+
+import com.beust.jcommander.JCommander;
+import java.lang.invoke.MethodHandles;
+import java.util.Arrays;
+import org.apache.jena.geosparql.configuration.SrsException;
+import org.apache.jena.geosparql.spatial.SpatialIndexException;
+import org.apache.jena.fuseki.geosparql.cli.ArgsConfig;
+import org.apache.jena.query.Dataset;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.slf4j.bridge.SLF4JBridgeHandler;
+
+public class Main {
+
+ private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args) {
+
+ //Apache SIS j.u.l logging redirection.
+ SLF4JBridgeHandler.removeHandlersForRootLogger();
+ SLF4JBridgeHandler.install();
+
+ LOGGER.info("Arguments Received: {}", Arrays.asList(args));
+
+ ArgsConfig argsConfig = new ArgsConfig();
+
+ JCommander jCommander = JCommander.newBuilder()
+ .addObject(argsConfig)
+ .build();
+
+ jCommander.setProgramName("GeoSPARQL Fuseki");
+ jCommander.parse(args);
+ if (argsConfig.isHelp()) {
+ jCommander.usage();
+ return;
+ }
+
+ //Setup dataset
+ try {
+ Dataset dataset = DatasetOperations.setup(argsConfig);
+
+ //Configure server
+ GeosparqlServer server = new GeosparqlServer(argsConfig.getPort(), argsConfig.getDatsetName(), argsConfig.isLoopbackOnly(), dataset, argsConfig.isUpdateAllowed());
+ server.start();
+ } catch (SrsException | DatasetException | SpatialIndexException ex) {
+ LOGGER.error("GeoSPARQL Server: Exiting - {}: {}", ex.getMessage(), argsConfig.getDatsetName());
+ }
+
+ }
+
+}
diff --git a/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/MainTest.java b/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/MainTest.java
index 49a4fc4..4427ad6 100644
--- a/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/MainTest.java
+++ b/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/MainTest.java
@@ -1,124 +1,124 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.fuseki.geosparql;
-
-import com.beust.jcommander.JCommander;
-import java.util.ArrayList;
-import java.util.List;
-import org.apache.jena.fuseki.geosparql.cli.ArgsConfig;
-import org.apache.jena.geosparql.spatial.SpatialIndexException;
-import org.apache.jena.query.Dataset;
-import org.apache.jena.query.QueryExecution;
-import org.apache.jena.query.QueryExecutionFactory;
-import org.apache.jena.query.QuerySolution;
-import org.apache.jena.query.ResultSet;
-import org.apache.jena.rdf.model.Resource;
-import org.apache.jena.rdf.model.ResourceFactory;
-import org.junit.After;
-import org.junit.AfterClass;
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- *
- *
- */
-public class MainTest {
-
- private static GeosparqlServer SERVER;
-
- public MainTest() {
- }
-
- @BeforeClass
- public static void setUpClass() throws DatasetException, SpatialIndexException {
- String[] args = {"-rf", "geosparql_test.rdf>xml", "-i"};
-
- ArgsConfig argsConfig = new ArgsConfig();
- JCommander.newBuilder()
- .addObject(argsConfig)
- .build()
- .parse(args);
-
- //Setup dataset
- Dataset dataset = DatasetOperations.setup(argsConfig);
-
- //Configure server
- SERVER = new GeosparqlServer(argsConfig.getPort(), argsConfig.getDatsetName(), argsConfig.isLoopbackOnly(), dataset, argsConfig.isUpdateAllowed());
- SERVER.start();
-
- System.out.println("Server: " + SERVER.getLocalServiceURL());
- }
-
- @AfterClass
- public static void tearDownClass() {
- SERVER.shutdown();
- }
-
- @Before
- public void setUp() {
- }
-
- @After
- public void tearDown() {
- }
-
- /**
- * Test of main method, of class Main.
- */
- @Test
- public void testMain() {
- System.out.println("main");
-
- String query = "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n"
- + "\n"
- + "SELECT ?obj\n"
- + "WHERE{\n"
- + " <http://example.org/Geometry#PolygonH> geo:sfContains ?obj .\n"
- + "}ORDER by ?obj";
- List<Resource> result = new ArrayList<>();
- try (QueryExecution qe = QueryExecutionFactory.sparqlService(SERVER.getLocalServiceURL(), query)) {
- ResultSet rs = qe.execSelect();
-
- while (rs.hasNext()) {
- QuerySolution qs = rs.nextSolution();
- Resource obj = qs.getResource("obj");
- result.add(obj);
- }
-
- //ResultSetFormatter.outputAsTSV(rs);
- }
-
- List<Resource> expResult = new ArrayList<>();
- expResult.add(ResourceFactory.createResource("http://example.org/Feature#A"));
- expResult.add(ResourceFactory.createResource("http://example.org/Feature#D"));
- expResult.add(ResourceFactory.createResource("http://example.org/Feature#H"));
- expResult.add(ResourceFactory.createResource("http://example.org/Feature#K"));
- expResult.add(ResourceFactory.createResource("http://example.org/Geometry#LineStringD"));
- expResult.add(ResourceFactory.createResource("http://example.org/Geometry#PointA"));
- expResult.add(ResourceFactory.createResource("http://example.org/Geometry#PolygonH"));
- expResult.add(ResourceFactory.createResource("http://example.org/Geometry#PolygonK"));
-
- //System.out.println("Exp: " + expResult);
- //System.out.println("Res: " + result);
- assertEquals(expResult, result);
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.fuseki.geosparql;
+
+import com.beust.jcommander.JCommander;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.jena.fuseki.geosparql.cli.ArgsConfig;
+import org.apache.jena.geosparql.spatial.SpatialIndexException;
+import org.apache.jena.query.Dataset;
+import org.apache.jena.query.QueryExecution;
+import org.apache.jena.query.QueryExecutionFactory;
+import org.apache.jena.query.QuerySolution;
+import org.apache.jena.query.ResultSet;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.ResourceFactory;
+import org.junit.After;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertEquals;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ *
+ */
+public class MainTest {
+
+ private static GeosparqlServer SERVER;
+
+ public MainTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() throws DatasetException, SpatialIndexException {
+ String[] args = {"-rf", "geosparql_test.rdf>xml", "-i"};
+
+ ArgsConfig argsConfig = new ArgsConfig();
+ JCommander.newBuilder()
+ .addObject(argsConfig)
+ .build()
+ .parse(args);
+
+ //Setup dataset
+ Dataset dataset = DatasetOperations.setup(argsConfig);
+
+ //Configure server
+ SERVER = new GeosparqlServer(argsConfig.getPort(), argsConfig.getDatsetName(), argsConfig.isLoopbackOnly(), dataset, argsConfig.isUpdateAllowed());
+ SERVER.start();
+
+ System.out.println("Server: " + SERVER.getLocalServiceURL());
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ SERVER.shutdown();
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of main method, of class Main.
+ */
+ @Test
+ public void testMain() {
+ System.out.println("main");
+
+ String query = "PREFIX geo: <http://www.opengis.net/ont/geosparql#>\n"
+ + "\n"
+ + "SELECT ?obj\n"
+ + "WHERE{\n"
+ + " <http://example.org/Geometry#PolygonH> geo:sfContains ?obj .\n"
+ + "}ORDER by ?obj";
+ List<Resource> result = new ArrayList<>();
+ try (QueryExecution qe = QueryExecutionFactory.sparqlService(SERVER.getLocalServiceURL(), query)) {
+ ResultSet rs = qe.execSelect();
+
+ while (rs.hasNext()) {
+ QuerySolution qs = rs.nextSolution();
+ Resource obj = qs.getResource("obj");
+ result.add(obj);
+ }
+
+ //ResultSetFormatter.outputAsTSV(rs);
+ }
+
+ List<Resource> expResult = new ArrayList<>();
+ expResult.add(ResourceFactory.createResource("http://example.org/Feature#A"));
+ expResult.add(ResourceFactory.createResource("http://example.org/Feature#D"));
+ expResult.add(ResourceFactory.createResource("http://example.org/Feature#H"));
+ expResult.add(ResourceFactory.createResource("http://example.org/Feature#K"));
+ expResult.add(ResourceFactory.createResource("http://example.org/Geometry#LineStringD"));
+ expResult.add(ResourceFactory.createResource("http://example.org/Geometry#PointA"));
+ expResult.add(ResourceFactory.createResource("http://example.org/Geometry#PolygonH"));
+ expResult.add(ResourceFactory.createResource("http://example.org/Geometry#PolygonK"));
+
+ //System.out.println("Exp: " + expResult);
+ //System.out.println("Res: " + result);
+ assertEquals(expResult, result);
+ }
+
+}
diff --git a/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/cli/RDFFileParameterTest.java b/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/cli/RDFFileParameterTest.java
index c0044a3..9580cd7 100644
--- a/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/cli/RDFFileParameterTest.java
+++ b/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/cli/RDFFileParameterTest.java
@@ -1,101 +1,101 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.fuseki.geosparql.cli;
-
-import com.beust.jcommander.ParameterException;
-import java.io.File;
-import java.util.Arrays;
-import java.util.List;
-import org.apache.jena.riot.RDFFormat;
-import org.junit.After;
-import org.junit.AfterClass;
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- *
- *
- */
-public class RDFFileParameterTest {
-
- public RDFFileParameterTest() {
- }
-
- @BeforeClass
- public static void setUpClass() {
- }
-
- @AfterClass
- public static void tearDownClass() {
- }
-
- @Before
- public void setUp() {
- }
-
- @After
- public void tearDown() {
- }
-
- /**
- * Test of convert method, of class RDFFileParameter.
- */
- @Test
- public void testConvert() {
- System.out.println("convert");
- String value = "test.rdf#test>xml,test2.rdf";
- RDFFileParameter instance = new RDFFileParameter();
- List<FileGraphFormat> expResult = Arrays.asList(new FileGraphFormat(new File("test.rdf"), "test", RDFFormat.RDFXML), new FileGraphFormat(new File("test2.rdf"), "", RDFFormat.TTL));
- List<FileGraphFormat> result = instance.convert(value);
-
- //System.out.println("Exp: " + expResult);
- //System.out.println("Res: " + result);
- assertEquals(expResult, result);
- }
-
- /**
- * Test of build method, of class RDFFileParameter.
- */
- @Test
- public void testBuild() {
- System.out.println("build");
- String value = "test.rdf>xml";
- RDFFileParameter instance = new RDFFileParameter();
- FileGraphFormat expResult = new FileGraphFormat(new File("test.rdf"), "", RDFFormat.RDFXML);
- FileGraphFormat result = instance.build(value);
-
- //System.out.println("Exp: " + expResult);
- //System.out.println("Res: " + result);
- assertEquals(expResult, result);
- }
-
- /**
- * Test of validate method, of class RDFFileParameter.
- */
- @Test(expected = ParameterException.class)
- public void testValidate() {
- System.out.println("validate");
- String name = "--rdf_file";
- String value = "test.rdf>xml#test";
- RDFFileParameter instance = new RDFFileParameter();
- instance.validate(name, value);
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.fuseki.geosparql.cli;
+
+import com.beust.jcommander.ParameterException;
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+import org.apache.jena.riot.RDFFormat;
+import org.junit.After;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertEquals;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ *
+ */
+public class RDFFileParameterTest {
+
+ public RDFFileParameterTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of convert method, of class RDFFileParameter.
+ */
+ @Test
+ public void testConvert() {
+ System.out.println("convert");
+ String value = "test.rdf#test>xml,test2.rdf";
+ RDFFileParameter instance = new RDFFileParameter();
+ List<FileGraphFormat> expResult = Arrays.asList(new FileGraphFormat(new File("test.rdf"), "test", RDFFormat.RDFXML), new FileGraphFormat(new File("test2.rdf"), "", RDFFormat.TTL));
+ List<FileGraphFormat> result = instance.convert(value);
+
+ //System.out.println("Exp: " + expResult);
+ //System.out.println("Res: " + result);
+ assertEquals(expResult, result);
+ }
+
+ /**
+ * Test of build method, of class RDFFileParameter.
+ */
+ @Test
+ public void testBuild() {
+ System.out.println("build");
+ String value = "test.rdf>xml";
+ RDFFileParameter instance = new RDFFileParameter();
+ FileGraphFormat expResult = new FileGraphFormat(new File("test.rdf"), "", RDFFormat.RDFXML);
+ FileGraphFormat result = instance.build(value);
+
+ //System.out.println("Exp: " + expResult);
+ //System.out.println("Res: " + result);
+ assertEquals(expResult, result);
+ }
+
+ /**
+ * Test of validate method, of class RDFFileParameter.
+ */
+ @Test(expected = ParameterException.class)
+ public void testValidate() {
+ System.out.println("validate");
+ String name = "--rdf_file";
+ String value = "test.rdf>xml#test";
+ RDFFileParameter instance = new RDFFileParameter();
+ instance.validate(name, value);
+ }
+
+}
diff --git a/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/cli/TabFileParameterTest.java b/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/cli/TabFileParameterTest.java
index d3312ea..cb74942 100644
--- a/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/cli/TabFileParameterTest.java
+++ b/jena-fuseki-geosparql/src/test/java/org/apache/jena/fuseki/geosparql/cli/TabFileParameterTest.java
@@ -1,100 +1,100 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.fuseki.geosparql.cli;
-
-import com.beust.jcommander.ParameterException;
-import java.io.File;
-import java.util.Arrays;
-import java.util.List;
-import org.junit.After;
-import org.junit.AfterClass;
-import static org.junit.Assert.assertEquals;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-/**
- *
- * @author Gerg
- */
-public class TabFileParameterTest {
-
- public TabFileParameterTest() {
- }
-
- @BeforeClass
- public static void setUpClass() {
- }
-
- @AfterClass
- public static void tearDownClass() {
- }
-
- @Before
- public void setUp() {
- }
-
- @After
- public void tearDown() {
- }
-
- /**
- * Test of convert method, of class TabFileParameter.
- */
- @Test
- public void testConvert() {
- System.out.println("convert");
- String value = "test.rdf#test|TAB,test2.rdf";
- TabFileParameter instance = new TabFileParameter();
- List<FileGraphDelimiter> expResult = Arrays.asList(new FileGraphDelimiter(new File("test.rdf"), "test", "TAB"), new FileGraphDelimiter(new File("test2.rdf"), "", "COMMA"));
- List<FileGraphDelimiter> result = instance.convert(value);
-
- //System.out.println("Exp: " + expResult);
- //System.out.println("Res: " + result);
- assertEquals(expResult, result);
- }
-
- /**
- * Test of build method, of class TabFileParameter.
- */
- @Test
- public void testBuild() {
- System.out.println("build");
- String value = "test.rdf|SPACE";
- TabFileParameter instance = new TabFileParameter();
- FileGraphDelimiter expResult = new FileGraphDelimiter(new File("test.rdf"), "", "SPACE");
- FileGraphDelimiter result = instance.build(value);
-
- //System.out.println("Exp: " + expResult);
- //System.out.println("Res: " + result);
- assertEquals(expResult, result);
- }
-
- /**
- * Test of validate method, of class TabFileParameter.
- */
- @Test(expected = ParameterException.class)
- public void testValidate() {
- System.out.println("validate");
- String name = "--tab_file";
- String value = "test.csv|COMMA#test";
- TabFileParameter instance = new TabFileParameter();
- instance.validate(name, value);
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.fuseki.geosparql.cli;
+
+import com.beust.jcommander.ParameterException;
+import java.io.File;
+import java.util.Arrays;
+import java.util.List;
+import org.junit.After;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertEquals;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ *
+ * @author Gerg
+ */
+public class TabFileParameterTest {
+
+ public TabFileParameterTest() {
+ }
+
+ @BeforeClass
+ public static void setUpClass() {
+ }
+
+ @AfterClass
+ public static void tearDownClass() {
+ }
+
+ @Before
+ public void setUp() {
+ }
+
+ @After
+ public void tearDown() {
+ }
+
+ /**
+ * Test of convert method, of class TabFileParameter.
+ */
+ @Test
+ public void testConvert() {
+ System.out.println("convert");
+ String value = "test.rdf#test|TAB,test2.rdf";
+ TabFileParameter instance = new TabFileParameter();
+ List<FileGraphDelimiter> expResult = Arrays.asList(new FileGraphDelimiter(new File("test.rdf"), "test", "TAB"), new FileGraphDelimiter(new File("test2.rdf"), "", "COMMA"));
+ List<FileGraphDelimiter> result = instance.convert(value);
+
+ //System.out.println("Exp: " + expResult);
+ //System.out.println("Res: " + result);
+ assertEquals(expResult, result);
+ }
+
+ /**
+ * Test of build method, of class TabFileParameter.
+ */
+ @Test
+ public void testBuild() {
+ System.out.println("build");
+ String value = "test.rdf|SPACE";
+ TabFileParameter instance = new TabFileParameter();
+ FileGraphDelimiter expResult = new FileGraphDelimiter(new File("test.rdf"), "", "SPACE");
+ FileGraphDelimiter result = instance.build(value);
+
+ //System.out.println("Exp: " + expResult);
+ //System.out.println("Res: " + result);
+ assertEquals(expResult, result);
+ }
+
+ /**
+ * Test of validate method, of class TabFileParameter.
+ */
+ @Test(expected = ParameterException.class)
+ public void testValidate() {
+ System.out.println("validate");
+ String name = "--tab_file";
+ String value = "test.csv|COMMA#test";
+ TabFileParameter instance = new TabFileParameter();
+ instance.validate(name, value);
+ }
+
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/configuration/GeoSPARQLConfig.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/configuration/GeoSPARQLConfig.java
index e60742f..7a15c06 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/configuration/GeoSPARQLConfig.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/configuration/GeoSPARQLConfig.java
@@ -1,277 +1,277 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.configuration;
-
-import java.io.File;
-import org.apache.jena.geosparql.geof.topological.RelateFF;
-import org.apache.jena.geosparql.implementation.datatype.GeometryDatatype;
-import org.apache.jena.geosparql.implementation.function_registration.Egenhofer;
-import org.apache.jena.geosparql.implementation.function_registration.GeometryProperty;
-import org.apache.jena.geosparql.implementation.function_registration.NonTopological;
-import org.apache.jena.geosparql.implementation.function_registration.RCC8;
-import org.apache.jena.geosparql.implementation.function_registration.Relate;
-import org.apache.jena.geosparql.implementation.function_registration.SimpleFeatures;
-import org.apache.jena.geosparql.implementation.function_registration.Spatial;
-import org.apache.jena.geosparql.implementation.index.IndexConfiguration;
-import org.apache.jena.geosparql.implementation.index.IndexConfiguration.IndexOption;
-import org.apache.jena.geosparql.implementation.index.QueryRewriteIndex;
-import org.apache.jena.geosparql.implementation.registry.SRSRegistry;
-import org.apache.jena.geosparql.implementation.vocabulary.Geo;
-import org.apache.jena.geosparql.spatial.SpatialIndex;
-import org.apache.jena.geosparql.spatial.SpatialIndexException;
-import org.apache.jena.query.Dataset;
-import org.apache.jena.sparql.function.FunctionRegistry;
-import org.apache.jena.sparql.pfunction.PropertyFunctionRegistry;
-
-/**
- *
- *
- */
-public class GeoSPARQLConfig {
-
- /**
- * GeoSPARQL schema
- */
- private static Boolean IS_FUNCTIONS_REGISTERED = false;
- private static Boolean IS_QUERY_REWRITE_ENABLED = true;
-
- /**
- * Initialise all GeoSPARQL property and filter functions with memory
- * indexing.
- * <br>Use this for in-memory indexing GeoSPARQL setup. Query re-write
- * enabled.
- * <br>This does not affect the use of Spatial Indexes for Datasets.
- *
- */
- public static final void setupMemoryIndex() {
- setup(IndexOption.MEMORY, true);
- }
-
- /**
- * Initialise all GeoSPARQL property and filter functions with memory
- * indexing.
- * <br>Use this for in-memory indexing GeoSPARQL setup. Query re-write
- * optional.
- * <br>This does not affect the use of Spatial Indexes for Datasets.
- *
- * @param isQueryRewriteEnabled
- */
- public static final void setupMemoryIndex(Boolean isQueryRewriteEnabled) {
- setup(IndexOption.MEMORY, isQueryRewriteEnabled);
- }
-
- /**
- * Initialise all GeoSPARQL property and filter functions with memory
- * indexing.
- * <br>Use this for in-memory indexing GeoSPARQL setup and to control the
- * index sizes. Expiry is defaulted to 5,000 milliseconds.
- * <br>This does not affect the use of Spatial Indexes for Datasets.
- *
- * @param geometryLiteralIndex
- * @param geometryTransformIndex
- * @param queryRewriteIndex
- */
- public static final void setupMemoryIndexSize(Integer geometryLiteralIndex, Integer geometryTransformIndex, Integer queryRewriteIndex) {
- setup(IndexOption.MEMORY, true);
- IndexConfiguration.setIndexMaxSize(geometryLiteralIndex, geometryTransformIndex, queryRewriteIndex);
- }
-
- /**
- * Initialise all GeoSPARQL property and filter functions with memory
- * indexing.
- * <br>Use this for in-memory indexing GeoSPARQL setup and to control the
- * index expiry rate (milliseconds). Size is defaulted to unlimited.
- * <br>This does not affect the use of Spatial Indexes for Datasets.
- *
- * @param geometryLiteralIndex
- * @param geometryTransformIndex
- * @param queryRewriteIndex
- */
- public static final void setupMemoryIndexExpiry(Long geometryLiteralIndex, Long geometryTransformIndex, Long queryRewriteIndex) {
- setup(IndexOption.MEMORY, true);
- IndexConfiguration.setIndexExpiry(geometryLiteralIndex, geometryTransformIndex, queryRewriteIndex);
- }
-
- /**
- * Initialise all GeoSPARQL property and filter functions with memory
- * indexing.
- * <br>Use this for in-memory indexing GeoSPARQL setup and to control the
- * index sizes (default: unlimited) and expiry rate (default: 5,000
- * milliseconds).
- * <br>This does not affect the use of Spatial Indexes for Datasets.
- *
- * @param geometryLiteralIndex
- * @param geometryTransformIndex
- * @param queryRewriteIndex
- * @param geometryLiteralIndexExpiry
- * @param geometryTransformIndexExpiry
- * @param queryRewriteIndexExpiry
- * @param isQueryRewriteEnabled
- */
- public static final void setupMemoryIndex(Integer geometryLiteralIndex, Integer geometryTransformIndex, Integer queryRewriteIndex, Long geometryLiteralIndexExpiry, Long geometryTransformIndexExpiry, Long queryRewriteIndexExpiry, Boolean isQueryRewriteEnabled) {
- setup(IndexOption.MEMORY, isQueryRewriteEnabled);
- IndexConfiguration.setIndexMaxSize(geometryLiteralIndex, geometryTransformIndex, queryRewriteIndex);
- IndexConfiguration.setIndexExpiry(geometryLiteralIndexExpiry, geometryTransformIndexExpiry, queryRewriteIndexExpiry);
- }
-
- /**
- * Initialise all GeoSPARQL property and filter functions with no indexing.
- * <br>Use this for no indexing GeoSPARQL setup.
- * <br>This does not affect the use of Spatial Indexes for Datasets.
- */
- public static final void setupNoIndex() {
- setup(IndexOption.NONE, true);
- }
-
- /**
- * Initialise all GeoSPARQL property and filter functions with no indexing.
- * <br>Use this for no indexing GeoSPARQL setup.
- * <br>This does not affect the use of Spatial Indexes for Datasets.
- *
- * @param isQueryRewriteEnabled
- */
- public static final void setupNoIndex(Boolean isQueryRewriteEnabled) {
- setup(IndexOption.NONE, isQueryRewriteEnabled);
- }
-
- /**
- * Initialise all GeoSPARQL property and filter functions. Query rewrite
- * enabled.
- * <br>This does not affect the use of Spatial Indexes for Datasets.
- *
- * @param indexOption
- */
- public static final void setup(IndexOption indexOption) {
- setup(indexOption, true);
- }
-
- /**
- * Initialise all GeoSPARQL property and filter functions.
- * <br>This does not affect the use of Spatial Indexes for Datasets.
- *
- * @param indexOption
- * @param isQueryRewriteEnabled
- */
- public static final void setup(IndexOption indexOption, Boolean isQueryRewriteEnabled) {
-
- IS_QUERY_REWRITE_ENABLED = isQueryRewriteEnabled;
-
- //Set the configuration for indexing.
- IndexConfiguration.setConfig(indexOption);
-
- //Only register functions once.
- if (!IS_FUNCTIONS_REGISTERED) {
-
- //Setup Default Cordinate Reference Systems
- SRSRegistry.setupDefaultSRS();
-
- //Register GeometryDatatypes with the TypeMapper.
- GeometryDatatype.registerDatatypes();
-
- //Register Property and Filter functions.
- PropertyFunctionRegistry propertyRegistry = PropertyFunctionRegistry.get();
- FunctionRegistry functionRegistry = FunctionRegistry.get();
- NonTopological.loadFilterFunctions(functionRegistry);
- functionRegistry.put(Geo.RELATE_NAME, RelateFF.class);
- SimpleFeatures.loadPropertyFunctions(propertyRegistry);
- SimpleFeatures.loadFilterFunctions(functionRegistry);
- Egenhofer.loadPropertyFunctions(propertyRegistry);
- Egenhofer.loadFilterFunctions(functionRegistry);
- RCC8.loadPropertyFunctions(propertyRegistry);
- RCC8.loadFilterFunctions(functionRegistry);
- Relate.loadRelateFunction(functionRegistry);
- GeometryProperty.loadPropertyFunctions(propertyRegistry);
- GeometryProperty.loadFilterFunctions(functionRegistry);
- Spatial.loadPropertyFunctions(propertyRegistry);
- Spatial.loadFilterFunctions(functionRegistry);
- IS_FUNCTIONS_REGISTERED = true;
- }
- }
-
- /**
- *
- * @return True, if the GeoSPARQL functions have been registered.
- */
- public static final Boolean isFunctionRegistered() {
- return IS_FUNCTIONS_REGISTERED;
- }
-
- /**
- * Empty all indexes and registries currently in use.
- * <br>This does not affect Spatial Indexes for Datasets.
- */
- public static final void reset() {
- //Convenience method so that setup and clearing in one class.
- IndexConfiguration.resetIndexesAndRegistries();
- }
-
- /**
- *
- * @return True if query rewrite enabled.
- */
- public static Boolean isQueryRewriteEnabled() {
- return IS_QUERY_REWRITE_ENABLED;
- }
-
- /**
- * Setup Query Rewrite Index using Dataset.<br>
- * The index will be set active.
- *
- * @param dataset
- * @param queryRewriteLabel
- * @param maxSize
- * @param expiryInterval
- */
- public static final void setupQueryRewriteIndex(Dataset dataset, String queryRewriteLabel, int maxSize, long expiryInterval) {
- QueryRewriteIndex.prepare(dataset, queryRewriteLabel, maxSize, expiryInterval);
- }
-
- /**
- * Setup Spatial Index using Dataset and most frequent SRS URI in Dataset.
- *
- * @param dataset
- */
- public static final void setupSpatialIndex(Dataset dataset) throws SpatialIndexException {
- SpatialIndex.buildSpatialIndex(dataset);
- }
-
- /**
- * Setup Spatial Index using Dataset and most frequent SRS URI in
- * Dataset.<br>
- * Spatial Index written to file once created.
- *
- * @param dataset
- * @param spatialIndexFile
- */
- public static final void setupSpatialIndex(Dataset dataset, File spatialIndexFile) throws SpatialIndexException {
- SpatialIndex.buildSpatialIndex(dataset, spatialIndexFile);
- }
-
- /**
- * Setup Spatial Index using Dataset using provided SRS URI.<br>
- * Spatial Index written to file once created.
- *
- * @param dataset
- * @param srsURI
- * @param spatialIndexFile
- */
- public static final void setupSpatialIndex(Dataset dataset, String srsURI, File spatialIndexFile) throws SpatialIndexException {
- SpatialIndex.buildSpatialIndex(dataset, srsURI, spatialIndexFile);
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.configuration;
+
+import java.io.File;
+import org.apache.jena.geosparql.geof.topological.RelateFF;
+import org.apache.jena.geosparql.implementation.datatype.GeometryDatatype;
+import org.apache.jena.geosparql.implementation.function_registration.Egenhofer;
+import org.apache.jena.geosparql.implementation.function_registration.GeometryProperty;
+import org.apache.jena.geosparql.implementation.function_registration.NonTopological;
+import org.apache.jena.geosparql.implementation.function_registration.RCC8;
+import org.apache.jena.geosparql.implementation.function_registration.Relate;
+import org.apache.jena.geosparql.implementation.function_registration.SimpleFeatures;
+import org.apache.jena.geosparql.implementation.function_registration.Spatial;
+import org.apache.jena.geosparql.implementation.index.IndexConfiguration;
+import org.apache.jena.geosparql.implementation.index.IndexConfiguration.IndexOption;
+import org.apache.jena.geosparql.implementation.index.QueryRewriteIndex;
+import org.apache.jena.geosparql.implementation.registry.SRSRegistry;
+import org.apache.jena.geosparql.implementation.vocabulary.Geo;
+import org.apache.jena.geosparql.spatial.SpatialIndex;
+import org.apache.jena.geosparql.spatial.SpatialIndexException;
+import org.apache.jena.query.Dataset;
+import org.apache.jena.sparql.function.FunctionRegistry;
+import org.apache.jena.sparql.pfunction.PropertyFunctionRegistry;
+
+/**
+ *
+ *
+ */
+public class GeoSPARQLConfig {
+
+ /**
+ * GeoSPARQL schema
+ */
+ private static Boolean IS_FUNCTIONS_REGISTERED = false;
+ private static Boolean IS_QUERY_REWRITE_ENABLED = true;
+
+ /**
+ * Initialise all GeoSPARQL property and filter functions with memory
+ * indexing.
+ * <br>Use this for in-memory indexing GeoSPARQL setup. Query re-write
+ * enabled.
+ * <br>This does not affect the use of Spatial Indexes for Datasets.
+ *
+ */
+ public static final void setupMemoryIndex() {
+ setup(IndexOption.MEMORY, true);
+ }
+
+ /**
+ * Initialise all GeoSPARQL property and filter functions with memory
+ * indexing.
+ * <br>Use this for in-memory indexing GeoSPARQL setup. Query re-write
+ * optional.
+ * <br>This does not affect the use of Spatial Indexes for Datasets.
+ *
+ * @param isQueryRewriteEnabled
+ */
+ public static final void setupMemoryIndex(Boolean isQueryRewriteEnabled) {
+ setup(IndexOption.MEMORY, isQueryRewriteEnabled);
+ }
+
+ /**
+ * Initialise all GeoSPARQL property and filter functions with memory
+ * indexing.
+ * <br>Use this for in-memory indexing GeoSPARQL setup and to control the
+ * index sizes. Expiry is defaulted to 5,000 milliseconds.
+ * <br>This does not affect the use of Spatial Indexes for Datasets.
+ *
+ * @param geometryLiteralIndex
+ * @param geometryTransformIndex
+ * @param queryRewriteIndex
+ */
+ public static final void setupMemoryIndexSize(Integer geometryLiteralIndex, Integer geometryTransformIndex, Integer queryRewriteIndex) {
+ setup(IndexOption.MEMORY, true);
+ IndexConfiguration.setIndexMaxSize(geometryLiteralIndex, geometryTransformIndex, queryRewriteIndex);
+ }
+
+ /**
+ * Initialise all GeoSPARQL property and filter functions with memory
+ * indexing.
+ * <br>Use this for in-memory indexing GeoSPARQL setup and to control the
+ * index expiry rate (milliseconds). Size is defaulted to unlimited.
+ * <br>This does not affect the use of Spatial Indexes for Datasets.
+ *
+ * @param geometryLiteralIndex
+ * @param geometryTransformIndex
+ * @param queryRewriteIndex
+ */
+ public static final void setupMemoryIndexExpiry(Long geometryLiteralIndex, Long geometryTransformIndex, Long queryRewriteIndex) {
+ setup(IndexOption.MEMORY, true);
+ IndexConfiguration.setIndexExpiry(geometryLiteralIndex, geometryTransformIndex, queryRewriteIndex);
+ }
+
+ /**
+ * Initialise all GeoSPARQL property and filter functions with memory
+ * indexing.
+ * <br>Use this for in-memory indexing GeoSPARQL setup and to control the
+ * index sizes (default: unlimited) and expiry rate (default: 5,000
+ * milliseconds).
+ * <br>This does not affect the use of Spatial Indexes for Datasets.
+ *
+ * @param geometryLiteralIndex
+ * @param geometryTransformIndex
+ * @param queryRewriteIndex
+ * @param geometryLiteralIndexExpiry
+ * @param geometryTransformIndexExpiry
+ * @param queryRewriteIndexExpiry
+ * @param isQueryRewriteEnabled
+ */
+ public static final void setupMemoryIndex(Integer geometryLiteralIndex, Integer geometryTransformIndex, Integer queryRewriteIndex, Long geometryLiteralIndexExpiry, Long geometryTransformIndexExpiry, Long queryRewriteIndexExpiry, Boolean isQueryRewriteEnabled) {
+ setup(IndexOption.MEMORY, isQueryRewriteEnabled);
+ IndexConfiguration.setIndexMaxSize(geometryLiteralIndex, geometryTransformIndex, queryRewriteIndex);
+ IndexConfiguration.setIndexExpiry(geometryLiteralIndexExpiry, geometryTransformIndexExpiry, queryRewriteIndexExpiry);
+ }
+
+ /**
+ * Initialise all GeoSPARQL property and filter functions with no indexing.
+ * <br>Use this for no indexing GeoSPARQL setup.
+ * <br>This does not affect the use of Spatial Indexes for Datasets.
+ */
+ public static final void setupNoIndex() {
+ setup(IndexOption.NONE, true);
+ }
+
+ /**
+ * Initialise all GeoSPARQL property and filter functions with no indexing.
+ * <br>Use this for no indexing GeoSPARQL setup.
+ * <br>This does not affect the use of Spatial Indexes for Datasets.
+ *
+ * @param isQueryRewriteEnabled
+ */
+ public static final void setupNoIndex(Boolean isQueryRewriteEnabled) {
+ setup(IndexOption.NONE, isQueryRewriteEnabled);
+ }
+
+ /**
+ * Initialise all GeoSPARQL property and filter functions. Query rewrite
+ * enabled.
+ * <br>This does not affect the use of Spatial Indexes for Datasets.
+ *
+ * @param indexOption
+ */
+ public static final void setup(IndexOption indexOption) {
+ setup(indexOption, true);
+ }
+
+ /**
+ * Initialise all GeoSPARQL property and filter functions.
+ * <br>This does not affect the use of Spatial Indexes for Datasets.
+ *
+ * @param indexOption
+ * @param isQueryRewriteEnabled
+ */
+ public static final void setup(IndexOption indexOption, Boolean isQueryRewriteEnabled) {
+
+ IS_QUERY_REWRITE_ENABLED = isQueryRewriteEnabled;
+
+ //Set the configuration for indexing.
+ IndexConfiguration.setConfig(indexOption);
+
+ //Only register functions once.
+ if (!IS_FUNCTIONS_REGISTERED) {
+
+ //Setup Default Cordinate Reference Systems
+ SRSRegistry.setupDefaultSRS();
+
+ //Register GeometryDatatypes with the TypeMapper.
+ GeometryDatatype.registerDatatypes();
+
+ //Register Property and Filter functions.
+ PropertyFunctionRegistry propertyRegistry = PropertyFunctionRegistry.get();
+ FunctionRegistry functionRegistry = FunctionRegistry.get();
+ NonTopological.loadFilterFunctions(functionRegistry);
+ functionRegistry.put(Geo.RELATE_NAME, RelateFF.class);
+ SimpleFeatures.loadPropertyFunctions(propertyRegistry);
+ SimpleFeatures.loadFilterFunctions(functionRegistry);
+ Egenhofer.loadPropertyFunctions(propertyRegistry);
+ Egenhofer.loadFilterFunctions(functionRegistry);
+ RCC8.loadPropertyFunctions(propertyRegistry);
+ RCC8.loadFilterFunctions(functionRegistry);
+ Relate.loadRelateFunction(functionRegistry);
+ GeometryProperty.loadPropertyFunctions(propertyRegistry);
+ GeometryProperty.loadFilterFunctions(functionRegistry);
+ Spatial.loadPropertyFunctions(propertyRegistry);
+ Spatial.loadFilterFunctions(functionRegistry);
+ IS_FUNCTIONS_REGISTERED = true;
+ }
+ }
+
+ /**
+ *
+ * @return True, if the GeoSPARQL functions have been registered.
+ */
+ public static final Boolean isFunctionRegistered() {
+ return IS_FUNCTIONS_REGISTERED;
+ }
+
+ /**
+ * Empty all indexes and registries currently in use.
+ * <br>This does not affect Spatial Indexes for Datasets.
+ */
+ public static final void reset() {
+ //Convenience method so that setup and clearing in one class.
+ IndexConfiguration.resetIndexesAndRegistries();
+ }
+
+ /**
+ *
+ * @return True if query rewrite enabled.
+ */
+ public static Boolean isQueryRewriteEnabled() {
+ return IS_QUERY_REWRITE_ENABLED;
+ }
+
+ /**
+ * Setup Query Rewrite Index using Dataset.<br>
+ * The index will be set active.
+ *
+ * @param dataset
+ * @param queryRewriteLabel
+ * @param maxSize
+ * @param expiryInterval
+ */
+ public static final void setupQueryRewriteIndex(Dataset dataset, String queryRewriteLabel, int maxSize, long expiryInterval) {
+ QueryRewriteIndex.prepare(dataset, queryRewriteLabel, maxSize, expiryInterval);
+ }
+
+ /**
+ * Setup Spatial Index using Dataset and most frequent SRS URI in Dataset.
+ *
+ * @param dataset
+ */
+ public static final void setupSpatialIndex(Dataset dataset) throws SpatialIndexException {
+ SpatialIndex.buildSpatialIndex(dataset);
+ }
+
+ /**
+ * Setup Spatial Index using Dataset and most frequent SRS URI in
+ * Dataset.<br>
+ * Spatial Index written to file once created.
+ *
+ * @param dataset
+ * @param spatialIndexFile
+ */
+ public static final void setupSpatialIndex(Dataset dataset, File spatialIndexFile) throws SpatialIndexException {
+ SpatialIndex.buildSpatialIndex(dataset, spatialIndexFile);
+ }
+
+ /**
+ * Setup Spatial Index using Dataset using provided SRS URI.<br>
+ * Spatial Index written to file once created.
+ *
+ * @param dataset
+ * @param srsURI
+ * @param spatialIndexFile
+ */
+ public static final void setupSpatialIndex(Dataset dataset, String srsURI, File spatialIndexFile) throws SpatialIndexException {
+ SpatialIndex.buildSpatialIndex(dataset, srsURI, spatialIndexFile);
+ }
+
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geo/topological/GenericPropertyFunction.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geo/topological/GenericPropertyFunction.java
index 37184ea..138697a 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geo/topological/GenericPropertyFunction.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geo/topological/GenericPropertyFunction.java
@@ -1,327 +1,327 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geo.topological;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.apache.jena.geosparql.implementation.index.QueryRewriteIndex;
-import org.apache.jena.geosparql.implementation.vocabulary.Geo;
-import org.apache.jena.geosparql.implementation.vocabulary.SpatialExtension;
-import org.apache.jena.geosparql.spatial.SpatialIndex;
-import org.apache.jena.geosparql.spatial.SpatialIndexException;
-import org.apache.jena.graph.Graph;
-import org.apache.jena.graph.Node;
-import org.apache.jena.graph.Triple;
-import org.apache.jena.rdf.model.Property;
-import org.apache.jena.rdf.model.Resource;
-import org.apache.jena.rdf.model.ResourceFactory;
-import org.apache.jena.sparql.core.Var;
-import org.apache.jena.sparql.engine.ExecutionContext;
-import org.apache.jena.sparql.engine.QueryIterator;
-import org.apache.jena.sparql.engine.binding.Binding;
-import org.apache.jena.sparql.engine.binding.BindingFactory;
-import org.apache.jena.sparql.engine.iterator.QueryIterConcat;
-import org.apache.jena.sparql.engine.iterator.QueryIterNullIterator;
-import org.apache.jena.sparql.engine.iterator.QueryIterSingleton;
-import org.apache.jena.sparql.expr.ExprEvalException;
-import org.apache.jena.sparql.pfunction.PFuncSimple;
-import org.apache.jena.sparql.util.FmtUtils;
-import org.apache.jena.util.iterator.ExtendedIterator;
-import org.apache.jena.vocabulary.RDF;
-import org.locationtech.jts.geom.Envelope;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- *
- */
-public abstract class GenericPropertyFunction extends PFuncSimple {
-
- private final GenericFilterFunction filterFunction;
-
- public GenericPropertyFunction(GenericFilterFunction filterFunction) {
- this.filterFunction = filterFunction;
- }
-
- @Override
- public QueryIterator execEvaluated(Binding binding, Node subject, Node predicate, Node object, ExecutionContext execCxt) {
- if (object.isLiteral()) {
- //These Property Functions do not accept literals as objects so exit quickly.
- return QueryIterNullIterator.create(execCxt);
- }
-
- if (subject.isConcrete() && object.isConcrete()) {
- //Both are bound.
- return bothBound(binding, subject, predicate, object, execCxt);
- } else if (subject.isVariable() && object.isVariable()) {
- //Both are unbound.
- return bothUnbound(binding, subject, predicate, object, execCxt);
- } else {
- //One bound and one unbound.
- return oneBound(binding, subject, predicate, object, execCxt);
- }
-
- }
-
- private QueryIterator bothBound(Binding binding, Node subject, Node predicate, Node object, ExecutionContext execCxt) {
-
- Graph graph = execCxt.getActiveGraph();
- QueryRewriteIndex queryRewriteIndex = QueryRewriteIndex.retrieve(execCxt);
-
- Boolean isPositiveResult = queryRewrite(graph, subject, predicate, object, queryRewriteIndex);
- if (isPositiveResult) {
- //Filter function test succeded so retain binding.
- return QueryIterSingleton.create(binding, execCxt);
- } else {
- //Filter function test failed so null result.
- return QueryIterNullIterator.create(execCxt);
- }
-
- }
-
- private QueryIterator bothUnbound(Binding binding, Node subject, Node predicate, Node object, ExecutionContext execCxt) {
-
- QueryIterConcat queryIterConcat = new QueryIterConcat(execCxt);
- Var subjectVar = Var.alloc(subject.getName());
-
- Graph graph = execCxt.getActiveGraph();
-
- ExtendedIterator<Triple> subjectTriples;
- if (graph.contains(null, RDF.type.asNode(), Geo.SPATIAL_OBJECT_NODE)) {
- subjectTriples = graph.find(null, RDF.type.asNode(), Geo.SPATIAL_OBJECT_NODE);
- } else {
- //Check for Geo Predicate Features in the Graph if no GeometryLiterals found.
- subjectTriples = graph.find(null, SpatialExtension.GEO_LAT_NODE, null);
-
- }
-
- //Bind all the Spatial Objects or Geo Predicates once as the subject and search for corresponding Objects.
- while (subjectTriples.hasNext()) {
- Triple subjectTriple = subjectTriples.next();
- Node boundSubject = subjectTriple.getSubject();
- Binding subjectBind = BindingFactory.binding(binding, subjectVar, boundSubject);
- QueryIterator queryIter = oneBound(subjectBind, boundSubject, predicate, object, execCxt);
- queryIterConcat.add(queryIter);
- }
-
- return queryIterConcat;
- }
-
- private QueryIterator oneBound(Binding binding, Node subject, Node predicate, Node object, ExecutionContext execCxt) {
-
- Graph graph = execCxt.getActiveGraph();
- Node boundNode;
- Node unboundNode;
- Boolean isSubjectBound;
- if (subject.isConcrete()) {
- //Subject is bound, object is unbound.
- boundNode = subject;
- unboundNode = object;
- isSubjectBound = true;
- } else {
- //Object is bound, subject is unbound.
- boundNode = object;
- unboundNode = subject;
- isSubjectBound = false;
- }
-
- if (!graph.contains(boundNode, RDF.type.asNode(), Geo.SPATIAL_OBJECT_NODE)) {
- if (!graph.contains(boundNode, SpatialExtension.GEO_LAT_NODE, null)) {
- //Bound node is not a Feature or a Geometry or has Geo predicates so exit.
- return QueryIterNullIterator.create(execCxt);
- }
- }
-
- boolean isSpatialIndex = SpatialIndex.isDefined(execCxt);
- QueryIterConcat queryIterConcat;
- if (!isSpatialIndex || filterFunction.isDisjoint() || filterFunction.isDisconnected()) {
- //Disjointed so retrieve all cases.
- queryIterConcat = findAll(graph, boundNode, unboundNode, binding, isSubjectBound, predicate, execCxt);
- } else {
- //Only retrieve those in the spatial index which are within same bounding box.
- queryIterConcat = findIndex(graph, boundNode, unboundNode, binding, isSubjectBound, predicate, execCxt);
- }
-
- return queryIterConcat;
- }
-
- private QueryIterConcat findAll(Graph graph, Node boundNode, Node unboundNode, Binding binding, boolean isSubjectBound, Node predicate, ExecutionContext execCxt) {
-
- //Prepare the results.
- Var unboundVar = Var.alloc(unboundNode.getName());
- QueryIterConcat queryIterConcat = new QueryIterConcat(execCxt);
-
- //Search for both Features and Geometry in the Graph.
- ExtendedIterator<Triple> spatialTriples;
- if (graph.contains(null, RDF.type.asNode(), Geo.SPATIAL_OBJECT_NODE)) {
- spatialTriples = graph.find(null, RDF.type.asNode(), Geo.SPATIAL_OBJECT_NODE);
- } else {
- //Check for Geo Predicate Features in the Graph if no GeometryLiterals found.
- spatialTriples = graph.find(null, SpatialExtension.GEO_LAT_NODE, null);
- }
-
- while (spatialTriples.hasNext()) {
- Triple spatialTriple = spatialTriples.next();
- Node spatialNode = spatialTriple.getSubject();
- Binding newBind = BindingFactory.binding(binding, unboundVar, spatialNode);
- QueryIterator queryIter;
- if (isSubjectBound) {
- queryIter = bothBound(newBind, boundNode, predicate, spatialNode, execCxt);
- } else {
- queryIter = bothBound(newBind, spatialNode, predicate, boundNode, execCxt);
- }
- queryIterConcat.add(queryIter);
- }
-
- return queryIterConcat;
- }
-
- private QueryIterConcat findIndex(Graph graph, Node boundNode, Node unboundNode, Binding binding, boolean isSubjectBound, Node predicate, ExecutionContext execCxt) throws ExprEvalException {
-
- try {
- //Prepare for results.
- Var unboundVar = Var.alloc(unboundNode.getName());
- QueryIterConcat queryIterConcat = new QueryIterConcat(execCxt);
-
- //Find the asserted triples.
- List<Node> assertedNodes = findAsserted(graph, boundNode, isSubjectBound, predicate);
- for (Node node : assertedNodes) {
- Binding newBind = BindingFactory.binding(binding, unboundVar, node);
- QueryIterator queryIter = QueryIterSingleton.create(newBind, execCxt);
- queryIterConcat.add(queryIter);
- }
-
- //Find the GeometryLiteral of the Bound Node.
- SpatialObjectGeometryLiteral boundGeometryLiteral = SpatialObjectGeometryLiteral.retrieve(graph, boundNode);
- if (!boundGeometryLiteral.isValid()) {
- //Bound Node is not a Feature or a Geometry or there is no GeometryLiteral so exit.
- return queryIterConcat;
- }
-
- Node geometryLiteral = boundGeometryLiteral.getGeometryLiteral();
-
- //Perform the search of the Spatial Index of the Dataset.
- SpatialIndex spatialIndex = SpatialIndex.retrieve(execCxt);
- GeometryWrapper geom = GeometryWrapper.extract(geometryLiteral);
- GeometryWrapper transformedGeom = geom.transform(spatialIndex.getSrsInfo());
- Envelope searchEnvelope = transformedGeom.getEnvelope();
- HashSet<Resource> features = spatialIndex.query(searchEnvelope);
-
- //Check each of the Features that match the search.
- for (Resource feature : features) {
- Node featureNode = feature.asNode();
-
- //Ensure not already an asserted node.
- if (!assertedNodes.contains(featureNode)) {
-
- Binding newBind = BindingFactory.binding(binding, unboundVar, featureNode);
- QueryIterator queryIter;
- if (isSubjectBound) {
- queryIter = bothBound(newBind, boundNode, predicate, featureNode, execCxt);
- } else {
- queryIter = bothBound(newBind, featureNode, predicate, boundNode, execCxt);
- }
- queryIterConcat.add(queryIter);
- }
-
- //Also test all Geometry of the Features. All, some or one Geometry may have matched.
- ExtendedIterator<Triple> featureGeometryTriples = graph.find(feature.asNode(), Geo.HAS_GEOMETRY_NODE, null);
- while (featureGeometryTriples.hasNext()) {
- Triple unboundTriple = featureGeometryTriples.next();
- Node geomNode = unboundTriple.getObject();
-
- //Ensure not already an asserted node.
- if (!assertedNodes.contains(geomNode)) {
- Binding newBind = BindingFactory.binding(binding, unboundVar, geomNode);
- QueryIterator queryIter;
- if (isSubjectBound) {
- queryIter = bothBound(newBind, boundNode, predicate, geomNode, execCxt);
- } else {
- queryIter = bothBound(newBind, geomNode, predicate, boundNode, execCxt);
- }
- queryIterConcat.add(queryIter);
- }
- }
- }
-
- return queryIterConcat;
- } catch (MismatchedDimensionException | TransformException | FactoryException | SpatialIndexException ex) {
- throw new ExprEvalException(ex.getMessage() + ": " + FmtUtils.stringForNode(boundNode) + ", " + FmtUtils.stringForNode(unboundNode) + ", " + FmtUtils.stringForNode(predicate), ex);
- }
- }
-
- private List<Node> findAsserted(Graph graph, Node boundNode, boolean isSubjectBound, Node predicate) {
- List<Node> assertedNodes = new ArrayList<>();
- if (isSubjectBound) {
- ExtendedIterator<Triple> assertedTriples = graph.find(boundNode, predicate, null);
- while (assertedTriples.hasNext()) {
- Node assertedNode = assertedTriples.next().getObject();
- assertedNodes.add(assertedNode);
- }
- } else {
- ExtendedIterator<Triple> assertedTriples = graph.find(null, predicate, boundNode);
- while (assertedTriples.hasNext()) {
- Node assertedNode = assertedTriples.next().getSubject();
- assertedNodes.add(assertedNode);
- }
- }
- return assertedNodes;
- }
-
- protected final Boolean queryRewrite(Graph graph, Node subject, Node predicate, Node object, QueryRewriteIndex queryRewriteIndex) {
-
- if (graph.contains(subject, predicate, object)) {
- //The graph contains the asserted triple, return the current binding.
- return true;
- }
-
- //If query re-writing is disabled then exit - already checked that graph does not contain the asserted relation.
- if (!queryRewriteIndex.isIndexActive()) {
- return false;
- }
-
- //Begin Query Re-write by finding the literals of the Feature or Geometry.
- SpatialObjectGeometryLiteral subjectSpatialLiteral = SpatialObjectGeometryLiteral.retrieve(graph, subject);
- if (!subjectSpatialLiteral.isValid()) {
- //Subject is not a Feature or a Geometry or there is no GeometryLiteral so exit.
- return false;
- }
-
- SpatialObjectGeometryLiteral objectSpatialLiteral = SpatialObjectGeometryLiteral.retrieve(graph, object);
- if (!objectSpatialLiteral.isValid()) {
- //Object is not a Feature or a Geometry or there is no GeometryLiteral so exit.
- return false;
- }
-
- //Check the QueryRewriteIndex for the result.
- Property predicateProp = ResourceFactory.createProperty(predicate.getURI());
- Boolean isPositive = queryRewriteIndex.test(subjectSpatialLiteral.getGeometryLiteral(), predicateProp, objectSpatialLiteral.getGeometryLiteral(), this);
- return isPositive;
- }
-
- public Boolean testFilterFunction(Node subjectGeometryLiteral, Node objectGeometryLiteral) {
- return filterFunction.exec(subjectGeometryLiteral, objectGeometryLiteral);
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geo.topological;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.apache.jena.geosparql.implementation.index.QueryRewriteIndex;
+import org.apache.jena.geosparql.implementation.vocabulary.Geo;
+import org.apache.jena.geosparql.implementation.vocabulary.SpatialExtension;
+import org.apache.jena.geosparql.spatial.SpatialIndex;
+import org.apache.jena.geosparql.spatial.SpatialIndexException;
+import org.apache.jena.graph.Graph;
+import org.apache.jena.graph.Node;
+import org.apache.jena.graph.Triple;
+import org.apache.jena.rdf.model.Property;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.ResourceFactory;
+import org.apache.jena.sparql.core.Var;
+import org.apache.jena.sparql.engine.ExecutionContext;
+import org.apache.jena.sparql.engine.QueryIterator;
+import org.apache.jena.sparql.engine.binding.Binding;
+import org.apache.jena.sparql.engine.binding.BindingFactory;
+import org.apache.jena.sparql.engine.iterator.QueryIterConcat;
+import org.apache.jena.sparql.engine.iterator.QueryIterNullIterator;
+import org.apache.jena.sparql.engine.iterator.QueryIterSingleton;
+import org.apache.jena.sparql.expr.ExprEvalException;
+import org.apache.jena.sparql.pfunction.PFuncSimple;
+import org.apache.jena.sparql.util.FmtUtils;
+import org.apache.jena.util.iterator.ExtendedIterator;
+import org.apache.jena.vocabulary.RDF;
+import org.locationtech.jts.geom.Envelope;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ *
+ */
+public abstract class GenericPropertyFunction extends PFuncSimple {
+
+ private final GenericFilterFunction filterFunction;
+
+ public GenericPropertyFunction(GenericFilterFunction filterFunction) {
+ this.filterFunction = filterFunction;
+ }
+
+ @Override
+ public QueryIterator execEvaluated(Binding binding, Node subject, Node predicate, Node object, ExecutionContext execCxt) {
+ if (object.isLiteral()) {
+ //These Property Functions do not accept literals as objects so exit quickly.
+ return QueryIterNullIterator.create(execCxt);
+ }
+
+ if (subject.isConcrete() && object.isConcrete()) {
+ //Both are bound.
+ return bothBound(binding, subject, predicate, object, execCxt);
+ } else if (subject.isVariable() && object.isVariable()) {
+ //Both are unbound.
+ return bothUnbound(binding, subject, predicate, object, execCxt);
+ } else {
+ //One bound and one unbound.
+ return oneBound(binding, subject, predicate, object, execCxt);
+ }
+
+ }
+
+ private QueryIterator bothBound(Binding binding, Node subject, Node predicate, Node object, ExecutionContext execCxt) {
+
+ Graph graph = execCxt.getActiveGraph();
+ QueryRewriteIndex queryRewriteIndex = QueryRewriteIndex.retrieve(execCxt);
+
+ Boolean isPositiveResult = queryRewrite(graph, subject, predicate, object, queryRewriteIndex);
+ if (isPositiveResult) {
+ //Filter function test succeded so retain binding.
+ return QueryIterSingleton.create(binding, execCxt);
+ } else {
+ //Filter function test failed so null result.
+ return QueryIterNullIterator.create(execCxt);
+ }
+
+ }
+
+ private QueryIterator bothUnbound(Binding binding, Node subject, Node predicate, Node object, ExecutionContext execCxt) {
+
+ QueryIterConcat queryIterConcat = new QueryIterConcat(execCxt);
+ Var subjectVar = Var.alloc(subject.getName());
+
+ Graph graph = execCxt.getActiveGraph();
+
+ ExtendedIterator<Triple> subjectTriples;
+ if (graph.contains(null, RDF.type.asNode(), Geo.SPATIAL_OBJECT_NODE)) {
+ subjectTriples = graph.find(null, RDF.type.asNode(), Geo.SPATIAL_OBJECT_NODE);
+ } else {
+ //Check for Geo Predicate Features in the Graph if no GeometryLiterals found.
+ subjectTriples = graph.find(null, SpatialExtension.GEO_LAT_NODE, null);
+
+ }
+
+ //Bind all the Spatial Objects or Geo Predicates once as the subject and search for corresponding Objects.
+ while (subjectTriples.hasNext()) {
+ Triple subjectTriple = subjectTriples.next();
+ Node boundSubject = subjectTriple.getSubject();
+ Binding subjectBind = BindingFactory.binding(binding, subjectVar, boundSubject);
+ QueryIterator queryIter = oneBound(subjectBind, boundSubject, predicate, object, execCxt);
+ queryIterConcat.add(queryIter);
+ }
+
+ return queryIterConcat;
+ }
+
+ private QueryIterator oneBound(Binding binding, Node subject, Node predicate, Node object, ExecutionContext execCxt) {
+
+ Graph graph = execCxt.getActiveGraph();
+ Node boundNode;
+ Node unboundNode;
+ Boolean isSubjectBound;
+ if (subject.isConcrete()) {
+ //Subject is bound, object is unbound.
+ boundNode = subject;
+ unboundNode = object;
+ isSubjectBound = true;
+ } else {
+ //Object is bound, subject is unbound.
+ boundNode = object;
+ unboundNode = subject;
+ isSubjectBound = false;
+ }
+
+ if (!graph.contains(boundNode, RDF.type.asNode(), Geo.SPATIAL_OBJECT_NODE)) {
+ if (!graph.contains(boundNode, SpatialExtension.GEO_LAT_NODE, null)) {
+ //Bound node is not a Feature or a Geometry or has Geo predicates so exit.
+ return QueryIterNullIterator.create(execCxt);
+ }
+ }
+
+ boolean isSpatialIndex = SpatialIndex.isDefined(execCxt);
+ QueryIterConcat queryIterConcat;
+ if (!isSpatialIndex || filterFunction.isDisjoint() || filterFunction.isDisconnected()) {
+ //Disjointed so retrieve all cases.
+ queryIterConcat = findAll(graph, boundNode, unboundNode, binding, isSubjectBound, predicate, execCxt);
+ } else {
+ //Only retrieve those in the spatial index which are within same bounding box.
+ queryIterConcat = findIndex(graph, boundNode, unboundNode, binding, isSubjectBound, predicate, execCxt);
+ }
+
+ return queryIterConcat;
+ }
+
+ private QueryIterConcat findAll(Graph graph, Node boundNode, Node unboundNode, Binding binding, boolean isSubjectBound, Node predicate, ExecutionContext execCxt) {
+
+ //Prepare the results.
+ Var unboundVar = Var.alloc(unboundNode.getName());
+ QueryIterConcat queryIterConcat = new QueryIterConcat(execCxt);
+
+ //Search for both Features and Geometry in the Graph.
+ ExtendedIterator<Triple> spatialTriples;
+ if (graph.contains(null, RDF.type.asNode(), Geo.SPATIAL_OBJECT_NODE)) {
+ spatialTriples = graph.find(null, RDF.type.asNode(), Geo.SPATIAL_OBJECT_NODE);
+ } else {
+ //Check for Geo Predicate Features in the Graph if no GeometryLiterals found.
+ spatialTriples = graph.find(null, SpatialExtension.GEO_LAT_NODE, null);
+ }
+
+ while (spatialTriples.hasNext()) {
+ Triple spatialTriple = spatialTriples.next();
+ Node spatialNode = spatialTriple.getSubject();
+ Binding newBind = BindingFactory.binding(binding, unboundVar, spatialNode);
+ QueryIterator queryIter;
+ if (isSubjectBound) {
+ queryIter = bothBound(newBind, boundNode, predicate, spatialNode, execCxt);
+ } else {
+ queryIter = bothBound(newBind, spatialNode, predicate, boundNode, execCxt);
+ }
+ queryIterConcat.add(queryIter);
+ }
+
+ return queryIterConcat;
+ }
+
+ private QueryIterConcat findIndex(Graph graph, Node boundNode, Node unboundNode, Binding binding, boolean isSubjectBound, Node predicate, ExecutionContext execCxt) throws ExprEvalException {
+
+ try {
+ //Prepare for results.
+ Var unboundVar = Var.alloc(unboundNode.getName());
+ QueryIterConcat queryIterConcat = new QueryIterConcat(execCxt);
+
+ //Find the asserted triples.
+ List<Node> assertedNodes = findAsserted(graph, boundNode, isSubjectBound, predicate);
+ for (Node node : assertedNodes) {
+ Binding newBind = BindingFactory.binding(binding, unboundVar, node);
+ QueryIterator queryIter = QueryIterSingleton.create(newBind, execCxt);
+ queryIterConcat.add(queryIter);
+ }
+
+ //Find the GeometryLiteral of the Bound Node.
+ SpatialObjectGeometryLiteral boundGeometryLiteral = SpatialObjectGeometryLiteral.retrieve(graph, boundNode);
+ if (!boundGeometryLiteral.isValid()) {
+ //Bound Node is not a Feature or a Geometry or there is no GeometryLiteral so exit.
+ return queryIterConcat;
+ }
+
+ Node geometryLiteral = boundGeometryLiteral.getGeometryLiteral();
+
+ //Perform the search of the Spatial Index of the Dataset.
+ SpatialIndex spatialIndex = SpatialIndex.retrieve(execCxt);
+ GeometryWrapper geom = GeometryWrapper.extract(geometryLiteral);
+ GeometryWrapper transformedGeom = geom.transform(spatialIndex.getSrsInfo());
+ Envelope searchEnvelope = transformedGeom.getEnvelope();
+ HashSet<Resource> features = spatialIndex.query(searchEnvelope);
+
+ //Check each of the Features that match the search.
+ for (Resource feature : features) {
+ Node featureNode = feature.asNode();
+
+ //Ensure not already an asserted node.
+ if (!assertedNodes.contains(featureNode)) {
+
+ Binding newBind = BindingFactory.binding(binding, unboundVar, featureNode);
+ QueryIterator queryIter;
+ if (isSubjectBound) {
+ queryIter = bothBound(newBind, boundNode, predicate, featureNode, execCxt);
+ } else {
+ queryIter = bothBound(newBind, featureNode, predicate, boundNode, execCxt);
+ }
+ queryIterConcat.add(queryIter);
+ }
+
+ //Also test all Geometry of the Features. All, some or one Geometry may have matched.
+ ExtendedIterator<Triple> featureGeometryTriples = graph.find(feature.asNode(), Geo.HAS_GEOMETRY_NODE, null);
+ while (featureGeometryTriples.hasNext()) {
+ Triple unboundTriple = featureGeometryTriples.next();
+ Node geomNode = unboundTriple.getObject();
+
+ //Ensure not already an asserted node.
+ if (!assertedNodes.contains(geomNode)) {
+ Binding newBind = BindingFactory.binding(binding, unboundVar, geomNode);
+ QueryIterator queryIter;
+ if (isSubjectBound) {
+ queryIter = bothBound(newBind, boundNode, predicate, geomNode, execCxt);
+ } else {
+ queryIter = bothBound(newBind, geomNode, predicate, boundNode, execCxt);
+ }
+ queryIterConcat.add(queryIter);
+ }
+ }
+ }
+
+ return queryIterConcat;
+ } catch (MismatchedDimensionException | TransformException | FactoryException | SpatialIndexException ex) {
+ throw new ExprEvalException(ex.getMessage() + ": " + FmtUtils.stringForNode(boundNode) + ", " + FmtUtils.stringForNode(unboundNode) + ", " + FmtUtils.stringForNode(predicate), ex);
+ }
+ }
+
+ private List<Node> findAsserted(Graph graph, Node boundNode, boolean isSubjectBound, Node predicate) {
+ List<Node> assertedNodes = new ArrayList<>();
+ if (isSubjectBound) {
+ ExtendedIterator<Triple> assertedTriples = graph.find(boundNode, predicate, null);
+ while (assertedTriples.hasNext()) {
+ Node assertedNode = assertedTriples.next().getObject();
+ assertedNodes.add(assertedNode);
+ }
+ } else {
+ ExtendedIterator<Triple> assertedTriples = graph.find(null, predicate, boundNode);
+ while (assertedTriples.hasNext()) {
+ Node assertedNode = assertedTriples.next().getSubject();
+ assertedNodes.add(assertedNode);
+ }
+ }
+ return assertedNodes;
+ }
+
+ protected final Boolean queryRewrite(Graph graph, Node subject, Node predicate, Node object, QueryRewriteIndex queryRewriteIndex) {
+
+ if (graph.contains(subject, predicate, object)) {
+ //The graph contains the asserted triple, return the current binding.
+ return true;
+ }
+
+ //If query re-writing is disabled then exit - already checked that graph does not contain the asserted relation.
+ if (!queryRewriteIndex.isIndexActive()) {
+ return false;
+ }
+
+ //Begin Query Re-write by finding the literals of the Feature or Geometry.
+ SpatialObjectGeometryLiteral subjectSpatialLiteral = SpatialObjectGeometryLiteral.retrieve(graph, subject);
+ if (!subjectSpatialLiteral.isValid()) {
+ //Subject is not a Feature or a Geometry or there is no GeometryLiteral so exit.
+ return false;
+ }
+
+ SpatialObjectGeometryLiteral objectSpatialLiteral = SpatialObjectGeometryLiteral.retrieve(graph, object);
+ if (!objectSpatialLiteral.isValid()) {
+ //Object is not a Feature or a Geometry or there is no GeometryLiteral so exit.
+ return false;
+ }
+
+ //Check the QueryRewriteIndex for the result.
+ Property predicateProp = ResourceFactory.createProperty(predicate.getURI());
+ Boolean isPositive = queryRewriteIndex.test(subjectSpatialLiteral.getGeometryLiteral(), predicateProp, objectSpatialLiteral.getGeometryLiteral(), this);
+ return isPositive;
+ }
+
+ public Boolean testFilterFunction(Node subjectGeometryLiteral, Node objectGeometryLiteral) {
+ return filterFunction.exec(subjectGeometryLiteral, objectGeometryLiteral);
+ }
+
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/GenericFilterFunction.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/GenericFilterFunction.java
index 80037dd..1e034ef 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/GenericFilterFunction.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/GenericFilterFunction.java
@@ -1,81 +1,81 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological;
-
-import org.apache.jena.datatypes.DatatypeFormatException;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.apache.jena.geosparql.implementation.index.GeometryLiteralIndex.GeometryIndex;
-import org.apache.jena.graph.Node;
-import org.apache.jena.sparql.expr.ExprEvalException;
-import org.apache.jena.sparql.expr.NodeValue;
-import org.apache.jena.sparql.function.FunctionBase2;
-import org.apache.jena.sparql.util.FmtUtils;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public abstract class GenericFilterFunction extends FunctionBase2 {
-
- @Override
- public NodeValue exec(NodeValue v1, NodeValue v2) {
- boolean result = exec(v1.asNode(), v2.asNode());
- return NodeValue.makeBoolean(result);
- }
-
- public Boolean exec(Node v1, Node v2) {
- try {
-
- //Check if the first literal is unparseable or geometry is empty (always fails).
- GeometryWrapper geometry1 = GeometryWrapper.extract(v1, GeometryIndex.PRIMARY);
-
- if (geometry1.isEmpty()) {
- return Boolean.FALSE;
- }
-
- //Check if the second literal is unparseable or geometry is empty (always fails).
- GeometryWrapper geometry2 = GeometryWrapper.extract(v2, GeometryIndex.SECONDARY);
-
- if (geometry2.isEmpty()) {
- return Boolean.FALSE;
- }
-
- if (!permittedTopology(geometry1.getDimensionInfo(), geometry2.getDimensionInfo())) {
- return Boolean.FALSE;
- }
-
- boolean result = relate(geometry1, geometry2);
- return result;
- } catch (DatatypeFormatException | FactoryException | MismatchedDimensionException | TransformException ex) {
- throw new ExprEvalException(ex.getMessage() + ": " + FmtUtils.stringForNode(v1) + ", " + FmtUtils.stringForNode(v2), ex);
- }
- }
-
- protected abstract boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo);
-
- protected abstract boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException;
-
- public abstract boolean isDisjoint();
-
- public abstract boolean isDisconnected();
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological;
+
+import org.apache.jena.datatypes.DatatypeFormatException;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.apache.jena.geosparql.implementation.index.GeometryLiteralIndex.GeometryIndex;
+import org.apache.jena.graph.Node;
+import org.apache.jena.sparql.expr.ExprEvalException;
+import org.apache.jena.sparql.expr.NodeValue;
+import org.apache.jena.sparql.function.FunctionBase2;
+import org.apache.jena.sparql.util.FmtUtils;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public abstract class GenericFilterFunction extends FunctionBase2 {
+
+ @Override
+ public NodeValue exec(NodeValue v1, NodeValue v2) {
+ boolean result = exec(v1.asNode(), v2.asNode());
+ return NodeValue.makeBoolean(result);
+ }
+
+ public Boolean exec(Node v1, Node v2) {
+ try {
+
+ //Check if the first literal is unparseable or geometry is empty (always fails).
+ GeometryWrapper geometry1 = GeometryWrapper.extract(v1, GeometryIndex.PRIMARY);
+
+ if (geometry1.isEmpty()) {
+ return Boolean.FALSE;
+ }
+
+ //Check if the second literal is unparseable or geometry is empty (always fails).
+ GeometryWrapper geometry2 = GeometryWrapper.extract(v2, GeometryIndex.SECONDARY);
+
+ if (geometry2.isEmpty()) {
+ return Boolean.FALSE;
+ }
+
+ if (!permittedTopology(geometry1.getDimensionInfo(), geometry2.getDimensionInfo())) {
+ return Boolean.FALSE;
+ }
+
+ boolean result = relate(geometry1, geometry2);
+ return result;
+ } catch (DatatypeFormatException | FactoryException | MismatchedDimensionException | TransformException ex) {
+ throw new ExprEvalException(ex.getMessage() + ": " + FmtUtils.stringForNode(v1) + ", " + FmtUtils.stringForNode(v2), ex);
+ }
+ }
+
+ protected abstract boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo);
+
+ protected abstract boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException;
+
+ public abstract boolean isDisjoint();
+
+ public abstract boolean isDisconnected();
+
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhContainsFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhContainsFF.java
index 42373ca..5afe0b1 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhContainsFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhContainsFF.java
@@ -1,54 +1,54 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.egenhofer;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.apache.jena.geosparql.implementation.intersection_patterns.EgenhoferIntersectionPattern;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class EhContainsFF extends GenericFilterFunction {
-
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.relate(targetGeometry, EgenhoferIntersectionPattern.CONTAINS);
- }
-
- @Override
- public boolean isDisjoint() {
- return false;
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return true;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.egenhofer;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.apache.jena.geosparql.implementation.intersection_patterns.EgenhoferIntersectionPattern;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class EhContainsFF extends GenericFilterFunction {
+
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.relate(targetGeometry, EgenhoferIntersectionPattern.CONTAINS);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return false;
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return true;
+ }
+
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhCoveredByFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhCoveredByFF.java
index d594aa2..54e7ad0 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhCoveredByFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhCoveredByFF.java
@@ -1,53 +1,53 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.egenhofer;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.apache.jena.geosparql.implementation.intersection_patterns.EgenhoferIntersectionPattern;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class EhCoveredByFF extends GenericFilterFunction {
-
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.relate(targetGeometry, EgenhoferIntersectionPattern.COVERED_BY);
- }
-
- @Override
- public boolean isDisjoint() {
- return false;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return (sourceDimensionInfo.isArea() && targetDimensionInfo.isArea()) || (sourceDimensionInfo.isLine() && targetDimensionInfo.isArea()) || (sourceDimensionInfo.isLine() && targetDimensionInfo.isLine());
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.egenhofer;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.apache.jena.geosparql.implementation.intersection_patterns.EgenhoferIntersectionPattern;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class EhCoveredByFF extends GenericFilterFunction {
+
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.relate(targetGeometry, EgenhoferIntersectionPattern.COVERED_BY);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return false;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return (sourceDimensionInfo.isArea() && targetDimensionInfo.isArea()) || (sourceDimensionInfo.isLine() && targetDimensionInfo.isArea()) || (sourceDimensionInfo.isLine() && targetDimensionInfo.isLine());
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhCoversFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhCoversFF.java
index 019def5..663ae86 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhCoversFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhCoversFF.java
@@ -1,53 +1,53 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.egenhofer;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.apache.jena.geosparql.implementation.intersection_patterns.EgenhoferIntersectionPattern;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class EhCoversFF extends GenericFilterFunction {
-
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.relate(targetGeometry, EgenhoferIntersectionPattern.COVERS);
- }
-
- @Override
- public boolean isDisjoint() {
- return false;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return (sourceDimensionInfo.isArea() && targetDimensionInfo.isArea()) || (sourceDimensionInfo.isArea() && targetDimensionInfo.isLine()) || (sourceDimensionInfo.isLine() && targetDimensionInfo.isLine());
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.egenhofer;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.apache.jena.geosparql.implementation.intersection_patterns.EgenhoferIntersectionPattern;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class EhCoversFF extends GenericFilterFunction {
+
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.relate(targetGeometry, EgenhoferIntersectionPattern.COVERS);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return false;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return (sourceDimensionInfo.isArea() && targetDimensionInfo.isArea()) || (sourceDimensionInfo.isArea() && targetDimensionInfo.isLine()) || (sourceDimensionInfo.isLine() && targetDimensionInfo.isLine());
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhDisjointFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhDisjointFF.java
index ec92e30..333b4a3 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhDisjointFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhDisjointFF.java
@@ -1,53 +1,53 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.egenhofer;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class EhDisjointFF extends GenericFilterFunction {
-
- //Simple Features and Egenhofer disjoint intersection patterns are the same, see GeoSPARQL standard page 11.
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.disjoint(targetGeometry);
- }
-
- @Override
- public boolean isDisjoint() {
- return true;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return true;
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.egenhofer;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class EhDisjointFF extends GenericFilterFunction {
+
+ //Simple Features and Egenhofer disjoint intersection patterns are the same, see GeoSPARQL standard page 11.
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.disjoint(targetGeometry);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return true;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return true;
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhEqualsFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhEqualsFF.java
index 43acef7..15c5be6 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhEqualsFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhEqualsFF.java
@@ -1,53 +1,53 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.egenhofer;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.apache.jena.geosparql.implementation.intersection_patterns.EgenhoferIntersectionPattern;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class EhEqualsFF extends GenericFilterFunction {
-
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.relate(targetGeometry, EgenhoferIntersectionPattern.EQUALS);
- }
-
- @Override
- public boolean isDisjoint() {
- return false;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return true;
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.egenhofer;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.apache.jena.geosparql.implementation.intersection_patterns.EgenhoferIntersectionPattern;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class EhEqualsFF extends GenericFilterFunction {
+
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.relate(targetGeometry, EgenhoferIntersectionPattern.EQUALS);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return false;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return true;
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhInsideFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhInsideFF.java
index 0f89856..228060a 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhInsideFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhInsideFF.java
@@ -1,53 +1,53 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.egenhofer;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.apache.jena.geosparql.implementation.intersection_patterns.EgenhoferIntersectionPattern;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class EhInsideFF extends GenericFilterFunction {
-
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.relate(targetGeometry, EgenhoferIntersectionPattern.INSIDE);
- }
-
- @Override
- public boolean isDisjoint() {
- return false;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return true;
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.egenhofer;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.apache.jena.geosparql.implementation.intersection_patterns.EgenhoferIntersectionPattern;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class EhInsideFF extends GenericFilterFunction {
+
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.relate(targetGeometry, EgenhoferIntersectionPattern.INSIDE);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return false;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return true;
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhMeetFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhMeetFF.java
index 2c59b04..4689975 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhMeetFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhMeetFF.java
@@ -1,53 +1,53 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.egenhofer;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class EhMeetFF extends GenericFilterFunction {
-
- //Simple Features touches and Egenhofer meet intersection patterns are the same, see GeoSPARQL standard page 11.
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.touches(targetGeometry);
- }
-
- @Override
- public boolean isDisjoint() {
- return false;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return !(sourceDimensionInfo.isPoint() && targetDimensionInfo.isPoint());
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.egenhofer;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class EhMeetFF extends GenericFilterFunction {
+
+ //Simple Features touches and Egenhofer meet intersection patterns are the same, see GeoSPARQL standard page 11.
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.touches(targetGeometry);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return false;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return !(sourceDimensionInfo.isPoint() && targetDimensionInfo.isPoint());
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhOverlapFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhOverlapFF.java
index bcb1b7a..5568276 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhOverlapFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/egenhofer/EhOverlapFF.java
@@ -1,53 +1,53 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.egenhofer;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.apache.jena.geosparql.implementation.intersection_patterns.EgenhoferIntersectionPattern;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class EhOverlapFF extends GenericFilterFunction {
-
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.relate(targetGeometry, EgenhoferIntersectionPattern.OVERLAP);
- }
-
- @Override
- public boolean isDisjoint() {
- return false;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return true;
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.egenhofer;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.apache.jena.geosparql.implementation.intersection_patterns.EgenhoferIntersectionPattern;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class EhOverlapFF extends GenericFilterFunction {
+
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.relate(targetGeometry, EgenhoferIntersectionPattern.OVERLAP);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return false;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return true;
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccDisconnectedFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccDisconnectedFF.java
index de6419e..ccb15d7 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccDisconnectedFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccDisconnectedFF.java
@@ -1,53 +1,53 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.rcc8;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.apache.jena.geosparql.implementation.intersection_patterns.RCC8IntersectionPattern;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class RccDisconnectedFF extends GenericFilterFunction {
-
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.relate(targetGeometry, RCC8IntersectionPattern.DISCONNECTED);
- }
-
- @Override
- public boolean isDisjoint() {
- return true;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return sourceDimensionInfo.isArea() && targetDimensionInfo.isArea();
- }
-
- @Override
- public boolean isDisconnected() {
- return true;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.rcc8;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.apache.jena.geosparql.implementation.intersection_patterns.RCC8IntersectionPattern;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class RccDisconnectedFF extends GenericFilterFunction {
+
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.relate(targetGeometry, RCC8IntersectionPattern.DISCONNECTED);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return true;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return sourceDimensionInfo.isArea() && targetDimensionInfo.isArea();
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return true;
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccEqualsFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccEqualsFF.java
index 4cc7565..34a62a9 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccEqualsFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccEqualsFF.java
@@ -1,53 +1,53 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.rcc8;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.apache.jena.geosparql.implementation.intersection_patterns.RCC8IntersectionPattern;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class RccEqualsFF extends GenericFilterFunction {
-
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.relate(targetGeometry, RCC8IntersectionPattern.EQUALS);
- }
-
- @Override
- public boolean isDisjoint() {
- return false;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return sourceDimensionInfo.isArea() && targetDimensionInfo.isArea();
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.rcc8;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.apache.jena.geosparql.implementation.intersection_patterns.RCC8IntersectionPattern;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class RccEqualsFF extends GenericFilterFunction {
+
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.relate(targetGeometry, RCC8IntersectionPattern.EQUALS);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return false;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return sourceDimensionInfo.isArea() && targetDimensionInfo.isArea();
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccExternallyConnectedFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccExternallyConnectedFF.java
index 4763dc3..99275d4 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccExternallyConnectedFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccExternallyConnectedFF.java
@@ -1,53 +1,53 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.rcc8;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.apache.jena.geosparql.implementation.intersection_patterns.RCC8IntersectionPattern;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class RccExternallyConnectedFF extends GenericFilterFunction {
-
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.relate(targetGeometry, RCC8IntersectionPattern.EXTERNALLY_CONNECTED);
- }
-
- @Override
- public boolean isDisjoint() {
- return false;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return sourceDimensionInfo.isArea() && targetDimensionInfo.isArea();
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.rcc8;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.apache.jena.geosparql.implementation.intersection_patterns.RCC8IntersectionPattern;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class RccExternallyConnectedFF extends GenericFilterFunction {
+
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.relate(targetGeometry, RCC8IntersectionPattern.EXTERNALLY_CONNECTED);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return false;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return sourceDimensionInfo.isArea() && targetDimensionInfo.isArea();
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccNonTangentialProperPartFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccNonTangentialProperPartFF.java
index 987fe1b..e78f3b9 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccNonTangentialProperPartFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccNonTangentialProperPartFF.java
@@ -1,53 +1,53 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.rcc8;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.apache.jena.geosparql.implementation.intersection_patterns.RCC8IntersectionPattern;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class RccNonTangentialProperPartFF extends GenericFilterFunction {
-
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.relate(targetGeometry, RCC8IntersectionPattern.NON_TANGENTIAL_PROPER_PART);
- }
-
- @Override
- public boolean isDisjoint() {
- return false;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return sourceDimensionInfo.isArea() && targetDimensionInfo.isArea();
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.rcc8;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.apache.jena.geosparql.implementation.intersection_patterns.RCC8IntersectionPattern;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class RccNonTangentialProperPartFF extends GenericFilterFunction {
+
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.relate(targetGeometry, RCC8IntersectionPattern.NON_TANGENTIAL_PROPER_PART);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return false;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return sourceDimensionInfo.isArea() && targetDimensionInfo.isArea();
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccNonTangentialProperPartInverseFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccNonTangentialProperPartInverseFF.java
index 70cac9a..0b90971 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccNonTangentialProperPartInverseFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccNonTangentialProperPartInverseFF.java
@@ -1,53 +1,53 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.rcc8;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.apache.jena.geosparql.implementation.intersection_patterns.RCC8IntersectionPattern;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class RccNonTangentialProperPartInverseFF extends GenericFilterFunction {
-
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.relate(targetGeometry, RCC8IntersectionPattern.NON_TANGENTIAL_PROPER_PART_INVERSE);
- }
-
- @Override
- public boolean isDisjoint() {
- return false;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return sourceDimensionInfo.isArea() && targetDimensionInfo.isArea();
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.rcc8;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.apache.jena.geosparql.implementation.intersection_patterns.RCC8IntersectionPattern;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class RccNonTangentialProperPartInverseFF extends GenericFilterFunction {
+
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.relate(targetGeometry, RCC8IntersectionPattern.NON_TANGENTIAL_PROPER_PART_INVERSE);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return false;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return sourceDimensionInfo.isArea() && targetDimensionInfo.isArea();
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccPartiallyOverlappingFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccPartiallyOverlappingFF.java
index 1f65dd9..5ec268d 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccPartiallyOverlappingFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccPartiallyOverlappingFF.java
@@ -1,54 +1,54 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.rcc8;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.apache.jena.geosparql.implementation.intersection_patterns.RCC8IntersectionPattern;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class RccPartiallyOverlappingFF extends GenericFilterFunction {
-
- //Simple Features overlaps and RCC8 partially overlapping intersection patterns are the same, see GeoSPARQL standard page 11.
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.relate(targetGeometry, RCC8IntersectionPattern.PARTIALLY_OVERLAPPING);
- }
-
- @Override
- public boolean isDisjoint() {
- return false;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return sourceDimensionInfo.isArea() && targetDimensionInfo.isArea();
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.rcc8;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.apache.jena.geosparql.implementation.intersection_patterns.RCC8IntersectionPattern;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class RccPartiallyOverlappingFF extends GenericFilterFunction {
+
+ //Simple Features overlaps and RCC8 partially overlapping intersection patterns are the same, see GeoSPARQL standard page 11.
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.relate(targetGeometry, RCC8IntersectionPattern.PARTIALLY_OVERLAPPING);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return false;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return sourceDimensionInfo.isArea() && targetDimensionInfo.isArea();
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccTangentialProperPartFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccTangentialProperPartFF.java
index e012c1e..0d540c2 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccTangentialProperPartFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccTangentialProperPartFF.java
@@ -1,53 +1,53 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.rcc8;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.apache.jena.geosparql.implementation.intersection_patterns.RCC8IntersectionPattern;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class RccTangentialProperPartFF extends GenericFilterFunction {
-
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.relate(targetGeometry, RCC8IntersectionPattern.TANGENTIAL_PROPER_PART);
- }
-
- @Override
- public boolean isDisjoint() {
- return false;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return sourceDimensionInfo.isArea() && targetDimensionInfo.isArea();
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.rcc8;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.apache.jena.geosparql.implementation.intersection_patterns.RCC8IntersectionPattern;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class RccTangentialProperPartFF extends GenericFilterFunction {
+
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.relate(targetGeometry, RCC8IntersectionPattern.TANGENTIAL_PROPER_PART);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return false;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return sourceDimensionInfo.isArea() && targetDimensionInfo.isArea();
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccTangentialProperPartInverseFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccTangentialProperPartInverseFF.java
index f331abf..3cb849f 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccTangentialProperPartInverseFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/rcc8/RccTangentialProperPartInverseFF.java
@@ -1,53 +1,53 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.rcc8;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.apache.jena.geosparql.implementation.intersection_patterns.RCC8IntersectionPattern;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class RccTangentialProperPartInverseFF extends GenericFilterFunction {
-
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.relate(targetGeometry, RCC8IntersectionPattern.TANGENTIAL_PROPER_PART_INVERSE);
- }
-
- @Override
- public boolean isDisjoint() {
- return false;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return sourceDimensionInfo.isArea() && targetDimensionInfo.isArea();
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.rcc8;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.apache.jena.geosparql.implementation.intersection_patterns.RCC8IntersectionPattern;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class RccTangentialProperPartInverseFF extends GenericFilterFunction {
+
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.relate(targetGeometry, RCC8IntersectionPattern.TANGENTIAL_PROPER_PART_INVERSE);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return false;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return sourceDimensionInfo.isArea() && targetDimensionInfo.isArea();
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfContainsFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfContainsFF.java
index 4caee05..faff8dc 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfContainsFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfContainsFF.java
@@ -1,53 +1,53 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.simple_features;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class SfContainsFF extends GenericFilterFunction {
-
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.contains(targetGeometry);
- }
-
- @Override
- public boolean isDisjoint() {
- return false;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return true;
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.simple_features;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class SfContainsFF extends GenericFilterFunction {
+
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.contains(targetGeometry);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return false;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return true;
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfCrossesFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfCrossesFF.java
index bdb86d2..ec86d18 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfCrossesFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfCrossesFF.java
@@ -1,52 +1,52 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.simple_features;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class SfCrossesFF extends GenericFilterFunction {
-
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.crosses(targetGeometry);
- }
-
- @Override
- public boolean isDisjoint() {
- return false;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return (sourceDimensionInfo.isPoint() && targetDimensionInfo.isLine()) || (sourceDimensionInfo.isPoint() && targetDimensionInfo.isArea()) || (sourceDimensionInfo.isLine() && targetDimensionInfo.isArea()) || (sourceDimensionInfo.isLine() && targetDimensionInfo.isLine());
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.simple_features;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class SfCrossesFF extends GenericFilterFunction {
+
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.crosses(targetGeometry);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return false;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return (sourceDimensionInfo.isPoint() && targetDimensionInfo.isLine()) || (sourceDimensionInfo.isPoint() && targetDimensionInfo.isArea()) || (sourceDimensionInfo.isLine() && targetDimensionInfo.isArea()) || (sourceDimensionInfo.isLine() && targetDimensionInfo.isLine());
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfDisjointFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfDisjointFF.java
index ee788aa..588fd33 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfDisjointFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfDisjointFF.java
@@ -1,52 +1,52 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.simple_features;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class SfDisjointFF extends GenericFilterFunction {
-
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.disjoint(targetGeometry);
- }
-
- @Override
- public boolean isDisjoint() {
- return true;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return true;
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.simple_features;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class SfDisjointFF extends GenericFilterFunction {
+
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.disjoint(targetGeometry);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return true;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return true;
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfEqualsFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfEqualsFF.java
index 842e95a..fe11f90 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfEqualsFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfEqualsFF.java
@@ -1,54 +1,54 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.simple_features;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.apache.jena.geosparql.implementation.intersection_patterns.SimpleFeaturesIntersectionPattern;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class SfEqualsFF extends GenericFilterFunction {
-
- //SimmpleFeatures equals patterns differs from those stated in JTS equals, see GeoSPARQL standard page 8.
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.relate(targetGeometry, SimpleFeaturesIntersectionPattern.EQUALS);
- }
-
- @Override
- public boolean isDisjoint() {
- return false;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return true;
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.simple_features;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.apache.jena.geosparql.implementation.intersection_patterns.SimpleFeaturesIntersectionPattern;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class SfEqualsFF extends GenericFilterFunction {
+
+ //SimmpleFeatures equals patterns differs from those stated in JTS equals, see GeoSPARQL standard page 8.
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.relate(targetGeometry, SimpleFeaturesIntersectionPattern.EQUALS);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return false;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return true;
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfIntersectsFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfIntersectsFF.java
index 75fdaad..6afccca 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfIntersectsFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfIntersectsFF.java
@@ -1,52 +1,52 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.simple_features;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class SfIntersectsFF extends GenericFilterFunction {
-
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.intersects(targetGeometry);
- }
-
- @Override
- public boolean isDisjoint() {
- return false;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return true;
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.simple_features;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class SfIntersectsFF extends GenericFilterFunction {
+
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.intersects(targetGeometry);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return false;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return true;
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfOverlapsFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfOverlapsFF.java
index a33e9ca..7872bb4 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfOverlapsFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfOverlapsFF.java
@@ -1,52 +1,52 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.simple_features;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class SfOverlapsFF extends GenericFilterFunction {
-
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.overlaps(targetGeometry);
- }
-
- @Override
- public boolean isDisjoint() {
- return false;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return (sourceDimensionInfo.isArea() && targetDimensionInfo.isArea()) || (sourceDimensionInfo.isPoint() && targetDimensionInfo.isPoint()) || (sourceDimensionInfo.isLine() && targetDimensionInfo.isLine());
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.simple_features;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class SfOverlapsFF extends GenericFilterFunction {
+
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.overlaps(targetGeometry);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return false;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return (sourceDimensionInfo.isArea() && targetDimensionInfo.isArea()) || (sourceDimensionInfo.isPoint() && targetDimensionInfo.isPoint()) || (sourceDimensionInfo.isLine() && targetDimensionInfo.isLine());
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfTouchesFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfTouchesFF.java
index 1470b32..5f14210 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfTouchesFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfTouchesFF.java
@@ -1,52 +1,52 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.simple_features;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class SfTouchesFF extends GenericFilterFunction {
-
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.touches(targetGeometry);
- }
-
- @Override
- public boolean isDisjoint() {
- return false;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return !(sourceDimensionInfo.isPoint() && targetDimensionInfo.isPoint());
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.simple_features;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class SfTouchesFF extends GenericFilterFunction {
+
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.touches(targetGeometry);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return false;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return !(sourceDimensionInfo.isPoint() && targetDimensionInfo.isPoint());
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfWithinFF.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfWithinFF.java
index e0b996c..a50822e 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfWithinFF.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/geof/topological/filter_functions/simple_features/SfWithinFF.java
@@ -1,52 +1,52 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.geof.topological.filter_functions.simple_features;
-
-import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class SfWithinFF extends GenericFilterFunction {
-
- @Override
- protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return sourceGeometry.within(targetGeometry);
- }
-
- @Override
- public boolean isDisjoint() {
- return false;
- }
-
- @Override
- protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
- return true;
- }
-
- @Override
- public boolean isDisconnected() {
- return false;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.geof.topological.filter_functions.simple_features;
+
+import org.apache.jena.geosparql.geof.topological.GenericFilterFunction;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class SfWithinFF extends GenericFilterFunction {
+
+ @Override
+ protected boolean relate(GeometryWrapper sourceGeometry, GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return sourceGeometry.within(targetGeometry);
+ }
+
+ @Override
+ public boolean isDisjoint() {
+ return false;
+ }
+
+ @Override
+ protected boolean permittedTopology(DimensionInfo sourceDimensionInfo, DimensionInfo targetDimensionInfo) {
+ return true;
+ }
+
+ @Override
+ public boolean isDisconnected() {
+ return false;
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/DimensionInfo.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/DimensionInfo.java
index cd9f1bd..6850974 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/DimensionInfo.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/DimensionInfo.java
@@ -1,216 +1,216 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.implementation;
-
-import java.io.Serializable;
-import java.util.List;
-import java.util.Objects;
-import org.apache.jena.geosparql.implementation.jts.CoordinateSequenceDimensions;
-import static org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence.findCoordinateSequenceDimensions;
-import org.locationtech.jts.geom.Coordinate;
-import org.locationtech.jts.geom.CoordinateXY;
-import org.locationtech.jts.geom.Geometry;
-
-/**
- *
- *
- */
-public class DimensionInfo implements Serializable {
-
- private final int coordinate;
- private final int spatial;
- private final int topological;
- private final CoordinateSequenceDimensions coordinateSequenceDimensions;
-
- private final boolean isPoint;
- private final boolean isLine;
- private final boolean isArea;
-
- public DimensionInfo(CoordinateSequenceDimensions coordinateSequenceDimensions, int topological) {
- this.coordinateSequenceDimensions = coordinateSequenceDimensions;
- this.topological = topological;
- this.coordinate = findCoordinateDimension(coordinateSequenceDimensions);
- this.spatial = findSpatialDimension(coordinateSequenceDimensions);
- this.isPoint = topological == 0;
- this.isLine = topological == 1;
- this.isArea = topological == 2;
- }
-
- public DimensionInfo(int coordinate, int spatial, int topological) {
- this.coordinate = coordinate;
- this.spatial = spatial;
- this.topological = topological;
- this.coordinateSequenceDimensions = findCoordinateSequenceDimensions(coordinate, spatial);
- this.isPoint = topological == 0;
- this.isLine = topological == 1;
- this.isArea = topological == 2;
- }
-
- public static int findSpatialDimension(CoordinateSequenceDimensions dims) {
-
- switch (dims) {
- case XYZ:
- case XYZM:
- return 3;
- default:
- return 2;
- }
- }
-
- public static int findCoordinateDimension(CoordinateSequenceDimensions dims) {
- switch (dims) {
- case XYZ:
- case XYM:
- return 3;
- case XYZM:
- return 4;
- default:
- return 2;
- }
- }
-
- public static DimensionInfo find(Coordinate coordinate, Geometry geometry) {
- CoordinateSequenceDimensions coordDims = CoordinateSequenceDimensions.find(coordinate);
- return new DimensionInfo(coordDims, geometry.getDimension());
- }
-
- private static final Coordinate XY_COORDINATE = new CoordinateXY(0, 0);
-
- public static DimensionInfo find(Coordinate[] coordinates, Geometry geometry) {
- Coordinate coordinate;
- if (coordinates.length == 0) {
- coordinate = XY_COORDINATE;
- } else {
- coordinate = coordinates[0];
- }
- return find(coordinate, geometry);
- }
-
- public static DimensionInfo find(List<Coordinate> coordinates, Geometry geometry) {
- Coordinate coordinate;
- if (coordinates.isEmpty()) {
- coordinate = XY_COORDINATE;
- } else {
- coordinate = coordinates.get(0);
- }
- return find(coordinate, geometry);
- }
-
- public static DimensionInfo findCollection(List<? extends Geometry> geometries, Geometry geometry) {
- Coordinate coordinate;
- if (geometries.isEmpty()) {
- coordinate = XY_COORDINATE;
- } else {
- Geometry geom = geometries.get(0);
- coordinate = geom.getCoordinate();
- }
- return find(coordinate, geometry);
- }
-
- public int getCoordinate() {
- return coordinate;
- }
-
- public int getSpatial() {
- return spatial;
- }
-
- public int getTopological() {
- return topological;
- }
-
- public boolean isPoint() {
- return isPoint;
- }
-
- public boolean isLine() {
- return isLine;
- }
-
- public boolean isArea() {
- return isArea;
- }
-
- public CoordinateSequenceDimensions getDimensions() {
- return coordinateSequenceDimensions;
- }
-
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 53 * hash + this.coordinate;
- hash = 53 * hash + this.spatial;
- hash = 53 * hash + this.topological;
- hash = 53 * hash + Objects.hashCode(this.coordinateSequenceDimensions);
- return hash;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final DimensionInfo other = (DimensionInfo) obj;
- if (this.coordinate != other.coordinate) {
- return false;
- }
- if (this.spatial != other.spatial) {
- return false;
- }
- if (this.topological != other.topological) {
- return false;
- }
- return this.coordinateSequenceDimensions == other.coordinateSequenceDimensions;
- }
-
- @Override
- public String toString() {
- return "DimensionInfo{" + "coordinate=" + coordinate + ", spatial=" + spatial + ", topological=" + topological + ", coordinateSequenceDimensions=" + coordinateSequenceDimensions + ", isPoint=" + isPoint + ", isLine=" + isLine + ", isArea=" + isArea + '}';
- }
-
- public static DimensionInfo XY_POINT = new DimensionInfo(2, 2, 0);
-
- public static DimensionInfo XYZ_POINT = new DimensionInfo(3, 3, 0);
-
- public static DimensionInfo XYM_POINT = new DimensionInfo(3, 2, 0);
-
- public static DimensionInfo XYZM_POINT = new DimensionInfo(4, 3, 0);
-
- public static DimensionInfo XY_LINESTRING = new DimensionInfo(2, 2, 1);
-
- public static DimensionInfo XYZ_LINESTRING = new DimensionInfo(3, 3, 1);
-
- public static DimensionInfo XYM_LINESTRING = new DimensionInfo(3, 2, 1);
-
- public static DimensionInfo XYZM_LINESTRING = new DimensionInfo(4, 3, 1);
-
- public static DimensionInfo XY_POLYGON = new DimensionInfo(2, 2, 2);
-
- public static DimensionInfo XYZ_POLYGON = new DimensionInfo(3, 3, 2);
-
- public static DimensionInfo XYM_POLYGON = new DimensionInfo(3, 2, 2);
-
- public static DimensionInfo XYZM_POLYGON = new DimensionInfo(4, 3, 2);
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.implementation;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Objects;
+import org.apache.jena.geosparql.implementation.jts.CoordinateSequenceDimensions;
+import static org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence.findCoordinateSequenceDimensions;
+import org.locationtech.jts.geom.Coordinate;
+import org.locationtech.jts.geom.CoordinateXY;
+import org.locationtech.jts.geom.Geometry;
+
+/**
+ *
+ *
+ */
+public class DimensionInfo implements Serializable {
+
+ private final int coordinate;
+ private final int spatial;
+ private final int topological;
+ private final CoordinateSequenceDimensions coordinateSequenceDimensions;
+
+ private final boolean isPoint;
+ private final boolean isLine;
+ private final boolean isArea;
+
+ public DimensionInfo(CoordinateSequenceDimensions coordinateSequenceDimensions, int topological) {
+ this.coordinateSequenceDimensions = coordinateSequenceDimensions;
+ this.topological = topological;
+ this.coordinate = findCoordinateDimension(coordinateSequenceDimensions);
+ this.spatial = findSpatialDimension(coordinateSequenceDimensions);
+ this.isPoint = topological == 0;
+ this.isLine = topological == 1;
+ this.isArea = topological == 2;
+ }
+
+ public DimensionInfo(int coordinate, int spatial, int topological) {
+ this.coordinate = coordinate;
+ this.spatial = spatial;
+ this.topological = topological;
+ this.coordinateSequenceDimensions = findCoordinateSequenceDimensions(coordinate, spatial);
+ this.isPoint = topological == 0;
+ this.isLine = topological == 1;
+ this.isArea = topological == 2;
+ }
+
+ public static int findSpatialDimension(CoordinateSequenceDimensions dims) {
+
+ switch (dims) {
+ case XYZ:
+ case XYZM:
+ return 3;
+ default:
+ return 2;
+ }
+ }
+
+ public static int findCoordinateDimension(CoordinateSequenceDimensions dims) {
+ switch (dims) {
+ case XYZ:
+ case XYM:
+ return 3;
+ case XYZM:
+ return 4;
+ default:
+ return 2;
+ }
+ }
+
+ public static DimensionInfo find(Coordinate coordinate, Geometry geometry) {
+ CoordinateSequenceDimensions coordDims = CoordinateSequenceDimensions.find(coordinate);
+ return new DimensionInfo(coordDims, geometry.getDimension());
+ }
+
+ private static final Coordinate XY_COORDINATE = new CoordinateXY(0, 0);
+
+ public static DimensionInfo find(Coordinate[] coordinates, Geometry geometry) {
+ Coordinate coordinate;
+ if (coordinates.length == 0) {
+ coordinate = XY_COORDINATE;
+ } else {
+ coordinate = coordinates[0];
+ }
+ return find(coordinate, geometry);
+ }
+
+ public static DimensionInfo find(List<Coordinate> coordinates, Geometry geometry) {
+ Coordinate coordinate;
+ if (coordinates.isEmpty()) {
+ coordinate = XY_COORDINATE;
+ } else {
+ coordinate = coordinates.get(0);
+ }
+ return find(coordinate, geometry);
+ }
+
+ public static DimensionInfo findCollection(List<? extends Geometry> geometries, Geometry geometry) {
+ Coordinate coordinate;
+ if (geometries.isEmpty()) {
+ coordinate = XY_COORDINATE;
+ } else {
+ Geometry geom = geometries.get(0);
+ coordinate = geom.getCoordinate();
+ }
+ return find(coordinate, geometry);
+ }
+
+ public int getCoordinate() {
+ return coordinate;
+ }
+
+ public int getSpatial() {
+ return spatial;
+ }
+
+ public int getTopological() {
+ return topological;
+ }
+
+ public boolean isPoint() {
+ return isPoint;
+ }
+
+ public boolean isLine() {
+ return isLine;
+ }
+
+ public boolean isArea() {
+ return isArea;
+ }
+
+ public CoordinateSequenceDimensions getDimensions() {
+ return coordinateSequenceDimensions;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 53 * hash + this.coordinate;
+ hash = 53 * hash + this.spatial;
+ hash = 53 * hash + this.topological;
+ hash = 53 * hash + Objects.hashCode(this.coordinateSequenceDimensions);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final DimensionInfo other = (DimensionInfo) obj;
+ if (this.coordinate != other.coordinate) {
+ return false;
+ }
+ if (this.spatial != other.spatial) {
+ return false;
+ }
+ if (this.topological != other.topological) {
+ return false;
+ }
+ return this.coordinateSequenceDimensions == other.coordinateSequenceDimensions;
+ }
+
+ @Override
+ public String toString() {
+ return "DimensionInfo{" + "coordinate=" + coordinate + ", spatial=" + spatial + ", topological=" + topological + ", coordinateSequenceDimensions=" + coordinateSequenceDimensions + ", isPoint=" + isPoint + ", isLine=" + isLine + ", isArea=" + isArea + '}';
+ }
+
+ public static DimensionInfo XY_POINT = new DimensionInfo(2, 2, 0);
+
+ public static DimensionInfo XYZ_POINT = new DimensionInfo(3, 3, 0);
+
+ public static DimensionInfo XYM_POINT = new DimensionInfo(3, 2, 0);
+
+ public static DimensionInfo XYZM_POINT = new DimensionInfo(4, 3, 0);
+
+ public static DimensionInfo XY_LINESTRING = new DimensionInfo(2, 2, 1);
+
+ public static DimensionInfo XYZ_LINESTRING = new DimensionInfo(3, 3, 1);
+
+ public static DimensionInfo XYM_LINESTRING = new DimensionInfo(3, 2, 1);
+
+ public static DimensionInfo XYZM_LINESTRING = new DimensionInfo(4, 3, 1);
+
+ public static DimensionInfo XY_POLYGON = new DimensionInfo(2, 2, 2);
+
+ public static DimensionInfo XYZ_POLYGON = new DimensionInfo(3, 3, 2);
+
+ public static DimensionInfo XYM_POLYGON = new DimensionInfo(3, 2, 2);
+
+ public static DimensionInfo XYZM_POLYGON = new DimensionInfo(4, 3, 2);
+
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/GeometryReverse.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/GeometryReverse.java
index af037ac..597221e 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/GeometryReverse.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/GeometryReverse.java
@@ -1,226 +1,226 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.implementation;
-
-import org.apache.jena.geosparql.implementation.registry.SRSRegistry;
-import org.locationtech.jts.geom.Coordinate;
-import org.locationtech.jts.geom.Geometry;
-import org.locationtech.jts.geom.GeometryCollection;
-import org.locationtech.jts.geom.GeometryFactory;
-import org.locationtech.jts.geom.LineString;
-import org.locationtech.jts.geom.LinearRing;
-import org.locationtech.jts.geom.Polygon;
-
-/**
- *
- *
- */
-public class GeometryReverse {
-
- /**
- * Checks the spatial reference system URI for y,x and reverses the supplied
- * geometry coordinates.
- *
- * @param geometry
- * @param srsURI
- * @return Geometry in x,y coordinate order.
- */
- public static final Geometry check(Geometry geometry, String srsURI) {
-
- Boolean isAxisXY = SRSRegistry.getAxisXY(srsURI);
- return check(geometry, isAxisXY);
- }
-
- /**
- * Checks the spatial reference system URI for y,x and reverses the supplied
- * geometry coordinates.
- *
- * @param geometry
- * @param srsInfo
- * @return Geometry in x,y coordinate order.
- */
- public static final Geometry check(Geometry geometry, SRSInfo srsInfo) {
- return check(geometry, srsInfo.isAxisXY());
- }
-
- /**
- * Checks the spatial reference system URI for y,x and reverses the supplied
- * geometry coordinates.
- *
- * @param geometry
- * @param isAxisXY
- * @return Geometry in x,y coordinate order.
- */
- public static final Geometry check(Geometry geometry, Boolean isAxisXY) {
-
- Geometry finalGeometry;
- if (isAxisXY) {
- finalGeometry = geometry;
- } else {
- finalGeometry = reverseGeometry(geometry);
- }
- return finalGeometry;
- }
-
- /**
- * Reverses coordinate order of the supplied geometry and produces a new
- * geometry.
- *
- * @param geometry
- * @return Geometry in x,y coordinate order.
- */
- public static Geometry reverseGeometry(Geometry geometry) {
-
- if (geometry.isEmpty()) {
- return geometry.copy();
- }
-
- GeometryFactory factory = geometry.getFactory();
- Geometry finalGeometry;
- Coordinate[] coordinates;
-
- String type = geometry.getGeometryType();
-
- switch (type) {
- case "LineString":
- coordinates = getReversedCoordinates(geometry);
- finalGeometry = factory.createLineString(coordinates);
- break;
- case "LinearRing":
- coordinates = getReversedCoordinates(geometry);
- finalGeometry = factory.createLinearRing(coordinates);
- break;
- case "MultiPoint":
- coordinates = getReversedCoordinates(geometry);
- finalGeometry = factory.createMultiPointFromCoords(coordinates);
- break;
- case "Polygon":
- finalGeometry = reversePolygon(geometry, factory);
- break;
- case "Point":
- coordinates = getReversedCoordinates(geometry);
- finalGeometry = factory.createPoint(coordinates[0]);
- break;
- case "MultiPolygon":
- Polygon[] polygons = unpackPolygons((GeometryCollection) geometry);
- finalGeometry = factory.createMultiPolygon(polygons);
- break;
- case "MultiLineString":
- LineString[] lineString = unpackLineStrings((GeometryCollection) geometry);
- finalGeometry = factory.createMultiLineString(lineString);
- break;
- case "GeometryCollection":
- Geometry[] geometries = unpackGeometryCollection((GeometryCollection) geometry);
- finalGeometry = factory.createGeometryCollection(geometries);
- break;
- default:
- finalGeometry = geometry;
- break;
- }
-
- return finalGeometry;
- }
-
- private static Coordinate[] getReversedCoordinates(Geometry geometry) {
-
- Coordinate[] original = geometry.getCoordinates();
- Coordinate[] reversed = new Coordinate[original.length];
-
- for (int i = 0; i < original.length; i++) {
- reversed[i] = new Coordinate(original[i].y, original[i].x);
- }
-
- return reversed;
-
- }
-
- private static Polygon reversePolygon(Geometry geometry, GeometryFactory factory) {
-
- Polygon finalGeometry;
- Polygon polygon = (Polygon) geometry;
- if (polygon.getNumInteriorRing() == 0) {
- //There are no interior rings so perform the standard reversal.
- Coordinate[] coordinates = getReversedCoordinates(geometry);
- finalGeometry = factory.createPolygon(coordinates);
- } else {
-
- LineString exteriorRing = polygon.getExteriorRing();
- Coordinate[] reversedExteriorCoordinates = getReversedCoordinates(exteriorRing);
- LinearRing reversedExteriorRing = factory.createLinearRing(reversedExteriorCoordinates);
-
- LinearRing[] reversedInteriorRings = new LinearRing[polygon.getNumInteriorRing()];
- for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
- LineString interiorRing = polygon.getInteriorRingN(i);
- Coordinate[] reversedInteriorCoordinates = getReversedCoordinates(interiorRing);
- LinearRing reversedInteriorRing = factory.createLinearRing(reversedInteriorCoordinates);
- reversedInteriorRings[i] = reversedInteriorRing;
- }
-
- finalGeometry = factory.createPolygon(reversedExteriorRing, reversedInteriorRings);
- }
-
- return finalGeometry;
- }
-
- private static Polygon[] unpackPolygons(GeometryCollection geoCollection) {
-
- GeometryFactory factory = geoCollection.getFactory();
-
- int count = geoCollection.getNumGeometries();
- Polygon[] polygons = new Polygon[count];
-
- for (int i = 0; i < count; i++) {
- Geometry geometry = geoCollection.getGeometryN(i);
- Polygon polygon = reversePolygon(geometry, factory);
- polygons[i] = polygon;
- }
-
- return polygons;
- }
-
- private static LineString[] unpackLineStrings(GeometryCollection geoCollection) {
-
- GeometryFactory factory = geoCollection.getFactory();
-
- int count = geoCollection.getNumGeometries();
- LineString[] lineStrings = new LineString[count];
-
- for (int i = 0; i < count; i++) {
- Geometry geometry = geoCollection.getGeometryN(i);
- Coordinate[] coordinates = getReversedCoordinates(geometry);
- LineString lineString = factory.createLineString(coordinates);
- lineStrings[i] = lineString;
- }
-
- return lineStrings;
- }
-
- private static Geometry[] unpackGeometryCollection(GeometryCollection geoCollection) {
-
- int count = geoCollection.getNumGeometries();
- Geometry[] geometries = new Geometry[count];
-
- for (int i = 0; i < count; i++) {
- Geometry geometry = geoCollection.getGeometryN(i);
- geometries[i] = reverseGeometry(geometry);
- }
-
- return geometries;
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.implementation;
+
+import org.apache.jena.geosparql.implementation.registry.SRSRegistry;
+import org.locationtech.jts.geom.Coordinate;
+import org.locationtech.jts.geom.Geometry;
+import org.locationtech.jts.geom.GeometryCollection;
+import org.locationtech.jts.geom.GeometryFactory;
+import org.locationtech.jts.geom.LineString;
+import org.locationtech.jts.geom.LinearRing;
+import org.locationtech.jts.geom.Polygon;
+
+/**
+ *
+ *
+ */
+public class GeometryReverse {
+
+ /**
+ * Checks the spatial reference system URI for y,x and reverses the supplied
+ * geometry coordinates.
+ *
+ * @param geometry
+ * @param srsURI
+ * @return Geometry in x,y coordinate order.
+ */
+ public static final Geometry check(Geometry geometry, String srsURI) {
+
+ Boolean isAxisXY = SRSRegistry.getAxisXY(srsURI);
+ return check(geometry, isAxisXY);
+ }
+
+ /**
+ * Checks the spatial reference system URI for y,x and reverses the supplied
+ * geometry coordinates.
+ *
+ * @param geometry
+ * @param srsInfo
+ * @return Geometry in x,y coordinate order.
+ */
+ public static final Geometry check(Geometry geometry, SRSInfo srsInfo) {
+ return check(geometry, srsInfo.isAxisXY());
+ }
+
+ /**
+ * Checks the spatial reference system URI for y,x and reverses the supplied
+ * geometry coordinates.
+ *
+ * @param geometry
+ * @param isAxisXY
+ * @return Geometry in x,y coordinate order.
+ */
+ public static final Geometry check(Geometry geometry, Boolean isAxisXY) {
+
+ Geometry finalGeometry;
+ if (isAxisXY) {
+ finalGeometry = geometry;
+ } else {
+ finalGeometry = reverseGeometry(geometry);
+ }
+ return finalGeometry;
+ }
+
+ /**
+ * Reverses coordinate order of the supplied geometry and produces a new
+ * geometry.
+ *
+ * @param geometry
+ * @return Geometry in x,y coordinate order.
+ */
+ public static Geometry reverseGeometry(Geometry geometry) {
+
+ if (geometry.isEmpty()) {
+ return geometry.copy();
+ }
+
+ GeometryFactory factory = geometry.getFactory();
+ Geometry finalGeometry;
+ Coordinate[] coordinates;
+
+ String type = geometry.getGeometryType();
+
+ switch (type) {
+ case "LineString":
+ coordinates = getReversedCoordinates(geometry);
+ finalGeometry = factory.createLineString(coordinates);
+ break;
+ case "LinearRing":
+ coordinates = getReversedCoordinates(geometry);
+ finalGeometry = factory.createLinearRing(coordinates);
+ break;
+ case "MultiPoint":
+ coordinates = getReversedCoordinates(geometry);
+ finalGeometry = factory.createMultiPointFromCoords(coordinates);
+ break;
+ case "Polygon":
+ finalGeometry = reversePolygon(geometry, factory);
+ break;
+ case "Point":
+ coordinates = getReversedCoordinates(geometry);
+ finalGeometry = factory.createPoint(coordinates[0]);
+ break;
+ case "MultiPolygon":
+ Polygon[] polygons = unpackPolygons((GeometryCollection) geometry);
+ finalGeometry = factory.createMultiPolygon(polygons);
+ break;
+ case "MultiLineString":
+ LineString[] lineString = unpackLineStrings((GeometryCollection) geometry);
+ finalGeometry = factory.createMultiLineString(lineString);
+ break;
+ case "GeometryCollection":
+ Geometry[] geometries = unpackGeometryCollection((GeometryCollection) geometry);
+ finalGeometry = factory.createGeometryCollection(geometries);
+ break;
+ default:
+ finalGeometry = geometry;
+ break;
+ }
+
+ return finalGeometry;
+ }
+
+ private static Coordinate[] getReversedCoordinates(Geometry geometry) {
+
+ Coordinate[] original = geometry.getCoordinates();
+ Coordinate[] reversed = new Coordinate[original.length];
+
+ for (int i = 0; i < original.length; i++) {
+ reversed[i] = new Coordinate(original[i].y, original[i].x);
+ }
+
+ return reversed;
+
+ }
+
+ private static Polygon reversePolygon(Geometry geometry, GeometryFactory factory) {
+
+ Polygon finalGeometry;
+ Polygon polygon = (Polygon) geometry;
+ if (polygon.getNumInteriorRing() == 0) {
+ //There are no interior rings so perform the standard reversal.
+ Coordinate[] coordinates = getReversedCoordinates(geometry);
+ finalGeometry = factory.createPolygon(coordinates);
+ } else {
+
+ LineString exteriorRing = polygon.getExteriorRing();
+ Coordinate[] reversedExteriorCoordinates = getReversedCoordinates(exteriorRing);
+ LinearRing reversedExteriorRing = factory.createLinearRing(reversedExteriorCoordinates);
+
+ LinearRing[] reversedInteriorRings = new LinearRing[polygon.getNumInteriorRing()];
+ for (int i = 0; i < polygon.getNumInteriorRing(); i++) {
+ LineString interiorRing = polygon.getInteriorRingN(i);
+ Coordinate[] reversedInteriorCoordinates = getReversedCoordinates(interiorRing);
+ LinearRing reversedInteriorRing = factory.createLinearRing(reversedInteriorCoordinates);
+ reversedInteriorRings[i] = reversedInteriorRing;
+ }
+
+ finalGeometry = factory.createPolygon(reversedExteriorRing, reversedInteriorRings);
+ }
+
+ return finalGeometry;
+ }
+
+ private static Polygon[] unpackPolygons(GeometryCollection geoCollection) {
+
+ GeometryFactory factory = geoCollection.getFactory();
+
+ int count = geoCollection.getNumGeometries();
+ Polygon[] polygons = new Polygon[count];
+
+ for (int i = 0; i < count; i++) {
+ Geometry geometry = geoCollection.getGeometryN(i);
+ Polygon polygon = reversePolygon(geometry, factory);
+ polygons[i] = polygon;
+ }
+
+ return polygons;
+ }
+
+ private static LineString[] unpackLineStrings(GeometryCollection geoCollection) {
+
+ GeometryFactory factory = geoCollection.getFactory();
+
+ int count = geoCollection.getNumGeometries();
+ LineString[] lineStrings = new LineString[count];
+
+ for (int i = 0; i < count; i++) {
+ Geometry geometry = geoCollection.getGeometryN(i);
+ Coordinate[] coordinates = getReversedCoordinates(geometry);
+ LineString lineString = factory.createLineString(coordinates);
+ lineStrings[i] = lineString;
+ }
+
+ return lineStrings;
+ }
+
+ private static Geometry[] unpackGeometryCollection(GeometryCollection geoCollection) {
+
+ int count = geoCollection.getNumGeometries();
+ Geometry[] geometries = new Geometry[count];
+
+ for (int i = 0; i < count; i++) {
+ Geometry geometry = geoCollection.getGeometryN(i);
+ geometries[i] = reverseGeometry(geometry);
+ }
+
+ return geometries;
+ }
+
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/GeometryWrapper.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/GeometryWrapper.java
index 8e97818..d8456ec 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/GeometryWrapper.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/GeometryWrapper.java
@@ -1,1248 +1,1248 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.implementation;
-
-import java.io.Serializable;
-import java.util.Objects;
-import org.apache.jena.datatypes.DatatypeFormatException;
-import org.apache.jena.geosparql.implementation.datatype.GMLDatatype;
-import org.apache.jena.geosparql.implementation.datatype.GeometryDatatype;
-import org.apache.jena.geosparql.implementation.datatype.WKTDatatype;
-import org.apache.jena.geosparql.implementation.great_circle.CoordinatePair;
-import org.apache.jena.geosparql.implementation.great_circle.GreatCircleDistance;
-import org.apache.jena.geosparql.implementation.index.GeometryLiteralIndex.GeometryIndex;
-import org.apache.jena.geosparql.implementation.index.GeometryTransformIndex;
-import org.apache.jena.geosparql.implementation.jts.CoordinateSequenceDimensions;
-import org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence;
-import org.apache.jena.geosparql.implementation.jts.CustomGeometryFactory;
-import org.apache.jena.geosparql.implementation.registry.MathTransformRegistry;
-import org.apache.jena.geosparql.implementation.registry.SRSRegistry;
-import org.apache.jena.geosparql.implementation.registry.UnitsRegistry;
-import org.apache.jena.geosparql.implementation.vocabulary.SRS_URI;
-import org.apache.jena.geosparql.implementation.vocabulary.Unit_URI;
-import org.apache.jena.graph.Node;
-import org.apache.jena.rdf.model.Literal;
-import org.apache.jena.rdf.model.ResourceFactory;
-import org.apache.jena.sparql.expr.NodeValue;
-import org.apache.sis.geometry.DirectPosition2D;
-import org.locationtech.jts.geom.Coordinate;
-import org.locationtech.jts.geom.Envelope;
-import org.locationtech.jts.geom.Geometry;
-import org.locationtech.jts.geom.GeometryFactory;
-import org.locationtech.jts.geom.IntersectionMatrix;
-import org.locationtech.jts.geom.Point;
-import org.locationtech.jts.geom.prep.PreparedGeometry;
-import org.locationtech.jts.geom.prep.PreparedGeometryFactory;
-import org.locationtech.jts.geom.util.AffineTransformation;
-import org.opengis.geometry.DirectPosition;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class GeometryWrapper implements Serializable {
-
- private final DimensionInfo dimensionInfo;
- private final SRSInfo srsInfo;
- private final Geometry xyGeometry;
- private final Geometry parsingGeometry;
- private PreparedGeometry preparedGeometry;
- private Envelope envelope;
- private Geometry translateXYGeometry;
- private final String geometryDatatypeURI;
- private GeometryDatatype geometryDatatype;
- private String lexicalForm;
- private String utmURI = null;
- private Double latitude = null;
-
- /**
- *
- * @param geometry In X/Y or Y/X coordinate order of the SRS URI.
- * @param srsURI
- * @param geometryDatatypeURI
- * @param dimensionInfo
- */
- public GeometryWrapper(Geometry geometry, String srsURI, String geometryDatatypeURI, DimensionInfo dimensionInfo) {
- this(geometry, srsURI, geometryDatatypeURI, dimensionInfo, null);
- }
-
- /**
- *
- * @param geometry In X/Y or Y/X coordinate order of the SRS URI.
- * @param srsURI
- * @param geometryDatatypeURI
- * @param dimensionInfo
- * @param geometryLiteral
- */
- public GeometryWrapper(Geometry geometry, String srsURI, String geometryDatatypeURI, DimensionInfo dimensionInfo, String geometryLiteral) {
- this(geometry, GeometryReverse.check(geometry, srsURI.isEmpty() ? SRS_URI.DEFAULT_WKT_CRS84 : srsURI), srsURI.isEmpty() ? SRS_URI.DEFAULT_WKT_CRS84 : srsURI, geometryDatatypeURI, dimensionInfo, geometryLiteral);
- }
-
- protected GeometryWrapper(Geometry parsingGeometry, Geometry xyGeometry, String srsURI, String geometryDatatypeURI, DimensionInfo dimensionInfo) {
- this(parsingGeometry, xyGeometry, srsURI, geometryDatatypeURI, dimensionInfo, null);
- }
-
- protected GeometryWrapper(Geometry parsingGeometry, Geometry xyGeometry, String srsURI, String geometryDatatypeURI, DimensionInfo dimensionInfo, String lexicalForm) {
-
- this.parsingGeometry = parsingGeometry;
- this.xyGeometry = xyGeometry;
- this.preparedGeometry = null; //Initialised when required by spatial relations checkPreparedGeometry.
- this.envelope = null; //Initialised when required by getEnvelope().
- this.translateXYGeometry = null; //Initialised when required by translateGeometry().
- this.geometryDatatypeURI = geometryDatatypeURI;
- this.geometryDatatype = null; //Inilialised when required by getGeometryDatatype().
-
- if (srsURI.isEmpty()) {
- srsURI = SRS_URI.DEFAULT_WKT_CRS84;
- }
-
- this.srsInfo = SRSRegistry.getSRSInfo(srsURI);
-
- this.dimensionInfo = dimensionInfo;
- this.lexicalForm = lexicalForm; //If not Initialised then required by asLiteral() etc.
- }
-
- /**
- * Default to WGS84 geometry and XY coordinate dimensions.
- *
- * @param geometry In X/Y or Y/X coordinate order of WGS84.
- * @param geometryDatatypeURI
- */
- public GeometryWrapper(Geometry geometry, String geometryDatatypeURI) {
- this(geometry, "", geometryDatatypeURI, DimensionInfo.XY_POINT);
- }
-
- /**
- * Default to XY coordinate dimensions.
- *
- * @param geometry In X/Y or Y/X coordinate order of the SRS URI.
- * @param srsURI
- * @param geometryDatatypeURI
- */
- public GeometryWrapper(Geometry geometry, String srsURI, String geometryDatatypeURI) {
- this(geometry, srsURI, geometryDatatypeURI, DimensionInfo.XY_POINT);
- }
-
- /**
- * Empty geometry with specified parameters.
- *
- * @param srsURI
- * @param geometryDatatypeURI
- */
- public GeometryWrapper(String srsURI, String geometryDatatypeURI) {
- this(new CustomCoordinateSequence(DimensionInfo.XY_POINT.getDimensions()), geometryDatatypeURI, srsURI);
- }
-
- /**
- * Point geometry with specified SRS.
- *
- * @param pointCoordinateSequence
- * @param geometryDatatypeURI
- * @param srsURI
- */
- public GeometryWrapper(CustomCoordinateSequence pointCoordinateSequence, String geometryDatatypeURI, String srsURI) {
- this(CustomGeometryFactory.theInstance().createPoint(pointCoordinateSequence), srsURI, geometryDatatypeURI, DimensionInfo.XY_POINT);
- }
-
- /**
- * Copy GeometryWrapper.
- *
- * @param geometryWrapper
- */
- public GeometryWrapper(GeometryWrapper geometryWrapper) {
-
- this.xyGeometry = geometryWrapper.xyGeometry;
- this.parsingGeometry = geometryWrapper.parsingGeometry;
- this.preparedGeometry = geometryWrapper.preparedGeometry;
- this.envelope = geometryWrapper.envelope;
- this.translateXYGeometry = geometryWrapper.translateXYGeometry;
- this.utmURI = geometryWrapper.utmURI;
- this.latitude = geometryWrapper.latitude;
- this.geometryDatatypeURI = geometryWrapper.geometryDatatypeURI;
- this.geometryDatatype = geometryWrapper.geometryDatatype;
-
- this.srsInfo = geometryWrapper.srsInfo;
- this.dimensionInfo = geometryWrapper.dimensionInfo;
- this.lexicalForm = geometryWrapper.lexicalForm;
- }
-
- /**
- * Transforms, if necessary, the provided target GeometryWrapper according
- * to this GeometryWrapper SRS_URI.
- *
- * @param targetGeometryWrapper
- * @return GeometryWrapper after transformation.
- * @throws FactoryException
- * @throws MismatchedDimensionException
- * @throws TransformException
- */
- public GeometryWrapper checkTransformSRS(GeometryWrapper targetGeometryWrapper) throws FactoryException, MismatchedDimensionException, TransformException {
-
- GeometryWrapper transformedGeometryWrapper;
- String srsURI = srsInfo.getSrsURI();
- if (srsURI.equals(targetGeometryWrapper.srsInfo.getSrsURI())) {
- transformedGeometryWrapper = targetGeometryWrapper;
- } else {
- transformedGeometryWrapper = targetGeometryWrapper.transform(srsURI);
- }
-
- return transformedGeometryWrapper;
- }
-
- /**
- * Transform the GeometryWrapper into another spatial reference system.<br>
- *
- * @param srsURI
- * @return New GeometryWrapper after transformation, or this GeometryWrapper
- * if no transformation.
- * @throws MismatchedDimensionException
- * @throws TransformException
- * @throws FactoryException
- */
- public GeometryWrapper transform(String srsURI) throws MismatchedDimensionException, TransformException, FactoryException {
- return transform(srsURI, true);
- }
-
- /**
- * Transform the GeometryWrapper into another spatial reference system.<br>
- *
- * @param srsInfo
- * @return New GeometryWrapper after transformation, or this GeometryWrapper
- * if no transformation.
- * @throws MismatchedDimensionException
- * @throws TransformException
- * @throws FactoryException
- */
- public GeometryWrapper transform(SRSInfo srsInfo) throws MismatchedDimensionException, TransformException, FactoryException {
- return transform(srsInfo.getSrsURI(), true);
- }
-
- /**
- * Transform the GeometryWrapper into another spatial reference system.<br>
- * Option to store the resulting GeometryWrapper in the index.
- *
- * @param srsURI
- * @param storeSRSTransform
- * @return GeometryWrapper after transformation.
- * @throws MismatchedDimensionException
- * @throws TransformException
- * @throws FactoryException
- */
- protected GeometryWrapper transform(String srsURI, Boolean storeSRSTransform) throws MismatchedDimensionException, TransformException, FactoryException {
- if (srsInfo.getSrsURI().equals(srsURI)) {
- return this;
- }
-
- return GeometryTransformIndex.transform(this, srsURI, storeSRSTransform);
- }
-
- /**
- * Checks whether the prepared geometry has been initialised.
- * <br>Done lazily as expensive.
- */
- private void checkPreparedGeometry() {
- if (preparedGeometry == null) {
- this.preparedGeometry = PreparedGeometryFactory.prepare(xyGeometry);
- }
- }
-
- /**
- * Returns this geometry wrapper converted to the SRS_URI URI.
- *
- * @param srsURI
- * @return GeometryWrapper after conversion.
- * @throws FactoryException
- * @throws MismatchedDimensionException
- * @throws TransformException
- */
- public GeometryWrapper convertSRS(String srsURI) throws FactoryException, MismatchedDimensionException, TransformException {
- return transform(srsURI);
- }
-
- /**
- *
- * @return Coordinate/Spatial reference system of the GeometryWrapper.
- */
- public CoordinateReferenceSystem getCRS() {
- return srsInfo.getCrs();
- }
-
- /**
- *
- * @return Geometry with coordinates in x,y order, regardless of SRS_URI.
- */
- public Geometry getXYGeometry() {
- return xyGeometry;
- }
-
- /**
- *
- * @return Geometry with coordinates as originally provided.
- */
- public Geometry getParsingGeometry() {
- return parsingGeometry;
- }
-
- /**
- * XY geometry translated by the domain range of the SRS, if a Geographic
- * SRS.<br>
- * Returns XY geometry if not a Geographic SRS.
- *
- * @return Geometry after translation in X direction.
- */
- public Geometry translateXYGeometry() {
-
- if (translateXYGeometry == null) {
-
- if (srsInfo.isGeographic()) {
- double xTranslate = srsInfo.getDomainRangeX();
- AffineTransformation translation = AffineTransformation.translationInstance(xTranslate, 0);
- translateXYGeometry = translation.transform(xyGeometry); //Translate seems to be copying Y values into Z and M.
- } else {
- translateXYGeometry = xyGeometry;
- }
-
- }
-
- return translateXYGeometry;
- }
-
- /**
- *
- * @return Coordinate/Spatial reference system URI.
- */
- public String getSrsURI() {
- return srsInfo.getSrsURI();
- }
-
- /**
- *
- * @return getSRID used in GeoSPARQL Standard page 22 to refer to srsURI.
- * i.e. getSrsURI and getSRID are the same.
- */
- public String getSRID() {
- return srsInfo.getSrsURI();
- }
-
- /**
- *
- * @return SRS information that the Geometry Wrapper is using.
- */
- public SRSInfo getSrsInfo() {
- return srsInfo;
- }
-
- /**
- *
- * @return Whether the SRS URI has been recognised. Operations may fail or
- * not perform correctly when false.
- */
- public Boolean isSRSRecognised() {
- return srsInfo.isSRSRecognised();
- }
-
- /**
- *
- * @return Datatype URI of the literal.
- */
- public String getGeometryDatatypeURI() {
- return geometryDatatypeURI;
- }
-
- /**
- *
- * @return The name of the parsing Geometry's actual class.
- */
- public String getGeometryType() {
- return parsingGeometry.getGeometryType();
- }
-
- /**
- *
- * @return GeometryDatatype of the literal.
- */
- public GeometryDatatype getGeometryDatatype() {
-
- if (geometryDatatype == null) {
- geometryDatatype = GeometryDatatype.get(geometryDatatypeURI);
- }
- return geometryDatatype;
- }
-
- /**
- *
- * @param distance
- * @param targetDistanceUnitsURI
- * @return Buffer around GeometryWrapper according the provided distance.
- * @throws FactoryException
- * @throws MismatchedDimensionException
- * @throws TransformException
- */
- public GeometryWrapper buffer(double distance, String targetDistanceUnitsURI) throws FactoryException, MismatchedDimensionException, TransformException {
-
- //Check whether the source geometry is linear units for cartesian calculation. If not then transform to relevant UTM SRS GeometryWrapper.
- Boolean isTargetUnitsLinear = UnitsRegistry.isLinearUnits(targetDistanceUnitsURI);
- GeometryWrapper transformedGeometryWrapper;
- Boolean isTransformNeeded;
-
- if (srsInfo.getUnitsOfMeasure().isLinearUnits() == isTargetUnitsLinear) {
- //Source geometry and target units are both the same.
- transformedGeometryWrapper = this;
- isTransformNeeded = false;
- } else if (isTargetUnitsLinear) {
- //Source geometry is not linear but targets are so convert to linear SRS.
- String sourceUtmURI = getUTMZoneURI();
- transformedGeometryWrapper = transform(sourceUtmURI);
- isTransformNeeded = true;
- } else {
- //Source geometry is linear but targets are not so convert to nonlinear SRS.
- transformedGeometryWrapper = transform(SRS_URI.DEFAULT_WKT_CRS84);
- isTransformNeeded = true;
- }
-
- //Check whether the units of the distance need converting.
- double transformedDistance = UnitsOfMeasure.conversion(distance, targetDistanceUnitsURI, transformedGeometryWrapper.srsInfo.getUnitsOfMeasure().getUnitURI());
-
- //Buffer the transformed geometry
- Geometry xyGeo = transformedGeometryWrapper.xyGeometry.buffer(transformedDistance);
- DimensionInfo bufferedDimensionInfo = new DimensionInfo(dimensionInfo.getCoordinate(), dimensionInfo.getSpatial(), xyGeo.getDimension());
- Geometry parsingGeo = GeometryReverse.check(xyGeo, transformedGeometryWrapper.srsInfo);
- GeometryWrapper bufferedGeometryWrapper = new GeometryWrapper(parsingGeo, xyGeo, transformedGeometryWrapper.srsInfo.getSrsURI(), transformedGeometryWrapper.geometryDatatypeURI, bufferedDimensionInfo);
-
- //Check whether need to transform back to the original srsURI.
- if (isTransformNeeded) {
- //Don't store the buffered geometry as it is dependent upon the target distance and so likely to vary beween calls.
- return bufferedGeometryWrapper.transform(srsInfo.getSrsURI(), false);
- } else {
- return bufferedGeometryWrapper;
- }
- }
-
- /**
- *
- * @return URI of the GeometryWrapper's UTM zone
- * @throws FactoryException
- * @throws MismatchedDimensionException
- * @throws TransformException
- */
- public String getUTMZoneURI() throws FactoryException, MismatchedDimensionException, TransformException {
-
- if (utmURI == null) {
-
- //Find a point in the parsing geometry so can directly apply the SRS.
- Point coord = parsingGeometry.getCentroid();
- DirectPosition2D point = new DirectPosition2D(coord.getX(), coord.getY());
-
- //Convert to WGS84. Use WGS84 and not CRS84 as assuming WGS8 is more prevalent.
- CoordinateReferenceSystem wgs84CRS = SRSRegistry.getCRS(SRS_URI.WGS84_CRS);
- MathTransform transform = MathTransformRegistry.getMathTransform(srsInfo.getCrs(), wgs84CRS);
-
- DirectPosition wgs84Point = transform.transform(point, null);
-
- //Find the UTM zone.
- utmURI = SRSRegistry.findUTMZoneURIFromWGS84(wgs84Point.getOrdinate(0), wgs84Point.getOrdinate(1));
-
- }
- return utmURI;
- }
-
- /**
- * Latitude if Geographic SRS or in WGS84.<br>
- * Used to convert between linear and non-linear units of measure.
- *
- * @return Latitude of Geometry.
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public Double getLatitude() throws FactoryException, MismatchedDimensionException, TransformException {
-
- if (latitude == null) {
- GeometryWrapper geoGeometryWrapper;
-
- if (srsInfo.isGeographic()) {
- //Already a geographic SRS.
- geoGeometryWrapper = this;
- } else {
- //Use WGS84 and not CRS84 as assuming WGS8 is more prevalent.
- geoGeometryWrapper = convertSRS(SRS_URI.WGS84_CRS);
- }
-
- //Latitude is Y-axis.
- Geometry geometry = geoGeometryWrapper.getXYGeometry();
- Point point = geometry.getCentroid();
- latitude = point.getY();
-
- }
- return latitude;
- }
-
- /**
- * Distance (Euclidean) defaulting to metres.
- *
- * @param targetGeometry
- * @return Distance
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public double distanceEuclidean(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return distanceEuclidean(targetGeometry, Unit_URI.METRE_URL);
- }
-
- /**
- * Distance (Euclidean) in the Units of Measure.
- *
- * @param targetGeometry
- * @param unitsOfMeasure
- * @return Distance
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public double distanceEuclidean(GeometryWrapper targetGeometry, UnitsOfMeasure unitsOfMeasure) throws FactoryException, MismatchedDimensionException, TransformException {
- return distanceEuclidean(targetGeometry, unitsOfMeasure.getUnitURI());
- }
-
- /**
- * Distance (Euclidean) in the Units of Measure stated in URI.
- *
- * @param targetGeometry
- * @param targetDistanceUnitsURI
- * @return Distance
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public double distanceEuclidean(GeometryWrapper targetGeometry, String targetDistanceUnitsURI) throws FactoryException, MismatchedDimensionException, TransformException {
-
- Boolean isUnitsLinear = srsInfo.getUnitsOfMeasure().isLinearUnits();
- Boolean isTargetUnitsLinear = UnitsRegistry.isLinearUnits(targetDistanceUnitsURI);
-
- GeometryWrapper transformedTargetGeometry = checkTransformSRS(targetGeometry);
-
- double distance = xyGeometry.distance(transformedTargetGeometry.xyGeometry);
- String unitsURI = srsInfo.getUnitsOfMeasure().getUnitURI();
-
- double targetDistance;
- if (isUnitsLinear.equals(isTargetUnitsLinear)) {
- //Units are same so straight conversion.
- targetDistance = UnitsOfMeasure.conversion(distance, unitsURI, targetDistanceUnitsURI);
- } else {
- targetDistance = UnitsOfMeasure.convertBetween(distance, unitsURI, targetDistanceUnitsURI, isTargetUnitsLinear, getLatitude());
- }
-
- return targetDistance;
- }
-
- /**
- * Distance (Great Circle) defaulting to metres.
- *
- * @param targetGeometry
- * @return Distance
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public double distanceGreatCircle(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return distanceGreatCircle(targetGeometry, Unit_URI.METRE_URL);
- }
-
- /**
- * Distance (Great Circle) in the Units of Measure.
- *
- * @param targetGeometry
- * @param unitsOfMeasure
- * @return Distance
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public double distanceGreatCircle(GeometryWrapper targetGeometry, UnitsOfMeasure unitsOfMeasure) throws FactoryException, MismatchedDimensionException, TransformException {
- return distanceGreatCircle(targetGeometry, unitsOfMeasure.getUnitURI());
- }
-
- /**
- * Distance (Great Circle) in the Units of Measure stated in URI.
- *
- * @param targetGeometry
- * @param targetDistanceUnitsURI
- * @return Distance
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public double distanceGreatCircle(GeometryWrapper targetGeometry, String targetDistanceUnitsURI) throws FactoryException, MismatchedDimensionException, TransformException {
-
- GeometryWrapper transformedSourceGeometry;
- if (srsInfo.isGeographic()) {
- //Already a geographic SRS.
- transformedSourceGeometry = this;
- } else {
- //Use WGS84 and not CRS84 as assuming WGS8 is more prevalent.
- transformedSourceGeometry = this.transform(SRS_URI.WGS84_CRS);
- }
-
- GeometryWrapper transformedTargetGeometry = transformedSourceGeometry.checkTransformSRS(targetGeometry);
-
- //Find the nearest pair of coordinates from each Geometry using Euclidean distance (adjusting for wrap around).
- //These are then used for Great Circle distance.
- CoordinatePair coordinatePair = CoordinatePair.findNearestPair(transformedSourceGeometry, transformedTargetGeometry);
-
- //Check whether the nearest pair are the same, i.e. the overlap or within each other.
- if (coordinatePair.isEqual()) {
- //Exit early as the distance is zero.
- return 0.0;
- }
-
- Coordinate coord1 = coordinatePair.getCoord1();
- Coordinate coord2 = coordinatePair.getCoord2();
-
- //Vincenty Formula is apparently more accurate at the Longitude boundary.
- double distance = GreatCircleDistance.vincentyFormula(coord1.getY(), coord1.getX(), coord2.getY(), coord2.getX());
- //double distance = GreatCircleDistance.haversineFormula(coord1.getY(), coord1.getX(), coord2.getY(), coord2.getX());
-
- //Convert the Great Circle distance from metres into the requested units.
- Boolean isTargetUnitsLinear = UnitsRegistry.isLinearUnits(targetDistanceUnitsURI);
- double targetDistance;
- if (isTargetUnitsLinear) {
- //Target units are linear so straight conversion. Distance is in metres already.
- targetDistance = UnitsOfMeasure.conversion(distance, Unit_URI.METRE_URL, targetDistanceUnitsURI);
- } else {
- targetDistance = UnitsOfMeasure.convertBetween(distance, Unit_URI.METRE_URL, targetDistanceUnitsURI, isTargetUnitsLinear, transformedSourceGeometry.getLatitude());
- }
-
- return targetDistance;
- }
-
- /**
- * Distance (Euclidean or Great Circle depending on Geometry SRS URI)
- * defaulting to metres.
- *
- * @param targetGeometry
- * @return Distance
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public double distance(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- return distance(targetGeometry, Unit_URI.METRE_URL);
- }
-
- /**
- * Distance (Euclidean or Great Circle depending on Geometry SRS URI) in the
- * Units of Measure.
- *
- * @param targetGeometry
- * @param unitsOfMeasure
- * @return Distance
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public double distance(GeometryWrapper targetGeometry, UnitsOfMeasure unitsOfMeasure) throws FactoryException, MismatchedDimensionException, TransformException {
- return distance(targetGeometry, unitsOfMeasure.getUnitURI());
- }
-
- /**
- * Distance (Euclidean or Great Circle depending on Geometry SRS URI) in the
- * Units of Measure stated in URI.
- *
- * @param targetGeometry
- * @param targetDistanceUnitsURI
- * @return Distance
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public double distance(GeometryWrapper targetGeometry, String targetDistanceUnitsURI) throws FactoryException, MismatchedDimensionException, TransformException {
-
- double targetDistance;
- if (srsInfo.isGeographic()) {
- targetDistance = distanceGreatCircle(targetGeometry, targetDistanceUnitsURI);
- } else {
- targetDistance = distanceEuclidean(targetGeometry, targetDistanceUnitsURI);
- }
-
- return targetDistance;
- }
-
- /**
- *
- * @return Boundary of GeometryWrapper
- */
- public GeometryWrapper boundary() {
- Geometry xyGeo = this.xyGeometry.getBoundary();
- Geometry parsingGeo = GeometryReverse.check(xyGeo, srsInfo);
- return new GeometryWrapper(parsingGeo, xyGeo, srsInfo.getSrsURI(), geometryDatatypeURI, dimensionInfo);
- }
-
- /**
- *
- * @return Convex Hull of GeometryWrapper
- */
- public GeometryWrapper convexHull() {
- Geometry xyGeo = this.xyGeometry.convexHull();
- Geometry parsingGeo = GeometryReverse.check(xyGeo, srsInfo);
- return new GeometryWrapper(parsingGeo, xyGeo, srsInfo.getSrsURI(), geometryDatatypeURI, dimensionInfo);
- }
-
- /**
- *
- * @param targetGeometry
- * @return Difference of GeometryWrapper with target.
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public GeometryWrapper difference(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
- Geometry xyGeo = this.xyGeometry.difference(transformedGeometry.xyGeometry);
- Geometry parsingGeo = GeometryReverse.check(xyGeo, srsInfo);
- return new GeometryWrapper(parsingGeo, xyGeo, srsInfo.getSrsURI(), geometryDatatypeURI, dimensionInfo);
- }
-
- /**
- * Envelope of GeometryWrapper with original coordinate order.
- *
- * @return Envelope of GeometryWrapper
- */
- public GeometryWrapper envelope() {
- GeometryFactory geometryFactory = this.xyGeometry.getFactory();
- Envelope xyEnvelope = this.getEnvelope();
- Geometry xyGeo = geometryFactory.toGeometry(xyEnvelope);
- Geometry parsingGeo = GeometryReverse.check(xyGeo, srsInfo);
- return new GeometryWrapper(parsingGeo, xyGeo, srsInfo.getSrsURI(), geometryDatatypeURI, dimensionInfo);
- }
-
- /**
- * Envelope of GeometryWrapper in XY order.
- *
- * @return Envelope of GeometryWrapper
- */
- public Envelope getEnvelope() {
- if (envelope == null) {
- envelope = this.xyGeometry.getEnvelopeInternal();
- }
-
- return envelope;
- }
-
- /**
- *
- * @param targetGeometry
- * @return Intersection of GeometryWrapper with target.
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public GeometryWrapper intersection(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
- Geometry xyGeo = this.xyGeometry.intersection(transformedGeometry.xyGeometry);
- Geometry parsingGeo = GeometryReverse.check(xyGeo, srsInfo);
- return new GeometryWrapper(parsingGeo, xyGeo, srsInfo.getSrsURI(), geometryDatatypeURI, dimensionInfo);
- }
-
- /**
- *
- * @param targetGeometry
- * @return Intersection Matrix of GeometryWrapper with target.
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public IntersectionMatrix relate(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
- return xyGeometry.relate(transformedGeometry.xyGeometry);
- }
-
- /**
- *
- * @param targetGeometry
- * @param intersectionPattern
- * @return Relation of GeometryWrapper with target.
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public boolean relate(GeometryWrapper targetGeometry, String intersectionPattern) throws FactoryException, MismatchedDimensionException, TransformException {
- GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
- return xyGeometry.relate(transformedGeometry.xyGeometry, intersectionPattern);
- }
-
- /**
- *
- * @param targetGeometry
- * @return Symmetric Difference of GeometryWrapper with target.
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public GeometryWrapper symDifference(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
- Geometry xyGeo = this.xyGeometry.symDifference(transformedGeometry.xyGeometry);
- Geometry parsingGeo = GeometryReverse.check(xyGeo, srsInfo);
- return new GeometryWrapper(parsingGeo, xyGeo, srsInfo.getSrsURI(), geometryDatatypeURI, dimensionInfo, null);
- }
-
- /**
- *
- * @param targetGeometry
- * @return Union of GeometryWrapper with target.
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public GeometryWrapper union(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
- Geometry xyGeo = this.xyGeometry.union(transformedGeometry.xyGeometry);
- Geometry parsingGeo = GeometryReverse.check(xyGeo, srsInfo);
- return new GeometryWrapper(parsingGeo, xyGeo, srsInfo.getSrsURI(), geometryDatatypeURI, dimensionInfo, null);
- }
-
- /**
- *
- * @param targetGeometry
- * @return sfContains of GeometryWrapper with target.
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public boolean contains(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- this.checkPreparedGeometry();
- GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
- return this.preparedGeometry.contains(transformedGeometry.xyGeometry);
- }
-
- /**
- *
- * @param targetGeometry
- * @return sfCrosses of GeometryWrapper with target.
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public boolean crosses(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- this.checkPreparedGeometry();
- GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
- return this.preparedGeometry.crosses(transformedGeometry.xyGeometry);
- }
-
- /**
- *
- * @param targetGeometry
- * @return sfDisjoint of GeometryWrapper with target.
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public boolean disjoint(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- this.checkPreparedGeometry();
- GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
- return this.preparedGeometry.disjoint(transformedGeometry.xyGeometry);
- }
-
- /**
- *
- * @param targetGeometry
- * @return Topology equals of GeometryWrapper with target.
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public boolean equalsTopo(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
- return this.xyGeometry.equalsTopo(transformedGeometry.xyGeometry);
- }
-
- /**
- *
- * @param targetGeometry
- * @return Equals exactly of GeometryWrapper with target.
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public boolean equalsExact(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
- return this.xyGeometry.equalsExact(transformedGeometry.xyGeometry);
- }
-
- /**
- *
- * @param targetGeometry
- * @param tolerance
- * @return Equals exactly of GeometryWrapper with target using provided
- * tolerance.
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public boolean equalsExact(GeometryWrapper targetGeometry, double tolerance) throws FactoryException, MismatchedDimensionException, TransformException {
- GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
- return this.xyGeometry.equalsExact(transformedGeometry.xyGeometry, tolerance);
- }
-
- /**
- *
- * @param targetGeometry
- * @return sfIntersects of GeometryWrapper with target.
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public boolean intersects(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- this.checkPreparedGeometry();
- GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
- return this.preparedGeometry.intersects(transformedGeometry.xyGeometry);
- }
-
- /**
- *
- * @param targetGeometry
- * @return sfOverlaps of GeometryWrapper with target.
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public boolean overlaps(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- this.checkPreparedGeometry();
- GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
- return this.preparedGeometry.overlaps(transformedGeometry.xyGeometry);
- }
-
- /**
- *
- * @param targetGeometry
- * @return sfTouches of GeometryWrapper with target.
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public boolean touches(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- this.checkPreparedGeometry();
- GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
- return this.preparedGeometry.touches(transformedGeometry.xyGeometry);
- }
-
- /**
- *
- * @param targetGeometry
- * @return sfWithin of GeometryWrapper with target.
- * @throws org.opengis.util.FactoryException
- * @throws org.opengis.referencing.operation.TransformException
- */
- public boolean within(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
- this.checkPreparedGeometry();
- GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
- return this.preparedGeometry.within(transformedGeometry.xyGeometry);
- }
-
- /**
- *
- * @return GeometryWrapper as NodeValue
- */
- public NodeValue asNodeValue() throws DatatypeFormatException {
- Literal literal = asLiteral();
- return NodeValue.makeNode(literal.getLexicalForm(), literal.getDatatype());
- }
-
- /**
- *
- * @return GeometryWrapper as Node
- */
- public Node asNode() throws DatatypeFormatException {
- return asNodeValue().asNode();
- }
-
- /**
- *
- * @return GeometryWrapper as Literal
- */
- public Literal asLiteral() throws DatatypeFormatException {
-
- GeometryDatatype datatype = getGeometryDatatype(); //Datatype is only retrieved when required.
- if (lexicalForm != null) {
- return ResourceFactory.createTypedLiteral(lexicalForm, datatype);
- }
-
- Literal literal = asLiteral(datatype);
- lexicalForm = literal.getLexicalForm();
- return literal;
- }
-
- /**
- *
- * @param outputGeometryDatatypeURI
- * @return GeometryWrapper as Literal in datatype form.
- */
- public Literal asLiteral(String outputGeometryDatatypeURI) throws DatatypeFormatException {
- GeometryDatatype datatype = GeometryDatatype.get(outputGeometryDatatypeURI);
- return asLiteral(datatype);
- }
-
- /**
- *
- * @param datatype
- * @return GeometryWrapper as Literal
- */
- public Literal asLiteral(GeometryDatatype datatype) {
- String tempLexicalForm = datatype.unparse(this);
- return ResourceFactory.createTypedLiteral(tempLexicalForm, datatype);
- }
-
- /**
- *
- * @return Coordinate dimension, i.e. 2 (x,y), 3 (x,y,z or x,y,m) or 4
- * (x,y,z,m)
- */
- public int getCoordinateDimension() {
- return dimensionInfo.getCoordinate();
- }
-
- /**
- *
- * @return Spatial dimension, i.e. 2 or 3
- */
- public int getSpatialDimension() {
- return dimensionInfo.getSpatial();
- }
-
- /**
- *
- * @return Topological dimension, i.e. 0, 1 or 2
- */
- public int getTopologicalDimension() {
- return dimensionInfo.getTopological();
- }
-
- /**
- *
- * @return Enum of coordinate dimensions.
- */
- public CoordinateSequenceDimensions getCoordinateSequenceDimensions() {
- return dimensionInfo.getDimensions();
- }
-
- /**
- *
- * @return Units of Measure for the GeometryWrapper SRS.
- */
- public UnitsOfMeasure getUnitsOfMeasure() {
- return srsInfo.getUnitsOfMeasure();
- }
-
- /**
- *
- * @return GeometryWrapper's coordinate, spatial and topological dimensions.
- */
- public DimensionInfo getDimensionInfo() {
- return dimensionInfo;
- }
-
- /**
- *
- * @return String literal of Geometry Wrapper.
- */
- public String getLexicalForm() {
-
- if (lexicalForm != null) {
- return lexicalForm;
- } else {
- Literal literal = asLiteral();
- return literal.getLexicalForm();
- }
- }
-
- /**
- *
- * @return Geometry is empty of coordinates.
- */
- public boolean isEmpty() {
- return this.xyGeometry.isEmpty();
- }
-
- /**
- *
- * @return Geometry is in simple form.
- */
- public boolean isSimple() {
- return this.xyGeometry.isSimple();
- }
-
- /**
- *
- * @return Geometry is topologically valid.
- */
- public boolean isValid() {
- return this.xyGeometry.isValid();
- }
-
- /**
- * Extract Geometry Wrapper from Geometry Literal.
- *
- * @param geometryLiteral
- * @param targetIndex
- * @return Geometry Wrapper of the Geometry Literal.
- */
- public static final GeometryWrapper extract(NodeValue geometryLiteral, GeometryIndex targetIndex) {
-
- Node node = geometryLiteral.asNode();
-
- return extract(node, targetIndex);
- }
-
- /**
- * Extract Geometry Wrapper from Geometry Literal.
- *
- * @param geometryLiteral
- * @param targetIndex
- * @return Geometry Wrapper of the Geometry Literal.
- */
- public static final GeometryWrapper extract(Node geometryLiteral, GeometryIndex targetIndex) throws DatatypeFormatException {
-
- if (!geometryLiteral.isLiteral()) {
- throw new DatatypeFormatException("Not a Literal: " + geometryLiteral);
- }
-
- String datatypeURI = geometryLiteral.getLiteralDatatypeURI();
- String lexicalForm = geometryLiteral.getLiteralLexicalForm();
- return extract(lexicalForm, datatypeURI, targetIndex);
- }
-
- /**
- * Extract Geometry Wrapper from Geometry Literal.
- *
- * @param geometryLiteral
- * @return Geometry Wrapper of the Geometry Literal.
- */
- public static final GeometryWrapper extract(NodeValue geometryLiteral) {
- return extract(geometryLiteral, GeometryIndex.PRIMARY);
- }
-
- /**
- * Extract Geometry Wrapper from Geometry Literal.
- *
- * @param geometryLiteral
- * @return Geometry Wrapper of the Geometry Literal.
- */
- public static final GeometryWrapper extract(Node geometryLiteral) {
- return extract(geometryLiteral, GeometryIndex.PRIMARY);
- }
-
- /**
- * Extract Geometry Wrapper from Geometry Literal. Returns null if invalid
- * literal provided.
- *
- * @param geometryLiteral
- * @param targetIndex
- * @return Geometry Wrapper of the Geometry Literal.
- */
- public static final GeometryWrapper extract(Literal geometryLiteral, GeometryIndex targetIndex) {
- return extract(geometryLiteral.getLexicalForm(), geometryLiteral.getDatatypeURI(), targetIndex);
- }
-
- /**
- * Extract Geometry Wrapper from Geometry Literal.
- *
- * @param geometryLiteral
- * @return Geometry Wrapper of the Geometry Literal.
- */
- public static final GeometryWrapper extract(Literal geometryLiteral) {
- return extract(geometryLiteral, GeometryIndex.PRIMARY);
- }
-
- /**
- * Extract Geometry Wrapper from Geometry Literal.
- *
- * @param lexicalForm
- * @param datatypeURI
- * @return Geometry Wrapper of the Geometry Literal.
- */
- public static GeometryWrapper extract(String lexicalForm, String datatypeURI) {
- return extract(lexicalForm, datatypeURI, GeometryIndex.PRIMARY);
- }
-
- /**
- * Extract Geometry Wrapper from Geometry Literal.
- *
- * @param lexicalForm
- * @param datatypeURI
- * @param targetIndex
- * @return Geometry Wrapper of the Geometry Literal.
- */
- public static GeometryWrapper extract(String lexicalForm, String datatypeURI, GeometryIndex targetIndex) throws DatatypeFormatException {
-
- if (lexicalForm == null || datatypeURI == null) {
- throw new DatatypeFormatException("GeometryWrapper extraction: arguments cannot be null - " + lexicalForm + ", " + datatypeURI);
- }
-
- GeometryDatatype datatype = GeometryDatatype.get(datatypeURI);
- GeometryWrapper geometry = datatype.parse(lexicalForm, targetIndex);
- return geometry;
- }
-
- /**
- * Builds a WKT Point of Geometry Wrapper.<br>
- * This method does not use the GeometryLiteralIndex and so is best used for
- * one of Geometry Wrappers.
- *
- * @return Geometry Wrapper of WKT Point.
- */
- public static final GeometryWrapper fromPoint(double x, double y, String srsURI) {
- CustomCoordinateSequence coordSequence = CustomCoordinateSequence.createPoint(x, y);
- GeometryWrapper geometryWrapper = new GeometryWrapper(coordSequence, WKTDatatype.URI, srsURI);
- return geometryWrapper;
- }
-
- /**
- *
- * @return Empty GeometryWrapper in WKT datatype.
- */
- public static final GeometryWrapper getEmptyWKT() {
- return WKTDatatype.INSTANCE.read("");
- }
-
- /**
- *
- * @return Empty GeometryWrapper in GML datatype.
- */
- public static final GeometryWrapper getEmptyGML() {
- return GMLDatatype.INSTANCE.read("");
- }
-
- @Override
- public int hashCode() {
- int hash = 3;
- hash = 23 * hash + Objects.hashCode(this.dimensionInfo);
- hash = 23 * hash + Objects.hashCode(this.srsInfo);
- hash = 23 * hash + Objects.hashCode(this.xyGeometry);
- hash = 23 * hash + Objects.hashCode(this.geometryDatatypeURI);
- return hash;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final GeometryWrapper other = (GeometryWrapper) obj;
- if (!Objects.equals(this.geometryDatatypeURI, other.geometryDatatypeURI)) {
- return false;
- }
- if (!Objects.equals(this.dimensionInfo, other.dimensionInfo)) {
- return false;
- }
- if (!Objects.equals(this.srsInfo, other.srsInfo)) {
- return false;
- }
- return Objects.equals(this.xyGeometry, other.xyGeometry);
- }
-
- @Override
- public String toString() {
- return "GeometryWrapper{" + "dimensionInfo=" + dimensionInfo + ", geometryDatatypeURI=" + geometryDatatypeURI + ", lexicalForm=" + lexicalForm + ", utmURI=" + utmURI + ", latitude=" + latitude + ", xyGeometry=" + xyGeometry + ", parsingGeometry=" + parsingGeometry + ", preparedGeometry=" + preparedGeometry + ", srsInfo=" + srsInfo + '}';
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.implementation;
+
+import java.io.Serializable;
+import java.util.Objects;
+import org.apache.jena.datatypes.DatatypeFormatException;
+import org.apache.jena.geosparql.implementation.datatype.GMLDatatype;
+import org.apache.jena.geosparql.implementation.datatype.GeometryDatatype;
+import org.apache.jena.geosparql.implementation.datatype.WKTDatatype;
+import org.apache.jena.geosparql.implementation.great_circle.CoordinatePair;
+import org.apache.jena.geosparql.implementation.great_circle.GreatCircleDistance;
+import org.apache.jena.geosparql.implementation.index.GeometryLiteralIndex.GeometryIndex;
+import org.apache.jena.geosparql.implementation.index.GeometryTransformIndex;
+import org.apache.jena.geosparql.implementation.jts.CoordinateSequenceDimensions;
+import org.apache.jena.geosparql.implementation.jts.CustomCoordinateSequence;
+import org.apache.jena.geosparql.implementation.jts.CustomGeometryFactory;
+import org.apache.jena.geosparql.implementation.registry.MathTransformRegistry;
+import org.apache.jena.geosparql.implementation.registry.SRSRegistry;
+import org.apache.jena.geosparql.implementation.registry.UnitsRegistry;
+import org.apache.jena.geosparql.implementation.vocabulary.SRS_URI;
+import org.apache.jena.geosparql.implementation.vocabulary.Unit_URI;
+import org.apache.jena.graph.Node;
+import org.apache.jena.rdf.model.Literal;
+import org.apache.jena.rdf.model.ResourceFactory;
+import org.apache.jena.sparql.expr.NodeValue;
+import org.apache.sis.geometry.DirectPosition2D;
+import org.locationtech.jts.geom.Coordinate;
+import org.locationtech.jts.geom.Envelope;
+import org.locationtech.jts.geom.Geometry;
+import org.locationtech.jts.geom.GeometryFactory;
+import org.locationtech.jts.geom.IntersectionMatrix;
+import org.locationtech.jts.geom.Point;
+import org.locationtech.jts.geom.prep.PreparedGeometry;
+import org.locationtech.jts.geom.prep.PreparedGeometryFactory;
+import org.locationtech.jts.geom.util.AffineTransformation;
+import org.opengis.geometry.DirectPosition;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.referencing.operation.MathTransform;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class GeometryWrapper implements Serializable {
+
+ private final DimensionInfo dimensionInfo;
+ private final SRSInfo srsInfo;
+ private final Geometry xyGeometry;
+ private final Geometry parsingGeometry;
+ private PreparedGeometry preparedGeometry;
+ private Envelope envelope;
+ private Geometry translateXYGeometry;
+ private final String geometryDatatypeURI;
+ private GeometryDatatype geometryDatatype;
+ private String lexicalForm;
+ private String utmURI = null;
+ private Double latitude = null;
+
+ /**
+ *
+ * @param geometry In X/Y or Y/X coordinate order of the SRS URI.
+ * @param srsURI
+ * @param geometryDatatypeURI
+ * @param dimensionInfo
+ */
+ public GeometryWrapper(Geometry geometry, String srsURI, String geometryDatatypeURI, DimensionInfo dimensionInfo) {
+ this(geometry, srsURI, geometryDatatypeURI, dimensionInfo, null);
+ }
+
+ /**
+ *
+ * @param geometry In X/Y or Y/X coordinate order of the SRS URI.
+ * @param srsURI
+ * @param geometryDatatypeURI
+ * @param dimensionInfo
+ * @param geometryLiteral
+ */
+ public GeometryWrapper(Geometry geometry, String srsURI, String geometryDatatypeURI, DimensionInfo dimensionInfo, String geometryLiteral) {
+ this(geometry, GeometryReverse.check(geometry, srsURI.isEmpty() ? SRS_URI.DEFAULT_WKT_CRS84 : srsURI), srsURI.isEmpty() ? SRS_URI.DEFAULT_WKT_CRS84 : srsURI, geometryDatatypeURI, dimensionInfo, geometryLiteral);
+ }
+
+ protected GeometryWrapper(Geometry parsingGeometry, Geometry xyGeometry, String srsURI, String geometryDatatypeURI, DimensionInfo dimensionInfo) {
+ this(parsingGeometry, xyGeometry, srsURI, geometryDatatypeURI, dimensionInfo, null);
+ }
+
+ protected GeometryWrapper(Geometry parsingGeometry, Geometry xyGeometry, String srsURI, String geometryDatatypeURI, DimensionInfo dimensionInfo, String lexicalForm) {
+
+ this.parsingGeometry = parsingGeometry;
+ this.xyGeometry = xyGeometry;
+ this.preparedGeometry = null; //Initialised when required by spatial relations checkPreparedGeometry.
+ this.envelope = null; //Initialised when required by getEnvelope().
+ this.translateXYGeometry = null; //Initialised when required by translateGeometry().
+ this.geometryDatatypeURI = geometryDatatypeURI;
+ this.geometryDatatype = null; //Inilialised when required by getGeometryDatatype().
+
+ if (srsURI.isEmpty()) {
+ srsURI = SRS_URI.DEFAULT_WKT_CRS84;
+ }
+
+ this.srsInfo = SRSRegistry.getSRSInfo(srsURI);
+
+ this.dimensionInfo = dimensionInfo;
+ this.lexicalForm = lexicalForm; //If not Initialised then required by asLiteral() etc.
+ }
+
+ /**
+ * Default to WGS84 geometry and XY coordinate dimensions.
+ *
+ * @param geometry In X/Y or Y/X coordinate order of WGS84.
+ * @param geometryDatatypeURI
+ */
+ public GeometryWrapper(Geometry geometry, String geometryDatatypeURI) {
+ this(geometry, "", geometryDatatypeURI, DimensionInfo.XY_POINT);
+ }
+
+ /**
+ * Default to XY coordinate dimensions.
+ *
+ * @param geometry In X/Y or Y/X coordinate order of the SRS URI.
+ * @param srsURI
+ * @param geometryDatatypeURI
+ */
+ public GeometryWrapper(Geometry geometry, String srsURI, String geometryDatatypeURI) {
+ this(geometry, srsURI, geometryDatatypeURI, DimensionInfo.XY_POINT);
+ }
+
+ /**
+ * Empty geometry with specified parameters.
+ *
+ * @param srsURI
+ * @param geometryDatatypeURI
+ */
+ public GeometryWrapper(String srsURI, String geometryDatatypeURI) {
+ this(new CustomCoordinateSequence(DimensionInfo.XY_POINT.getDimensions()), geometryDatatypeURI, srsURI);
+ }
+
+ /**
+ * Point geometry with specified SRS.
+ *
+ * @param pointCoordinateSequence
+ * @param geometryDatatypeURI
+ * @param srsURI
+ */
+ public GeometryWrapper(CustomCoordinateSequence pointCoordinateSequence, String geometryDatatypeURI, String srsURI) {
+ this(CustomGeometryFactory.theInstance().createPoint(pointCoordinateSequence), srsURI, geometryDatatypeURI, DimensionInfo.XY_POINT);
+ }
+
+ /**
+ * Copy GeometryWrapper.
+ *
+ * @param geometryWrapper
+ */
+ public GeometryWrapper(GeometryWrapper geometryWrapper) {
+
+ this.xyGeometry = geometryWrapper.xyGeometry;
+ this.parsingGeometry = geometryWrapper.parsingGeometry;
+ this.preparedGeometry = geometryWrapper.preparedGeometry;
+ this.envelope = geometryWrapper.envelope;
+ this.translateXYGeometry = geometryWrapper.translateXYGeometry;
+ this.utmURI = geometryWrapper.utmURI;
+ this.latitude = geometryWrapper.latitude;
+ this.geometryDatatypeURI = geometryWrapper.geometryDatatypeURI;
+ this.geometryDatatype = geometryWrapper.geometryDatatype;
+
+ this.srsInfo = geometryWrapper.srsInfo;
+ this.dimensionInfo = geometryWrapper.dimensionInfo;
+ this.lexicalForm = geometryWrapper.lexicalForm;
+ }
+
+ /**
+ * Transforms, if necessary, the provided target GeometryWrapper according
+ * to this GeometryWrapper SRS_URI.
+ *
+ * @param targetGeometryWrapper
+ * @return GeometryWrapper after transformation.
+ * @throws FactoryException
+ * @throws MismatchedDimensionException
+ * @throws TransformException
+ */
+ public GeometryWrapper checkTransformSRS(GeometryWrapper targetGeometryWrapper) throws FactoryException, MismatchedDimensionException, TransformException {
+
+ GeometryWrapper transformedGeometryWrapper;
+ String srsURI = srsInfo.getSrsURI();
+ if (srsURI.equals(targetGeometryWrapper.srsInfo.getSrsURI())) {
+ transformedGeometryWrapper = targetGeometryWrapper;
+ } else {
+ transformedGeometryWrapper = targetGeometryWrapper.transform(srsURI);
+ }
+
+ return transformedGeometryWrapper;
+ }
+
+ /**
+ * Transform the GeometryWrapper into another spatial reference system.<br>
+ *
+ * @param srsURI
+ * @return New GeometryWrapper after transformation, or this GeometryWrapper
+ * if no transformation.
+ * @throws MismatchedDimensionException
+ * @throws TransformException
+ * @throws FactoryException
+ */
+ public GeometryWrapper transform(String srsURI) throws MismatchedDimensionException, TransformException, FactoryException {
+ return transform(srsURI, true);
+ }
+
+ /**
+ * Transform the GeometryWrapper into another spatial reference system.<br>
+ *
+ * @param srsInfo
+ * @return New GeometryWrapper after transformation, or this GeometryWrapper
+ * if no transformation.
+ * @throws MismatchedDimensionException
+ * @throws TransformException
+ * @throws FactoryException
+ */
+ public GeometryWrapper transform(SRSInfo srsInfo) throws MismatchedDimensionException, TransformException, FactoryException {
+ return transform(srsInfo.getSrsURI(), true);
+ }
+
+ /**
+ * Transform the GeometryWrapper into another spatial reference system.<br>
+ * Option to store the resulting GeometryWrapper in the index.
+ *
+ * @param srsURI
+ * @param storeSRSTransform
+ * @return GeometryWrapper after transformation.
+ * @throws MismatchedDimensionException
+ * @throws TransformException
+ * @throws FactoryException
+ */
+ protected GeometryWrapper transform(String srsURI, Boolean storeSRSTransform) throws MismatchedDimensionException, TransformException, FactoryException {
+ if (srsInfo.getSrsURI().equals(srsURI)) {
+ return this;
+ }
+
+ return GeometryTransformIndex.transform(this, srsURI, storeSRSTransform);
+ }
+
+ /**
+ * Checks whether the prepared geometry has been initialised.
+ * <br>Done lazily as expensive.
+ */
+ private void checkPreparedGeometry() {
+ if (preparedGeometry == null) {
+ this.preparedGeometry = PreparedGeometryFactory.prepare(xyGeometry);
+ }
+ }
+
+ /**
+ * Returns this geometry wrapper converted to the SRS_URI URI.
+ *
+ * @param srsURI
+ * @return GeometryWrapper after conversion.
+ * @throws FactoryException
+ * @throws MismatchedDimensionException
+ * @throws TransformException
+ */
+ public GeometryWrapper convertSRS(String srsURI) throws FactoryException, MismatchedDimensionException, TransformException {
+ return transform(srsURI);
+ }
+
+ /**
+ *
+ * @return Coordinate/Spatial reference system of the GeometryWrapper.
+ */
+ public CoordinateReferenceSystem getCRS() {
+ return srsInfo.getCrs();
+ }
+
+ /**
+ *
+ * @return Geometry with coordinates in x,y order, regardless of SRS_URI.
+ */
+ public Geometry getXYGeometry() {
+ return xyGeometry;
+ }
+
+ /**
+ *
+ * @return Geometry with coordinates as originally provided.
+ */
+ public Geometry getParsingGeometry() {
+ return parsingGeometry;
+ }
+
+ /**
+ * XY geometry translated by the domain range of the SRS, if a Geographic
+ * SRS.<br>
+ * Returns XY geometry if not a Geographic SRS.
+ *
+ * @return Geometry after translation in X direction.
+ */
+ public Geometry translateXYGeometry() {
+
+ if (translateXYGeometry == null) {
+
+ if (srsInfo.isGeographic()) {
+ double xTranslate = srsInfo.getDomainRangeX();
+ AffineTransformation translation = AffineTransformation.translationInstance(xTranslate, 0);
+ translateXYGeometry = translation.transform(xyGeometry); //Translate seems to be copying Y values into Z and M.
+ } else {
+ translateXYGeometry = xyGeometry;
+ }
+
+ }
+
+ return translateXYGeometry;
+ }
+
+ /**
+ *
+ * @return Coordinate/Spatial reference system URI.
+ */
+ public String getSrsURI() {
+ return srsInfo.getSrsURI();
+ }
+
+ /**
+ *
+ * @return getSRID used in GeoSPARQL Standard page 22 to refer to srsURI.
+ * i.e. getSrsURI and getSRID are the same.
+ */
+ public String getSRID() {
+ return srsInfo.getSrsURI();
+ }
+
+ /**
+ *
+ * @return SRS information that the Geometry Wrapper is using.
+ */
+ public SRSInfo getSrsInfo() {
+ return srsInfo;
+ }
+
+ /**
+ *
+ * @return Whether the SRS URI has been recognised. Operations may fail or
+ * not perform correctly when false.
+ */
+ public Boolean isSRSRecognised() {
+ return srsInfo.isSRSRecognised();
+ }
+
+ /**
+ *
+ * @return Datatype URI of the literal.
+ */
+ public String getGeometryDatatypeURI() {
+ return geometryDatatypeURI;
+ }
+
+ /**
+ *
+ * @return The name of the parsing Geometry's actual class.
+ */
+ public String getGeometryType() {
+ return parsingGeometry.getGeometryType();
+ }
+
+ /**
+ *
+ * @return GeometryDatatype of the literal.
+ */
+ public GeometryDatatype getGeometryDatatype() {
+
+ if (geometryDatatype == null) {
+ geometryDatatype = GeometryDatatype.get(geometryDatatypeURI);
+ }
+ return geometryDatatype;
+ }
+
+ /**
+ *
+ * @param distance
+ * @param targetDistanceUnitsURI
+ * @return Buffer around GeometryWrapper according the provided distance.
+ * @throws FactoryException
+ * @throws MismatchedDimensionException
+ * @throws TransformException
+ */
+ public GeometryWrapper buffer(double distance, String targetDistanceUnitsURI) throws FactoryException, MismatchedDimensionException, TransformException {
+
+ //Check whether the source geometry is linear units for cartesian calculation. If not then transform to relevant UTM SRS GeometryWrapper.
+ Boolean isTargetUnitsLinear = UnitsRegistry.isLinearUnits(targetDistanceUnitsURI);
+ GeometryWrapper transformedGeometryWrapper;
+ Boolean isTransformNeeded;
+
+ if (srsInfo.getUnitsOfMeasure().isLinearUnits() == isTargetUnitsLinear) {
+ //Source geometry and target units are both the same.
+ transformedGeometryWrapper = this;
+ isTransformNeeded = false;
+ } else if (isTargetUnitsLinear) {
+ //Source geometry is not linear but targets are so convert to linear SRS.
+ String sourceUtmURI = getUTMZoneURI();
+ transformedGeometryWrapper = transform(sourceUtmURI);
+ isTransformNeeded = true;
+ } else {
+ //Source geometry is linear but targets are not so convert to nonlinear SRS.
+ transformedGeometryWrapper = transform(SRS_URI.DEFAULT_WKT_CRS84);
+ isTransformNeeded = true;
+ }
+
+ //Check whether the units of the distance need converting.
+ double transformedDistance = UnitsOfMeasure.conversion(distance, targetDistanceUnitsURI, transformedGeometryWrapper.srsInfo.getUnitsOfMeasure().getUnitURI());
+
+ //Buffer the transformed geometry
+ Geometry xyGeo = transformedGeometryWrapper.xyGeometry.buffer(transformedDistance);
+ DimensionInfo bufferedDimensionInfo = new DimensionInfo(dimensionInfo.getCoordinate(), dimensionInfo.getSpatial(), xyGeo.getDimension());
+ Geometry parsingGeo = GeometryReverse.check(xyGeo, transformedGeometryWrapper.srsInfo);
+ GeometryWrapper bufferedGeometryWrapper = new GeometryWrapper(parsingGeo, xyGeo, transformedGeometryWrapper.srsInfo.getSrsURI(), transformedGeometryWrapper.geometryDatatypeURI, bufferedDimensionInfo);
+
+ //Check whether need to transform back to the original srsURI.
+ if (isTransformNeeded) {
+ //Don't store the buffered geometry as it is dependent upon the target distance and so likely to vary beween calls.
+ return bufferedGeometryWrapper.transform(srsInfo.getSrsURI(), false);
+ } else {
+ return bufferedGeometryWrapper;
+ }
+ }
+
+ /**
+ *
+ * @return URI of the GeometryWrapper's UTM zone
+ * @throws FactoryException
+ * @throws MismatchedDimensionException
+ * @throws TransformException
+ */
+ public String getUTMZoneURI() throws FactoryException, MismatchedDimensionException, TransformException {
+
+ if (utmURI == null) {
+
+ //Find a point in the parsing geometry so can directly apply the SRS.
+ Point coord = parsingGeometry.getCentroid();
+ DirectPosition2D point = new DirectPosition2D(coord.getX(), coord.getY());
+
+ //Convert to WGS84. Use WGS84 and not CRS84 as assuming WGS8 is more prevalent.
+ CoordinateReferenceSystem wgs84CRS = SRSRegistry.getCRS(SRS_URI.WGS84_CRS);
+ MathTransform transform = MathTransformRegistry.getMathTransform(srsInfo.getCrs(), wgs84CRS);
+
+ DirectPosition wgs84Point = transform.transform(point, null);
+
+ //Find the UTM zone.
+ utmURI = SRSRegistry.findUTMZoneURIFromWGS84(wgs84Point.getOrdinate(0), wgs84Point.getOrdinate(1));
+
+ }
+ return utmURI;
+ }
+
+ /**
+ * Latitude if Geographic SRS or in WGS84.<br>
+ * Used to convert between linear and non-linear units of measure.
+ *
+ * @return Latitude of Geometry.
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public Double getLatitude() throws FactoryException, MismatchedDimensionException, TransformException {
+
+ if (latitude == null) {
+ GeometryWrapper geoGeometryWrapper;
+
+ if (srsInfo.isGeographic()) {
+ //Already a geographic SRS.
+ geoGeometryWrapper = this;
+ } else {
+ //Use WGS84 and not CRS84 as assuming WGS8 is more prevalent.
+ geoGeometryWrapper = convertSRS(SRS_URI.WGS84_CRS);
+ }
+
+ //Latitude is Y-axis.
+ Geometry geometry = geoGeometryWrapper.getXYGeometry();
+ Point point = geometry.getCentroid();
+ latitude = point.getY();
+
+ }
+ return latitude;
+ }
+
+ /**
+ * Distance (Euclidean) defaulting to metres.
+ *
+ * @param targetGeometry
+ * @return Distance
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public double distanceEuclidean(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return distanceEuclidean(targetGeometry, Unit_URI.METRE_URL);
+ }
+
+ /**
+ * Distance (Euclidean) in the Units of Measure.
+ *
+ * @param targetGeometry
+ * @param unitsOfMeasure
+ * @return Distance
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public double distanceEuclidean(GeometryWrapper targetGeometry, UnitsOfMeasure unitsOfMeasure) throws FactoryException, MismatchedDimensionException, TransformException {
+ return distanceEuclidean(targetGeometry, unitsOfMeasure.getUnitURI());
+ }
+
+ /**
+ * Distance (Euclidean) in the Units of Measure stated in URI.
+ *
+ * @param targetGeometry
+ * @param targetDistanceUnitsURI
+ * @return Distance
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public double distanceEuclidean(GeometryWrapper targetGeometry, String targetDistanceUnitsURI) throws FactoryException, MismatchedDimensionException, TransformException {
+
+ Boolean isUnitsLinear = srsInfo.getUnitsOfMeasure().isLinearUnits();
+ Boolean isTargetUnitsLinear = UnitsRegistry.isLinearUnits(targetDistanceUnitsURI);
+
+ GeometryWrapper transformedTargetGeometry = checkTransformSRS(targetGeometry);
+
+ double distance = xyGeometry.distance(transformedTargetGeometry.xyGeometry);
+ String unitsURI = srsInfo.getUnitsOfMeasure().getUnitURI();
+
+ double targetDistance;
+ if (isUnitsLinear.equals(isTargetUnitsLinear)) {
+ //Units are same so straight conversion.
+ targetDistance = UnitsOfMeasure.conversion(distance, unitsURI, targetDistanceUnitsURI);
+ } else {
+ targetDistance = UnitsOfMeasure.convertBetween(distance, unitsURI, targetDistanceUnitsURI, isTargetUnitsLinear, getLatitude());
+ }
+
+ return targetDistance;
+ }
+
+ /**
+ * Distance (Great Circle) defaulting to metres.
+ *
+ * @param targetGeometry
+ * @return Distance
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public double distanceGreatCircle(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return distanceGreatCircle(targetGeometry, Unit_URI.METRE_URL);
+ }
+
+ /**
+ * Distance (Great Circle) in the Units of Measure.
+ *
+ * @param targetGeometry
+ * @param unitsOfMeasure
+ * @return Distance
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public double distanceGreatCircle(GeometryWrapper targetGeometry, UnitsOfMeasure unitsOfMeasure) throws FactoryException, MismatchedDimensionException, TransformException {
+ return distanceGreatCircle(targetGeometry, unitsOfMeasure.getUnitURI());
+ }
+
+ /**
+ * Distance (Great Circle) in the Units of Measure stated in URI.
+ *
+ * @param targetGeometry
+ * @param targetDistanceUnitsURI
+ * @return Distance
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public double distanceGreatCircle(GeometryWrapper targetGeometry, String targetDistanceUnitsURI) throws FactoryException, MismatchedDimensionException, TransformException {
+
+ GeometryWrapper transformedSourceGeometry;
+ if (srsInfo.isGeographic()) {
+ //Already a geographic SRS.
+ transformedSourceGeometry = this;
+ } else {
+ //Use WGS84 and not CRS84 as assuming WGS8 is more prevalent.
+ transformedSourceGeometry = this.transform(SRS_URI.WGS84_CRS);
+ }
+
+ GeometryWrapper transformedTargetGeometry = transformedSourceGeometry.checkTransformSRS(targetGeometry);
+
+ //Find the nearest pair of coordinates from each Geometry using Euclidean distance (adjusting for wrap around).
+ //These are then used for Great Circle distance.
+ CoordinatePair coordinatePair = CoordinatePair.findNearestPair(transformedSourceGeometry, transformedTargetGeometry);
+
+ //Check whether the nearest pair are the same, i.e. the overlap or within each other.
+ if (coordinatePair.isEqual()) {
+ //Exit early as the distance is zero.
+ return 0.0;
+ }
+
+ Coordinate coord1 = coordinatePair.getCoord1();
+ Coordinate coord2 = coordinatePair.getCoord2();
+
+ //Vincenty Formula is apparently more accurate at the Longitude boundary.
+ double distance = GreatCircleDistance.vincentyFormula(coord1.getY(), coord1.getX(), coord2.getY(), coord2.getX());
+ //double distance = GreatCircleDistance.haversineFormula(coord1.getY(), coord1.getX(), coord2.getY(), coord2.getX());
+
+ //Convert the Great Circle distance from metres into the requested units.
+ Boolean isTargetUnitsLinear = UnitsRegistry.isLinearUnits(targetDistanceUnitsURI);
+ double targetDistance;
+ if (isTargetUnitsLinear) {
+ //Target units are linear so straight conversion. Distance is in metres already.
+ targetDistance = UnitsOfMeasure.conversion(distance, Unit_URI.METRE_URL, targetDistanceUnitsURI);
+ } else {
+ targetDistance = UnitsOfMeasure.convertBetween(distance, Unit_URI.METRE_URL, targetDistanceUnitsURI, isTargetUnitsLinear, transformedSourceGeometry.getLatitude());
+ }
+
+ return targetDistance;
+ }
+
+ /**
+ * Distance (Euclidean or Great Circle depending on Geometry SRS URI)
+ * defaulting to metres.
+ *
+ * @param targetGeometry
+ * @return Distance
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public double distance(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ return distance(targetGeometry, Unit_URI.METRE_URL);
+ }
+
+ /**
+ * Distance (Euclidean or Great Circle depending on Geometry SRS URI) in the
+ * Units of Measure.
+ *
+ * @param targetGeometry
+ * @param unitsOfMeasure
+ * @return Distance
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public double distance(GeometryWrapper targetGeometry, UnitsOfMeasure unitsOfMeasure) throws FactoryException, MismatchedDimensionException, TransformException {
+ return distance(targetGeometry, unitsOfMeasure.getUnitURI());
+ }
+
+ /**
+ * Distance (Euclidean or Great Circle depending on Geometry SRS URI) in the
+ * Units of Measure stated in URI.
+ *
+ * @param targetGeometry
+ * @param targetDistanceUnitsURI
+ * @return Distance
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public double distance(GeometryWrapper targetGeometry, String targetDistanceUnitsURI) throws FactoryException, MismatchedDimensionException, TransformException {
+
+ double targetDistance;
+ if (srsInfo.isGeographic()) {
+ targetDistance = distanceGreatCircle(targetGeometry, targetDistanceUnitsURI);
+ } else {
+ targetDistance = distanceEuclidean(targetGeometry, targetDistanceUnitsURI);
+ }
+
+ return targetDistance;
+ }
+
+ /**
+ *
+ * @return Boundary of GeometryWrapper
+ */
+ public GeometryWrapper boundary() {
+ Geometry xyGeo = this.xyGeometry.getBoundary();
+ Geometry parsingGeo = GeometryReverse.check(xyGeo, srsInfo);
+ return new GeometryWrapper(parsingGeo, xyGeo, srsInfo.getSrsURI(), geometryDatatypeURI, dimensionInfo);
+ }
+
+ /**
+ *
+ * @return Convex Hull of GeometryWrapper
+ */
+ public GeometryWrapper convexHull() {
+ Geometry xyGeo = this.xyGeometry.convexHull();
+ Geometry parsingGeo = GeometryReverse.check(xyGeo, srsInfo);
+ return new GeometryWrapper(parsingGeo, xyGeo, srsInfo.getSrsURI(), geometryDatatypeURI, dimensionInfo);
+ }
+
+ /**
+ *
+ * @param targetGeometry
+ * @return Difference of GeometryWrapper with target.
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public GeometryWrapper difference(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
+ Geometry xyGeo = this.xyGeometry.difference(transformedGeometry.xyGeometry);
+ Geometry parsingGeo = GeometryReverse.check(xyGeo, srsInfo);
+ return new GeometryWrapper(parsingGeo, xyGeo, srsInfo.getSrsURI(), geometryDatatypeURI, dimensionInfo);
+ }
+
+ /**
+ * Envelope of GeometryWrapper with original coordinate order.
+ *
+ * @return Envelope of GeometryWrapper
+ */
+ public GeometryWrapper envelope() {
+ GeometryFactory geometryFactory = this.xyGeometry.getFactory();
+ Envelope xyEnvelope = this.getEnvelope();
+ Geometry xyGeo = geometryFactory.toGeometry(xyEnvelope);
+ Geometry parsingGeo = GeometryReverse.check(xyGeo, srsInfo);
+ return new GeometryWrapper(parsingGeo, xyGeo, srsInfo.getSrsURI(), geometryDatatypeURI, dimensionInfo);
+ }
+
+ /**
+ * Envelope of GeometryWrapper in XY order.
+ *
+ * @return Envelope of GeometryWrapper
+ */
+ public Envelope getEnvelope() {
+ if (envelope == null) {
+ envelope = this.xyGeometry.getEnvelopeInternal();
+ }
+
+ return envelope;
+ }
+
+ /**
+ *
+ * @param targetGeometry
+ * @return Intersection of GeometryWrapper with target.
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public GeometryWrapper intersection(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
+ Geometry xyGeo = this.xyGeometry.intersection(transformedGeometry.xyGeometry);
+ Geometry parsingGeo = GeometryReverse.check(xyGeo, srsInfo);
+ return new GeometryWrapper(parsingGeo, xyGeo, srsInfo.getSrsURI(), geometryDatatypeURI, dimensionInfo);
+ }
+
+ /**
+ *
+ * @param targetGeometry
+ * @return Intersection Matrix of GeometryWrapper with target.
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public IntersectionMatrix relate(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
+ return xyGeometry.relate(transformedGeometry.xyGeometry);
+ }
+
+ /**
+ *
+ * @param targetGeometry
+ * @param intersectionPattern
+ * @return Relation of GeometryWrapper with target.
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public boolean relate(GeometryWrapper targetGeometry, String intersectionPattern) throws FactoryException, MismatchedDimensionException, TransformException {
+ GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
+ return xyGeometry.relate(transformedGeometry.xyGeometry, intersectionPattern);
+ }
+
+ /**
+ *
+ * @param targetGeometry
+ * @return Symmetric Difference of GeometryWrapper with target.
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public GeometryWrapper symDifference(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
+ Geometry xyGeo = this.xyGeometry.symDifference(transformedGeometry.xyGeometry);
+ Geometry parsingGeo = GeometryReverse.check(xyGeo, srsInfo);
+ return new GeometryWrapper(parsingGeo, xyGeo, srsInfo.getSrsURI(), geometryDatatypeURI, dimensionInfo, null);
+ }
+
+ /**
+ *
+ * @param targetGeometry
+ * @return Union of GeometryWrapper with target.
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public GeometryWrapper union(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
+ Geometry xyGeo = this.xyGeometry.union(transformedGeometry.xyGeometry);
+ Geometry parsingGeo = GeometryReverse.check(xyGeo, srsInfo);
+ return new GeometryWrapper(parsingGeo, xyGeo, srsInfo.getSrsURI(), geometryDatatypeURI, dimensionInfo, null);
+ }
+
+ /**
+ *
+ * @param targetGeometry
+ * @return sfContains of GeometryWrapper with target.
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public boolean contains(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ this.checkPreparedGeometry();
+ GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
+ return this.preparedGeometry.contains(transformedGeometry.xyGeometry);
+ }
+
+ /**
+ *
+ * @param targetGeometry
+ * @return sfCrosses of GeometryWrapper with target.
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public boolean crosses(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ this.checkPreparedGeometry();
+ GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
+ return this.preparedGeometry.crosses(transformedGeometry.xyGeometry);
+ }
+
+ /**
+ *
+ * @param targetGeometry
+ * @return sfDisjoint of GeometryWrapper with target.
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public boolean disjoint(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ this.checkPreparedGeometry();
+ GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
+ return this.preparedGeometry.disjoint(transformedGeometry.xyGeometry);
+ }
+
+ /**
+ *
+ * @param targetGeometry
+ * @return Topology equals of GeometryWrapper with target.
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public boolean equalsTopo(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
+ return this.xyGeometry.equalsTopo(transformedGeometry.xyGeometry);
+ }
+
+ /**
+ *
+ * @param targetGeometry
+ * @return Equals exactly of GeometryWrapper with target.
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public boolean equalsExact(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
+ return this.xyGeometry.equalsExact(transformedGeometry.xyGeometry);
+ }
+
+ /**
+ *
+ * @param targetGeometry
+ * @param tolerance
+ * @return Equals exactly of GeometryWrapper with target using provided
+ * tolerance.
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public boolean equalsExact(GeometryWrapper targetGeometry, double tolerance) throws FactoryException, MismatchedDimensionException, TransformException {
+ GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
+ return this.xyGeometry.equalsExact(transformedGeometry.xyGeometry, tolerance);
+ }
+
+ /**
+ *
+ * @param targetGeometry
+ * @return sfIntersects of GeometryWrapper with target.
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public boolean intersects(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ this.checkPreparedGeometry();
+ GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
+ return this.preparedGeometry.intersects(transformedGeometry.xyGeometry);
+ }
+
+ /**
+ *
+ * @param targetGeometry
+ * @return sfOverlaps of GeometryWrapper with target.
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public boolean overlaps(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ this.checkPreparedGeometry();
+ GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
+ return this.preparedGeometry.overlaps(transformedGeometry.xyGeometry);
+ }
+
+ /**
+ *
+ * @param targetGeometry
+ * @return sfTouches of GeometryWrapper with target.
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public boolean touches(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ this.checkPreparedGeometry();
+ GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
+ return this.preparedGeometry.touches(transformedGeometry.xyGeometry);
+ }
+
+ /**
+ *
+ * @param targetGeometry
+ * @return sfWithin of GeometryWrapper with target.
+ * @throws org.opengis.util.FactoryException
+ * @throws org.opengis.referencing.operation.TransformException
+ */
+ public boolean within(GeometryWrapper targetGeometry) throws FactoryException, MismatchedDimensionException, TransformException {
+ this.checkPreparedGeometry();
+ GeometryWrapper transformedGeometry = checkTransformSRS(targetGeometry);
+ return this.preparedGeometry.within(transformedGeometry.xyGeometry);
+ }
+
+ /**
+ *
+ * @return GeometryWrapper as NodeValue
+ */
+ public NodeValue asNodeValue() throws DatatypeFormatException {
+ Literal literal = asLiteral();
+ return NodeValue.makeNode(literal.getLexicalForm(), literal.getDatatype());
+ }
+
+ /**
+ *
+ * @return GeometryWrapper as Node
+ */
+ public Node asNode() throws DatatypeFormatException {
+ return asNodeValue().asNode();
+ }
+
+ /**
+ *
+ * @return GeometryWrapper as Literal
+ */
+ public Literal asLiteral() throws DatatypeFormatException {
+
+ GeometryDatatype datatype = getGeometryDatatype(); //Datatype is only retrieved when required.
+ if (lexicalForm != null) {
+ return ResourceFactory.createTypedLiteral(lexicalForm, datatype);
+ }
+
+ Literal literal = asLiteral(datatype);
+ lexicalForm = literal.getLexicalForm();
+ return literal;
+ }
+
+ /**
+ *
+ * @param outputGeometryDatatypeURI
+ * @return GeometryWrapper as Literal in datatype form.
+ */
+ public Literal asLiteral(String outputGeometryDatatypeURI) throws DatatypeFormatException {
+ GeometryDatatype datatype = GeometryDatatype.get(outputGeometryDatatypeURI);
+ return asLiteral(datatype);
+ }
+
+ /**
+ *
+ * @param datatype
+ * @return GeometryWrapper as Literal
+ */
+ public Literal asLiteral(GeometryDatatype datatype) {
+ String tempLexicalForm = datatype.unparse(this);
+ return ResourceFactory.createTypedLiteral(tempLexicalForm, datatype);
+ }
+
+ /**
+ *
+ * @return Coordinate dimension, i.e. 2 (x,y), 3 (x,y,z or x,y,m) or 4
+ * (x,y,z,m)
+ */
+ public int getCoordinateDimension() {
+ return dimensionInfo.getCoordinate();
+ }
+
+ /**
+ *
+ * @return Spatial dimension, i.e. 2 or 3
+ */
+ public int getSpatialDimension() {
+ return dimensionInfo.getSpatial();
+ }
+
+ /**
+ *
+ * @return Topological dimension, i.e. 0, 1 or 2
+ */
+ public int getTopologicalDimension() {
+ return dimensionInfo.getTopological();
+ }
+
+ /**
+ *
+ * @return Enum of coordinate dimensions.
+ */
+ public CoordinateSequenceDimensions getCoordinateSequenceDimensions() {
+ return dimensionInfo.getDimensions();
+ }
+
+ /**
+ *
+ * @return Units of Measure for the GeometryWrapper SRS.
+ */
+ public UnitsOfMeasure getUnitsOfMeasure() {
+ return srsInfo.getUnitsOfMeasure();
+ }
+
+ /**
+ *
+ * @return GeometryWrapper's coordinate, spatial and topological dimensions.
+ */
+ public DimensionInfo getDimensionInfo() {
+ return dimensionInfo;
+ }
+
+ /**
+ *
+ * @return String literal of Geometry Wrapper.
+ */
+ public String getLexicalForm() {
+
+ if (lexicalForm != null) {
+ return lexicalForm;
+ } else {
+ Literal literal = asLiteral();
+ return literal.getLexicalForm();
+ }
+ }
+
+ /**
+ *
+ * @return Geometry is empty of coordinates.
+ */
+ public boolean isEmpty() {
+ return this.xyGeometry.isEmpty();
+ }
+
+ /**
+ *
+ * @return Geometry is in simple form.
+ */
+ public boolean isSimple() {
+ return this.xyGeometry.isSimple();
+ }
+
+ /**
+ *
+ * @return Geometry is topologically valid.
+ */
+ public boolean isValid() {
+ return this.xyGeometry.isValid();
+ }
+
+ /**
+ * Extract Geometry Wrapper from Geometry Literal.
+ *
+ * @param geometryLiteral
+ * @param targetIndex
+ * @return Geometry Wrapper of the Geometry Literal.
+ */
+ public static final GeometryWrapper extract(NodeValue geometryLiteral, GeometryIndex targetIndex) {
+
+ Node node = geometryLiteral.asNode();
+
+ return extract(node, targetIndex);
+ }
+
+ /**
+ * Extract Geometry Wrapper from Geometry Literal.
+ *
+ * @param geometryLiteral
+ * @param targetIndex
+ * @return Geometry Wrapper of the Geometry Literal.
+ */
+ public static final GeometryWrapper extract(Node geometryLiteral, GeometryIndex targetIndex) throws DatatypeFormatException {
+
+ if (!geometryLiteral.isLiteral()) {
+ throw new DatatypeFormatException("Not a Literal: " + geometryLiteral);
+ }
+
+ String datatypeURI = geometryLiteral.getLiteralDatatypeURI();
+ String lexicalForm = geometryLiteral.getLiteralLexicalForm();
+ return extract(lexicalForm, datatypeURI, targetIndex);
+ }
+
+ /**
+ * Extract Geometry Wrapper from Geometry Literal.
+ *
+ * @param geometryLiteral
+ * @return Geometry Wrapper of the Geometry Literal.
+ */
+ public static final GeometryWrapper extract(NodeValue geometryLiteral) {
+ return extract(geometryLiteral, GeometryIndex.PRIMARY);
+ }
+
+ /**
+ * Extract Geometry Wrapper from Geometry Literal.
+ *
+ * @param geometryLiteral
+ * @return Geometry Wrapper of the Geometry Literal.
+ */
+ public static final GeometryWrapper extract(Node geometryLiteral) {
+ return extract(geometryLiteral, GeometryIndex.PRIMARY);
+ }
+
+ /**
+ * Extract Geometry Wrapper from Geometry Literal. Returns null if invalid
+ * literal provided.
+ *
+ * @param geometryLiteral
+ * @param targetIndex
+ * @return Geometry Wrapper of the Geometry Literal.
+ */
+ public static final GeometryWrapper extract(Literal geometryLiteral, GeometryIndex targetIndex) {
+ return extract(geometryLiteral.getLexicalForm(), geometryLiteral.getDatatypeURI(), targetIndex);
+ }
+
+ /**
+ * Extract Geometry Wrapper from Geometry Literal.
+ *
+ * @param geometryLiteral
+ * @return Geometry Wrapper of the Geometry Literal.
+ */
+ public static final GeometryWrapper extract(Literal geometryLiteral) {
+ return extract(geometryLiteral, GeometryIndex.PRIMARY);
+ }
+
+ /**
+ * Extract Geometry Wrapper from Geometry Literal.
+ *
+ * @param lexicalForm
+ * @param datatypeURI
+ * @return Geometry Wrapper of the Geometry Literal.
+ */
+ public static GeometryWrapper extract(String lexicalForm, String datatypeURI) {
+ return extract(lexicalForm, datatypeURI, GeometryIndex.PRIMARY);
+ }
+
+ /**
+ * Extract Geometry Wrapper from Geometry Literal.
+ *
+ * @param lexicalForm
+ * @param datatypeURI
+ * @param targetIndex
+ * @return Geometry Wrapper of the Geometry Literal.
+ */
+ public static GeometryWrapper extract(String lexicalForm, String datatypeURI, GeometryIndex targetIndex) throws DatatypeFormatException {
+
+ if (lexicalForm == null || datatypeURI == null) {
+ throw new DatatypeFormatException("GeometryWrapper extraction: arguments cannot be null - " + lexicalForm + ", " + datatypeURI);
+ }
+
+ GeometryDatatype datatype = GeometryDatatype.get(datatypeURI);
+ GeometryWrapper geometry = datatype.parse(lexicalForm, targetIndex);
+ return geometry;
+ }
+
+ /**
+ * Builds a WKT Point of Geometry Wrapper.<br>
+ * This method does not use the GeometryLiteralIndex and so is best used for
+ * one of Geometry Wrappers.
+ *
+ * @return Geometry Wrapper of WKT Point.
+ */
+ public static final GeometryWrapper fromPoint(double x, double y, String srsURI) {
+ CustomCoordinateSequence coordSequence = CustomCoordinateSequence.createPoint(x, y);
+ GeometryWrapper geometryWrapper = new GeometryWrapper(coordSequence, WKTDatatype.URI, srsURI);
+ return geometryWrapper;
+ }
+
+ /**
+ *
+ * @return Empty GeometryWrapper in WKT datatype.
+ */
+ public static final GeometryWrapper getEmptyWKT() {
+ return WKTDatatype.INSTANCE.read("");
+ }
+
+ /**
+ *
+ * @return Empty GeometryWrapper in GML datatype.
+ */
+ public static final GeometryWrapper getEmptyGML() {
+ return GMLDatatype.INSTANCE.read("");
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 3;
+ hash = 23 * hash + Objects.hashCode(this.dimensionInfo);
+ hash = 23 * hash + Objects.hashCode(this.srsInfo);
+ hash = 23 * hash + Objects.hashCode(this.xyGeometry);
+ hash = 23 * hash + Objects.hashCode(this.geometryDatatypeURI);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final GeometryWrapper other = (GeometryWrapper) obj;
+ if (!Objects.equals(this.geometryDatatypeURI, other.geometryDatatypeURI)) {
+ return false;
+ }
+ if (!Objects.equals(this.dimensionInfo, other.dimensionInfo)) {
+ return false;
+ }
+ if (!Objects.equals(this.srsInfo, other.srsInfo)) {
+ return false;
+ }
+ return Objects.equals(this.xyGeometry, other.xyGeometry);
+ }
+
+ @Override
+ public String toString() {
+ return "GeometryWrapper{" + "dimensionInfo=" + dimensionInfo + ", geometryDatatypeURI=" + geometryDatatypeURI + ", lexicalForm=" + lexicalForm + ", utmURI=" + utmURI + ", latitude=" + latitude + ", xyGeometry=" + xyGeometry + ", parsingGeometry=" + parsingGeometry + ", preparedGeometry=" + preparedGeometry + ", srsInfo=" + srsInfo + '}';
+ }
+
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/UnitsOfMeasure.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/UnitsOfMeasure.java
index af9d20f..072d0cc 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/UnitsOfMeasure.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/UnitsOfMeasure.java
@@ -1,224 +1,224 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.implementation;
-
-import java.io.Serializable;
-import java.util.Objects;
-import javax.measure.Quantity;
-import javax.measure.Unit;
-import javax.measure.quantity.Length;
-import org.apache.jena.geosparql.implementation.registry.UnitsRegistry;
-import org.apache.jena.geosparql.implementation.vocabulary.Unit_URI;
-import org.apache.sis.measure.Quantities;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-
-/**
- * Based on:
- * http://www.geoapi.org/3.0/javadoc/org/opengis/referencing/doc-files/WKT.html
- * Based on: http://docs.opengeospatial.org/is/12-063r5/12-063r5.html
- *
- * Based on: https://sis.apache.org/apidocs/org/apache/sis/measure/Units.html
- *
- *
- */
-public class UnitsOfMeasure implements Serializable {
-
- private final Unit<Length> unit;
- private final String unitURI;
- private final boolean isLinearUnits;
-
- public static final UnitsOfMeasure METRE_UNITS = new UnitsOfMeasure(Unit_URI.METRE_URL);
- public static final UnitsOfMeasure DEGREE_UNITS = new UnitsOfMeasure(Unit_URI.DEGREE_URL);
-
- //https://en.wikipedia.org/wiki/Decimal_degrees
- public static final double EQUATORIAL_DEGREE_TO_METRES = 111319.8922;
- public static final double EARTH_MEAN_RADIUS = 6371008.7714; //Earth Mean Radius
-
- @SuppressWarnings("unchecked")
- public UnitsOfMeasure(CoordinateReferenceSystem crs) {
- this.unit = (Unit<Length>) crs.getCoordinateSystem().getAxis(0).getUnit();
- this.unitURI = UnitsRegistry.getUnitURI(unit);
- this.isLinearUnits = UnitsRegistry.isLinearUnits(unitURI);
- }
-
- @SuppressWarnings("unchecked")
- public UnitsOfMeasure(String unitURI) {
- this.unit = (Unit<Length>) UnitsRegistry.getUnit(unitURI);
- this.unitURI = UnitsRegistry.getUnitURI(unit);
- this.isLinearUnits = UnitsRegistry.isLinearUnits(unitURI);
- }
-
- public Unit<Length> getUnit() {
- return unit;
- }
-
- public String getUnitURI() {
- return unitURI;
- }
-
- public boolean isLinearUnits() {
- return isLinearUnits;
- }
-
- /**
- * Conversion from target distance in units to source Units Of Measure.
- *
- * @param sourceDistance
- * @param sourceDistanceUnitsURI
- * @param targetDistanceUnitsURI
- * @return Distance after conversion.
- * @throws UnitsConversionException
- */
- public static final Double conversion(double sourceDistance, String sourceDistanceUnitsURI, String targetDistanceUnitsURI) throws UnitsConversionException {
- return conversion(sourceDistance, new UnitsOfMeasure(sourceDistanceUnitsURI), new UnitsOfMeasure(targetDistanceUnitsURI));
- }
-
- /**
- * Conversion from target distance in units to source Units Of Measure.
- *
- * @param sourceDistance
- * @param sourceUnits
- * @param targetUnits
- * @return Distance after conversion.
- * @throws UnitsConversionException
- */
- public static final Double conversion(double sourceDistance, UnitsOfMeasure sourceUnits, UnitsOfMeasure targetUnits) throws UnitsConversionException {
-
- Boolean isSourceUnitsLinear = sourceUnits.isLinearUnits();
- Boolean isTargetUnitsLinear = targetUnits.isLinearUnits();
-
- if (!isSourceUnitsLinear.equals(isTargetUnitsLinear)) {
- throw new UnitsConversionException("Conversion between linear and non-linear units not supported (convertBetween method): " + sourceUnits.unitURI + " and " + targetUnits.unitURI);
- }
-
- //Source and Target are the same units, so return the source distance.
- if (sourceUnits.unitURI.equals(targetUnits.unitURI)) {
- return sourceDistance;
- }
-
- //Find which type of measure for the distance is being used.
- Unit<Length> sourceUnit = sourceUnits.getUnit();
- Unit<Length> targetUnit = targetUnits.getUnit();
-
- Quantity<Length> distance = Quantities.create(sourceDistance, sourceUnit);
- Quantity<Length> targetDistance = distance.to(targetUnit);
-
- return targetDistance.getValue().doubleValue();
-
- }
-
- /**
- * Convert between linear and non-linear units and vice versa.<br>
- * Will convert linear/linear and non-linear/non-linear units.
- *
- * @param distance
- * @param unitsURI
- * @param targetDistanceUnitsURI
- * @param isTargetUnitsLinear
- * @param latitude
- * @return Distance in target units.
- */
- public static final double convertBetween(double distance, String unitsURI, String targetDistanceUnitsURI, boolean isTargetUnitsLinear, double latitude) {
- double targetDistance;
- if (isTargetUnitsLinear) {
- double metresDistance = UnitsOfMeasure.convertToMetres(distance, unitsURI, latitude);
- targetDistance = UnitsOfMeasure.conversion(metresDistance, Unit_URI.METRE_URL, targetDistanceUnitsURI);
- } else {
- double degreesDistance = UnitsOfMeasure.convertToDegrees(distance, unitsURI, latitude);
- targetDistance = UnitsOfMeasure.conversion(degreesDistance, Unit_URI.DEGREE_URL, targetDistanceUnitsURI);
- }
-
- return targetDistance;
- }
-
- /**
- * Provides conversion of linear units to degrees.
- * <br> Conversion from linear (i.e. metres) to degrees based on equatorial
- * radius of 111.32km.
- * <br> Therefore, this should only be used for rough bounding area before
- * using more precise distance methods of GeometryWrapper.
- *
- * @param distance
- * @param unitsURI
- * @param latitude
- * @return Converted distance in the provided units.
- */
- public static final double convertToDegrees(double distance, String unitsURI, double latitude) {
-
- UnitsOfMeasure units = new UnitsOfMeasure(unitsURI);
-
- if (units.isLinearUnits()) {
- double latitudeRadians = Math.toRadians(latitude);
- double longitudeRatio = Math.cos(latitudeRadians) * EQUATORIAL_DEGREE_TO_METRES;
- double metreDistance = UnitsOfMeasure.conversion(distance, units, METRE_UNITS);
- return metreDistance / longitudeRatio;
- } else {
- return UnitsOfMeasure.conversion(distance, units, DEGREE_UNITS);
- }
-
- }
-
- public static final double convertToMetres(double distance, String unitsURI, double latitude) {
- UnitsOfMeasure units = new UnitsOfMeasure(unitsURI);
- if (!units.isLinearUnits()) {
- double latitudeRadians = Math.toRadians(latitude);
- double longitudeRatio = Math.cos(latitudeRadians) * EQUATORIAL_DEGREE_TO_METRES;
- double degreeDistance = UnitsOfMeasure.conversion(distance, units, DEGREE_UNITS);
- return degreeDistance * longitudeRatio;
- } else {
- return UnitsOfMeasure.conversion(distance, units, METRE_UNITS);
- }
- }
-
- @Override
- public String toString() {
- return "UnitsOfMeasure{" + "unit=" + unit + ", unitURI=" + unitURI + ", isLinearUnits=" + isLinearUnits + '}';
- }
-
- @Override
- public int hashCode() {
- int hash = 7;
- hash = 71 * hash + Objects.hashCode(this.unit);
- hash = 71 * hash + Objects.hashCode(this.unitURI);
- hash = 71 * hash + (this.isLinearUnits ? 1 : 0);
- return hash;
- }
-
- @Override
- public boolean equals(Object obj
- ) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final UnitsOfMeasure other = (UnitsOfMeasure) obj;
- if (this.isLinearUnits != other.isLinearUnits) {
- return false;
- }
- if (!Objects.equals(this.unitURI, other.unitURI)) {
- return false;
- }
- return Objects.equals(this.unit, other.unit);
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.implementation;
+
+import java.io.Serializable;
+import java.util.Objects;
+import javax.measure.Quantity;
+import javax.measure.Unit;
+import javax.measure.quantity.Length;
+import org.apache.jena.geosparql.implementation.registry.UnitsRegistry;
+import org.apache.jena.geosparql.implementation.vocabulary.Unit_URI;
+import org.apache.sis.measure.Quantities;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+
+/**
+ * Based on:
+ * http://www.geoapi.org/3.0/javadoc/org/opengis/referencing/doc-files/WKT.html
+ * Based on: http://docs.opengeospatial.org/is/12-063r5/12-063r5.html
+ *
+ * Based on: https://sis.apache.org/apidocs/org/apache/sis/measure/Units.html
+ *
+ *
+ */
+public class UnitsOfMeasure implements Serializable {
+
+ private final Unit<Length> unit;
+ private final String unitURI;
+ private final boolean isLinearUnits;
+
+ public static final UnitsOfMeasure METRE_UNITS = new UnitsOfMeasure(Unit_URI.METRE_URL);
+ public static final UnitsOfMeasure DEGREE_UNITS = new UnitsOfMeasure(Unit_URI.DEGREE_URL);
+
+ //https://en.wikipedia.org/wiki/Decimal_degrees
+ public static final double EQUATORIAL_DEGREE_TO_METRES = 111319.8922;
+ public static final double EARTH_MEAN_RADIUS = 6371008.7714; //Earth Mean Radius
+
+ @SuppressWarnings("unchecked")
+ public UnitsOfMeasure(CoordinateReferenceSystem crs) {
+ this.unit = (Unit<Length>) crs.getCoordinateSystem().getAxis(0).getUnit();
+ this.unitURI = UnitsRegistry.getUnitURI(unit);
+ this.isLinearUnits = UnitsRegistry.isLinearUnits(unitURI);
+ }
+
+ @SuppressWarnings("unchecked")
+ public UnitsOfMeasure(String unitURI) {
+ this.unit = (Unit<Length>) UnitsRegistry.getUnit(unitURI);
+ this.unitURI = UnitsRegistry.getUnitURI(unit);
+ this.isLinearUnits = UnitsRegistry.isLinearUnits(unitURI);
+ }
+
+ public Unit<Length> getUnit() {
+ return unit;
+ }
+
+ public String getUnitURI() {
+ return unitURI;
+ }
+
+ public boolean isLinearUnits() {
+ return isLinearUnits;
+ }
+
+ /**
+ * Conversion from target distance in units to source Units Of Measure.
+ *
+ * @param sourceDistance
+ * @param sourceDistanceUnitsURI
+ * @param targetDistanceUnitsURI
+ * @return Distance after conversion.
+ * @throws UnitsConversionException
+ */
+ public static final Double conversion(double sourceDistance, String sourceDistanceUnitsURI, String targetDistanceUnitsURI) throws UnitsConversionException {
+ return conversion(sourceDistance, new UnitsOfMeasure(sourceDistanceUnitsURI), new UnitsOfMeasure(targetDistanceUnitsURI));
+ }
+
+ /**
+ * Conversion from target distance in units to source Units Of Measure.
+ *
+ * @param sourceDistance
+ * @param sourceUnits
+ * @param targetUnits
+ * @return Distance after conversion.
+ * @throws UnitsConversionException
+ */
+ public static final Double conversion(double sourceDistance, UnitsOfMeasure sourceUnits, UnitsOfMeasure targetUnits) throws UnitsConversionException {
+
+ Boolean isSourceUnitsLinear = sourceUnits.isLinearUnits();
+ Boolean isTargetUnitsLinear = targetUnits.isLinearUnits();
+
+ if (!isSourceUnitsLinear.equals(isTargetUnitsLinear)) {
+ throw new UnitsConversionException("Conversion between linear and non-linear units not supported (convertBetween method): " + sourceUnits.unitURI + " and " + targetUnits.unitURI);
+ }
+
+ //Source and Target are the same units, so return the source distance.
+ if (sourceUnits.unitURI.equals(targetUnits.unitURI)) {
+ return sourceDistance;
+ }
+
+ //Find which type of measure for the distance is being used.
+ Unit<Length> sourceUnit = sourceUnits.getUnit();
+ Unit<Length> targetUnit = targetUnits.getUnit();
+
+ Quantity<Length> distance = Quantities.create(sourceDistance, sourceUnit);
+ Quantity<Length> targetDistance = distance.to(targetUnit);
+
+ return targetDistance.getValue().doubleValue();
+
+ }
+
+ /**
+ * Convert between linear and non-linear units and vice versa.<br>
+ * Will convert linear/linear and non-linear/non-linear units.
+ *
+ * @param distance
+ * @param unitsURI
+ * @param targetDistanceUnitsURI
+ * @param isTargetUnitsLinear
+ * @param latitude
+ * @return Distance in target units.
+ */
+ public static final double convertBetween(double distance, String unitsURI, String targetDistanceUnitsURI, boolean isTargetUnitsLinear, double latitude) {
+ double targetDistance;
+ if (isTargetUnitsLinear) {
+ double metresDistance = UnitsOfMeasure.convertToMetres(distance, unitsURI, latitude);
+ targetDistance = UnitsOfMeasure.conversion(metresDistance, Unit_URI.METRE_URL, targetDistanceUnitsURI);
+ } else {
+ double degreesDistance = UnitsOfMeasure.convertToDegrees(distance, unitsURI, latitude);
+ targetDistance = UnitsOfMeasure.conversion(degreesDistance, Unit_URI.DEGREE_URL, targetDistanceUnitsURI);
+ }
+
+ return targetDistance;
+ }
+
+ /**
+ * Provides conversion of linear units to degrees.
+ * <br> Conversion from linear (i.e. metres) to degrees based on equatorial
+ * radius of 111.32km.
+ * <br> Therefore, this should only be used for rough bounding area before
+ * using more precise distance methods of GeometryWrapper.
+ *
+ * @param distance
+ * @param unitsURI
+ * @param latitude
+ * @return Converted distance in the provided units.
+ */
+ public static final double convertToDegrees(double distance, String unitsURI, double latitude) {
+
+ UnitsOfMeasure units = new UnitsOfMeasure(unitsURI);
+
+ if (units.isLinearUnits()) {
+ double latitudeRadians = Math.toRadians(latitude);
+ double longitudeRatio = Math.cos(latitudeRadians) * EQUATORIAL_DEGREE_TO_METRES;
+ double metreDistance = UnitsOfMeasure.conversion(distance, units, METRE_UNITS);
+ return metreDistance / longitudeRatio;
+ } else {
+ return UnitsOfMeasure.conversion(distance, units, DEGREE_UNITS);
+ }
+
+ }
+
+ public static final double convertToMetres(double distance, String unitsURI, double latitude) {
+ UnitsOfMeasure units = new UnitsOfMeasure(unitsURI);
+ if (!units.isLinearUnits()) {
+ double latitudeRadians = Math.toRadians(latitude);
+ double longitudeRatio = Math.cos(latitudeRadians) * EQUATORIAL_DEGREE_TO_METRES;
+ double degreeDistance = UnitsOfMeasure.conversion(distance, units, DEGREE_UNITS);
+ return degreeDistance * longitudeRatio;
+ } else {
+ return UnitsOfMeasure.conversion(distance, units, METRE_UNITS);
+ }
+ }
+
+ @Override
+ public String toString() {
+ return "UnitsOfMeasure{" + "unit=" + unit + ", unitURI=" + unitURI + ", isLinearUnits=" + isLinearUnits + '}';
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 71 * hash + Objects.hashCode(this.unit);
+ hash = 71 * hash + Objects.hashCode(this.unitURI);
+ hash = 71 * hash + (this.isLinearUnits ? 1 : 0);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object obj
+ ) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final UnitsOfMeasure other = (UnitsOfMeasure) obj;
+ if (this.isLinearUnits != other.isLinearUnits) {
+ return false;
+ }
+ if (!Objects.equals(this.unitURI, other.unitURI)) {
+ return false;
+ }
+ return Objects.equals(this.unit, other.unit);
+ }
+
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/index/GeometryLiteralIndex.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/index/GeometryLiteralIndex.java
index 762a33a..59fa1d2 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/index/GeometryLiteralIndex.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/index/GeometryLiteralIndex.java
@@ -1,162 +1,162 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.implementation.index;
-
-import io.github.galbiston.expiring_map.ExpiringMap;
-import static io.github.galbiston.expiring_map.MapDefaultValues.MAP_EXPIRY_INTERVAL;
-import static io.github.galbiston.expiring_map.MapDefaultValues.UNLIMITED_MAP;
-import java.util.Map;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.apache.jena.geosparql.implementation.datatype.GeometryDatatype;
-
-/**
- *
- *
- */
-public class GeometryLiteralIndex {
-
- private static boolean INDEX_ACTIVE = false;
- private static final String PRIMARY_INDEX_LABEL = "Primary Geometry Literal Index";
- private static final String SECONDARY_INDEX_LABEL = "Secondary Geometry Literal Index";
- private static ExpiringMap<String, GeometryWrapper> PRIMARY_INDEX = new ExpiringMap<>(PRIMARY_INDEX_LABEL, UNLIMITED_MAP, MAP_EXPIRY_INTERVAL);
- private static ExpiringMap<String, GeometryWrapper> SECONDARY_INDEX = new ExpiringMap<>(SECONDARY_INDEX_LABEL, UNLIMITED_MAP, MAP_EXPIRY_INTERVAL);
-
- public enum GeometryIndex {
- PRIMARY, SECONDARY
- }
-
- public static final GeometryWrapper retrieve(String geometryLiteral, GeometryDatatype geometryDatatype, GeometryIndex targetIndex) {
- GeometryWrapper geometryWrapper;
-
- switch (targetIndex) {
- case SECONDARY:
- geometryWrapper = retrieveMemoryIndex(geometryLiteral, geometryDatatype, SECONDARY_INDEX, PRIMARY_INDEX);
- break;
- default:
- geometryWrapper = retrieveMemoryIndex(geometryLiteral, geometryDatatype, PRIMARY_INDEX, SECONDARY_INDEX);
- }
-
- return geometryWrapper;
- }
-
- private static GeometryWrapper retrieveMemoryIndex(String geometryLiteral, GeometryDatatype geometryDatatype, Map<String, GeometryWrapper> index, Map<String, GeometryWrapper> otherIndex) {
-
- GeometryWrapper geometryWrapper;
-
- if (INDEX_ACTIVE) {
-
- if (index.containsKey(geometryLiteral)) {
- geometryWrapper = index.get(geometryLiteral);
- } else {
- if (otherIndex.containsKey(geometryLiteral)) {
- geometryWrapper = otherIndex.get(geometryLiteral);
- } else {
- geometryWrapper = geometryDatatype.read(geometryLiteral);
- }
- index.put(geometryLiteral, geometryWrapper);
- }
-
- return geometryWrapper;
- }
-
- return geometryDatatype.read(geometryLiteral);
-
- }
-
- /**
- * Empty the Geometry Literal Index.
- */
- public static final void clear() {
- PRIMARY_INDEX.clear();
- SECONDARY_INDEX.clear();
- }
-
- /**
- * Sets the maximum size of Geometry Literal Index.
- *
- * @param maxSize : use -1 for unlimited size
- */
- public static final void setMaxSize(int maxSize) {
- PRIMARY_INDEX.setMaxSize(maxSize);
- SECONDARY_INDEX.setMaxSize(maxSize);
- }
-
- /**
- * Sets the expiry time in milliseconds of the Geometry Literal Indexes, if
- * active.
- *
- * @param expiryInterval : use 0 or negative for unlimited timeout
- */
- public static final void setExpiry(long expiryInterval) {
- PRIMARY_INDEX.setExpiryInterval(expiryInterval);
- SECONDARY_INDEX.setExpiryInterval(expiryInterval);
- }
-
- /**
- *
- * @return Number of items in the primary index.
- */
- public static final long getPrimaryIndexSize() {
- return PRIMARY_INDEX.mappingCount();
- }
-
- /**
- *
- * @return Number of items in the secondary index.
- */
- public static final long getSecondaryIndexSize() {
- return SECONDARY_INDEX.mappingCount();
- }
-
- /**
- *
- * @return True if index is active.
- */
- public static boolean isIndexActive() {
- return INDEX_ACTIVE;
- }
-
- /**
- * Sets whether the index is active.
- *
- * @param indexActive
- */
- public static void setIndexActive(boolean indexActive) {
- INDEX_ACTIVE = indexActive;
- if (INDEX_ACTIVE) {
- PRIMARY_INDEX.startExpiry();
- SECONDARY_INDEX.startExpiry();
- } else {
- PRIMARY_INDEX.stopExpiry();
- SECONDARY_INDEX.stopExpiry();
- }
- }
-
- /**
- * Reset the indexes to the provided max size and expiry interval.<br>
- * All contents will be lost.
- *
- * @param maxSize
- * @param expiryInterval
- */
- public static void reset(int maxSize, long expiryInterval) {
- PRIMARY_INDEX = new ExpiringMap<>(PRIMARY_INDEX_LABEL, maxSize, expiryInterval);
- SECONDARY_INDEX = new ExpiringMap<>(SECONDARY_INDEX_LABEL, maxSize, expiryInterval);
- }
-
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.implementation.index;
+
+import io.github.galbiston.expiring_map.ExpiringMap;
+import static io.github.galbiston.expiring_map.MapDefaultValues.MAP_EXPIRY_INTERVAL;
+import static io.github.galbiston.expiring_map.MapDefaultValues.UNLIMITED_MAP;
+import java.util.Map;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.apache.jena.geosparql.implementation.datatype.GeometryDatatype;
+
+/**
+ *
+ *
+ */
+public class GeometryLiteralIndex {
+
+ private static boolean INDEX_ACTIVE = false;
+ private static final String PRIMARY_INDEX_LABEL = "Primary Geometry Literal Index";
+ private static final String SECONDARY_INDEX_LABEL = "Secondary Geometry Literal Index";
+ private static ExpiringMap<String, GeometryWrapper> PRIMARY_INDEX = new ExpiringMap<>(PRIMARY_INDEX_LABEL, UNLIMITED_MAP, MAP_EXPIRY_INTERVAL);
+ private static ExpiringMap<String, GeometryWrapper> SECONDARY_INDEX = new ExpiringMap<>(SECONDARY_INDEX_LABEL, UNLIMITED_MAP, MAP_EXPIRY_INTERVAL);
+
+ public enum GeometryIndex {
+ PRIMARY, SECONDARY
+ }
+
+ public static final GeometryWrapper retrieve(String geometryLiteral, GeometryDatatype geometryDatatype, GeometryIndex targetIndex) {
+ GeometryWrapper geometryWrapper;
+
+ switch (targetIndex) {
+ case SECONDARY:
+ geometryWrapper = retrieveMemoryIndex(geometryLiteral, geometryDatatype, SECONDARY_INDEX, PRIMARY_INDEX);
+ break;
+ default:
+ geometryWrapper = retrieveMemoryIndex(geometryLiteral, geometryDatatype, PRIMARY_INDEX, SECONDARY_INDEX);
+ }
+
+ return geometryWrapper;
+ }
+
+ private static GeometryWrapper retrieveMemoryIndex(String geometryLiteral, GeometryDatatype geometryDatatype, Map<String, GeometryWrapper> index, Map<String, GeometryWrapper> otherIndex) {
+
+ GeometryWrapper geometryWrapper;
+
+ if (INDEX_ACTIVE) {
+
+ if (index.containsKey(geometryLiteral)) {
+ geometryWrapper = index.get(geometryLiteral);
+ } else {
+ if (otherIndex.containsKey(geometryLiteral)) {
+ geometryWrapper = otherIndex.get(geometryLiteral);
+ } else {
+ geometryWrapper = geometryDatatype.read(geometryLiteral);
+ }
+ index.put(geometryLiteral, geometryWrapper);
+ }
+
+ return geometryWrapper;
+ }
+
+ return geometryDatatype.read(geometryLiteral);
+
+ }
+
+ /**
+ * Empty the Geometry Literal Index.
+ */
+ public static final void clear() {
+ PRIMARY_INDEX.clear();
+ SECONDARY_INDEX.clear();
+ }
+
+ /**
+ * Sets the maximum size of Geometry Literal Index.
+ *
+ * @param maxSize : use -1 for unlimited size
+ */
+ public static final void setMaxSize(int maxSize) {
+ PRIMARY_INDEX.setMaxSize(maxSize);
+ SECONDARY_INDEX.setMaxSize(maxSize);
+ }
+
+ /**
+ * Sets the expiry time in milliseconds of the Geometry Literal Indexes, if
+ * active.
+ *
+ * @param expiryInterval : use 0 or negative for unlimited timeout
+ */
+ public static final void setExpiry(long expiryInterval) {
+ PRIMARY_INDEX.setExpiryInterval(expiryInterval);
+ SECONDARY_INDEX.setExpiryInterval(expiryInterval);
+ }
+
+ /**
+ *
+ * @return Number of items in the primary index.
+ */
+ public static final long getPrimaryIndexSize() {
+ return PRIMARY_INDEX.mappingCount();
+ }
+
+ /**
+ *
+ * @return Number of items in the secondary index.
+ */
+ public static final long getSecondaryIndexSize() {
+ return SECONDARY_INDEX.mappingCount();
+ }
+
+ /**
+ *
+ * @return True if index is active.
+ */
+ public static boolean isIndexActive() {
+ return INDEX_ACTIVE;
+ }
+
+ /**
+ * Sets whether the index is active.
+ *
+ * @param indexActive
+ */
+ public static void setIndexActive(boolean indexActive) {
+ INDEX_ACTIVE = indexActive;
+ if (INDEX_ACTIVE) {
+ PRIMARY_INDEX.startExpiry();
+ SECONDARY_INDEX.startExpiry();
+ } else {
+ PRIMARY_INDEX.stopExpiry();
+ SECONDARY_INDEX.stopExpiry();
+ }
+ }
+
+ /**
+ * Reset the indexes to the provided max size and expiry interval.<br>
+ * All contents will be lost.
+ *
+ * @param maxSize
+ * @param expiryInterval
+ */
+ public static void reset(int maxSize, long expiryInterval) {
+ PRIMARY_INDEX = new ExpiringMap<>(PRIMARY_INDEX_LABEL, maxSize, expiryInterval);
+ SECONDARY_INDEX = new ExpiringMap<>(SECONDARY_INDEX_LABEL, maxSize, expiryInterval);
+ }
+
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/index/GeometryTransformIndex.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/index/GeometryTransformIndex.java
index ebc1071..b13b3d7 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/index/GeometryTransformIndex.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/index/GeometryTransformIndex.java
@@ -1,159 +1,159 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.implementation.index;
-
-import io.github.galbiston.expiring_map.ExpiringMap;
-import static io.github.galbiston.expiring_map.MapDefaultValues.MAP_EXPIRY_INTERVAL;
-import static io.github.galbiston.expiring_map.MapDefaultValues.UNLIMITED_MAP;
-import org.apache.jena.geosparql.implementation.DimensionInfo;
-import org.apache.jena.geosparql.implementation.GeometryWrapper;
-import org.apache.jena.geosparql.implementation.jts.GeometryTransformation;
-import org.apache.jena.geosparql.implementation.registry.MathTransformRegistry;
-import org.apache.jena.geosparql.implementation.registry.SRSRegistry;
-import org.locationtech.jts.geom.Geometry;
-import org.opengis.geometry.MismatchedDimensionException;
-import org.opengis.referencing.crs.CoordinateReferenceSystem;
-import org.opengis.referencing.operation.MathTransform;
-import org.opengis.referencing.operation.TransformException;
-import org.opengis.util.FactoryException;
-
-/**
- *
- *
- */
-public class GeometryTransformIndex {
-
- private static boolean INDEX_ACTIVE = false;
- private static final String GEOMETRY_TRANSFORM_LABEL = "Geometry Transform";
- private static ExpiringMap<String, GeometryWrapper> GEOMETRY_TRANSFORM_INDEX = new ExpiringMap<>(GEOMETRY_TRANSFORM_LABEL, UNLIMITED_MAP, MAP_EXPIRY_INTERVAL);
-
- /**
- *
- * @param sourceGeometryWrapper
- * @param srsURI
- * @param storeSRSTransform
- * @return GeometryWrapper following transformation.
- * @throws TransformException
- * @throws org.opengis.util.FactoryException
- */
- public static final GeometryWrapper transform(GeometryWrapper sourceGeometryWrapper, String srsURI, Boolean storeSRSTransform) throws TransformException, FactoryException {
-
- GeometryWrapper transformedGeometryWrapper;
- String key = sourceGeometryWrapper.getLexicalForm() + "@" + srsURI;
-
- if (INDEX_ACTIVE && storeSRSTransform) {
- try {
- if (GEOMETRY_TRANSFORM_INDEX.containsKey(key)) {
-
- transformedGeometryWrapper = GEOMETRY_TRANSFORM_INDEX.get(key);
-
- } else {
- transformedGeometryWrapper = transform(sourceGeometryWrapper, srsURI);
- GEOMETRY_TRANSFORM_INDEX.put(key, transformedGeometryWrapper);
- }
- return transformedGeometryWrapper;
- } catch (NullPointerException ex) {
- //Catch NullPointerException and fall through to default action.
- }
- }
- return transform(sourceGeometryWrapper, srsURI);
-
- }
-
- private static GeometryWrapper transform(GeometryWrapper sourceGeometryWrapper, String srsURI) throws MismatchedDimensionException, FactoryException, TransformException {
- CoordinateReferenceSystem sourceCRS = sourceGeometryWrapper.getCRS();
- CoordinateReferenceSystem targetCRS = SRSRegistry.getCRS(srsURI);
- MathTransform transform = MathTransformRegistry.getMathTransform(sourceCRS, targetCRS);
- Geometry parsingGeometry = sourceGeometryWrapper.getParsingGeometry();
-
- //Transform the coordinates into a new Geometry.
- Geometry transformedGeometry = GeometryTransformation.transform(parsingGeometry, transform);
-
- //Construct a new GeometryWrapper using info from original GeometryWrapper.
- String geometryDatatypeURI = sourceGeometryWrapper.getGeometryDatatypeURI();
- DimensionInfo dimensionInfo = sourceGeometryWrapper.getDimensionInfo();
- return new GeometryWrapper(transformedGeometry, srsURI, geometryDatatypeURI, dimensionInfo);
- }
-
- /**
- * Empty the Geometry Transform Index.
- */
- public static final void clear() {
- GEOMETRY_TRANSFORM_INDEX.clear();
- }
-
- /**
- * Sets whether the maximum size of the Geometry Transform Index.
- *
- * @param maxSize : use -1 for unlimited size
- */
- public static final void setMaxSize(int maxSize) {
- GEOMETRY_TRANSFORM_INDEX.setMaxSize(maxSize);
- }
-
- /**
- * Sets the expiry time in milliseconds of the Geometry Transform Index, if
- * active.
- *
- * @param expiryInterval : use 0 or negative for unlimited timeout
- */
- public static final void setExpiry(long expiryInterval) {
- GEOMETRY_TRANSFORM_INDEX.setExpiryInterval(expiryInterval);
- }
-
- /**
- *
- * @return Number of items in the index.
- */
- public static final long getGeometryTransformIndexSize() {
- return GEOMETRY_TRANSFORM_INDEX.mappingCount();
- }
-
- /**
- *
- * @return True if index is active.
- */
- public static boolean isIndexActive() {
- return INDEX_ACTIVE;
- }
-
- /**
- * Sets whether the index is active.
- *
- * @param indexActive
- */
- public static void setIndexActive(boolean indexActive) {
- INDEX_ACTIVE = indexActive;
- if (INDEX_ACTIVE) {
- GEOMETRY_TRANSFORM_INDEX.startExpiry();
- } else {
- GEOMETRY_TRANSFORM_INDEX.stopExpiry();
- }
- }
-
- /**
- * Reset the index to the provided max size and expiry interval.<br>
- * All contents will be lost.
- *
- * @param maxSize
- * @param expiryInterval
- */
- public static void reset(int maxSize, long expiryInterval) {
- GEOMETRY_TRANSFORM_INDEX = new ExpiringMap<>(GEOMETRY_TRANSFORM_LABEL, maxSize, expiryInterval);
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.implementation.index;
+
+import io.github.galbiston.expiring_map.ExpiringMap;
+import static io.github.galbiston.expiring_map.MapDefaultValues.MAP_EXPIRY_INTERVAL;
+import static io.github.galbiston.expiring_map.MapDefaultValues.UNLIMITED_MAP;
+import org.apache.jena.geosparql.implementation.DimensionInfo;
+import org.apache.jena.geosparql.implementation.GeometryWrapper;
+import org.apache.jena.geosparql.implementation.jts.GeometryTransformation;
+import org.apache.jena.geosparql.implementation.registry.MathTransformRegistry;
+import org.apache.jena.geosparql.implementation.registry.SRSRegistry;
+import org.locationtech.jts.geom.Geometry;
+import org.opengis.geometry.MismatchedDimensionException;
+import org.opengis.referencing.crs.CoordinateReferenceSystem;
+import org.opengis.referencing.operation.MathTransform;
+import org.opengis.referencing.operation.TransformException;
+import org.opengis.util.FactoryException;
+
+/**
+ *
+ *
+ */
+public class GeometryTransformIndex {
+
+ private static boolean INDEX_ACTIVE = false;
+ private static final String GEOMETRY_TRANSFORM_LABEL = "Geometry Transform";
+ private static ExpiringMap<String, GeometryWrapper> GEOMETRY_TRANSFORM_INDEX = new ExpiringMap<>(GEOMETRY_TRANSFORM_LABEL, UNLIMITED_MAP, MAP_EXPIRY_INTERVAL);
+
+ /**
+ *
+ * @param sourceGeometryWrapper
+ * @param srsURI
+ * @param storeSRSTransform
+ * @return GeometryWrapper following transformation.
+ * @throws TransformException
+ * @throws org.opengis.util.FactoryException
+ */
+ public static final GeometryWrapper transform(GeometryWrapper sourceGeometryWrapper, String srsURI, Boolean storeSRSTransform) throws TransformException, FactoryException {
+
+ GeometryWrapper transformedGeometryWrapper;
+ String key = sourceGeometryWrapper.getLexicalForm() + "@" + srsURI;
+
+ if (INDEX_ACTIVE && storeSRSTransform) {
+ try {
+ if (GEOMETRY_TRANSFORM_INDEX.containsKey(key)) {
+
+ transformedGeometryWrapper = GEOMETRY_TRANSFORM_INDEX.get(key);
+
+ } else {
+ transformedGeometryWrapper = transform(sourceGeometryWrapper, srsURI);
+ GEOMETRY_TRANSFORM_INDEX.put(key, transformedGeometryWrapper);
+ }
+ return transformedGeometryWrapper;
+ } catch (NullPointerException ex) {
+ //Catch NullPointerException and fall through to default action.
+ }
+ }
+ return transform(sourceGeometryWrapper, srsURI);
+
+ }
+
+ private static GeometryWrapper transform(GeometryWrapper sourceGeometryWrapper, String srsURI) throws MismatchedDimensionException, FactoryException, TransformException {
+ CoordinateReferenceSystem sourceCRS = sourceGeometryWrapper.getCRS();
+ CoordinateReferenceSystem targetCRS = SRSRegistry.getCRS(srsURI);
+ MathTransform transform = MathTransformRegistry.getMathTransform(sourceCRS, targetCRS);
+ Geometry parsingGeometry = sourceGeometryWrapper.getParsingGeometry();
+
+ //Transform the coordinates into a new Geometry.
+ Geometry transformedGeometry = GeometryTransformation.transform(parsingGeometry, transform);
+
+ //Construct a new GeometryWrapper using info from original GeometryWrapper.
+ String geometryDatatypeURI = sourceGeometryWrapper.getGeometryDatatypeURI();
+ DimensionInfo dimensionInfo = sourceGeometryWrapper.getDimensionInfo();
+ return new GeometryWrapper(transformedGeometry, srsURI, geometryDatatypeURI, dimensionInfo);
+ }
+
+ /**
+ * Empty the Geometry Transform Index.
+ */
+ public static final void clear() {
+ GEOMETRY_TRANSFORM_INDEX.clear();
+ }
+
+ /**
+ * Sets whether the maximum size of the Geometry Transform Index.
+ *
+ * @param maxSize : use -1 for unlimited size
+ */
+ public static final void setMaxSize(int maxSize) {
+ GEOMETRY_TRANSFORM_INDEX.setMaxSize(maxSize);
+ }
+
+ /**
+ * Sets the expiry time in milliseconds of the Geometry Transform Index, if
+ * active.
+ *
+ * @param expiryInterval : use 0 or negative for unlimited timeout
+ */
+ public static final void setExpiry(long expiryInterval) {
+ GEOMETRY_TRANSFORM_INDEX.setExpiryInterval(expiryInterval);
+ }
+
+ /**
+ *
+ * @return Number of items in the index.
+ */
+ public static final long getGeometryTransformIndexSize() {
+ return GEOMETRY_TRANSFORM_INDEX.mappingCount();
+ }
+
+ /**
+ *
+ * @return True if index is active.
+ */
+ public static boolean isIndexActive() {
+ return INDEX_ACTIVE;
+ }
+
+ /**
+ * Sets whether the index is active.
+ *
+ * @param indexActive
+ */
+ public static void setIndexActive(boolean indexActive) {
+ INDEX_ACTIVE = indexActive;
+ if (INDEX_ACTIVE) {
+ GEOMETRY_TRANSFORM_INDEX.startExpiry();
+ } else {
+ GEOMETRY_TRANSFORM_INDEX.stopExpiry();
+ }
+ }
+
+ /**
+ * Reset the index to the provided max size and expiry interval.<br>
+ * All contents will be lost.
+ *
+ * @param maxSize
+ * @param expiryInterval
+ */
+ public static void reset(int maxSize, long expiryInterval) {
+ GEOMETRY_TRANSFORM_INDEX = new ExpiringMap<>(GEOMETRY_TRANSFORM_LABEL, maxSize, expiryInterval);
+ }
+}
diff --git a/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/index/QueryRewriteIndex.java b/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/index/QueryRewriteIndex.java
index 915a555..cc19ace 100644
--- a/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/index/QueryRewriteIndex.java
+++ b/jena-geosparql/src/main/java/org/apache/jena/geosparql/implementation/index/QueryRewriteIndex.java
@@ -1,301 +1,301 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.jena.geosparql.implementation.index;
-
-import io.github.galbiston.expiring_map.ExpiringMap;
-import static io.github.galbiston.expiring_map.MapDefaultValues.MAP_EXPIRY_INTERVAL;
-import static io.github.galbiston.expiring_map.MapDefaultValues.UNLIMITED_MAP;
-import java.util.Map.Entry;
-import org.apache.jena.geosparql.configuration.GeoSPARQLConfig;
-import org.apache.jena.geosparql.geo.topological.GenericPropertyFunction;
-import org.apache.jena.graph.Node;
-import org.apache.jena.query.Dataset;
-import org.apache.jena.query.DatasetFactory;
-import org.apache.jena.rdf.model.Model;
-import org.apache.jena.rdf.model.ModelFactory;
-import org.apache.jena.rdf.model.Property;
-import org.apache.jena.rdf.model.Resource;
-import org.apache.jena.rdf.model.ResourceFactory;
-import org.apache.jena.sparql.engine.ExecutionContext;
-import org.apache.jena.sparql.util.Context;
-import org.apache.jena.sparql.util.Symbol;
-
-/**
- *
- */
-public class QueryRewriteIndex {
-
- private boolean indexActive;
- private final String queryRewriteLabel;
- private ExpiringMap<String, Boolean> index;
- private static String LABEL_DEFAULT = "Query Rewrite";
- private static int MAP_SIZE_DEFAULT = UNLIMITED_MAP;
- private static long MAP_EXPIRY_INTERVAL_DEFAULT = MAP_EXPIRY_INTERVAL;
- private static final String KEY_SEPARATOR = "@";
-
- public static final Symbol QUERY_REWRITE_INDEX_SYMBOL = Symbol.create("http://jena.apache.org/spatial#query-index");
-
- public QueryRewriteIndex() {
- this.queryRewriteLabel = LABEL_DEFAULT;
- this.indexActive = GeoSPARQLConfig.isQueryRewriteEnabled();
- this.index = new ExpiringMap<>(queryRewriteLabel, MAP_SIZE_DEFAULT, MAP_EXPIRY_INTERVAL_DEFAULT);
- if (indexActive) {
- index.startExpiry();
- }
- }
-
- public QueryRewriteIndex(String queryRewriteLabel, int maxSize, long expiryInterval) {
- this.queryRewriteLabel = queryRewriteLabel;
- this.indexActive = true;
- this.index = new ExpiringMap<>(queryRewriteLabel, maxSize, expiryInterval);
- this.index.startExpiry();
- }
-
- /**
- *
- * @param subjectGeometryLiteral
- * @param predicate
- * @param objectGeometryLiteral
- * @param propertyFunction
- * @return Result of relation between subject and object.
- */
- public final Boolean test(Node subjectGeometryLiteral, Property predicate, Node objectGeometryLiteral, GenericPropertyFunction propertyFunction) {
-
- if (!subjectGeometryLiteral.isLiteral() || !objectGeometryLiteral.isLiteral()) {
- return false;
- }
-
- if (indexActive) {
- String key = subjectGeometryLiteral.getLiteralLexicalForm() + KEY_SEPARATOR + predicate.getURI() + KEY_SEPARATOR + objectGeometryLiteral.getLiteralLexicalForm();
- try {
- Boolean result;
- if (index.containsKey(key)) {
- result = index.get(key);
- } else {
- result = propertyFunction.testFilterFunction(subjectGeometryLiteral, objectGeometryLiteral);
- index.put(key, result);
- }
- return result;
- } catch (NullPointerException ex) {
- //Catch NullPointerException and fall through to default action.
- }
- }
-
- return propertyFunction.testFilterFunction(subjectGeometryLiteral, objectGeometryLiteral);
- }
-
- /**
- * Empty the index.
- */
- public final void clear() {
- index.clear();
- }
-
- /**
- * Sets whether the Query Rewrite Index is active.
- * <br> The index will be empty after this process.
- *
- * @param maxSize : use -1 for unlimited size
- */
- public final void setMapSize(int maxSize) {
- index.setMaxSize(maxSize);
- }
-
- /**
- * Sets the expiry time in milliseconds of the Query Rewrite Index, if
- * active.
- *
- * @param expiryInterval : use 0 or negative for unlimited timeout
- */
- public final void setMapExpiry(long expiryInterval) {
- index.setExpiryInterval(expiryInterval);
- }
-
- /**
- *
- * @return True if index is active.
- */
- public boolean isIndexActive() {
- return indexActive;
- }
-
- /**
- * COnverts the index to a model of asserted spatial relation statements.
- *
- * @return Model containing all true assertions.
- */
- public Model toModel() {
- Model model = ModelFactory.createDefaultModel();
- for (Entry<String, Boolean> entry : index.entrySet()) {
- Boolean value = entry.getValue();
- if (value) {
- String[] parts = entry.getKey().split(KEY_SEPARATOR);
- Resource subject = ResourceFactory.createResource(parts[0]);
- Property property = ResourceFactory.createProperty(parts[1]);
- Resource object = ResourceFactory.createResource(parts[2]);
- model.add(subject, property, object);
- }
- }
-
- return model;
- }
-
- /**
- * Sets whether the index is active.
- *
- * @param indexActive
- */
- public final void setActive(boolean indexActive) {
- this.indexActive = indexActive;
-
- if (indexActive) {
- index.startExpiry();
- } else {
- index.stopExpiry();
- }
- }
-
- /**
- *
- * @return Number of items in the index.
- */
- public final long getIndexSize() {
- return index.mappingCount();
- }
-
- /**
- * Reset the index to the provided max size and expiry interval.<br>
- * All contents will be lost.
- *
- * @param maxSize
- * @param expiryInterval
- */
- public void reset(int maxSize, long expiryInterval) {
- index = new ExpiringMap<>(queryRewriteLabel, maxSize, expiryInterval);
- }
-
- /**
- * Set the maximum default size of QueryRewriteIndexes. -1 for no limit, 0
- * for no storage.
- *
- * @param mapSizeDefault
- */
- public static final void setMaxSize(int mapSizeDefault) {
- QueryRewriteIndex.MAP_SIZE_DEFAULT = mapSizeDefault;
- }
-
- /**
- * Set the maximum default expiry interval in millisecond of
- * QueryRewriteIndexes. 0 for no expiry.
- *
- * @param mapExpiryIntervalDefault
- */
- public static final void setExpiry(long mapExpiryIntervalDefault) {
- QueryRewriteIndex.MAP_EXPIRY_INTERVAL_DEFAULT = mapExpiryIntervalDefault;
- }
-
- /**
- * Create QueryRewriteIndex using the default global settings.
- *
- * @return Query Rewrite Index using default global settings.
- */
- public static final QueryRewriteIndex createDefault() {
- return new QueryRewriteIndex();
- }
-
- /**
- * Prepare a Dataset with the default QueryRewriteIndex settings.
- *
- * @param dataset
- */
- public static final void prepare(Dataset dataset) {
- Context context = dataset.getContext();
- context.set(QUERY_REWRITE_INDEX_SYMBOL, createDefault());
- }
-
- /**
- * Prepare a Dataset with the provided QueryRewriteIndex settings.
- *
- * @param dataset
- * @param queryRewriteLabel
- * @param maxSize
- * @param expiryInterval
- */
- public static final void prepare(Dataset dataset, String queryRewriteLabel, int maxSize, long expiryInterval) {
- Context context = dataset.getContext();
- context.set(QUERY_REWRITE_INDEX_SYMBOL, new QueryRewriteIndex(queryRewriteLabel, maxSize, expiryInterval));
- }
-
- /**
- * Retrieve the QueryRewriteIndex from the Context.<br>
- * If no index has been setup then QueryRewriteIndex is created.
- *
- * @param execCxt
- * @return QueryRewriteIndex contained in the Context.
- */
- public static final QueryRewriteIndex retrieve(ExecutionContext execCxt) {
-
- Context context = execCxt.getContext();
- return retrieve(context);
- }
-
- /**
- * Retrieve the QueryRewriteIndex from the Dataset Context.<br>
- * If no index has been setup then QueryRewriteIndex is created.
- *
- * @param dataset
- * @return QueryRewriteIndex contained in the Context.
- */
- public static final QueryRewriteIndex retrieve(Dataset dataset) {
-
- Context context = dataset.getContext();
- return retrieve(context);
- }
-
- /**
- * Retrieve the QueryRewriteIndex from the Dataset Context.<br>
- * If no index has been setup then QueryRewriteIndex is created.
- *
- * @param context
- * @return QueryRewriteIndex contained in the Context.
- */
- public static final QueryRewriteIndex retrieve(Context context) {
- QueryRewriteIndex queryRewriteIndex = (QueryRewriteIndex) context.get(QUERY_REWRITE_INDEX_SYMBOL, null);
-
- if (queryRewriteIndex == null) {
- queryRewriteIndex = createDefault();
- context.set(QUERY_REWRITE_INDEX_SYMBOL, queryRewriteIndex);
- }
-
- return queryRewriteIndex;
- }
-
- /**
- * Wrap Model in a Dataset and include QueryRewriteIndex.
- *
- * @param model
- * @return Dataset with default Model and QueryRewriteIndex in Context.
- */
- public static final Dataset wrapModel(Model model) {
- Dataset dataset = DatasetFactory.createTxnMem();
- dataset.setDefaultModel(model);
- prepare(dataset);
-
- return dataset;
- }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jena.geosparql.implementation.index;
+
+import io.github.galbiston.expiring_map.ExpiringMap;
+import static io.github.galbiston.expiring_map.MapDefaultValues.MAP_EXPIRY_INTERVAL;
+import static io.github.galbiston.expiring_map.MapDefaultValues.UNLIMITED_MAP;
+import java.util.Map.Entry;
+import org.apache.jena.geosparql.configuration.GeoSPARQLConfig;
+import org.apache.jena.geosparql.geo.topological.GenericPropertyFunction;
+import org.apache.jena.graph.Node;
+import org.apache.jena.query.Dataset;
+import org.apache.jena.query.DatasetFactory;
+import org.apache.jena.rdf.model.Model;
+import org.apache.jena.rdf.model.ModelFactory;
+import org.apache.jena.rdf.model.Property;
+import org.apache.jena.rdf.model.Resource;
+import org.apache.jena.rdf.model.ResourceFactory;
+import org.apache.jena.sparql.engine.ExecutionContext;
+import org.apache.jena.sparql.util.Context;
+import org.apache.jena.sparql.util.Symbol;
+
+/**
+ *
+ */
+public class QueryRewriteIndex {
+
+ private boolean indexActive;
+ private final String queryRewriteLabel;
+ private ExpiringMap<String, Boolean> index;
+ private static String LABEL_DEFAULT = "Query Rewrite";
+ private static int MAP_SIZE_DEFAULT = UNLIMITED_MAP;
+ private static long MAP_EXPIRY_INTERVAL_DEFAULT = MAP_EXPIRY_INTERVAL;
+ private static final String KEY_SEPARATOR = "@";
+
+ public static final Symbol QUERY_REWRITE_INDEX_SYMBOL = Symbol.create("http://jena.apache.org/spatial#query-index");
+
+ public QueryRewriteIndex() {
+ this.queryRewriteLabel = LABEL_DEFAULT;
+ this.indexActive = GeoSPARQLConfig.isQueryRewriteEnabled();
+ this.index = new ExpiringMap<>(queryRewriteLabel, MAP_SIZE_DEFAULT, MAP_EXPIRY_INTERVAL_DEFAULT);
+ if (indexActive) {
+ index.startExpiry();
+ }
+ }
+
+ public QueryRewriteIndex(String queryRewriteLabel, int maxSize, long expiryInterval) {
+ this.queryRewriteLabel = queryRewriteLabel;
+ this.indexActive = true;
+ this.index = new ExpiringMap<>(queryRewriteLabel, maxSize, expiryInterval);
+ this.index.startExpiry();
+ }
+
+ /**
+ *
+ * @param subjectGeometryLiteral
+ * @param predicate
+ * @param objectGeometryLiteral
+ * @param propertyFunction
+ * @return Result of relation between subject and object.
+ */
+ public final Boolean test(Node subjectGeometryLiteral, Property predicate, Node objectGeometryLiteral, GenericPropertyFunction propertyFunction) {
+
+ if (!subjectGeometryLiteral.isLiteral() || !objectGeometryLiteral.isLiteral()) {
+ return false;
+ }
+
+ if (indexActive) {
+ String key = subjectGeometryLiteral.getLiteralLexicalForm() + KEY_SEPARATOR + predicate.getURI() + KEY_SEPARATOR + objectGeometryLiteral.getLiteralLexicalForm();
+ try {
+ Boolean result;
+ if (index.containsKey(key)) {
+ result = index.get(key);
+ } else {
+ result = propertyFunction.testFilterFunction(subjectGeometryLiteral, objectGeometryLiteral);
+ index.put(key, result);
+ }
+ return result;
+ } catch (NullPointerException ex) {
+ //Catch NullPointerException and fall through to default action.
+ }
+ }
+
+ return propertyFunction.testFilterFunction(subjectGeometryLiteral, objectGeometryLiteral);
+ }
+
+ /**
+ * Empty the index.
+ */
+ public final void clear() {
+ index.clear();
+ }
+
+ /**
+ * Sets whether the Query Rewrite Index is active.
+ * <br> The index will be empty after this process.
+ *
+ * @param maxSize : use -1 for unlimited size
+ */
+ public final void setMapSize(int maxSize) {
+ index.setMaxSize(maxSize);
+ }
+
+ /**
+ * Sets the expiry time in milliseconds of the Query Rewrite Index, if
+ * active.
+ *
+ * @param expiryInterval : use 0 or negative for unlimited timeout
+ */
+ public final void setMapExpiry(long expiryInterval) {
+ index.setExpiryInterval(expiryInterval);
+ }
+
+ /**
+ *
+ * @return True if index is active.
+ */
+ public boolean isIndexActive() {
+ return indexActive;
+ }
+
+ /**
+ * COnverts the index to a model of asserted spatial relation statements.
+ *
+ * @return Model containing all true assertions.
+ */
+ public Model toModel() {
+ Model model = ModelFactory.createDefaultModel();
+ for (Entry<String, Boolean> entry : index.entrySet()) {
+ Boolean value = entry.getValue();
+ if (value) {
+ String[] parts = entry.getKey().split(KEY_SEPARATOR);
+ Resource subject = ResourceFactory.createResource(parts[0]);
+ Property property = ResourceFactory.createProperty(parts[1]);
+ Resource object = ResourceFactory.createResource(parts[2]);
+ model.add(subject, property, object);
+ }
+ }
+
+ return model;
+ }
+
+ /**
+ * Sets whether the index is active.
+ *
+ * @param indexActive
+ */
+ public final void setActive(boolean indexActive) {
+ this.indexActive = indexActive;
+
+ if (indexActive) {
+ index.startExpiry();
+ } else {
+ index.stopExpiry();
+ }
+ }
+
+ /**
+ *
+ * @return Number of items in the index.
+ */
+ public final long getIndexSize() {
+ return index.mappingCount();
+ }
+
+ /**
+ * Reset the index to the provided max size and expiry interval.<br>
+ * All contents will be lost.
+ *
+ * @param maxSize
+ * @param expiryInterval
+ */
+ public void reset(int maxSize, long expiryInterval) {
+ index = new ExpiringMap<>(queryRewriteLabel, maxSize, expiryInterval);
+ }
+
+ /**
... 38630 lines suppressed ...