diff --git a/docs/tutorial/IndexerService.md b/docs/tutorial/IndexerService.md
index d11f167561fe101c5aa81affb1d7a0eae0b2496a..0873557d9b48c398bdb17e8aeae3b6a6426f1f38 100644
--- a/docs/tutorial/IndexerService.md
+++ b/docs/tutorial/IndexerService.md
@@ -8,6 +8,7 @@
- [Copy Index ](#copy-index)
- [Get task status ](#get-task-status)
- [Schema Service adoption ](#schema-service-adoption)
+ - [R3 Schema Support ](#r3-schema-support)
##Introduction
@@ -251,7 +252,7 @@ API will respond with status of task.
[Back to table of contents](#TOC)
-##Shema Service adoption
+##Schema Service adoption
Indexer service is in adaptation process to use schemas from the Schema service instead of Storage Service.
The Indexer Service retrieves a schema from the Schema Service if the schema is not found on the Storage Service.
@@ -260,3 +261,38 @@ Later call to the Storage Service will be deprecated and then removed (after the
[Back to table of contents](#TOC)
+###R3 Schema Support
+
+Indexer service support r3 schema. These schemas are created via Schema service.
+
+Here is an example following end-to-end workflow can be exercised (please update the schema based on your environment):
+
+* Ingest r3 schema for `opendes:wks:master-data--Wellbore:1.0.0`. Schema service payload can be found [here](https://community.opengroup.org/osdu/platform/system/indexer-service/-/blob/master/testing/indexer-test-core/src/main/resources/testData/r3-index_record_wks_master.schema.json).
+
+* Ingest r3 master-data Wellbore record. Storage service payload can be found [here](https://community.opengroup.org/osdu/platform/system/indexer-service/-/blob/master/testing/indexer-test-core/src/main/resources/testData/r3-index_record_wks_master.json)
+
+* Records can be searched via Search service. Here is sample payload:
+
+```
+POST /api/search/v2/query HTTP/1.1
+Content-Type: application/json
+data-partition-id: opendes
+{
+ "kind": "opendes:wks:master-data--Wellbore:1.0.0",
+ "spatialFilter": {
+ "field": "data.SpatialLocation.Wgs84Coordinates",
+ "byBoundingBox": {
+ "topLeft": {
+ "longitude": -100.0,
+ "latitude": 52.0
+ },
+ "bottomRight": {
+ "longitude": 100.0,
+ "latitude": 0.0
+ }
+ }
+ }
+}
+```
+[Back to table of contents](#TOC)
+
diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/Feature.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/Feature.java
new file mode 100644
index 0000000000000000000000000000000000000000..4d03bbe093b622e8fb08fd4659623fcb194feb0a
--- /dev/null
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/Feature.java
@@ -0,0 +1,40 @@
+// Copyright © Schlumberger
+//
+// Licensed 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.opengroup.osdu.indexer.model.geojson;
+
+import com.fasterxml.jackson.annotation.JsonInclude;
+import lombok.Data;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Data
+public class Feature extends GeoJsonObject {
+
+ @JsonInclude()
+ private Map properties = new HashMap<>();
+ @JsonInclude()
+ private GeoJsonObject geometry;
+ private String id;
+
+ public void setProperty(String key, Object value) {
+ properties.put(key, value);
+ }
+
+ @SuppressWarnings("unchecked")
+ public T getProperty(String key) {
+ return (T) properties.get(key);
+ }
+}
diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/FeatureCollection.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/FeatureCollection.java
new file mode 100644
index 0000000000000000000000000000000000000000..2040e646469ad32cd0dd036f732657f85da7a092
--- /dev/null
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/FeatureCollection.java
@@ -0,0 +1,45 @@
+// Copyright © Schlumberger
+//
+// Licensed 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.opengroup.osdu.indexer.model.geojson;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Data;
+import org.opengroup.osdu.indexer.model.geojson.jackson.FeatureCollectionSerializer;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+@Data
+@JsonSerialize(using = FeatureCollectionSerializer.class)
+public class FeatureCollection extends GeoJsonObject implements Iterable {
+
+ private List features = new ArrayList();
+
+ public FeatureCollection add(Feature feature) {
+ features.add(feature);
+ return this;
+ }
+
+ public void addAll(Collection features) {
+ this.features.addAll(features);
+ }
+
+ @Override
+ public Iterator iterator() {
+ return features.iterator();
+ }
+}
diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/GeoJsonObject.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/GeoJsonObject.java
new file mode 100644
index 0000000000000000000000000000000000000000..2f137a5fbb232400f51bb55ef5de4e40d3fd4909
--- /dev/null
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/GeoJsonObject.java
@@ -0,0 +1,36 @@
+// Copyright © Schlumberger
+//
+// Licensed 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.opengroup.osdu.indexer.model.geojson;
+
+import java.io.Serializable;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.annotation.JsonSubTypes;
+import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
+import com.fasterxml.jackson.annotation.JsonTypeInfo;
+import com.fasterxml.jackson.annotation.JsonTypeInfo.Id;
+import lombok.Data;
+
+@Data
+@JsonTypeInfo(property = "type", use = Id.NAME)
+@JsonSubTypes({ @Type(Feature.class), @Type(Polygon.class), @Type(MultiPolygon.class), @Type(FeatureCollection.class),
+ @Type(Point.class), @Type(MultiPoint.class), @Type(MultiLineString.class), @Type(LineString.class),
+ @Type(GeometryCollection.class) })
+@JsonInclude(Include.NON_NULL)
+@JsonIgnoreProperties(ignoreUnknown = true)
+public abstract class GeoJsonObject implements Serializable {
+}
diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/Geometry.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/Geometry.java
new file mode 100644
index 0000000000000000000000000000000000000000..99b0841ac5e9d1319ef7cca9ecd79ceb6928988b
--- /dev/null
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/Geometry.java
@@ -0,0 +1,45 @@
+// Copyright © Schlumberger
+//
+// Licensed 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.opengroup.osdu.indexer.model.geojson;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class Geometry extends GeoJsonObject {
+
+ protected List coordinates = new ArrayList();
+
+ public Geometry() {
+ }
+
+ public Geometry(T... elements) {
+ for (T coordinate : elements) {
+ coordinates.add(coordinate);
+ }
+ }
+
+ public Geometry add(T elements) {
+ coordinates.add(elements);
+ return this;
+ }
+
+ public List getCoordinates() {
+ return coordinates;
+ }
+
+ public void setCoordinates(List coordinates) {
+ this.coordinates = coordinates;
+ }
+}
diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/GeometryCollection.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/GeometryCollection.java
new file mode 100644
index 0000000000000000000000000000000000000000..903ac08186b4dc12eb02b0e4792e5f43c3a934df
--- /dev/null
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/GeometryCollection.java
@@ -0,0 +1,37 @@
+// Copyright © Schlumberger
+//
+// Licensed 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.opengroup.osdu.indexer.model.geojson;
+
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+@Data
+public class GeometryCollection extends GeoJsonObject implements Iterable {
+
+ private List geometries = new ArrayList();
+
+ @Override
+ public Iterator iterator() {
+ return geometries.iterator();
+ }
+
+ public GeometryCollection add(GeoJsonObject geometry) {
+ geometries.add(geometry);
+ return this;
+ }
+}
diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/LineString.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/LineString.java
new file mode 100644
index 0000000000000000000000000000000000000000..8eee047745dd486fc91ac4287b491525e9572c5e
--- /dev/null
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/LineString.java
@@ -0,0 +1,25 @@
+// Copyright © Schlumberger
+//
+// Licensed 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.opengroup.osdu.indexer.model.geojson;
+
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor
+public class LineString extends MultiPoint {
+
+ public LineString(Position... points) {
+ super(points);
+ }
+}
diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/MultiLineString.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/MultiLineString.java
new file mode 100644
index 0000000000000000000000000000000000000000..2e16db6e8ac5d06565cd9af8ccfa2e91da1faca6
--- /dev/null
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/MultiLineString.java
@@ -0,0 +1,27 @@
+// Copyright © Schlumberger
+//
+// Licensed 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.opengroup.osdu.indexer.model.geojson;
+
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+@NoArgsConstructor
+public class MultiLineString extends Geometry> {
+
+ public MultiLineString(List line) {
+ add(line);
+ }
+}
diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/MultiPoint.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/MultiPoint.java
new file mode 100644
index 0000000000000000000000000000000000000000..aabbdda84f31e9c4b30c986e6c5b4ae805788c05
--- /dev/null
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/MultiPoint.java
@@ -0,0 +1,25 @@
+// Copyright © Schlumberger
+//
+// Licensed 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.opengroup.osdu.indexer.model.geojson;
+
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor
+public class MultiPoint extends Geometry {
+
+ public MultiPoint(Position... points) {
+ super(points);
+ }
+}
diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/MultiPolygon.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/MultiPolygon.java
new file mode 100644
index 0000000000000000000000000000000000000000..6c9d8af0cd6b7f43d7b0a1b0ff5b7a106856b210
--- /dev/null
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/MultiPolygon.java
@@ -0,0 +1,32 @@
+// Copyright © Schlumberger
+//
+// Licensed 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.opengroup.osdu.indexer.model.geojson;
+
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+@NoArgsConstructor
+public class MultiPolygon extends Geometry>> {
+
+ public MultiPolygon(Polygon polygon) {
+ add(polygon);
+ }
+
+ public MultiPolygon add(Polygon polygon) {
+ coordinates.add(polygon.getCoordinates());
+ return this;
+ }
+}
diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/Point.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/Point.java
new file mode 100644
index 0000000000000000000000000000000000000000..9808209aa43e9eec7dd1c974dc5772aa9e7676a3
--- /dev/null
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/Point.java
@@ -0,0 +1,35 @@
+// Copyright © Schlumberger
+//
+// Licensed 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.opengroup.osdu.indexer.model.geojson;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+@AllArgsConstructor
+public class Point extends GeoJsonObject {
+
+ private Position coordinates;
+
+ public Point(double longitude, double latitude) {
+ coordinates = new Position(longitude, latitude);
+ }
+
+ public Point(double longitude, double latitude, double altitude) {
+ coordinates = new Position(longitude, latitude, altitude);
+ }
+}
diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/Polygon.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/Polygon.java
new file mode 100644
index 0000000000000000000000000000000000000000..31461b421204d45bb9c00dbabd42922a8e9f0c43
--- /dev/null
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/Polygon.java
@@ -0,0 +1,73 @@
+// Copyright © Schlumberger
+//
+// Licensed 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.opengroup.osdu.indexer.model.geojson;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import lombok.NoArgsConstructor;
+
+import java.util.Arrays;
+import java.util.List;
+
+@NoArgsConstructor
+public class Polygon extends Geometry> {
+
+ public Polygon(List polygon) {
+ add(polygon);
+ }
+
+ public Polygon(Position... polygon) {
+ add(Arrays.asList(polygon));
+ }
+
+ public void setExteriorRing(List points) {
+ if (coordinates.isEmpty()) {
+ coordinates.add(0, points);
+ } else {
+ coordinates.set(0, points);
+ }
+ }
+
+ @JsonIgnore
+ public List getExteriorRing() {
+ assertExteriorRing();
+ return coordinates.get(0);
+ }
+
+ @JsonIgnore
+ public List> getInteriorRings() {
+ assertExteriorRing();
+ return coordinates.subList(1, coordinates.size());
+ }
+
+ public List getInteriorRing(int index) {
+ assertExteriorRing();
+ return coordinates.get(1 + index);
+ }
+
+ public void addInteriorRing(List points) {
+ assertExteriorRing();
+ coordinates.add(points);
+ }
+
+ public void addInteriorRing(Position... points) {
+ assertExteriorRing();
+ coordinates.add(Arrays.asList(points));
+ }
+
+ private void assertExteriorRing() {
+ if (coordinates.isEmpty())
+ throw new RuntimeException("No exterior ring defined");
+ }
+}
diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/Position.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/Position.java
new file mode 100644
index 0000000000000000000000000000000000000000..fa124ee189a132ee0056dc05e8a2ce1bd970adfd
--- /dev/null
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/Position.java
@@ -0,0 +1,70 @@
+// Copyright © Schlumberger
+//
+// Licensed 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.opengroup.osdu.indexer.model.geojson;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.NoArgsConstructor;
+import org.opengroup.osdu.indexer.model.geojson.jackson.PositionDeserializer;
+import org.opengroup.osdu.indexer.model.geojson.jackson.PositionSerializer;
+
+import java.io.Serializable;
+
+@Getter
+@NoArgsConstructor
+@JsonIgnoreProperties(ignoreUnknown = true)
+@AllArgsConstructor
+@JsonDeserialize(using = PositionDeserializer.class)
+@JsonSerialize(using = PositionSerializer.class)
+public class Position implements Serializable {
+
+ private double longitude;
+ private double latitude;
+ @JsonIgnore
+ private double altitude = Double.NaN;
+
+ public Position(double longitude, double latitude) {
+ this.setLongitude(longitude);
+ this.setLatitude(latitude);
+ }
+
+ public void setLongitude(double longitude) {
+ if (Double.isNaN(longitude))
+ throw new IllegalArgumentException("latitude must be number");
+ if (longitude > 180 || longitude < -180)
+ throw new IllegalArgumentException("'longitude' value is out of the range [-180, 180]");
+ this.longitude = longitude;
+ }
+
+ public void setLatitude(double latitude) {
+ if (Double.isNaN(latitude))
+ throw new IllegalArgumentException("latitude must be number");
+ if (latitude > 90 || latitude < -90)
+ throw new IllegalArgumentException("latitude value is out of the range [-90, 90]");
+ this.latitude = latitude;
+ }
+
+ public void setAltitude(double altitude) {
+ this.altitude = altitude;
+ }
+
+ public boolean hasAltitude() {
+ return !Double.isNaN(altitude);
+ }
+}
diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/jackson/FeatureCollectionSerializer.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/jackson/FeatureCollectionSerializer.java
new file mode 100644
index 0000000000000000000000000000000000000000..f5d412a042655bcabed7e0840c61e5f4d8785d7c
--- /dev/null
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/jackson/FeatureCollectionSerializer.java
@@ -0,0 +1,81 @@
+// Copyright © Schlumberger
+//
+// Licensed 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.opengroup.osdu.indexer.model.geojson.jackson;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import com.fasterxml.jackson.databind.jsontype.TypeSerializer;
+import lombok.Data;
+import org.opengroup.osdu.indexer.model.geojson.*;
+
+import java.io.IOException;
+
+@Data
+public class FeatureCollectionSerializer extends JsonSerializer {
+
+ @Override
+ public void serialize(FeatureCollection value, JsonGenerator jsonGenerator, SerializerProvider provider) throws IOException {
+ jsonGenerator.writeStartObject();
+ jsonGenerator.writeStringField("type", "geometrycollection");
+
+ jsonGenerator.writeArrayFieldStart("geometries");
+ for (Feature feature : value.getFeatures()) {
+ jsonGenerator.writeStartObject();
+ if (feature.getGeometry() instanceof GeometryCollection) {
+ GeometryCollection geometryCollection = (GeometryCollection) feature.getGeometry();
+ for (GeoJsonObject shape : geometryCollection.getGeometries()) {
+ serializeGeoShape(shape, jsonGenerator);
+ }
+ } else {
+ serializeGeoShape(feature.getGeometry(), jsonGenerator);
+ }
+ jsonGenerator.writeEndObject();
+ }
+ jsonGenerator.writeEndArray();
+
+ jsonGenerator.writeEndObject();
+ }
+
+ @Override
+ public void serializeWithType(FeatureCollection value, JsonGenerator jsonGenerator, SerializerProvider provider, TypeSerializer typeSerializer)
+ throws IOException, JsonProcessingException {
+
+ serialize(value, jsonGenerator, provider);
+ }
+
+ private void serializeGeoShape(GeoJsonObject geoJsonObject, JsonGenerator jsonGenerator) throws IOException {
+ if (geoJsonObject instanceof Point) {
+ jsonGenerator.writeStringField("type", "point");
+ jsonGenerator.writeObjectField("coordinates", ((Point) geoJsonObject).getCoordinates());
+ } else if (geoJsonObject instanceof LineString) {
+ jsonGenerator.writeStringField("type", "linestring");
+ jsonGenerator.writeObjectField("coordinates", ((LineString) geoJsonObject).getCoordinates());
+ } else if (geoJsonObject instanceof Polygon) {
+ jsonGenerator.writeStringField("type", "polygon");
+ jsonGenerator.writeObjectField("coordinates", ((Polygon) geoJsonObject).getCoordinates());
+ } else if (geoJsonObject instanceof MultiPoint) {
+ jsonGenerator.writeStringField("type", "multipoint");
+ jsonGenerator.writeObjectField("coordinates", ((MultiPoint) geoJsonObject).getCoordinates());
+ } else if (geoJsonObject instanceof MultiLineString) {
+ jsonGenerator.writeStringField("type", "multilinestring");
+ jsonGenerator.writeObjectField("coordinates", ((MultiLineString) geoJsonObject).getCoordinates());
+ } else if (geoJsonObject instanceof MultiPolygon) {
+ jsonGenerator.writeStringField("type", "multipolygon");
+ jsonGenerator.writeObjectField("coordinates", ((MultiPolygon) geoJsonObject).getCoordinates());
+ }
+ }
+}
diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/jackson/PositionDeserializer.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/jackson/PositionDeserializer.java
new file mode 100644
index 0000000000000000000000000000000000000000..5c721c2e3a3042956f4b46972e85a07620d3ba76
--- /dev/null
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/jackson/PositionDeserializer.java
@@ -0,0 +1,67 @@
+// Copyright © Schlumberger
+//
+// Licensed 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.opengroup.osdu.indexer.model.geojson.jackson;
+
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonToken;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import org.opengroup.osdu.indexer.model.geojson.Position;
+
+import java.io.IOException;
+
+public class PositionDeserializer extends JsonDeserializer {
+
+ @Override
+ public Position deserialize(JsonParser jsonParser, DeserializationContext context) throws IOException {
+ if (jsonParser.isExpectedStartArrayToken()) {
+ return deserializeArray(jsonParser, context);
+ }
+ throw context.mappingException(Position.class);
+ }
+
+ protected Position deserializeArray(JsonParser jsonParser, DeserializationContext context) throws IOException {
+ Position node = new Position();
+ node.setLongitude(extractDouble(jsonParser, context, false));
+ node.setLatitude(extractDouble(jsonParser, context, false));
+ node.setAltitude(extractDouble(jsonParser, context, true));
+ return node;
+ }
+
+ private double extractDouble(JsonParser jsonParser, DeserializationContext context, boolean optional) throws IOException {
+ JsonToken token = jsonParser.nextToken();
+ if (token == null) {
+ if (optional)
+ return Double.NaN;
+ else
+ throw context.mappingException("Unexpected end-of-input when binding data into Position");
+ } else {
+ switch (token) {
+ case END_ARRAY:
+ if (optional)
+ return Double.NaN;
+ else
+ throw context.mappingException("Unexpected end-of-input when binding data into Position");
+ case VALUE_NUMBER_FLOAT:
+ return jsonParser.getDoubleValue();
+ case VALUE_NUMBER_INT:
+ return jsonParser.getLongValue();
+ default:
+ throw context.mappingException(
+ "Unexpected token (" + token.name() + ") when binding data into Position");
+ }
+ }
+ }
+}
diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/jackson/PositionSerializer.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/jackson/PositionSerializer.java
new file mode 100644
index 0000000000000000000000000000000000000000..09275a25866265a802665217c2718f15967c6379
--- /dev/null
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/model/geojson/jackson/PositionSerializer.java
@@ -0,0 +1,36 @@
+// Copyright © Schlumberger
+//
+// Licensed 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.opengroup.osdu.indexer.model.geojson.jackson;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+import org.opengroup.osdu.indexer.model.geojson.Position;
+
+import java.io.IOException;
+
+public class PositionSerializer extends JsonSerializer {
+
+ @Override
+ public void serialize(Position value, JsonGenerator jsonGenerator, SerializerProvider provider) throws IOException {
+ jsonGenerator.writeStartArray();
+ jsonGenerator.writeNumber(value.getLongitude());
+ jsonGenerator.writeNumber(value.getLatitude());
+ if (value.hasAltitude()) {
+ jsonGenerator.writeNumber(value.getAltitude());
+ }
+ jsonGenerator.writeEndArray();
+ }
+}
diff --git a/indexer-core/src/main/java/org/opengroup/osdu/indexer/schema/converter/PropertiesProcessor.java b/indexer-core/src/main/java/org/opengroup/osdu/indexer/schema/converter/PropertiesProcessor.java
index d98b1f77281138a9c3de3304350da461cda9ac08..57c2cae2c13e0e1b99dd963a1b7c650225fa5a10 100644
--- a/indexer-core/src/main/java/org/opengroup/osdu/indexer/schema/converter/PropertiesProcessor.java
+++ b/indexer-core/src/main/java/org/opengroup/osdu/indexer/schema/converter/PropertiesProcessor.java
@@ -13,6 +13,7 @@
// limitations under the License.
package org.opengroup.osdu.indexer.schema.converter;
+
import org.apache.http.HttpStatus;
import org.opengroup.osdu.core.common.logging.JaxRsDpsLog;
import org.opengroup.osdu.core.common.model.http.AppException;
@@ -78,12 +79,16 @@ public class PropertiesProcessor {
String definitionSubRef = ref.substring(DEF_PREFIX.length());
- if (schemaConverterConfig.getSkippedDefinitions().contains(definitionSubRef)) {
+ String definitionIdentity = getDefinitionIdentity(definitionSubRef);
+
+ if (schemaConverterConfig.getSkippedDefinitions().contains(definitionIdentity)) {
return Stream.empty();
}
- if (Objects.nonNull(schemaConverterConfig.getSpecialDefinitionsMap().get(definitionSubRef))) {
- return storageSchemaEntry(schemaConverterConfig.getSpecialDefinitionsMap().get(definitionSubRef), pathPrefix);
+ if (Objects.nonNull(schemaConverterConfig.getSpecialDefinitionsMap().get(definitionIdentity))) {
+ return storageSchemaEntry(
+ schemaConverterConfig.getSpecialDefinitionsMap().get(definitionIdentity) + getDefinitionColonVersion(definitionSubRef),
+ pathPrefix);
}
Definition definition = definitions.getDefinition(definitionSubRef);
@@ -101,6 +106,26 @@ public class PropertiesProcessor {
return processProperties(definition.getProperties());
}
+ private String getDefinitionIdentity(String definitionSubRef) {
+ String[] components = definitionSubRef.split(":");
+ if (components.length < 4) {
+ throw new AppException(HttpStatus.SC_CONFLICT, "Wrong definition format:" + definitionSubRef,
+ "Wrong definition format:" + definitionSubRef);
+ }
+
+ return components[2];
+ }
+
+ private String getDefinitionColonVersion(String definitionSubRef) {
+ String[] components = definitionSubRef.split(":");
+ if (components.length < 4) {
+ throw new AppException(HttpStatus.SC_CONFLICT, "Wrong definition format:" + definitionSubRef,
+ "Wrong definition format:" + definitionSubRef);
+ }
+
+ return ":" + components[3];
+ }
+
private Stream