You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@polygene.apache.org by ni...@apache.org on 2015/04/17 18:46:33 UTC
[46/50] [abbrv] zest-qi4j git commit: Final cleanup
Final cleanup
Project: http://git-wip-us.apache.org/repos/asf/zest-qi4j/repo
Commit: http://git-wip-us.apache.org/repos/asf/zest-qi4j/commit/684bb9eb
Tree: http://git-wip-us.apache.org/repos/asf/zest-qi4j/tree/684bb9eb
Diff: http://git-wip-us.apache.org/repos/asf/zest-qi4j/diff/684bb9eb
Branch: refs/heads/ramtej-fb/spatial.queries
Commit: 684bb9eb3f99121a9817d5cd24e8f6c011fcdad5
Parents: 503532e
Author: jj <ju...@gmail.com>
Authored: Sat Jan 17 17:15:12 2015 +0100
Committer: jj <ju...@gmail.com>
Committed: Sat Jan 17 17:15:12 2015 +0100
----------------------------------------------------------------------
.../java/org/qi4j/api/geometry/TFeature.java | 34 +-
.../qi4j/api/geometry/TFeatureCollection.java | 18 +-
.../org/qi4j/api/geometry/TGeometryFactory.java | 41 +-
.../java/org/qi4j/api/geometry/TMultiPoint.java | 30 +-
.../main/java/org/qi4j/api/geometry/TPoint.java | 89 ++--
.../java/org/qi4j/api/geometry/TPolygon.java | 66 +--
.../main/java/org/qi4j/api/geometry/TUnit.java | 6 +-
.../qi4j/api/geometry/internal/Coordinate.java | 83 ++--
.../qi4j/api/geometry/internal/TLinearRing.java | 6 +-
.../internal/builders/TFeatureBuilder.java | 20 +-
.../internal/builders/TLineStringBuilder.java | 28 +-
.../builders/TMultiPolygonsBuilder.java | 29 +-
.../convert/ST_PointFromTextSpecification.java | 44 --
.../ST_WithinSpatialSpecification.java | 78 ---
.../predicate/ST_WithinSpecification.java | 36 +-
.../org/qi4j/api/geometry/TGeometryTest.java | 195 ++++----
.../spatial/ElasticSearchSpatialFinder.java | 49 +-
.../spatial/ElasticSearchSpatialIndexer.java | 121 +++--
.../configuration/SpatialConfiguration.java | 57 ++-
.../SpatialFunctionsSupportMatrix.java | 65 +--
.../functions/convert/ST_GeometryFromText.java | 14 +-
.../functions/predicates/ST_Disjoint.java | 24 +-
.../functions/predicates/ST_Intersects.java | 26 +-
.../mappings/builders/GeoPointBuilder.java | 29 +-
.../mappings/builders/GeoShapeBuilder.java | 21 +-
.../mappings/builders/MappingQueryBuilder.java | 6 +-
.../builders/SpatialMappingFactory.java | 12 +-
.../spatial/mappings/cache/MappingsCache.java | 46 +-
.../ElasticSearchSpatialClusterQueryTest.java | 484 -------------------
.../spatial/ElasticSearchSpatialBench.java | 170 -------
...earchSpatialQueryTestUsingUsingDefaults.java | 6 +-
.../extension/spatial/utils/RandomPoint.java | 148 ------
.../src/test/resources/RIAKBenchmark.properties | 1 -
libraries/spatial/build.gradle | 14 +-
libraries/spatial/dev-status.xml | 26 +-
.../conversions/from/GeoJsonFromConverter.java | 204 --------
.../from/TGeometryFromConverter.java | 38 --
.../conversions/from/WKTFromConverter.java | 226 ---------
.../conversions/to/GeoJsonToConverter.java | 66 ---
.../conversions/to/Spatial4JToConverter.java | 117 -----
.../conversions/to/TGeometryToConverter.java | 46 --
.../formats/conversions/TConversions.java | 31 ++
.../from/TGeometryFromConverter.java | 39 ++
.../conversions/from/WKTFromConverter.java | 164 +++++++
.../conversions/to/Spatial4JToConverter.java | 114 +++++
.../conversions/to/TGeometryToConverter.java | 47 ++
.../formats/conversions/to/ToHelper.java | 63 +++
.../transformations/fromto/ToHelper.java | 150 ------
.../transformations/TTransformations.java | 32 ++
.../ConvertFromGeoJsonToTGeometryTest.java | 179 -------
.../conversions/ConversionsFromWktTest.java | 33 ++
.../ConvertFromGeoJsonToTGeometryTest.java | 189 ++++++++
.../formats/data/GeoJSONSpec20080616.java | 28 ++
.../spatial/topo/GeoJSONSwissLakes2013.java | 79 ---
.../openstreetmap/model/FeatureEntity.java | 17 -
.../domain/openstreetmap/model/TagEntity.java | 15 -
.../OpenStreetMapDomainModelAssembler.java | 45 --
.../model/interactions/api/OSM.java | 110 -----
58 files changed, 1423 insertions(+), 2731 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/684bb9eb/core/api/src/main/java/org/qi4j/api/geometry/TFeature.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/geometry/TFeature.java b/core/api/src/main/java/org/qi4j/api/geometry/TFeature.java
index cf983e9..b47abec 100644
--- a/core/api/src/main/java/org/qi4j/api/geometry/TFeature.java
+++ b/core/api/src/main/java/org/qi4j/api/geometry/TFeature.java
@@ -17,18 +17,21 @@ package org.qi4j.api.geometry;
import org.qi4j.api.common.Optional;
import org.qi4j.api.geometry.internal.Coordinate;
import org.qi4j.api.geometry.internal.TGeometry;
-import org.qi4j.api.geometry.internal.TLinearRing;
import org.qi4j.api.injection.scope.Structure;
import org.qi4j.api.injection.scope.This;
import org.qi4j.api.mixin.Mixins;
import org.qi4j.api.property.Property;
import org.qi4j.api.structure.Module;
-import java.util.*;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
@Mixins(TFeature.Mixin.class)
-public interface TFeature extends TGeometry {
+public interface TFeature extends TGeometry
+{
@Optional
@@ -43,6 +46,7 @@ public interface TFeature extends TGeometry {
TFeature of(TGeometry geometry);
TFeature withProperties(Map<String, List<String>> properties);
+
TFeature addProperty(String name, String value);
TGeometry asGeometry();
@@ -50,7 +54,8 @@ public interface TFeature extends TGeometry {
Map<String, List<String>> asProperties();
- public abstract class Mixin implements TFeature {
+ public abstract class Mixin implements TFeature
+ {
@Structure
Module module;
@@ -58,7 +63,8 @@ public interface TFeature extends TGeometry {
@This
TFeature self;
- public TFeature of(TGeometry geometry) {
+ public TFeature of(TGeometry geometry)
+ {
self.geometryType().set(TGEOMETRY_TYPE.FEATURE);
self.geometry().set(geometry);
@@ -76,10 +82,9 @@ public interface TFeature extends TGeometry {
if (self.properties() == null || self.properties().get() == null || !self.properties().get().containsKey(name))
{
Map<String, List<String>> properties = new HashMap<>();
- properties.put(name, Arrays.asList(value) );
+ properties.put(name, Arrays.asList(value));
self.properties().set(properties);
- }
- else
+ } else
{
self.properties().get().get(name).add(value);
}
@@ -87,7 +92,8 @@ public interface TFeature extends TGeometry {
}
- public boolean isEmpty() {
+ public boolean isEmpty()
+ {
return (self.geometry() == null) || (self.geometry().get() == null) || (self.geometry().get().isEmpty()) ? true : false;
}
@@ -96,16 +102,20 @@ public interface TFeature extends TGeometry {
{
return self.geometry().get().getCoordinates();
}
- public int getNumPoints() {
+
+ public int getNumPoints()
+ {
return isEmpty() ? 0 : self.geometry().get().getNumPoints();
}
- public TGeometry asGeometry() {
+ public TGeometry asGeometry()
+ {
return self.geometry().get();
}
- public Map<String, List<String>> asProperties() {
+ public Map<String, List<String>> asProperties()
+ {
return self.properties().get();
}
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/684bb9eb/core/api/src/main/java/org/qi4j/api/geometry/TFeatureCollection.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/geometry/TFeatureCollection.java b/core/api/src/main/java/org/qi4j/api/geometry/TFeatureCollection.java
index 406a718..99593d3 100644
--- a/core/api/src/main/java/org/qi4j/api/geometry/TFeatureCollection.java
+++ b/core/api/src/main/java/org/qi4j/api/geometry/TFeatureCollection.java
@@ -25,29 +25,34 @@ import java.util.ArrayList;
import java.util.List;
@Mixins(TFeatureCollection.Mixin.class)
-public interface TFeatureCollection extends GeometryCollections {
+public interface TFeatureCollection extends GeometryCollections
+{
TFeatureCollection of(TFeature... features);
TFeatureCollection of(List<TFeature> features);
- public abstract class Mixin extends GeometryCollections.Mixin implements TFeatureCollection {
+ public abstract class Mixin extends GeometryCollections.Mixin implements TFeatureCollection
+ {
@Structure
Module module;
@This
TFeatureCollection self;
- public TFeatureCollection of(List<TFeature> features) {
+ public TFeatureCollection of(List<TFeature> features)
+ {
of(features.toArray(new TFeature[features.size()]));
return self;
}
- public TFeatureCollection of(TFeature... features) {
+ public TFeatureCollection of(TFeature... features)
+ {
self.geometryType().set(TGEOMETRY_TYPE.FEATURECOLLECTION);
init();
List<TGeometry> l = new ArrayList<>();
- for (TFeature f : features) {
+ for (TFeature f : features)
+ {
l.add(f);
}
@@ -58,8 +63,5 @@ public interface TFeatureCollection extends GeometryCollections {
return self;
}
-
-
}
-
}
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/684bb9eb/core/api/src/main/java/org/qi4j/api/geometry/TGeometryFactory.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/geometry/TGeometryFactory.java b/core/api/src/main/java/org/qi4j/api/geometry/TGeometryFactory.java
index 33b1709..7292e28 100644
--- a/core/api/src/main/java/org/qi4j/api/geometry/TGeometryFactory.java
+++ b/core/api/src/main/java/org/qi4j/api/geometry/TGeometryFactory.java
@@ -17,48 +17,51 @@ package org.qi4j.api.geometry;
import org.qi4j.api.geometry.internal.builders.*;
import org.qi4j.api.structure.Module;
-/**
- * Created by jj on 26.11.14.
- */
-public class TGeometryFactory {
+
+public class TGeometryFactory
+{
- public static TCRSBuilder TCrs(Module module) {
+ public static TCRSBuilder TCrs(Module module)
+ {
return new TCRSBuilder(module);
}
-
- public static TPointBuilder TPoint(Module module) {
+ public static TPointBuilder TPoint(Module module)
+ {
return new TPointBuilder(module);
}
- public static TMultiPointBuilder TMultiPoint(Module module) {
+ public static TMultiPointBuilder TMultiPoint(Module module)
+ {
return new TMultiPointBuilder(module);
}
-
- public static TLinearRingBuilder TLinearRing(Module module) {
+ public static TLinearRingBuilder TLinearRing(Module module)
+ {
return new TLinearRingBuilder(module);
}
-
- public static TLineStringBuilder TLineString(Module module) {
+ public static TLineStringBuilder TLineString(Module module)
+ {
return new TLineStringBuilder(module);
}
-
public static TMultiLineStringBuilder TMultiLineString(Module module)
{
return new TMultiLineStringBuilder(module);
}
- public static TPolygonBuilder TPolygon(Module module) {
+
+ public static TPolygonBuilder TPolygon(Module module)
+ {
return new TPolygonBuilder(module);
}
- public static TMultiPolygonsBuilder TMultiPolygon(Module module) {
+ public static TMultiPolygonsBuilder TMultiPolygon(Module module)
+ {
return new TMultiPolygonsBuilder(module);
}
-
- public static TFeatureBuilder TFeature(Module module) {
+ public static TFeatureBuilder TFeature(Module module)
+ {
return new TFeatureBuilder(module);
}
-
- public static TFeatureCollectionBuilder TFeatureCollection(Module module) {
+ public static TFeatureCollectionBuilder TFeatureCollection(Module module)
+ {
return new TFeatureCollectionBuilder(module);
}
}
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/684bb9eb/core/api/src/main/java/org/qi4j/api/geometry/TMultiPoint.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/geometry/TMultiPoint.java b/core/api/src/main/java/org/qi4j/api/geometry/TMultiPoint.java
index 2a85011..00e0a6f 100644
--- a/core/api/src/main/java/org/qi4j/api/geometry/TMultiPoint.java
+++ b/core/api/src/main/java/org/qi4j/api/geometry/TMultiPoint.java
@@ -26,42 +26,38 @@ import java.util.List;
@Mixins(TMultiPoint.Mixin.class)
-public interface TMultiPoint extends GeometryCollections {
-
-
+public interface TMultiPoint extends GeometryCollections
+{
TMultiPoint of(TPoint... points);
TMultiPoint of(List<TPoint> points);
-
TMultiPoint yx(double y, double x);
- public abstract class Mixin extends GeometryCollections.Mixin implements TMultiPoint {
-
+ public abstract class Mixin extends GeometryCollections.Mixin implements TMultiPoint
+ {
@This
TMultiPoint self;
-
@Structure
Module module;
- public TMultiPoint of(List<TPoint> points) {
+ public TMultiPoint of(List<TPoint> points)
+ {
of(points.toArray(new TPoint[points.size()]));
return self;
}
-
- public TMultiPoint yx(double y, double x) {
+ public TMultiPoint yx(double y, double x)
+ {
of(module.newValueBuilder(TPoint.class).prototype().x(x).y(y));
return self;
}
-
-
- public TMultiPoint of(TPoint... points) {
+ public TMultiPoint of(TPoint... points)
+ {
self.geometryType().set(TGEOMETRY_TYPE.MULTIPOINT);
init();
List<TGeometry> l = new ArrayList<>();
-
- for (TPoint p : points) {
+ for (TPoint p : points)
+ {
l.add(p);
}
-
if (self.isEmpty())
self.geometries().set(l); // points().set(l);
else
@@ -69,7 +65,5 @@ public interface TMultiPoint extends GeometryCollections {
return self;
}
-
-
}
}
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/684bb9eb/core/api/src/main/java/org/qi4j/api/geometry/TPoint.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/geometry/TPoint.java b/core/api/src/main/java/org/qi4j/api/geometry/TPoint.java
index 80b72d8..e7106ef 100644
--- a/core/api/src/main/java/org/qi4j/api/geometry/TPoint.java
+++ b/core/api/src/main/java/org/qi4j/api/geometry/TPoint.java
@@ -15,7 +15,6 @@
package org.qi4j.api.geometry;
import org.qi4j.api.geometry.internal.Coordinate;
-import org.qi4j.api.geometry.internal.HasNoArea;
import org.qi4j.api.geometry.internal.TGeometry;
import org.qi4j.api.injection.scope.Structure;
import org.qi4j.api.injection.scope.This;
@@ -28,7 +27,7 @@ import java.util.List;
/**
* Lat = Y Lon = X
- *
+ * <p/>
* For type "Point", each element in the coordinates array is a number representing the point coordinate in one
* dimension. There must be at least two elements, and may be more. The order of elements must follow x, y, z order
* (or longitude, latitude, altitude for coordinates in a geographic coordinate reference system). Any number of
@@ -36,36 +35,46 @@ import java.util.List;
* this specification.
*/
@Mixins(TPoint.Mixin.class)
-public interface TPoint extends HasNoArea, TGeometry {
+public interface TPoint extends TGeometry
+{
Property<List<Coordinate>> coordinates();
TPoint of(Coordinate... coordinates);
+
TPoint of(double x, double y, double z);
+
TPoint of();
TPoint x(double x);
+
TPoint y(double y);
+
TPoint z(double z);
double x();
+
double y();
+
double z();
Coordinate getCoordinate();
+
int compareTo(Object o);
- public abstract class Mixin implements TPoint {
+ public abstract class Mixin implements TPoint
+ {
@Structure
Module module;
@This
TPoint self;
- private void init() {
-
- if (self.coordinates().get() == null) {
+ private void init()
+ {
+ if (self.coordinates().get() == null)
+ {
List<Coordinate> c = new ArrayList<Coordinate>();
c.add(module.newValueBuilder(Coordinate.class).prototype().x(0).y(0).z(0));
@@ -75,31 +84,33 @@ public interface TPoint extends HasNoArea, TGeometry {
}
@Override
- public boolean isEmpty() {
+ public boolean isEmpty()
+ {
return (self.coordinates() == null) || (self.coordinates().get() == null) || (self.coordinates().get().isEmpty()) ? true : false;
}
- public TPoint of() {
+ public TPoint of()
+ {
if (isEmpty())
return self.of(0.0d, 0.0d, 0.0d);
else
return self;
}
-
- public TPoint of(double x, double y, double z) {
+ public TPoint of(double x, double y, double z)
+ {
init();
- self.x(x); // JJ TODO use fluent DSL
- self.y(y);
- self.z(z);
+ self.x(x).y(y).z(z);
self.geometryType().set(TGEOMETRY_TYPE.POINT);
return self;
}
- public TPoint of(Coordinate... coordinates) {
+ public TPoint of(Coordinate... coordinates)
+ {
List<Coordinate> c = new ArrayList<Coordinate>();
- for (Coordinate xyzn : coordinates) {
+ for (Coordinate xyzn : coordinates)
+ {
c.add(xyzn);
}
self.coordinates().set(c);
@@ -107,66 +118,68 @@ public interface TPoint extends HasNoArea, TGeometry {
return self;
}
- public TPoint x(double x) {
+ public TPoint x(double x)
+ {
init();
self.coordinates().get().get(0).x(x);
return self;
}
- public double x() {
-
+ public double x()
+ {
return self.coordinates().get().get(0).getOrdinate(Coordinate.X);
}
-
-
- public TPoint y(double y) {
+ public TPoint y(double y)
+ {
init();
self.coordinates().get().get(0).y(y);
-
return self;
}
-
- public double y() {
+ public double y()
+ {
return self.coordinates().get().get(0).getOrdinate(Coordinate.Y);
}
- public double z() {
+ public double z()
+ {
return self.coordinates().get().get(0).getOrdinate(Coordinate.Z);
}
-
-
- public TPoint z(double z) {
+ public TPoint z(double z)
+ {
init();
self.coordinates().get().get(0).z(z);
-
return self;
}
- public TPoint of(List<Double> coordinates) {
-
+ public TPoint of(List<Double> coordinates)
+ {
List<Coordinate> c = new ArrayList<Coordinate>();
-
- for (Double xyzn : coordinates) {
+ for (Double xyzn : coordinates)
+ {
c.add(module.newValueBuilder(Coordinate.class).prototype().of(xyzn));
}
return null;
}
@Override
- public Coordinate[] getCoordinates() {
+ public Coordinate[] getCoordinates()
+ {
List<Coordinate> coordinates = new ArrayList<>();
coordinates.add(getCoordinate());
return coordinates.toArray(new Coordinate[coordinates.size()]);
}
- public Coordinate getCoordinate() {
+ public Coordinate getCoordinate()
+ {
return self.coordinates().get().size() != 0 ? self.coordinates().get().get(0) : null;
}
- public int getNumPoints() {
+ public int getNumPoints()
+ {
return isEmpty() ? 0 : 1;
}
- public int compareTo(Object other) {
+ public int compareTo(Object other)
+ {
TPoint point = (TPoint) other;
return getCoordinate().compareTo(point.getCoordinate());
}
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/684bb9eb/core/api/src/main/java/org/qi4j/api/geometry/TPolygon.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/geometry/TPolygon.java b/core/api/src/main/java/org/qi4j/api/geometry/TPolygon.java
index 26a900b..7c2b627 100644
--- a/core/api/src/main/java/org/qi4j/api/geometry/TPolygon.java
+++ b/core/api/src/main/java/org/qi4j/api/geometry/TPolygon.java
@@ -16,9 +16,9 @@ package org.qi4j.api.geometry;
import org.qi4j.api.common.Optional;
import org.qi4j.api.geometry.internal.Coordinate;
-import org.qi4j.api.geometry.internal.TShape;
import org.qi4j.api.geometry.internal.TGeometry;
import org.qi4j.api.geometry.internal.TLinearRing;
+import org.qi4j.api.geometry.internal.TShape;
import org.qi4j.api.injection.scope.Structure;
import org.qi4j.api.injection.scope.This;
import org.qi4j.api.mixin.Mixins;
@@ -29,7 +29,8 @@ import java.util.ArrayList;
import java.util.List;
@Mixins(TPolygon.Mixin.class)
-public interface TPolygon extends TShape, TGeometry {
+public interface TPolygon extends TShape, TGeometry
+{
Property<TLinearRing> shell();
@@ -38,52 +39,54 @@ public interface TPolygon extends TShape, TGeometry {
TPolygon of(TLinearRing shell);
TPolygon of(TLinearRing shell, @Optional TLinearRing... holes);
-
TPolygon withHole(TLinearRing hole);
TPolygon withHoles(@Optional TLinearRing... holes);
-
boolean isEmpty();
- public abstract class Mixin implements TPolygon {
+ public abstract class Mixin implements TPolygon
+ {
@Structure
Module module;
@This
TPolygon self;
- private void init() {
-
- if (self.holes().get() == null) {
-
+ private void init()
+ {
+ if (self.holes().get() == null)
+ {
List<TLinearRing> ring = new ArrayList<>();
self.holes().set(ring);
self.geometryType().set(TGEOMETRY_TYPE.POINT);
}
}
- public TPolygon of(TLinearRing shell) {
+ public TPolygon of(TLinearRing shell)
+ {
return of(shell, null);
}
- public TPolygon of(TLinearRing shell, TLinearRing... holes) {
+ public TPolygon of(TLinearRing shell, TLinearRing... holes)
+ {
init();
-
- if (shell != null) {
+ if (shell != null)
+ {
self.shell().set(shell);
}
-
withHoles(holes);
self.geometryType().set(TGEOMETRY_TYPE.POLYGON);
return self;
}
- public TPolygon withHole(TLinearRing hole) {
+ public TPolygon withHole(TLinearRing hole)
+ {
if (hole != null) self.holes().get().add(hole);
return self;
}
-
- public TPolygon withHoles(TLinearRing... holes) {
- if (holes != null && holes.length != 0) {
+ public TPolygon withHoles(TLinearRing... holes)
+ {
+ if (holes != null && holes.length != 0)
+ {
for (TLinearRing hole : holes)
withHole(hole);
}
@@ -91,22 +94,25 @@ public interface TPolygon extends TShape, TGeometry {
}
@Override
- public Coordinate[] getCoordinates() {
- if (isEmpty()) {
+ public Coordinate[] getCoordinates()
+ {
+ if (isEmpty())
+ {
return new Coordinate[]{};
}
-
Coordinate[] coordinates = new Coordinate[getNumPoints()];
-
int k = -1;
Coordinate[] shellCoordinates = self.shell().get().getCoordinates();
- for (int x = 0; x < shellCoordinates.length; x++) {
+ for (int x = 0; x < shellCoordinates.length; x++)
+ {
k++;
coordinates[k] = shellCoordinates[x];
}
- for (int i = 0; i < self.holes().get().size(); i++) {
+ for (int i = 0; i < self.holes().get().size(); i++)
+ {
Coordinate[] childCoordinates = self.holes().get().get(i).getCoordinates();
- for (int j = 0; j < childCoordinates.length; j++) {
+ for (int j = 0; j < childCoordinates.length; j++)
+ {
k++;
coordinates[k] = childCoordinates[j];
}
@@ -114,18 +120,20 @@ public interface TPolygon extends TShape, TGeometry {
return coordinates;
}
- public boolean isEmpty() {
+ public boolean isEmpty()
+ {
return (self.shell() == null) || (self.shell().get() == null) || (self.shell().get().isEmpty()) ? true : false;
}
- public int getNumPoints() {
+ public int getNumPoints()
+ {
int numPoints = self.shell().get().getNumPoints();
- for (int i = 0; i < self.holes().get().size(); i++) {
+ for (int i = 0; i < self.holes().get().size(); i++)
+ {
numPoints += self.holes().get().get(i).getNumPoints();
}
return numPoints;
}
-
}
}
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/684bb9eb/core/api/src/main/java/org/qi4j/api/geometry/TUnit.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/geometry/TUnit.java b/core/api/src/main/java/org/qi4j/api/geometry/TUnit.java
index 7de5a49..308fd9b 100644
--- a/core/api/src/main/java/org/qi4j/api/geometry/TUnit.java
+++ b/core/api/src/main/java/org/qi4j/api/geometry/TUnit.java
@@ -14,10 +14,8 @@
package org.qi4j.api.geometry;
-/**
- * Created by jj on 02.12.14.
- */
-public enum TUnit {
+public enum TUnit
+{
RADIAN,
DEGREE,
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/684bb9eb/core/api/src/main/java/org/qi4j/api/geometry/internal/Coordinate.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/geometry/internal/Coordinate.java b/core/api/src/main/java/org/qi4j/api/geometry/internal/Coordinate.java
index ac01539..e49e96e 100644
--- a/core/api/src/main/java/org/qi4j/api/geometry/internal/Coordinate.java
+++ b/core/api/src/main/java/org/qi4j/api/geometry/internal/Coordinate.java
@@ -28,7 +28,8 @@ import java.util.List;
*/
@Mixins(Coordinate.Mixin.class)
-public interface Coordinate extends Comparable, ValueComposite, TGeometryRoot {
+public interface Coordinate extends Comparable, ValueComposite
+{
public static final int X = 0;
public static final int Y = 1;
@@ -42,7 +43,6 @@ public interface Coordinate extends Comparable, ValueComposite, TGeometryRoot {
Coordinate of(double x, double y, double z);
Coordinate of(double... coordinates);
-
Coordinate x(double x);
Coordinate y(double y);
Coordinate z(double z);
@@ -52,20 +52,20 @@ public interface Coordinate extends Comparable, ValueComposite, TGeometryRoot {
double z();
double getOrdinate(int ordinateIndex);
-
int compareTo(Object o);
-
double[] source();
-
- public abstract class Mixin implements Coordinate {
+ public abstract class Mixin implements Coordinate
+ {
List<Double> EMPTY = new ArrayList<>(X + Y + Z);
@This
Coordinate self;
- private void init() {
- if (isEmpty()) {
+ private void init()
+ {
+ if (isEmpty())
+ {
EMPTY.add(new Double(0.0));
EMPTY.add(new Double(0.0));
EMPTY.add(new Double(0.0));
@@ -74,15 +74,18 @@ public interface Coordinate extends Comparable, ValueComposite, TGeometryRoot {
}
}
- private boolean isEmpty() {
+ private boolean isEmpty()
+ {
return (self.coordinate() == null) || (self.coordinate().get() == null) || (self.coordinate().get().isEmpty()) ? true : false;
}
- public Coordinate of() {
+ public Coordinate of()
+ {
return self.of(0.0d, 0.0d, 0.0d);
}
- public Coordinate of(double x, double y, double z) {
+ public Coordinate of(double x, double y, double z)
+ {
init();
self.x(x);
self.y(y);
@@ -91,50 +94,52 @@ public interface Coordinate extends Comparable, ValueComposite, TGeometryRoot {
}
- public double x() {
+ public double x()
+ {
return getOrdinate(X);
}
-
- public double y() {
+ public double y()
+ {
return getOrdinate(Y);
}
-
- public double z() {
+ public double z()
+ {
return getOrdinate(Z);
}
- public Coordinate x(double x) {
+ public Coordinate x(double x)
+ {
init();
-
- if (!Double.isNaN(x) && !Double.isInfinite(x)) {
+ if (!Double.isNaN(x) && !Double.isInfinite(x))
+ {
self.coordinate().get().set(X, x);
}
return self;
}
- public Coordinate y(double y) {
-
+ public Coordinate y(double y)
+ {
init();
-
- if (!Double.isNaN(y) && !Double.isInfinite(y)) {
+ if (!Double.isNaN(y) && !Double.isInfinite(y))
+ {
self.coordinate().get().set(Y, y);
}
return self;
}
- public Coordinate z(double z) {
-
+ public Coordinate z(double z)
+ {
init();
-
- if (!Double.isNaN(z) && !Double.isInfinite(z)) {
+ if (!Double.isNaN(z) && !Double.isInfinite(z))
+ {
self.coordinate().get().set(Z, z);
}
return self;
}
- public int compareTo(Object o) {
+ public int compareTo(Object o)
+ {
Coordinate other = (Coordinate) o;
-
if (self.coordinate().get().get(X) < other.coordinate().get().get(X)) return -1;
if (self.coordinate().get().get(X) > other.coordinate().get().get(X)) return 1;
if (self.coordinate().get().get(Y) < other.coordinate().get().get(Y)) return -1;
@@ -142,8 +147,10 @@ public interface Coordinate extends Comparable, ValueComposite, TGeometryRoot {
return 0;
}
- public double getOrdinate(int ordinateIndex) {
- switch (ordinateIndex) {
+ public double getOrdinate(int ordinateIndex)
+ {
+ switch (ordinateIndex)
+ {
case X:
return self.coordinate().get().get(X);
case Y:
@@ -154,28 +161,26 @@ public interface Coordinate extends Comparable, ValueComposite, TGeometryRoot {
throw new IllegalArgumentException("Invalid ordinate index: " + ordinateIndex);
}
- public double[] source() {
+ public double[] source()
+ {
double[] source = new double[X + Y + Z];
source[X] = getOrdinate(X);
source[Y] = getOrdinate(Y);
source[Z] = getOrdinate(Z);
-
return source;
}
- public Coordinate of(double... coordinates) {
-
+ public Coordinate of(double... coordinates)
+ {
List<Double> l = new ArrayList<Double>(coordinates.length);
-
- for (double xyzn : coordinates) {
+ for (double xyzn : coordinates)
+ {
// only values that makes "sense"
if (!Double.isNaN(xyzn) && !Double.isInfinite(xyzn))
l.add(new Double(xyzn));
}
-
self.coordinate().set(l);
-
return self;
}
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/684bb9eb/core/api/src/main/java/org/qi4j/api/geometry/internal/TLinearRing.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/geometry/internal/TLinearRing.java b/core/api/src/main/java/org/qi4j/api/geometry/internal/TLinearRing.java
index 87fc414..2b99f9a 100644
--- a/core/api/src/main/java/org/qi4j/api/geometry/internal/TLinearRing.java
+++ b/core/api/src/main/java/org/qi4j/api/geometry/internal/TLinearRing.java
@@ -19,7 +19,8 @@ import org.qi4j.api.injection.scope.This;
import org.qi4j.api.mixin.Mixins;
@Mixins(TLinearRing.Mixin.class)
-public interface TLinearRing extends TLineString {
+public interface TLinearRing extends TLineString
+{
boolean isValid();
@@ -29,7 +30,8 @@ public interface TLinearRing extends TLineString {
TLinearRing self;
@Override
- public boolean isValid() {
+ public boolean isValid()
+ {
if (self.getStartPoint() == null || self.getEndPoint() == null) return false;
return self.getStartPoint().compareTo(self.getEndPoint()) == 0 ? true : false;
}
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/684bb9eb/core/api/src/main/java/org/qi4j/api/geometry/internal/builders/TFeatureBuilder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/geometry/internal/builders/TFeatureBuilder.java b/core/api/src/main/java/org/qi4j/api/geometry/internal/builders/TFeatureBuilder.java
index 58932e2..7cce0bd 100644
--- a/core/api/src/main/java/org/qi4j/api/geometry/internal/builders/TFeatureBuilder.java
+++ b/core/api/src/main/java/org/qi4j/api/geometry/internal/builders/TFeatureBuilder.java
@@ -18,22 +18,23 @@ import org.qi4j.api.geometry.TFeature;
import org.qi4j.api.geometry.internal.TGeometry;
import org.qi4j.api.structure.Module;
-/**
- * Created by jj on 26.11.14.
- */
-public class TFeatureBuilder {
+
+public class TFeatureBuilder
+{
private Module module;
private TFeature geometry;
- public TFeatureBuilder(Module module) {
+ public TFeatureBuilder(Module module)
+ {
this.module = module;
geometry = module.newValueBuilder(TFeature.class).prototype();
}
- public TFeatureBuilder of(TGeometry feature) {
+ public TFeatureBuilder of(TGeometry feature)
+ {
geometry.of(feature);
return this;
}
@@ -44,10 +45,13 @@ public class TFeatureBuilder {
return this;
}
- public TFeature geometry() {
+ public TFeature geometry()
+ {
return geometry;
}
- public TFeature geometry(int srid) {
+
+ public TFeature geometry(int srid)
+ {
return geometry();
}
}
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/684bb9eb/core/api/src/main/java/org/qi4j/api/geometry/internal/builders/TLineStringBuilder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/geometry/internal/builders/TLineStringBuilder.java b/core/api/src/main/java/org/qi4j/api/geometry/internal/builders/TLineStringBuilder.java
index df1bbb8..21b6f6d 100644
--- a/core/api/src/main/java/org/qi4j/api/geometry/internal/builders/TLineStringBuilder.java
+++ b/core/api/src/main/java/org/qi4j/api/geometry/internal/builders/TLineStringBuilder.java
@@ -18,45 +18,51 @@ import org.qi4j.api.geometry.TLineString;
import org.qi4j.api.geometry.TPoint;
import org.qi4j.api.structure.Module;
-/**
- * Created by jj on 26.11.14.
- */
-public class TLineStringBuilder {
+
+public class TLineStringBuilder
+{
private Module module;
private TLineString geometry;
- public TLineStringBuilder(Module module) {
+ public TLineStringBuilder(Module module)
+ {
this.module = module;
geometry = module.newValueBuilder(TLineString.class).prototype();
}
- public TLineStringBuilder points(double[][] points) {
- for (double yx[] : points) {
+ public TLineStringBuilder points(double[][] points)
+ {
+ for (double yx[] : points)
+ {
if (yx.length < 2) return null;
geometry.yx(yx[0], yx[1]);
}
return this;
}
- public TLineStringBuilder of(TPoint... points) {
+ public TLineStringBuilder of(TPoint... points)
+ {
geometry().of(points);
return this;
}
- public TLineStringBuilder of() {
+ public TLineStringBuilder of()
+ {
geometry().of();
return this;
}
- public TLineString geometry() {
+ public TLineString geometry()
+ {
return geometry;
}
- public TLineString geometry(int srid) {
+ public TLineString geometry(int srid)
+ {
return geometry();
}
}
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/684bb9eb/core/api/src/main/java/org/qi4j/api/geometry/internal/builders/TMultiPolygonsBuilder.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/geometry/internal/builders/TMultiPolygonsBuilder.java b/core/api/src/main/java/org/qi4j/api/geometry/internal/builders/TMultiPolygonsBuilder.java
index 342e92e..c57bb16 100644
--- a/core/api/src/main/java/org/qi4j/api/geometry/internal/builders/TMultiPolygonsBuilder.java
+++ b/core/api/src/main/java/org/qi4j/api/geometry/internal/builders/TMultiPolygonsBuilder.java
@@ -20,45 +20,50 @@ import org.qi4j.api.structure.Module;
import java.util.List;
-/**
- * Created by jj on 26.11.14.
- */
-public class TMultiPolygonsBuilder {
+
+public class TMultiPolygonsBuilder
+{
private Module module;
private TMultiPolygon geometry;
- public TMultiPolygonsBuilder(Module module) {
+ public TMultiPolygonsBuilder(Module module)
+ {
this.module = module;
geometry = module.newValueBuilder(TMultiPolygon.class).prototype();
}
- public TMultiPolygonsBuilder points(double[][][] points) {
- for (double xy[][] : points) {
+ public TMultiPolygonsBuilder points(double[][][] points)
+ {
+ for (double xy[][] : points)
+ {
if (xy.length < 2) return null;
- // geometry.xy(xy[0], xy[1]);
}
return this;
}
- public TMultiPolygonsBuilder of(List<TPolygon> polygons) {
+ public TMultiPolygonsBuilder of(List<TPolygon> polygons)
+ {
geometry.of(polygons);
return this;
}
- public TMultiPolygonsBuilder of(TPolygon... polygons) {
+ public TMultiPolygonsBuilder of(TPolygon... polygons)
+ {
geometry.of(polygons);
return this;
}
- public TMultiPolygon geometry() {
+ public TMultiPolygon geometry()
+ {
return geometry;
}
- public TMultiPolygon geometry(int srid) {
+ public TMultiPolygon geometry(int srid)
+ {
return geometry();
}
}
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/684bb9eb/core/api/src/main/java/org/qi4j/api/query/grammar/extensions/spatial/convert/ST_PointFromTextSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/extensions/spatial/convert/ST_PointFromTextSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/extensions/spatial/convert/ST_PointFromTextSpecification.java
deleted file mode 100644
index 4498f40..0000000
--- a/core/api/src/main/java/org/qi4j/api/query/grammar/extensions/spatial/convert/ST_PointFromTextSpecification.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package org.qi4j.api.query.grammar.extensions.spatial.convert;
-
-import com.spatial4j.core.context.SpatialContext;
-import com.spatial4j.core.context.jts.JtsSpatialContextFactory;
-import com.spatial4j.core.io.jts.JtsWKTReaderShapeParser;
-import com.spatial4j.core.io.jts.JtsWktShapeParser;
-import com.spatial4j.core.shape.Point;
-import com.spatial4j.core.shape.Shape;
-import org.qi4j.api.geometry.internal.TGeometry;
-import org.qi4j.api.injection.scope.Structure;
-import org.qi4j.api.structure.Module;
-
-import java.text.ParseException;
-
-/**
- * ST_Within Specification.
- *
- *
- */
-public class ST_PointFromTextSpecification<T extends TGeometry>
- extends SpatialConvertSpecification<T>
-{
-
-
-
-
- public ST_PointFromTextSpecification(String wkt, String crs)
- {
- super( wkt, crs );
- }
-
- @Structure
- Module module;
-
-
-
-
-
- @Override
- public String toString()
- {
- return "converting"; //property.toString() + " is within " + value.toString();
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/684bb9eb/core/api/src/main/java/org/qi4j/api/query/grammar/extensions/spatial/measurements/ST_WithinSpatialSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/extensions/spatial/measurements/ST_WithinSpatialSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/extensions/spatial/measurements/ST_WithinSpatialSpecification.java
deleted file mode 100644
index b2f5681..0000000
--- a/core/api/src/main/java/org/qi4j/api/query/grammar/extensions/spatial/measurements/ST_WithinSpatialSpecification.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package org.qi4j.api.query.grammar.extensions.spatial.measurements;
-
-import org.qi4j.api.query.grammar.PropertyFunction;
-
-import java.util.Collection;
-
-/**
- * Regular expression match Specification.
- */
-public class ST_WithinSpatialSpecification<T>
- extends SpatialMeasurementsSpecification
-{
-
-
-
- // public ST_WithinSpatialSpecification(Property<T> property, T value, Double range)
- // PropertyFunction<T> property
- public ST_WithinSpatialSpecification(PropertyFunction<T> property, T value, Double range)
- {
- // super( property, value );
- // super(T);
- super (property, value);
- }
-
- private PropertyFunction<? extends Collection<T>> collectionProperty;
- private Iterable<T> valueCollection;
-
-// public WithInSpatialSpecification( PropertyFunction<? extends Collection<T>> collectionProperty,
-// Iterable<T> valueCollection
-// )
-// {
-// this.collectionProperty = collectionProperty;
-// this.valueCollection = valueCollection;
-// }
-
- public PropertyFunction<? extends Collection<T>> collectionProperty()
- {
- return collectionProperty;
- }
-
- public Iterable<T> containedValues()
- {
- return valueCollection;
- }
-
- // @Override
- public boolean satisfiedBy( Object item )
- {
- return true;
- }
-
-// @Override
-// public boolean satisfiedBy( Composite item )
-// {
-// Collection<T> collection = collectionProperty.map( item ).get();
-//
-// if( collection == null )
-// {
-// return false;
-// }
-//
-// for( T value : valueCollection )
-// {
-// if( !collection.contains( value ) )
-// {
-// return false;
-// }
-// }
-//
-// return true;
-// }
-
- @Override
- public String toString()
- {
- return "WithInSpatialSpecification()"; // collectionProperty + " contains " + Iterables.toList(valueCollection);
- }
-}
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/684bb9eb/core/api/src/main/java/org/qi4j/api/query/grammar/extensions/spatial/predicate/ST_WithinSpecification.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/qi4j/api/query/grammar/extensions/spatial/predicate/ST_WithinSpecification.java b/core/api/src/main/java/org/qi4j/api/query/grammar/extensions/spatial/predicate/ST_WithinSpecification.java
index cd28a85..4483fa6 100644
--- a/core/api/src/main/java/org/qi4j/api/query/grammar/extensions/spatial/predicate/ST_WithinSpecification.java
+++ b/core/api/src/main/java/org/qi4j/api/query/grammar/extensions/spatial/predicate/ST_WithinSpecification.java
@@ -4,13 +4,12 @@ import org.qi4j.api.geometry.TPoint;
import org.qi4j.api.geometry.TUnit;
import org.qi4j.api.geometry.internal.TGeometry;
import org.qi4j.api.query.grammar.PropertyFunction;
-import org.qi4j.api.query.grammar.Variable;
import org.qi4j.api.query.grammar.extensions.spatial.convert.SpatialConvertSpecification;
import org.qi4j.functional.Specification;
public class ST_WithinSpecification<T extends TGeometry>
- extends SpatialPredicatesSpecification<T>
+ extends SpatialPredicatesSpecification<T>
{
private double distance;
@@ -18,37 +17,44 @@ public class ST_WithinSpecification<T extends TGeometry>
public ST_WithinSpecification(PropertyFunction<T> property, TGeometry param)
{
- super( property, param );
+ super(property, param);
}
public ST_WithinSpecification(PropertyFunction<T> property, TPoint param, double distance, TUnit unit)
{
- super( property, param );
- this.distance = distance;
- this.unit = unit;
+ super(property, param);
+ this.distance = distance;
+ this.unit = unit;
}
public ST_WithinSpecification(PropertyFunction<T> property, Specification<SpatialConvertSpecification> operator, double distance, TUnit unit)
{
- super( property, operator );
- this.distance = distance;
- this.unit = unit;
+ super(property, operator);
+ this.distance = distance;
+ this.unit = unit;
}
public ST_WithinSpecification(PropertyFunction<T> property, Specification<SpatialConvertSpecification> operator)
{
- super( property, operator );
+ super(property, operator);
}
- public double getDistance() { return distance; }
- public TUnit getUnit() { return unit; }
+ public double getDistance()
+ {
+ return distance;
+ }
+
+ public TUnit getUnit()
+ {
+ return unit;
+ }
- @Override
- protected boolean compare( TGeometry param )
+ @Override
+ protected boolean compare(TGeometry param)
{
- return param.equals( this.param );
+ return param.equals(this.param);
}
@Override
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/684bb9eb/core/api/src/test/java/org/qi4j/api/geometry/TGeometryTest.java
----------------------------------------------------------------------
diff --git a/core/api/src/test/java/org/qi4j/api/geometry/TGeometryTest.java b/core/api/src/test/java/org/qi4j/api/geometry/TGeometryTest.java
index 2c12c18..99f0493 100644
--- a/core/api/src/test/java/org/qi4j/api/geometry/TGeometryTest.java
+++ b/core/api/src/test/java/org/qi4j/api/geometry/TGeometryTest.java
@@ -26,16 +26,15 @@ import org.qi4j.test.AbstractQi4jTest;
import static org.hamcrest.core.IsEqual.equalTo;
import static org.junit.Assert.*;
-import static org.junit.Assert.assertEquals;
/**
* JAVADOC
*/
public class TGeometryTest
- extends AbstractQi4jTest
+ extends AbstractQi4jTest
{
- public void assemble( ModuleAssembly module )
- throws AssemblyException
+ public void assemble(ModuleAssembly module)
+ throws AssemblyException
{
// internal values
module.values(Coordinate.class, TLinearRing.class, TCircle.class, TGeometry.class);
@@ -58,14 +57,14 @@ public class TGeometryTest
String CRS = "urn:ogc:def:crs:OGC:1.3:CRS84";
ValueBuilder<TCRS> builder = module.newValueBuilder(TCRS.class);
TCRS crs = builder.prototype().of(CRS);
- assertThat(crs.crs(), equalTo( CRS ));
+ assertThat(crs.crs(), equalTo(CRS));
}
- @Test
+ @Test
public void script02()
{
ValueBuilder<Coordinate> builder = module.newValueBuilder(Coordinate.class);
- Coordinate coordinate1 = builder.prototype().of(1d,2d,3d);
+ Coordinate coordinate1 = builder.prototype().of(1d, 2d, 3d);
assertNotNull(coordinate1);
assertEquals(1d, coordinate1.x(), 0.0d);
@@ -86,11 +85,11 @@ public class TGeometryTest
assertEquals(2d, point1.y(), 0.0d);
assertEquals(3d, point1.z(), 0.0d);
- // assertTrue(point1.isEmpty() == false);
+ // assertTrue(point1.isEmpty() == false);
ValueBuilder<TPoint> builder2 = module.newValueBuilder(TPoint.class);
- TPoint point2 = builder2.prototype().of(1d,2d,3d);
+ TPoint point2 = builder2.prototype().of(1d, 2d, 3d);
assertEquals(1d, point2.x(), 0.0d);
assertEquals(2d, point2.y(), 0.0d);
assertEquals(3d, point2.z(), 0.0d);
@@ -105,7 +104,7 @@ public class TGeometryTest
ValueBuilder<TPoint> builder4 = module.newValueBuilder(TPoint.class);
- TPoint point4 = builder4.prototype().x(10d).y(20d).z(30d).of(1d,2d,3d); // check dsl
+ TPoint point4 = builder4.prototype().x(10d).y(20d).z(30d).of(1d, 2d, 3d); // check dsl
assertEquals(1d, point4.x(), 0.0d);
assertEquals(2d, point4.y(), 0.0d);
assertEquals(3d, point4.z(), 0.0d);
@@ -140,7 +139,8 @@ public class TGeometryTest
}
@Test
- public void script05() {
+ public void script05()
+ {
ValueBuilder<TLineString> builder = module.newValueBuilder(TLineString.class);
TLineString lineString = builder.prototype().of()
@@ -155,7 +155,8 @@ public class TGeometryTest
}
@Test
- public void script06() {
+ public void script06()
+ {
ValueBuilder<TMultiLineString> builder = module.newValueBuilder(TMultiLineString.class);
TMultiLineString multiLineString = builder.prototype().of(
@@ -165,19 +166,19 @@ public class TGeometryTest
.yx(0d, 1d)
.yx(1d, 0d)
.yx(1d, 1d)
- .yx(0d, 0d) );
+ .yx(0d, 0d));
assertEquals(5, multiLineString.getNumPoints());
assertTrue(multiLineString.getGeometryN(0).isLineString());
}
- @Test
+ @Test
public void script07()
{
ValueBuilder<TLinearRing> builder = module.newValueBuilder(TLinearRing.class);
- TLinearRing linearRing = (TLinearRing)builder.prototype().of(
+ TLinearRing linearRing = (TLinearRing) builder.prototype().of(
module.newValueBuilder(TPoint.class).prototype().x(0d).y(0d).z(0d),
module.newValueBuilder(TPoint.class).prototype().x(0d).y(1d).z(0d),
module.newValueBuilder(TPoint.class).prototype().x(1d).y(0d).z(0d),
@@ -193,7 +194,7 @@ public class TGeometryTest
{
ValueBuilder<TLinearRing> builder = module.newValueBuilder(TLinearRing.class);
- TLinearRing linearRing = (TLinearRing)builder.prototype().of(
+ TLinearRing linearRing = (TLinearRing) builder.prototype().of(
module.newValueBuilder(TPoint.class).prototype().x(0d).y(0d).z(0d),
module.newValueBuilder(TPoint.class).prototype().x(0d).y(1d).z(0d),
module.newValueBuilder(TPoint.class).prototype().x(1d).y(0d).z(0d),
@@ -209,7 +210,7 @@ public class TGeometryTest
{
ValueBuilder<TLinearRing> builder = module.newValueBuilder(TLinearRing.class);
- TLinearRing shell = (TLinearRing)builder.prototype().of()
+ TLinearRing shell = (TLinearRing) builder.prototype().of()
.yx(0d, 0d)
.yx(0d, 1d)
@@ -228,15 +229,15 @@ public class TGeometryTest
{
ValueBuilder<TPolygon> builder = module.newValueBuilder(TPolygon.class);
/**
- builder.prototype().of(
- module.newValueBuilder((TLinearRing.class).prototype().of()
- .xy(0d, 0d)
- .xy(0d, 10d)
- .xy(10d, 0d)
- .xy(1d, 10d)
- .xy(0d, 0d)
- );
-*/
+ builder.prototype().of(
+ module.newValueBuilder((TLinearRing.class).prototype().of()
+ .xy(0d, 0d)
+ .xy(0d, 10d)
+ .xy(10d, 0d)
+ .xy(1d, 10d)
+ .xy(0d, 0d)
+ );
+ */
//builder.prototype().of(
// module.newValueBuilder(TLinearRing.class).prototype().
}
@@ -247,21 +248,21 @@ public class TGeometryTest
{
ValueBuilder<TLineString> builder = module.newValueBuilder(TLineString.class);
assertNotNull(
- builder.prototype().of
- (
- module.newValueBuilder(TPoint.class).prototype().of
- (
- module.newValueBuilder(Coordinate.class).prototype().of(1d), //x
- module.newValueBuilder(Coordinate.class).prototype().of(1d) //y
- )
- ,
- module.newValueBuilder(TPoint.class).prototype().of
- (
- module.newValueBuilder(Coordinate.class).prototype().of(2d), //x
- module.newValueBuilder(Coordinate.class).prototype().of(2d) //y
- )
-
- )
+ builder.prototype().of
+ (
+ module.newValueBuilder(TPoint.class).prototype().of
+ (
+ module.newValueBuilder(Coordinate.class).prototype().of(1d), //x
+ module.newValueBuilder(Coordinate.class).prototype().of(1d) //y
+ )
+ ,
+ module.newValueBuilder(TPoint.class).prototype().of
+ (
+ module.newValueBuilder(Coordinate.class).prototype().of(2d), //x
+ module.newValueBuilder(Coordinate.class).prototype().of(2d) //y
+ )
+
+ )
);
}
@@ -271,21 +272,21 @@ public class TGeometryTest
{
ValueBuilder<TLinearRing> builder = module.newValueBuilder(TLinearRing.class);
assertNotNull(
- builder.prototype().of
- (
- module.newValueBuilder(TPoint.class).prototype().of
- (
- module.newValueBuilder(Coordinate.class).prototype().of(1d), //x
- module.newValueBuilder(Coordinate.class).prototype().of(1d) //y
- )
- ,
- module.newValueBuilder(TPoint.class).prototype().of
- (
- module.newValueBuilder(Coordinate.class).prototype().of(2d), //x
- module.newValueBuilder(Coordinate.class).prototype().of(2d) //y
- )
-
- )
+ builder.prototype().of
+ (
+ module.newValueBuilder(TPoint.class).prototype().of
+ (
+ module.newValueBuilder(Coordinate.class).prototype().of(1d), //x
+ module.newValueBuilder(Coordinate.class).prototype().of(1d) //y
+ )
+ ,
+ module.newValueBuilder(TPoint.class).prototype().of
+ (
+ module.newValueBuilder(Coordinate.class).prototype().of(2d), //x
+ module.newValueBuilder(Coordinate.class).prototype().of(2d) //y
+ )
+
+ )
);
}
@@ -295,46 +296,46 @@ public class TGeometryTest
{
ValueBuilder<TPolygon> builder = module.newValueBuilder(TPolygon.class);
assertNotNull(
- builder.prototype().of
- (
- // shell
- (TLinearRing)module.newValueBuilder(TLinearRing.class).prototype().of
- (
- module.newValueBuilder(TPoint.class).prototype().of
- (
- module.newValueBuilder(Coordinate.class).prototype().of(1d), //x
- module.newValueBuilder(Coordinate.class).prototype().of(1d) //y
- )
- ,
- module.newValueBuilder(TPoint.class).prototype().of
- (
- module.newValueBuilder(Coordinate.class).prototype().of(1d), //x
- module.newValueBuilder(Coordinate.class).prototype().of(2d) //y
- )
- ,
- module.newValueBuilder(TPoint.class).prototype().of
- (
- module.newValueBuilder(Coordinate.class).prototype().of(2d), //x
- module.newValueBuilder(Coordinate.class).prototype().of(2d) //y
- )
- ,
- module.newValueBuilder(TPoint.class).prototype().of
- (
- module.newValueBuilder(Coordinate.class).prototype().of(2d), //x
- module.newValueBuilder(Coordinate.class).prototype().of(1d) //y
- )
- ,
- module.newValueBuilder(TPoint.class).prototype().of
- (
- module.newValueBuilder(Coordinate.class).prototype().of(1d), //x
- module.newValueBuilder(Coordinate.class).prototype().of(1d) //y
- )
-
- )
- ,
- // no holes
- null
- )
+ builder.prototype().of
+ (
+ // shell
+ (TLinearRing) module.newValueBuilder(TLinearRing.class).prototype().of
+ (
+ module.newValueBuilder(TPoint.class).prototype().of
+ (
+ module.newValueBuilder(Coordinate.class).prototype().of(1d), //x
+ module.newValueBuilder(Coordinate.class).prototype().of(1d) //y
+ )
+ ,
+ module.newValueBuilder(TPoint.class).prototype().of
+ (
+ module.newValueBuilder(Coordinate.class).prototype().of(1d), //x
+ module.newValueBuilder(Coordinate.class).prototype().of(2d) //y
+ )
+ ,
+ module.newValueBuilder(TPoint.class).prototype().of
+ (
+ module.newValueBuilder(Coordinate.class).prototype().of(2d), //x
+ module.newValueBuilder(Coordinate.class).prototype().of(2d) //y
+ )
+ ,
+ module.newValueBuilder(TPoint.class).prototype().of
+ (
+ module.newValueBuilder(Coordinate.class).prototype().of(2d), //x
+ module.newValueBuilder(Coordinate.class).prototype().of(1d) //y
+ )
+ ,
+ module.newValueBuilder(TPoint.class).prototype().of
+ (
+ module.newValueBuilder(Coordinate.class).prototype().of(1d), //x
+ module.newValueBuilder(Coordinate.class).prototype().of(1d) //y
+ )
+
+ )
+ ,
+ // no holes
+ null
+ )
);
}
@@ -353,7 +354,7 @@ public class TGeometryTest
TCircle tCircle = builder.prototype().of(48.13905780942574, 11.57958984375, 100);
TPolygon tPolygon = tCircle.polygonize(360);
assertTrue(tPolygon.shell().get().isValid());
- assertTrue(tPolygon.shell().get().getNumPoints() == (360 + 1) );
+ assertTrue(tPolygon.shell().get().getNumPoints() == (360 + 1));
}
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/684bb9eb/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/ElasticSearchSpatialFinder.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/ElasticSearchSpatialFinder.java b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/ElasticSearchSpatialFinder.java
index 29c38c4..fe42a47 100644
--- a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/ElasticSearchSpatialFinder.java
+++ b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/ElasticSearchSpatialFinder.java
@@ -1,4 +1,3 @@
-
/*
* Copyright 2014 Jiri Jetmar.
*
@@ -48,36 +47,43 @@ import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Map;
-public final class ElasticSearchSpatialFinder {
+public final class ElasticSearchSpatialFinder
+{
private static final Logger LOGGER = LoggerFactory.getLogger(ElasticSearchSpatialFinder.class);
private static final Map<Class<?>, SpatialQuerySpecSupport> SPATIAL_QUERY_EXPRESSIONS_CATALOG = new HashMap<>(2);
- static {
+ static
+ {
SPATIAL_QUERY_EXPRESSIONS_CATALOG.put(SpatialPredicatesSpecification.class, new PredicateFinderSupport());
SPATIAL_QUERY_EXPRESSIONS_CATALOG.put(SpatialConvertSpecification.class, new ConvertFinderSupport());
}
- private ElasticSearchSpatialFinder() {
+ private ElasticSearchSpatialFinder()
+ {
}
- public interface Support {
+ public interface Support
+ {
SpatialQuerySpecSupport support(Module module, ElasticSearchSupport support);
}
- public static interface SpatialQuerySpecSupport extends Support {
+ public static interface SpatialQuerySpecSupport extends Support
+ {
void processSpecification(FilterBuilder filterBuilder, Specification<?> spec, Map<String, Object> variables) throws EntityFinderException;
}
public static class SpatialSpecSupport
- implements SpatialQuerySpecSupport {
+ implements SpatialQuerySpecSupport
+ {
private Module module;
private ElasticSearchSupport support;
- public SpatialQuerySpecSupport support(Module module, ElasticSearchSupport support) {
+ public SpatialQuerySpecSupport support(Module module, ElasticSearchSupport support)
+ {
this.module = module;
this.support = support;
return this;
@@ -87,19 +93,22 @@ public final class ElasticSearchSpatialFinder {
public void processSpecification(FilterBuilder filterBuilder,
Specification<?> spec,
Map<String, Object> variables)
- throws EntityFinderException {
+ throws EntityFinderException
+ {
SPATIAL_QUERY_EXPRESSIONS_CATALOG.get(spec.getClass().getSuperclass()).support(module, support).processSpecification(filterBuilder, spec, variables);
}
}
public static class SpatialTypeSupport
- implements ElasticSearchFinderSupport.ComplexTypeSupport {
+ implements ElasticSearchFinderSupport.ComplexTypeSupport
+ {
private Module module;
private ElasticSearchSupport support;
- public ElasticSearchFinderSupport.ComplexTypeSupport support(Module module, ElasticSearchSupport support) {
+ public ElasticSearchFinderSupport.ComplexTypeSupport support(Module module, ElasticSearchSupport support)
+ {
this.module = module;
this.support = support;
@@ -107,24 +116,30 @@ public final class ElasticSearchSpatialFinder {
}
- public FilterBuilder comparison(ComparisonSpecification<?> spec, Map<String, Object> variables) {
+ public FilterBuilder comparison(ComparisonSpecification<?> spec, Map<String, Object> variables)
+ {
throw new RuntimeException("Unsupported operation");
}
- public FilterBuilder contains(ContainsSpecification<?> spec, Map<String, Object> variables) {
+ public FilterBuilder contains(ContainsSpecification<?> spec, Map<String, Object> variables)
+ {
throw new RuntimeException("Unsupported operation");
}
- public FilterBuilder containsAll(ContainsAllSpecification<?> spec, Map<String, Object> variables) {
+ public FilterBuilder containsAll(ContainsAllSpecification<?> spec, Map<String, Object> variables)
+ {
throw new RuntimeException("Unsupported operation");
}
- public void orderBy(SearchRequestBuilder request, Specification<Composite> whereClause, OrderBy orderBySegment, Map<String, Object> variables) throws EntityFinderException {
- if (!TPoint.class.isAssignableFrom(InternalUtils.classOfPropertyType(orderBySegment.property()))) {
+ public void orderBy(SearchRequestBuilder request, Specification<Composite> whereClause, OrderBy orderBySegment, Map<String, Object> variables) throws EntityFinderException
+ {
+ if (!TPoint.class.isAssignableFrom(InternalUtils.classOfPropertyType(orderBySegment.property())))
+ {
throw new EntityFinderException("Ordering can only be done on TPoints.. TODO");
}
- if (!SpatialIndexMapper.IndexMappingCache.isMappedAsGeoPoint(support.index(), support.entitiesType(), orderBySegment.property().toString())) {
+ if (!SpatialIndexMapper.IndexMappingCache.isMappedAsGeoPoint(support.index(), support.entitiesType(), orderBySegment.property().toString()))
+ {
throw new EntityFinderException("OrderBy is only supported when GEO_POINT indexing is used");
}
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/684bb9eb/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/ElasticSearchSpatialIndexer.java
----------------------------------------------------------------------
diff --git a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/ElasticSearchSpatialIndexer.java b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/ElasticSearchSpatialIndexer.java
index 7fd7a2a..c51f31d 100644
--- a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/ElasticSearchSpatialIndexer.java
+++ b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/ElasticSearchSpatialIndexer.java
@@ -28,7 +28,7 @@ import org.qi4j.index.elasticsearch.ElasticSearchIndexException;
import org.qi4j.index.elasticsearch.ElasticSearchSupport;
import org.qi4j.index.elasticsearch.extensions.spatial.configuration.SpatialConfiguration;
import org.qi4j.index.elasticsearch.extensions.spatial.mappings.SpatialIndexMapper;
-import org.qi4j.library.spatial.projection.ProjectionsRegistry;
+import org.qi4j.library.spatial.projections.ProjectionsRegistry;
import java.util.HashMap;
import java.util.ListIterator;
@@ -36,23 +36,27 @@ import java.util.Map;
import java.util.Stack;
import static org.qi4j.index.elasticsearch.extensions.spatial.mappings.SpatialIndexMapper.IndexMappingCache;
-import static org.qi4j.library.spatial.projection.transformations.TTransformations.Transform;
+import static org.qi4j.library.spatial.projections.transformations.TTransformations.Transform;
-public final class ElasticSearchSpatialIndexer {
+public final class ElasticSearchSpatialIndexer
+{
private static final String EPSG_4326 = "EPSG:4326";
private static final String DefaultSupportedProjection = EPSG_4326;
private static final double DefaultProjectionConversionPrecisionInMeters = 2.00;
private Module module;
- private ElasticSearchSpatialIndexer() {
+ private ElasticSearchSpatialIndexer()
+ {
}
- public static void toJSON(ElasticSearchSupport support, TGeometry geometry, String property, String deepProperty, JSONObject json, Module module) throws ElasticSearchIndexException {
+ public static void toJSON(ElasticSearchSupport support, TGeometry geometry, String property, String deepProperty, JSONObject json, Module module) throws ElasticSearchIndexException
+ {
// Spatial Mappings
{
- if (SpatialConfiguration.isEnabled(support.spatialConfiguration())) {
+ if (SpatialConfiguration.isEnabled(support.spatialConfiguration()))
+ {
SpatialIndexMapper.createIfNotExist(support, geometry, deepProperty);
} else throw new ElasticSearchIndexException("Spatial support is disabled. No spatial indexing available");
}
@@ -61,50 +65,65 @@ public final class ElasticSearchSpatialIndexer {
{
if (new ProjectionsRegistry().getCRS(geometry.getCRS()) == null)
throw new ElasticSearchIndexException("Project with the CRS Identity " + geometry.getCRS() + " is unknown. Supported projections are JJ TODO");
- if (SpatialConfiguration.isIndexerProjectionConversionEnabled(support.spatialConfiguration())) {
+ if (SpatialConfiguration.isIndexerProjectionConversionEnabled(support.spatialConfiguration()))
+ {
Transform(module).from(geometry).to(DefaultSupportedProjection, SpatialConfiguration.getIndexerProjectionConversionAccuracy(support.spatialConfiguration()));
} else if (!geometry.getCRS().equalsIgnoreCase(DefaultSupportedProjection))
throw new ElasticSearchIndexException("Project with the CRS Identity " + geometry.getCRS() + " is not supported by ElasticSearch and projection conversion is " +
"disabled in the configuration.");
}
- try {
+ try
+ {
- if (geometry.isPoint()) {
- if (IndexMappingCache.isMappedAsGeoPoint(support.index(), support.entitiesType(), deepProperty)) {
+ if (geometry.isPoint())
+ {
+ if (IndexMappingCache.isMappedAsGeoPoint(support.index(), support.entitiesType(), deepProperty))
+ {
createIndexPointAsGeoPointType(property, json, (TPoint) geometry);
- } else if (IndexMappingCache.isMappedAsGeoShape(support.index(), support.entitiesType(), deepProperty)) {
+ } else if (IndexMappingCache.isMappedAsGeoShape(support.index(), support.entitiesType(), deepProperty))
+ {
createIndexPointAsGeoShapeType(property, json, (TPoint) geometry);
} else
new ElasticSearchIndexException("No spatial mapping for property " + deepProperty + " available.");
- } else if (geometry.isMultiPoint()) {
+ } else if (geometry.isMultiPoint())
+ {
createIndexMultiPoint(property, json, (TMultiPoint) geometry);
- } else if (geometry.isLineString()) {
+ } else if (geometry.isLineString())
+ {
createIndexLineString(property, json, (TLineString) geometry);
- } else if (geometry.isMultiLineString()) {
+ } else if (geometry.isMultiLineString())
+ {
createIndexMultiLineString(property, json, (TMultiLineString) geometry);
- } else if (geometry.isPolygon()) {
+ } else if (geometry.isPolygon())
+ {
createIndexPolygon(property, json, (TPolygon) geometry);
- } else if (geometry.isMultiPolygon()) {
+ } else if (geometry.isMultiPolygon())
+ {
createIndexMultiPolygon(property, json, (TMultiPolygon) geometry);
- } else if (geometry.isFeature()) {
+ } else if (geometry.isFeature())
+ {
createIndexFeature(property, json, (TFeature) geometry);
- } else if (geometry.isFeatureCollection()) {
+ } else if (geometry.isFeatureCollection())
+ {
createIndexFeatureCollection(property, json, (TFeatureCollection) geometry);
} else new ElasticSearchIndexException("Unsupported Geometry : " + geometry.getClass());
- } catch (JSONException _ex) {
+ } catch (JSONException _ex)
+ {
throw new ElasticSearchIndexException("", _ex);
}
}
- private static void createIndexMultiPoint(String property, JSONObject json, TMultiPoint tMultiPoint) throws JSONException {
+ private static void createIndexMultiPoint(String property, JSONObject json, TMultiPoint tMultiPoint) throws JSONException
+ {
Map tMultiPointMap = new HashMap();
tMultiPointMap.put("type", "multipoint");
JSONArray points = new JSONArray();
- for (int i = 0; i < tMultiPoint.getNumPoints(); i++) {
+ for (int i = 0; i < tMultiPoint.getNumPoints(); i++)
+ {
TPoint point = (TPoint) tMultiPoint.getGeometryN(i);
points.put(new JSONArray().put(point.y()).put(point.x()));
}
@@ -114,12 +133,14 @@ public final class ElasticSearchSpatialIndexer {
}
- private static void createIndexLineString(String property, JSONObject json, TLineString tLineString) throws JSONException {
+ private static void createIndexLineString(String property, JSONObject json, TLineString tLineString) throws JSONException
+ {
Map tLineStringMap = new HashMap();
tLineStringMap.put("type", "linestring");
JSONArray points = new JSONArray();
- for (int i = 0; i < tLineString.getNumPoints(); i++) {
+ for (int i = 0; i < tLineString.getNumPoints(); i++)
+ {
TPoint point = (TPoint) tLineString.getPointN(i);
points.put(new JSONArray().put(point.y()).put(point.x()));
}
@@ -160,7 +181,8 @@ public final class ElasticSearchSpatialIndexer {
* @param tPoint
* @throws Exception
*/
- private static void createIndexPointAsGeoPointType(String property, JSONObject json, TPoint tPoint) throws JSONException {
+ private static void createIndexPointAsGeoPointType(String property, JSONObject json, TPoint tPoint) throws JSONException
+ {
Map tPointMap = new HashMap();
tPointMap.put("lat", tPoint.y());
tPointMap.put("lon", tPoint.x());
@@ -168,7 +190,8 @@ public final class ElasticSearchSpatialIndexer {
json.put(property, tPointMap);
}
- private static void createIndexPointAsGeoShapeType(String property, JSONObject json, TPoint tPoint) throws JSONException {
+ private static void createIndexPointAsGeoShapeType(String property, JSONObject json, TPoint tPoint) throws JSONException
+ {
Map tPointMap = new HashMap();
tPointMap.put("type", "point");
tPointMap.put("coordinates", new JSONArray().put(tPoint.x()).put(tPoint.y()));
@@ -176,18 +199,21 @@ public final class ElasticSearchSpatialIndexer {
json.put(property, tPointMap);
}
- private static void createIndexMultiLineString(String property, JSONObject json, TMultiLineString tMultiLineString) throws JSONException {
+ private static void createIndexMultiLineString(String property, JSONObject json, TMultiLineString tMultiLineString) throws JSONException
+ {
Map tMultiLineStringMap = new HashMap();
tMultiLineStringMap.put("type", "multilinestring");
JSONArray coordinates = new JSONArray();
- for (int i = 0; i < tMultiLineString.geometries().get().size(); i++) {
+ for (int i = 0; i < tMultiLineString.geometries().get().size(); i++)
+ {
JSONArray p = new JSONArray();
int nPoints = ((TLineString) tMultiLineString.getGeometryN(i)).getNumPoints();
JSONArray line = new JSONArray();
- for (int j = 0; j < nPoints; j++) {
+ for (int j = 0; j < nPoints; j++)
+ {
JSONArray xy = new JSONArray();
xy.put(((TLineString) tMultiLineString.getGeometryN(i)).getPointN(j).x());
xy.put(((TLineString) tMultiLineString.getGeometryN(i)).getPointN(j).y());
@@ -199,7 +225,8 @@ public final class ElasticSearchSpatialIndexer {
json.put(property, tMultiLineStringMap);
}
- private static void createIndexPolygon(String property, JSONObject json, TPolygon tPolygon) throws JSONException {
+ private static void createIndexPolygon(String property, JSONObject json, TPolygon tPolygon) throws JSONException
+ {
if (!tPolygon.shell().get().isValid())
throw new ElasticSearchIndexException("Polygon shell has to be closed - first and last point must match. ");
@@ -211,7 +238,8 @@ public final class ElasticSearchSpatialIndexer {
// shell
{
JSONArray shell = new JSONArray();
- for (int i = 0; i < tPolygon.shell().get().getNumPoints(); i++) {
+ for (int i = 0; i < tPolygon.shell().get().getNumPoints(); i++)
+ {
JSONArray p = new JSONArray();
p.put(tPolygon.shell().get().getPointN(i).x());
@@ -224,10 +252,12 @@ public final class ElasticSearchSpatialIndexer {
// wholes
{
- for (int i = 0; i < tPolygon.holes().get().size(); i++) {
+ for (int i = 0; i < tPolygon.holes().get().size(); i++)
+ {
JSONArray whole = new JSONArray();
// TLinearRing whole = tPolygon.holes().get().get(i);
- for (int j = 0; j < tPolygon.holes().get().get(i).getNumPoints(); j++) {
+ for (int j = 0; j < tPolygon.holes().get().get(i).getNumPoints(); j++)
+ {
if (!tPolygon.holes().get().get(i).isValid())
throw new ElasticSearchIndexException("Polygon whole has to be closed - first and last point must match. ");
@@ -246,12 +276,14 @@ public final class ElasticSearchSpatialIndexer {
json.put(property, tPolygonMap);
}
- private static void createIndexMultiPolygon(String property, JSONObject json, TMultiPolygon tMultiPolygon) throws JSONException {
+ private static void createIndexMultiPolygon(String property, JSONObject json, TMultiPolygon tMultiPolygon) throws JSONException
+ {
Map tMultiPolygonMap = new HashMap();
tMultiPolygonMap.put("type", "multipolygon");
JSONArray coordinates = new JSONArray();
- for (int i = 0; i < tMultiPolygon.geometries().get().size(); i++) {
+ for (int i = 0; i < tMultiPolygon.geometries().get().size(); i++)
+ {
JSONObject _json = new JSONObject();
createIndexPolygon(property, _json, (TPolygon) tMultiPolygon.getGeometryN(i));
coordinates.put(((JSONObject) _json.get(property)).get("coordinates"));
@@ -260,16 +292,19 @@ public final class ElasticSearchSpatialIndexer {
json.put(property, tMultiPolygonMap);
}
- private static void createIndexFeatureCollection(String property, JSONObject json, TFeatureCollection tFeatureCollection) throws JSONException {
+ private static void createIndexFeatureCollection(String property, JSONObject json, TFeatureCollection tFeatureCollection) throws JSONException
+ {
Map tFeatureMap = new HashMap();
tFeatureMap.put("type", "geometrycollection");
JSONArray geometries = new JSONArray();
JSONObject _json = new JSONObject();
- for (TGeometry tGeometry : tFeatureCollection.geometries().get()) {
+ for (TGeometry tGeometry : tFeatureCollection.geometries().get())
+ {
TFeature tFeature = (TFeature) tGeometry;
- switch (tFeature.asGeometry().getType()) {
+ switch (tFeature.asGeometry().getType())
+ {
case POINT:
createIndexPointAsGeoShapeType(property, _json, (TPoint) tFeature.asGeometry());
break;
@@ -296,14 +331,16 @@ public final class ElasticSearchSpatialIndexer {
json.put(property, tFeatureMap);
}
- private static void createIndexFeature(String property, JSONObject json, TFeature tFeature) throws JSONException {
+ private static void createIndexFeature(String property, JSONObject json, TFeature tFeature) throws JSONException
+ {
Map tFeatureMap = new HashMap();
tFeatureMap.put("type", "geometrycollection");
JSONArray geometries = new JSONArray();
JSONObject _json = new JSONObject();
- switch (tFeature.asGeometry().getType()) {
+ switch (tFeature.asGeometry().getType())
+ {
case POINT:
createIndexPointAsGeoShapeType(property, _json, (TPoint) tFeature.asGeometry());
break;
@@ -330,11 +367,13 @@ public final class ElasticSearchSpatialIndexer {
json.put(property, tFeatureMap);
}
- public static String spatialMappingPropertyName(Stack<String> stack) {
+ public static String spatialMappingPropertyName(Stack<String> stack)
+ {
ListIterator<String> it = stack.listIterator();
if (!it.hasNext()) return "";
StringBuilder sb = new StringBuilder();
- for (; ; ) {
+ for (; ; )
+ {
String s = it.next();
sb.append(s);
if (!it.hasNext())