From b0b1c7c2848872220a77edcf6301cbb5dae8b2f8 Mon Sep 17 00:00:00 2001 From: Michele Rastelli Date: Thu, 5 Sep 2024 16:51:30 +0200 Subject: [PATCH] added legacy option to GeoJSONAnalyzerProperties (#572) --- .../analyzer/GeoJSONAnalyzerProperties.java | 24 +++++++++++++++++-- .../com/arangodb/ArangoSearchAsyncTest.java | 1 + .../java/com/arangodb/ArangoSearchTest.java | 1 + 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/arangodb/entity/arangosearch/analyzer/GeoJSONAnalyzerProperties.java b/core/src/main/java/com/arangodb/entity/arangosearch/analyzer/GeoJSONAnalyzerProperties.java index 9e43c6d3c..2a7cc5594 100644 --- a/core/src/main/java/com/arangodb/entity/arangosearch/analyzer/GeoJSONAnalyzerProperties.java +++ b/core/src/main/java/com/arangodb/entity/arangosearch/analyzer/GeoJSONAnalyzerProperties.java @@ -30,6 +30,7 @@ public final class GeoJSONAnalyzerProperties { private GeoJSONAnalyzerType type; private GeoAnalyzerOptions options; + private Boolean legacy; public GeoJSONAnalyzerType getType() { return type; @@ -51,17 +52,36 @@ public void setOptions(GeoAnalyzerOptions options) { this.options = options; } + /** + * @return This option controls how GeoJSON Polygons are interpreted (introduced in v3.10.5). + * - If `legacy` is `true`, the smaller of the two regions defined by a + * linear ring is interpreted as the interior of the ring and a ring can at most + * enclose half the Earth's surface. + * - If `legacy` is `false`, the area to the left of the boundary ring's + * path is considered to be the interior and a ring can enclose the entire + * surface of the Earth. + *

+ * The default is `false`. + */ + public Boolean getLegacy() { + return legacy; + } + + public void setLegacy(Boolean legacy) { + this.legacy = legacy; + } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; GeoJSONAnalyzerProperties that = (GeoJSONAnalyzerProperties) o; - return type == that.type && Objects.equals(options, that.options); + return type == that.type && Objects.equals(options, that.options) && Objects.equals(legacy, that.legacy); } @Override public int hashCode() { - return Objects.hash(type, options); + return Objects.hash(type, options, legacy); } public enum GeoJSONAnalyzerType { diff --git a/test-functional/src/test/java/com/arangodb/ArangoSearchAsyncTest.java b/test-functional/src/test/java/com/arangodb/ArangoSearchAsyncTest.java index 04bb95d8d..27cf4e31e 100644 --- a/test-functional/src/test/java/com/arangodb/ArangoSearchAsyncTest.java +++ b/test-functional/src/test/java/com/arangodb/ArangoSearchAsyncTest.java @@ -861,6 +861,7 @@ void geoJsonAnalyzer(ArangoDatabaseAsync db) throws ExecutionException, Interrup GeoJSONAnalyzerProperties properties = new GeoJSONAnalyzerProperties(); properties.setOptions(options); properties.setType(GeoJSONAnalyzerProperties.GeoJSONAnalyzerType.point); + properties.setLegacy(true); Set features = new HashSet<>(); features.add(AnalyzerFeature.frequency); diff --git a/test-functional/src/test/java/com/arangodb/ArangoSearchTest.java b/test-functional/src/test/java/com/arangodb/ArangoSearchTest.java index da759b483..cc0412bbf 100644 --- a/test-functional/src/test/java/com/arangodb/ArangoSearchTest.java +++ b/test-functional/src/test/java/com/arangodb/ArangoSearchTest.java @@ -860,6 +860,7 @@ void geoJsonAnalyzer(ArangoDatabase db) { GeoJSONAnalyzerProperties properties = new GeoJSONAnalyzerProperties(); properties.setOptions(options); properties.setType(GeoJSONAnalyzerProperties.GeoJSONAnalyzerType.point); + properties.setLegacy(true); Set features = new HashSet<>(); features.add(AnalyzerFeature.frequency);