http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/503532e9/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/ElasticSearchFinder.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/ElasticSearchFinder.java b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/ElasticSearchFinder.java index 1936d50..3b59443 100644 --- a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/ElasticSearchFinder.java +++ b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/ElasticSearchFinder.java @@ -152,9 +152,6 @@ public interface ElasticSearchFinder // Log LOGGER.debug( "Will search Entities: {}", request ); - System.out.println("Request " + request.toString()); - - // Execute SearchResponse response = request.execute().actionGet(); @@ -187,8 +184,6 @@ public interface ElasticSearchFinder // Log LOGGER.debug( "Will search Entity: {}", request ); - System.out.println("request " + request.toString()); - // Execute SearchResponse response = request.execute().actionGet();
http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/503532e9/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/ElasticSearchIndexer.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/ElasticSearchIndexer.java b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/ElasticSearchIndexer.java index 0e7edd4..dee2e26 100644 --- a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/ElasticSearchIndexer.java +++ b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/ElasticSearchIndexer.java @@ -127,10 +127,9 @@ public interface ElasticSearchIndexer index( bulkBuilder, changedState.identity().identity(), updatedJson ); break; case NEW: - // LOGGER.trace( "Creating Entity State in Index: {}", changedState ); + LOGGER.trace( "Creating Entity State in Index: {}", changedState ); String newJson = toJSON(changedState, newStates, uow ); - // System.out.println("#Will index: {} : " + newJson); - // LOGGER.trace( "Will index: {}", newJson ); + LOGGER.trace( "Will index: {}", newJson ); index( bulkBuilder, changedState.identity().identity(), newJson ); break; case LOADED: http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/503532e9/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/functions/convert/ConvertFinderSupport.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/functions/convert/ConvertFinderSupport.java b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/functions/convert/ConvertFinderSupport.java index a6e4f11..bd72319 100644 --- a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/functions/convert/ConvertFinderSupport.java +++ b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/functions/convert/ConvertFinderSupport.java @@ -27,16 +27,21 @@ import java.util.HashMap; import java.util.Map; -public class ConvertFinderSupport implements ElasticSearchSpatialFinder.SpatialQuerySpecSupport { +public class ConvertFinderSupport implements ElasticSearchSpatialFinder.SpatialQuerySpecSupport +{ private static final Map<Class<?>, ConvertFinderSupport.ConvertSpecification> SPATIAL_CONVERT_OPERATIONS = new HashMap<>(2); - static { + + static + { SPATIAL_CONVERT_OPERATIONS.put(ST_GeomFromTextSpecification.class, new ST_GeometryFromText()); } + private Module module; private ElasticSearchSupport support; - public ElasticSearchSpatialFinder.SpatialQuerySpecSupport support(Module module, ElasticSearchSupport support) { + public ElasticSearchSpatialFinder.SpatialQuerySpecSupport support(Module module, ElasticSearchSupport support) + { this.module = module; this.support = support; @@ -46,11 +51,14 @@ public class ConvertFinderSupport implements ElasticSearchSpatialFinder.SpatialQ public void processSpecification(FilterBuilder filterBuilder, Specification<?> spec, Map<String, Object> variables) - throws EntityFinderException { + throws EntityFinderException + { - if (SPATIAL_CONVERT_OPERATIONS.get(spec.getClass()) != null) { + if (SPATIAL_CONVERT_OPERATIONS.get(spec.getClass()) != null) + { SPATIAL_CONVERT_OPERATIONS.get(spec.getClass()).support(module, support).processSpecification(filterBuilder, (SpatialConvertSpecification) spec, variables); - } else { + } else + { throw new UnsupportedOperationException("Spatial predicates specification unsupported by Elastic Search " + "(New Query API support missing?): " + spec.getClass() + ": " + spec); @@ -59,11 +67,13 @@ public class ConvertFinderSupport implements ElasticSearchSpatialFinder.SpatialQ } - public interface Support { + public interface Support + { ConvertSpecification support(Module module, ElasticSearchSupport support); } - public static interface ConvertSpecification extends Support { + public static interface ConvertSpecification extends Support + { void processSpecification(FilterBuilder filterBuilder, SpatialConvertSpecification<?> spec, Map<String, Object> variables) throws EntityFinderException; } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/503532e9/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/functions/predicates/PredicateFinderSupport.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/functions/predicates/PredicateFinderSupport.java b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/functions/predicates/PredicateFinderSupport.java index d0e3766..2360f5f 100644 --- a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/functions/predicates/PredicateFinderSupport.java +++ b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/functions/predicates/PredicateFinderSupport.java @@ -29,14 +29,23 @@ import java.util.HashMap; import java.util.Map; -public class PredicateFinderSupport implements ElasticSearchSpatialFinder.SpatialQuerySpecSupport { +public class PredicateFinderSupport implements ElasticSearchSpatialFinder.SpatialQuerySpecSupport +{ private static final Map<Class<?>, PredicateFinderSupport.PredicateSpecification> SPATIAL_PREDICATE_OPERATIONS = new HashMap<>(3); + static + { + SPATIAL_PREDICATE_OPERATIONS.put(ST_WithinSpecification.class, new ST_Within()); + SPATIAL_PREDICATE_OPERATIONS.put(ST_DisjointSpecification.class, new ST_Disjoint()); + SPATIAL_PREDICATE_OPERATIONS.put(ST_IntersectsSpecification.class, new ST_Intersects()); + } + private Module module; private ElasticSearchSupport support; - public ElasticSearchSpatialFinder.SpatialQuerySpecSupport support(Module module, ElasticSearchSupport support) { + public ElasticSearchSpatialFinder.SpatialQuerySpecSupport support(Module module, ElasticSearchSupport support) + { this.module = module; this.support = support; @@ -46,30 +55,31 @@ public class PredicateFinderSupport implements ElasticSearchSpatialFinder.Spatia public void processSpecification(FilterBuilder filterBuilder, Specification<?> spec, Map<String, Object> variables) - throws EntityFinderException { + throws EntityFinderException + { - if (SPATIAL_PREDICATE_OPERATIONS.get(spec.getClass()) != null) { + if (SPATIAL_PREDICATE_OPERATIONS.get(spec.getClass()) != null) + { SPATIAL_PREDICATE_OPERATIONS.get(spec.getClass()).support(module, support).processSpecification(filterBuilder, (SpatialPredicatesSpecification) spec, variables); - } else { + } else + { throw new UnsupportedOperationException("Spatial predicates specification unsupported by Elastic Search " + "(New Query API support missing?): " + spec.getClass() + ": " + spec); } } - public interface Support { + public interface Support + { PredicateSpecification support(Module module, ElasticSearchSupport support); } - public static interface PredicateSpecification extends Support { + public static interface PredicateSpecification extends Support + { void processSpecification(FilterBuilder filterBuilder, SpatialPredicatesSpecification<?> spec, Map<String, Object> variables) throws EntityFinderException; } - static { - SPATIAL_PREDICATE_OPERATIONS.put(ST_WithinSpecification.class, new ST_Within()); - SPATIAL_PREDICATE_OPERATIONS.put(ST_DisjointSpecification.class, new ST_Disjoint()); - SPATIAL_PREDICATE_OPERATIONS.put(ST_IntersectsSpecification.class, new ST_Intersects()); - } + } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/503532e9/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/functions/predicates/ST_Within.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/functions/predicates/ST_Within.java b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/functions/predicates/ST_Within.java index d00bd2e..1516038 100644 --- a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/functions/predicates/ST_Within.java +++ b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/functions/predicates/ST_Within.java @@ -31,13 +31,15 @@ import org.qi4j.spi.query.EntityFinderException; import java.util.Map; -public class ST_Within extends AbstractElasticSearchSpatialFunction implements PredicateFinderSupport.PredicateSpecification { +public class ST_Within extends AbstractElasticSearchSpatialFunction implements PredicateFinderSupport.PredicateSpecification +{ public void processSpecification(FilterBuilder filterBuilder, SpatialPredicatesSpecification<?> spec, Map<String, Object> variables) - throws EntityFinderException { + throws EntityFinderException + { TGeometry geomOfFilterProperty = resolveGeometry(filterBuilder, spec, module); if (!isValid(spec)) @@ -63,7 +65,8 @@ public class ST_Within extends AbstractElasticSearchSpatialFunction implements P isTPoint(geomOfFilterProperty) && isMappedAsGeoPoint(spec.property()) && ((ST_WithinSpecification) spec).getDistance() > 0 - ) { + ) + { addFilter(createGeoDistanceFilter ( spec.property().toString(), @@ -82,11 +85,14 @@ public class ST_Within extends AbstractElasticSearchSpatialFunction implements P * ST_Within (templafeFor(x.class).propertyOfTypeTPoint(), polygon); * */ - else if (isPropertyOfType(TPoint.class, spec.property())) { + else if (isPropertyOfType(TPoint.class, spec.property())) + { - if (isMappedAsGeoPoint(spec.property())) { + if (isMappedAsGeoPoint(spec.property())) + { - if (geomOfFilterProperty instanceof TPolygon) { + if (geomOfFilterProperty instanceof TPolygon) + { /** * This must not happen, but in case the expression is defined using WTK like : * @@ -105,7 +111,8 @@ public class ST_Within extends AbstractElasticSearchSpatialFunction implements P GeoPolygonFilterBuilder geoPolygonFilterBuilder = FilterBuilders.geoPolygonFilter(spec.property().toString()); - for (int i = 0; i < polygonFilter.shell().get().getNumPoints(); i++) { + for (int i = 0; i < polygonFilter.shell().get().getNumPoints(); i++) + { TPoint point = polygonFilter.shell().get().getPointN(i); geoPolygonFilterBuilder.addPoint(point.y(), point.x()); } @@ -114,23 +121,27 @@ public class ST_Within extends AbstractElasticSearchSpatialFunction implements P throw new EntityFinderException("Invalid ST_Within expression. Unsupported type " + geomOfFilterProperty.getClass().getSimpleName() + " On properties of type " + TPoint.class.getSimpleName() + " only filters of type distance or polygon are supported."); - } else if (isMappedAsGeoShape(spec.property())) { - if (geomOfFilterProperty instanceof TPolygon) { + } else if (isMappedAsGeoShape(spec.property())) + { + if (geomOfFilterProperty instanceof TPolygon) + { addFilter(createShapeFilter(spec.property().toString(), geomOfFilterProperty, ShapeRelation.WITHIN), filterBuilder); - } else if (((ST_WithinSpecification) spec).getDistance() > 0) { + } else if (((ST_WithinSpecification) spec).getDistance() > 0) + { double radiusInMeters = convertDistanceToMeters(((ST_WithinSpecification) spec).getDistance(), ((ST_WithinSpecification) spec).getUnit()); TPolygon polygonizedCircleFilter = polygonizeCircle((TPoint) verifyProjection(geomOfFilterProperty), radiusInMeters); addFilter(createShapeFilter(spec.property().toString(), polygonizedCircleFilter, ShapeRelation.WITHIN), filterBuilder); } } - } else { - + } else + { addFilter(createShapeFilter(spec.property().toString(), geomOfFilterProperty, ShapeRelation.WITHIN), filterBuilder); } } - public PredicateFinderSupport.PredicateSpecification support(Module module, ElasticSearchSupport support) { + public PredicateFinderSupport.PredicateSpecification support(Module module, ElasticSearchSupport support) + { this.module = module; this.support = support; http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/503532e9/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/internal/AbstractElasticSearchSpatialFunction.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/internal/AbstractElasticSearchSpatialFunction.java b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/internal/AbstractElasticSearchSpatialFunction.java index a5f6d79..efcb425 100644 --- a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/internal/AbstractElasticSearchSpatialFunction.java +++ b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/internal/AbstractElasticSearchSpatialFunction.java @@ -39,7 +39,7 @@ import org.qi4j.index.elasticsearch.ElasticSearchSupport; import org.qi4j.index.elasticsearch.extensions.spatial.ElasticSearchSpatialFinder; import org.qi4j.index.elasticsearch.extensions.spatial.configuration.SpatialConfiguration; import org.qi4j.index.elasticsearch.extensions.spatial.configuration.SpatialFunctionsSupportMatrix; -import org.qi4j.library.spatial.projection.ProjectionsRegistry; +import org.qi4j.library.spatial.projections.ProjectionsRegistry; import org.qi4j.spi.query.EntityFinderException; import java.lang.reflect.Type; @@ -47,13 +47,10 @@ import java.util.Map; import static org.qi4j.api.geometry.TGeometryFactory.TPoint; 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; - -/** - * Created by jj on 20.11.14. - */ -public abstract class AbstractElasticSearchSpatialFunction { +public abstract class AbstractElasticSearchSpatialFunction +{ private static final String EPSG_4326 = "EPSG:4326"; private static final String DefaultSupportedProjection = EPSG_4326; @@ -62,7 +59,8 @@ public abstract class AbstractElasticSearchSpatialFunction { protected Module module; protected ElasticSearchSupport support; - protected boolean isSupported(SpatialPredicatesSpecification<?> spec, TGeometry geometryOfFilter) throws EntityFinderException { + protected boolean isSupported(SpatialPredicatesSpecification<?> spec, TGeometry geometryOfFilter) throws EntityFinderException + { return SpatialFunctionsSupportMatrix.isSupported ( spec.getClass(), @@ -72,7 +70,8 @@ public abstract class AbstractElasticSearchSpatialFunction { ); } - protected boolean isValid(SpatialPredicatesSpecification<?> spec) throws EntityFinderException { + protected boolean isValid(SpatialPredicatesSpecification<?> spec) throws EntityFinderException + { if ((spec.param() == null && spec.operator() == null)) return false; else @@ -80,43 +79,48 @@ public abstract class AbstractElasticSearchSpatialFunction { } - protected void addFilter(FilterBuilder filter, FilterBuilder into) { - if (into instanceof AndFilterBuilder) { + protected void addFilter(FilterBuilder filter, FilterBuilder into) + { + if (into instanceof AndFilterBuilder) + { ((AndFilterBuilder) into).add(filter); - } else if (into instanceof OrFilterBuilder) { + } else if (into instanceof OrFilterBuilder) + { ((OrFilterBuilder) into).add(filter); - } else { + } else + { throw new UnsupportedOperationException("FilterBuilder is nor an AndFB nor an OrFB, cannot continue."); } } - protected TGeometry verifyProjection(TGeometry tGeometry) { + protected TGeometry verifyProjection(TGeometry tGeometry) + { if (new ProjectionsRegistry().getCRS(tGeometry.getCRS()) == null) throw new RuntimeException("Project with the CRS Identity " + tGeometry.getCRS() + " is unknown. Supported projections are JJ TODO"); - - try { - if (!tGeometry.getCRS().equalsIgnoreCase(DefaultSupportedProjection)) { - if (SpatialConfiguration.isFinderProjectionConversionEnabled(support.spatialConfiguration())) { - Transform(module).from(tGeometry).to(DefaultSupportedProjection, DefaultProjectionConversionPrecisionInMeters); - } else throw new Exception("Filter Projection has a unsupported Projection and conversion is disabled"); - } - } catch (Exception _ex) { - _ex.printStackTrace(); + if (!tGeometry.getCRS().equalsIgnoreCase(DefaultSupportedProjection)) + { + if (SpatialConfiguration.isFinderProjectionConversionEnabled(support.spatialConfiguration())) + { + Transform(module).from(tGeometry).to(DefaultSupportedProjection, DefaultProjectionConversionPrecisionInMeters); + } else + throw new RuntimeException("Filter Geometry uses a unsupported Projection and transformation is disabled."); } - - return tGeometry; // ATTENTION - we are transforming as per "Reference" + return tGeometry; // <- ATTENTION - transmation is done directly on the "reference" to avoid cloning of composites. } - protected boolean isPropertyOfType(Class type, PropertyFunction propertyFunction) { + protected boolean isPropertyOfType(Class type, PropertyFunction propertyFunction) + { Type returnType = Classes.typeOf(propertyFunction.accessor()); Type propertyTypeAsType = GenericPropertyInfo.toPropertyType(returnType); Class clazz; - try { + try + { clazz = Class.forName(propertyTypeAsType.getTypeName()); - } catch (Exception _ex) { + } catch (Exception _ex) + { throw new RuntimeException(_ex); } @@ -126,62 +130,35 @@ public abstract class AbstractElasticSearchSpatialFunction { return false; } - protected boolean isPropertyOfTypeTPoint(PropertyFunction propertyFunction) { - // String typeName = Classes.typeOf(propertyFunction.accessor()).getTypeName(); - // System.out.println(typeName); - - Type returnType = Classes.typeOf(propertyFunction.accessor()); - Type propertyTypeAsType = GenericPropertyInfo.toPropertyType(returnType); - - System.out.println("---- > " + propertyTypeAsType.getTypeName()); - - Class clazz; - - try { - clazz = Class.forName(propertyTypeAsType.getTypeName()); - } catch (Exception _ex) { - throw new RuntimeException(_ex); - } - // if (clazz instanceof TGeometry) - - if (TPoint.class.isAssignableFrom(clazz)) - return true; - else - return false; - } - - protected boolean isMappedAsGeoPoint(PropertyFunction property) { + protected boolean isMappedAsGeoPoint(PropertyFunction property) + { return IndexMappingCache.isMappedAsGeoPoint(support.index(), support.entitiesType(), property.toString()); } - - protected boolean isTPoint(TGeometry filterGeometry) { - return TPoint(module).isPoint(filterGeometry); - } - - protected boolean isMappedAsGeoShape(PropertyFunction property) { + protected boolean isMappedAsGeoShape(PropertyFunction property) + { return IndexMappingCache.isMappedAsGeoShape(support.index(), support.entitiesType(), property.toString()); } - - protected boolean isMapped(PropertyFunction property) { - return IndexMappingCache.mappingExists(support.index(), support.entitiesType(), property.toString()); + protected boolean isTPoint(TGeometry filterGeometry) + { + return TPoint(module).isPoint(filterGeometry); } - protected boolean isSpatial(PropertyFunction property) { - return false; + protected boolean isMapped(PropertyFunction property) + { + return IndexMappingCache.mappingExists(support.index(), support.entitiesType(), property.toString()); } - protected GeoShapeFilterBuilder createShapeFilter(String name, TPoint point, ShapeRelation relation, double distance, TUnit unit) { - return createShapeFilter(name, point, relation, distance, convertDistanceUnit(unit)); - } - protected GeoShapeFilterBuilder createShapeFilter(String name, TGeometry geometry, ShapeRelation relation) { + protected GeoShapeFilterBuilder createShapeFilter(String name, TGeometry geometry, ShapeRelation relation) + { return createShapeFilter(name, geometry, relation, 0, null); } - protected GeoDistanceFilterBuilder createGeoDistanceFilter(String name, TPoint tPoint, double distance, TUnit unit) { + protected GeoDistanceFilterBuilder createGeoDistanceFilter(String name, TPoint tPoint, double distance, TUnit unit) + { // Lat = Y Long = X return FilterBuilders.geoDistanceFilter(name) .lat(tPoint.y()) @@ -189,15 +166,18 @@ public abstract class AbstractElasticSearchSpatialFunction { .distance(distance, convertDistanceUnit(unit)); } - protected TPolygon polygonizeCircle(TPoint centre, double radiusInMeters) { + protected TPolygon polygonizeCircle(TPoint centre, double radiusInMeters) + { double radiusInDegrees = DistanceUtils.dist2Degrees(radiusInMeters, DistanceUtils.EARTH_MEAN_RADIUS_KM * 1000); TCircle tCircle = module.newValueBuilder(TCircle.class).prototype().of(centre, radiusInDegrees); return tCircle.polygonize(360); } - private DistanceUnit convertDistanceUnit(TUnit tUnit) { - switch (tUnit) { + private DistanceUnit convertDistanceUnit(TUnit tUnit) + { + switch (tUnit) + { case MILLIMETER: return DistanceUnit.MILLIMETERS; case CENTIMETER: @@ -211,8 +191,10 @@ public abstract class AbstractElasticSearchSpatialFunction { } } - protected double convertDistanceToMeters(double source, TUnit sourceUnit) { - switch (sourceUnit) { + protected double convertDistanceToMeters(double source, TUnit sourceUnit) + { + switch (sourceUnit) + { case MILLIMETER: return source / 1000; case CENTIMETER: @@ -227,44 +209,49 @@ public abstract class AbstractElasticSearchSpatialFunction { } - private GeoShapeFilterBuilder createShapeFilter(String name, TGeometry geometry, ShapeRelation relation, double distance, DistanceUnit unit) { - if (geometry instanceof TPoint) { + private GeoShapeFilterBuilder createShapeFilter(String name, TGeometry geometry, ShapeRelation relation, double distance, DistanceUnit unit) + { + if (geometry instanceof TPoint) + { CircleBuilder circleBuilder = ShapeBuilder.newCircleBuilder(); circleBuilder.center(((TPoint) geometry).x(), ((TPoint) geometry).y()).radius(distance, unit); return FilterBuilders.geoShapeFilter(name, circleBuilder, relation); - } else if (geometry instanceof TPolygon) { + } else if (geometry instanceof TPolygon) + { PolygonBuilder polygonBuilder = ShapeBuilder.newPolygon(); - - for (int i = 0; i < ((TPolygon) geometry).shell().get().points().get().size(); i++) { + for (int i = 0; i < ((TPolygon) geometry).shell().get().points().get().size(); i++) + { TPoint point = ((TPolygon) geometry).shell().get().getPointN(i); - // System.out.println(point); - polygonBuilder.point( point.x(), point.y() ); } return FilterBuilders.geoShapeFilter(name, polygonBuilder, relation); - } else { - + } else + { + // TODO } return null; } - protected TGeometry resolveGeometry(FilterBuilder filterBuilder, Specification<Composite> spec, Module module) throws EntityFinderException { + protected TGeometry resolveGeometry(FilterBuilder filterBuilder, Specification<Composite> spec, Module module) throws EntityFinderException + { - if (spec instanceof SpatialPredicatesSpecification) { - if (((SpatialPredicatesSpecification) spec).param() != null) { + if (spec instanceof SpatialPredicatesSpecification) + { + if (((SpatialPredicatesSpecification) spec).param() != null) + { return ((SpatialPredicatesSpecification) spec).param(); - } else if (((SpatialPredicatesSpecification) spec).operator() != null) { + } else if (((SpatialPredicatesSpecification) spec).operator() != null) + { - if (((SpatialPredicatesSpecification) spec).operator() instanceof SpatialConvertSpecification) { + if (((SpatialPredicatesSpecification) spec).operator() instanceof SpatialConvertSpecification) + { executeSpecification(filterBuilder, (SpatialPredicatesSpecification) spec, null); - System.out.println("Converted Geometry " + ((SpatialConvertSpecification) ((SpatialPredicatesSpecification) spec).operator()).getGeometry()); return ((SpatialConvertSpecification) ((SpatialPredicatesSpecification) spec).operator()).getGeometry(); - // return executeSpecification(filterBuilder, (SpatialPredicatesSpecification)spec, null); } return null; @@ -276,19 +263,23 @@ public abstract class AbstractElasticSearchSpatialFunction { private void executeSpecification(FilterBuilder filterBuilder, SpatialPredicatesSpecification<?> spec, - Map<String, Object> variables) throws EntityFinderException { + Map<String, Object> variables) throws EntityFinderException + { - if (((SpatialPredicatesSpecification) spec).operator() instanceof SpatialConvertSpecification) { + if (((SpatialPredicatesSpecification) spec).operator() instanceof SpatialConvertSpecification) + { - if (ElasticSearchFinder.Mixin.EXTENDED_SPEC_SUPPORTS.get(spec.operator().getClass().getSuperclass()) != null) { + if (ElasticSearchFinder.Mixin.EXTENDED_SPEC_SUPPORTS.get(spec.operator().getClass().getSuperclass()) != null) + { ElasticSearchSpatialFinder.SpatialQuerySpecSupport spatialQuerySpecSupport = ElasticSearchFinder.Mixin.EXTENDED_SPEC_SUPPORTS .get(spec.operator().getClass().getSuperclass()).support(module, support); spatialQuerySpecSupport.processSpecification(filterBuilder, spec.operator(), variables); - } else { + } else + { throw new UnsupportedOperationException("Query specification unsupported by Elastic Search " + "(New Query API support missing?): " + spec.getClass() + ": " + spec); http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/503532e9/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/internal/InternalUtils.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/internal/InternalUtils.java b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/internal/InternalUtils.java index f7ed650..8b2aa0e 100644 --- a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/internal/InternalUtils.java +++ b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/internal/InternalUtils.java @@ -25,22 +25,28 @@ import java.lang.reflect.Type; /** * Ugly - not proud on this... How to make it better ? */ -public class InternalUtils { +public class InternalUtils +{ - public static Class classOfPropertyType(PropertyFunction propertyFunction) { + public static Class classOfPropertyType(PropertyFunction propertyFunction) + { Type typeOfProperty = GenericPropertyInfo.toPropertyType(Classes.typeOf(propertyFunction.accessor())); Class classOfProperty = null; - try { + try + { classOfProperty = Class.forName(typeOfProperty.getTypeName()); - } catch (Exception _ex) { + } catch (Exception _ex) + { // must not happen // TODO, logger - } finally { + } finally + { return classOfProperty; } } - public static Class<? extends TGeometry> classOfGeometry(TGeometry geometry) { + public static Class<? extends TGeometry> classOfGeometry(TGeometry geometry) + { if (geometry instanceof TPoint) return TPoint.class; if (geometry instanceof TMultiPoint) return TMultiPoint.class; if (geometry instanceof TLineString) return TLineString.class; http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/503532e9/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/mappings/SpatialIndexMapper.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/mappings/SpatialIndexMapper.java b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/mappings/SpatialIndexMapper.java index c1de598..87e7a08 100644 --- a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/mappings/SpatialIndexMapper.java +++ b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/mappings/SpatialIndexMapper.java @@ -24,22 +24,28 @@ import org.slf4j.LoggerFactory; import static org.qi4j.api.geometry.TGeometryFactory.TPoint; import static org.qi4j.index.elasticsearch.extensions.spatial.mappings.builders.SpatialMappingFactory.*; -public class SpatialIndexMapper { +public class SpatialIndexMapper +{ private static final Logger LOGGER = LoggerFactory.getLogger(SpatialIndexMapper.class); - public static void createIfNotExist(ElasticSearchSupport support, TGeometry geometry, String property) { - if (!MappingsCachesTable.getMappingCache(support).exists(property)) { + public static void createIfNotExist(ElasticSearchSupport support, TGeometry geometry, String property) + { + if (!MappingsCachesTable.getMappingCache(support).exists(property)) + { String mappingsOnServer = MappingQuery(support).get(property); - System.out.println("Found " + mappingsOnServer); - if (mappingsOnServer != null) { + if (mappingsOnServer != null) + { // TODO JJ check mappings : configuration versus server-side settings MappingsCachesTable.getMappingCache(support).put(property, mappingsOnServer); - } else { - if (TPoint(support.getModule()).isPoint(geometry)) { - switch (SpatialConfiguration.getMethod(support.spatialConfiguration())) { + } else + { + if (TPoint(support.getModule()).isPoint(geometry)) + { + switch (SpatialConfiguration.getMethod(support.spatialConfiguration())) + { case GEO_POINT: GeoPointMapping(support).create(property); break; @@ -49,7 +55,8 @@ public class SpatialIndexMapper { default: throw new RuntimeException("Unknown Point Maping Type."); } - } else { + } else + { GeoShapeMapping(support).create(property); } } @@ -64,23 +71,27 @@ public class SpatialIndexMapper { { - public static boolean isMappedAsGeoShape(String index, String type, String property) { + public static boolean isMappedAsGeoShape(String index, String type, String property) + { if (!MappingsCachesTable.getMappingCache(index, type).exists(property)) // <- No mappings yet, as no data in the index ? return false; return MappingsCachesTable.getMappingCache(index, type).get(property).toString().indexOf("type=geo_shape") > -1 ? true : false; } - public static boolean isMappedAsGeoPoint(String index, String type, String property) { + public static boolean isMappedAsGeoPoint(String index, String type, String property) + { if (!MappingsCachesTable.getMappingCache(index, type).exists(property)) // <- No mappings yet, as no data in the index ? return false; return MappingsCachesTable.getMappingCache(index, type).get(property).toString().indexOf("type=geo_point") > -1 ? true : false; } - public static boolean mappingExists(String index, String type, String property) { + public static boolean mappingExists(String index, String type, String property) + { return MappingsCachesTable.getMappingCache(index, type).exists(property); } - public static void clear() { + public static void clear() + { MappingsCachesTable.clear(); } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/503532e9/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/mappings/builders/AbstractBuilder.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/mappings/builders/AbstractBuilder.java b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/mappings/builders/AbstractBuilder.java index 882c42c..6d2e957 100644 --- a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/mappings/builders/AbstractBuilder.java +++ b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/mappings/builders/AbstractBuilder.java @@ -18,14 +18,13 @@ import org.elasticsearch.action.admin.indices.mapping.put.PutMappingResponse; import org.qi4j.index.elasticsearch.ElasticSearchSupport; import org.qi4j.index.elasticsearch.extensions.spatial.mappings.cache.MappingsCachesTable; -/** - * Created by jj on 19.12.14. - */ -public class AbstractBuilder { +public class AbstractBuilder +{ protected ElasticSearchSupport support; - public String get(String field) { + public String get(String field) + { if (!isValid()) throw new RuntimeException("ElasticSearch Index or Type not defined"); String index = support.index(); @@ -39,7 +38,8 @@ public class AbstractBuilder { if (response != null && response.fieldMappings(index, type, field) != null && !response.fieldMappings(index, type, field).isNull() && - response.fieldMappings(index, type, field).fullName().equals(field)) { + response.fieldMappings(index, type, field).fullName().equals(field)) + { return response.fieldMappings(index, type, field).sourceAsMap().toString(); } else @@ -47,11 +47,13 @@ public class AbstractBuilder { } - protected boolean isValid() { + protected boolean isValid() + { return (support != null) && (support.index() != null) && (support.entitiesType() != null) ? true : false; } - protected boolean put(String field, String mappingJson) { + protected boolean put(String field, String mappingJson) + { if (!isValid()) throw new RuntimeException("ElasticSearch Index or Type not defined"); String index = support.index(); @@ -62,7 +64,8 @@ public class AbstractBuilder { .setSource(mappingJson) .execute().actionGet(); - if (ESSpatialMappingPUTResponse.isAcknowledged()) { + if (ESSpatialMappingPUTResponse.isAcknowledged()) + { // we are reading the mapping back from server to assure that the server-side mappings always "wins" MappingsCachesTable.getMappingCache(support.index(), support.entitiesType()).put(field, get(field)); return true; http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/503532e9/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/mappings/cache/MappingsCachesTable.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/mappings/cache/MappingsCachesTable.java b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/mappings/cache/MappingsCachesTable.java index d5f9aa3..bd2c297 100644 --- a/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/mappings/cache/MappingsCachesTable.java +++ b/extensions/indexing-elasticsearch/src/main/java/org/qi4j/index/elasticsearch/extensions/spatial/mappings/cache/MappingsCachesTable.java @@ -19,22 +19,27 @@ import com.google.common.collect.Table; import org.qi4j.index.elasticsearch.ElasticSearchSupport; -public class MappingsCachesTable { +public class MappingsCachesTable +{ private static final Table<String, String, MappingsCache> CACHES_TABLE = HashBasedTable.create(); - public static MappingsCache getMappingCache(String index, String type) { + public static MappingsCache getMappingCache(String index, String type) + { return CACHES_TABLE.get(index, type); } - public static MappingsCache getMappingCache(ElasticSearchSupport support) { - if (!CACHES_TABLE.contains(support.index(), support.entitiesType())) { + public static MappingsCache getMappingCache(ElasticSearchSupport support) + { + if (!CACHES_TABLE.contains(support.index(), support.entitiesType())) + { CACHES_TABLE.put(support.index(), support.entitiesType(), new MappingsCache(support)); } return CACHES_TABLE.get(support.index(), support.entitiesType()); } - public static void clear() { + public static void clear() + { CACHES_TABLE.clear(); } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/503532e9/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/ElasticSearchSpatialQueryTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/ElasticSearchSpatialQueryTest.java b/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/ElasticSearchSpatialQueryTest.java deleted file mode 100644 index 6746ade..0000000 --- a/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/ElasticSearchSpatialQueryTest.java +++ /dev/null @@ -1,237 +0,0 @@ -package org.qi4j.index.elasticsearch; - -// import com.fasterxml.jackson.databind.ObjectMapper; -// import org.geojson.Feature; -// import org.geojson.FeatureCollection; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.qi4j.api.common.Visibility; -import org.qi4j.api.entity.EntityBuilder; -import org.qi4j.api.geometry.TFeature; -import org.qi4j.api.geometry.TPoint; -import org.qi4j.api.injection.scope.Service; -import org.qi4j.api.query.Query; -import org.qi4j.api.query.QueryBuilder; -import org.qi4j.api.unitofwork.UnitOfWork; -import org.qi4j.bootstrap.AssemblyException; -import org.qi4j.bootstrap.ModuleAssembly; -import org.qi4j.index.elasticsearch.assembly.ESFilesystemIndexQueryAssembler; -import org.qi4j.library.fileconfig.FileConfigurationOverride; -import org.qi4j.library.fileconfig.FileConfigurationService; -// import org.qi4j.library.spatial.transformator.GeoJsonTransformator; -import org.qi4j.test.EntityTestAssembler; -import org.qi4j.test.indexing.AbstractSpatialQueryTest; -import org.qi4j.test.indexing.model.City; -import org.qi4j.test.indexing.model.Person; -import org.qi4j.test.util.DelTreeAfter; - -import java.io.File; - -import static org.qi4j.api.query.QueryExpressions.templateFor; -import static org.qi4j.api.query.grammar.extensions.spatial.SpatialQueryExpressions.ST_GeometryFromText; -import static org.qi4j.api.query.grammar.extensions.spatial.SpatialQueryExpressions.ST_Within; -import static org.qi4j.test.util.Assume.assumeNoIbmJdk; - -/** - * Created by jakes on 2/8/14. - */ -public class ElasticSearchSpatialQueryTest - extends AbstractSpatialQueryTest -{ - - - - - - - private static final File DATA_DIR = new File( "build/tmp/es-money-query-test" ); - @Rule - public final DelTreeAfter delTreeAfter = new DelTreeAfter( DATA_DIR ); - - @BeforeClass - public static void beforeClass_IBMJDK() - { - assumeNoIbmJdk(); - } - - @Override - public void assemble( ModuleAssembly module ) - throws AssemblyException - { - super.assemble( module ); - - - // Config module - ModuleAssembly config = module.layer().module( "config" ); - new EntityTestAssembler().assemble( config ); - - // Index/Query - new ESFilesystemIndexQueryAssembler(). - withConfig( config, Visibility.layer ). - assemble( module ); - ElasticSearchConfiguration esConfig = config.forMixin( ElasticSearchConfiguration.class ).declareDefaults(); - esConfig.indexNonAggregatedAssociations().set( Boolean.TRUE ); - - // FileConfig - FileConfigurationOverride override = new FileConfigurationOverride(). - withData( new File( DATA_DIR, "qi4j-data" ) ). - withLog( new File( DATA_DIR, "qi4j-logs" ) ). - withTemporary( new File( DATA_DIR, "qi4j-temp" ) ); - module.services( FileConfigurationService.class ). - setMetaInfo( override ); - } - -/** - // @Before - public void setup() - { - - - // UnitOfWork uow = module.newUnitOfWork(); - try - { - - - BufferedInputStream inputstream = new BufferedInputStream(new FileInputStream("/home/jakes/Projects/QI4J/Spatial/qi4j-sdk/libraries/spatial/src/test/resources/topo/geojson/germany/bavaria.neustadt.geojson")); - - // BufferedInputStream inputstream = new BufferedInputStream(new FileInputStream("/media/HDD_002/spatial/OpenStreetMap/geofabrik.de/nuenberg.geojson")); - - FeatureCollection featureCollection = - new ObjectMapper().readValue(inputstream, FeatureCollection.class); - - System.out.println("Found num of features " + featureCollection.getFeatures().size()); - - int count = 0; - - Iterator<Feature> features = featureCollection.getFeatures().iterator(); - - while (features.hasNext()) { - - count++; - - Feature feature = features.next(); - - TFeature tFeature = GeoJsonTransformator.withGeometryFactory(Geometry).transformGeoFeature(feature); - if (tFeature != null) - { - // System.out.println(tFeature); - - // if (tFeature.asGeometry().type().get().equalsIgnoreCase("point")) - if (tFeature.asGeometry() instanceof TPoint) - { - UnitOfWork uow1 = module.newUnitOfWork(); - MapFeature mapFeature = from(tFeature); - System.out.println(mapFeature); - uow1.complete(); - - } - } - - } - - - - } - catch( Exception ex ) - { - ex.printStackTrace(); - // log.error( ex.getMessage(), ex ); - // throw ex; - } - - } - - */ - - @Test - public void script0() throws Exception { - - // UnitOfWork uow = module.newUnitOfWork(); - try - { - - System.out.println("Test.."); - // setup(); - - - } - catch( Exception ex ) - { - ex.printStackTrace(); - // log.error( ex.getMessage(), ex ); - throw ex; - } - finally - { - // uow.discard(); - } - - // uow.complete(); - - } - - - - @Test - public void whenQueryUsePolygon() throws Exception - { - - - QueryBuilder<City> qb = this.module.newQueryBuilder(City.class); - - Query<City> query = unitOfWork.newQuery( - qb - .where( - ST_Within - ( - templateFor(City.class).location(), - - ST_GeometryFromText( - "POLYGON((" + - "49.56797785892715 10.62652587890625," + - "49.5835615987737 10.748062133789062," + - "49.533230478523684 10.78857421875," + - "49.484185749507716 10.72265625," + - "49.49310663031507 10.578460693359375," + - "49.5416968611641 10.583267211914062," + - "49.555507284155276 10.605239868164062," + - "49.56797785892715 10.62652587890625))") - ) - )); - - - // System.out.println( "*** script01: " + query ); - query.find(); - - System.out.println("Found Cities " + query.count()); - } - - - - - private MapFeature from(TFeature tFeature) - { - MapFeature feature; - EntityBuilder<MapFeature> featureBuilder = unitOfWork.newEntityBuilder( MapFeature.class ); - feature = featureBuilder.instance(); - - feature.geometry1().set(tFeature.asGeometry()); - // feature.properties().set(tFeature.asProperties()); - - feature = featureBuilder.newInstance(); - - return feature; - - } - - - @Test - public void whenQueryForPersonsInACity() { - - - - - } - -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/503532e9/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/ElasticSearchSpatialClusterQueryTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/ElasticSearchSpatialClusterQueryTest.java b/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/ElasticSearchSpatialClusterQueryTest.java deleted file mode 100644 index 4252da5..0000000 --- a/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/ElasticSearchSpatialClusterQueryTest.java +++ /dev/null @@ -1,132 +0,0 @@ -package org.qi4j.index.elasticsearch.extension.spatial; - -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.qi4j.api.common.Visibility; -import org.qi4j.api.query.QueryExecutionException; -import org.qi4j.bootstrap.AssemblyException; -import org.qi4j.bootstrap.ModuleAssembly; -import org.qi4j.entitystore.riak.RiakHttpMapEntityStoreAssembler; -import org.qi4j.index.elasticsearch.ElasticSearchConfiguration; -import org.qi4j.index.elasticsearch.assembly.ESClusterIndexQueryAssembler; -import org.qi4j.index.elasticsearch.extensions.spatial.configuration.SpatialConfiguration; -import org.qi4j.library.fileconfig.FileConfigurationOverride; -import org.qi4j.library.fileconfig.FileConfigurationService; -import org.qi4j.library.spatial.assembly.TGeometryAssembler; -import org.qi4j.spi.query.EntityFinderException; -import org.qi4j.test.EntityTestAssembler; -import org.qi4j.test.indexing.AbstractSpatialRegressionTest; -import org.qi4j.test.util.DelTreeAfter; -import org.qi4j.valueserialization.orgjson.OrgJsonValueSerializationAssembler; - -import java.io.File; - -import static org.qi4j.test.util.Assume.assumeNoIbmJdk; - -/** - * Created by jj on 21.12.14. - */ -public class ElasticSearchSpatialClusterQueryTest - extends AbstractSpatialRegressionTest -{ - private static final File DATA_DIR = new File( "build/tmp/es-spatial-query-test" ); - @Rule - public final DelTreeAfter delTreeAfter = new DelTreeAfter( DATA_DIR ); - - @BeforeClass - public static void beforeClass_IBMJDK() - { - assumeNoIbmJdk(); - } - - - @Override - public void assemble( ModuleAssembly module ) - throws AssemblyException - { - super.assemble( module ); - - // Geometry support - new TGeometryAssembler().assemble(module); - - - - // Config module - ModuleAssembly config = module.layer().module( "config" ); - new EntityTestAssembler().assemble( config ); - - config.values(SpatialConfiguration.Configuration.class, - SpatialConfiguration.FinderConfiguration.class, - SpatialConfiguration.IndexerConfiguration.class, - SpatialConfiguration.IndexingMethod.class, - SpatialConfiguration.ProjectionSupport.class). - visibleIn(Visibility.application); - - - // Index/Query - new ESClusterIndexQueryAssembler(). - withConfig(config, Visibility.layer). - identifiedBy("ElasticSearchBenchmark"). - assemble(module); - ElasticSearchConfiguration esConfig = config.forMixin(ElasticSearchConfiguration.class).declareDefaults(); - esConfig.indexNonAggregatedAssociations().set(Boolean.TRUE); - - // FileConfig - FileConfigurationOverride override = new FileConfigurationOverride(). - withData(new File(DATA_DIR, "qi4j-data")). - withLog(new File(DATA_DIR, "qi4j-logs")). - withTemporary(new File(DATA_DIR, "qi4j-temp")); - module.services(FileConfigurationService.class). - setMetaInfo(override); - - // In-Memory Entity Store - // new EntityTestAssembler().assemble( module ); - - - /** RIAK */ - ModuleAssembly configRiak = module.layer().module( "configRiak" ); - new EntityTestAssembler().assemble( configRiak ); - new OrgJsonValueSerializationAssembler().assemble( module ); - // START SNIPPET: assembly - new RiakHttpMapEntityStoreAssembler().withConfig( configRiak, Visibility.layer ).assemble( module ); - /** +++ */ - } - - - @Test(expected=QueryExecutionException.class) - public void script01c() - throws EntityFinderException - { - super.script01c(); // <- no orderBy() support for GeoShapes - } - - @Test(expected=QueryExecutionException.class) - public void script01d() - throws EntityFinderException - { - super.script01d(); // <- no orderBy() support for GeoShapes - } - - @Test(expected=QueryExecutionException.class) - public void script01e() - throws EntityFinderException - { - super.script01e(); // <- no orderBy() support for GeoShapes - } - - @Test(expected=QueryExecutionException.class) - public void script01f() - throws EntityFinderException - { - super.script01f(); // <- no orderBy() support for GeoShapes - } - - @Test(expected=QueryExecutionException.class) - public void script03c() - throws EntityFinderException - { - super.script03c(); // <- no orderBy() support for GeoShapes - } - -} http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/503532e9/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/ElasticSearchSpatialQueryTestUsingGeoPointIndexing.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/ElasticSearchSpatialQueryTestUsingGeoPointIndexing.java b/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/ElasticSearchSpatialQueryTestUsingGeoPointIndexing.java index bd27bd9..c476c8c 100644 --- a/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/ElasticSearchSpatialQueryTestUsingGeoPointIndexing.java +++ b/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/ElasticSearchSpatialQueryTestUsingGeoPointIndexing.java @@ -102,7 +102,7 @@ public class ElasticSearchSpatialQueryTestUsingGeoPointIndexing public void script02a() throws EntityFinderException { - super.script02a(); + super.script02a(); // <- no ST_Disjoint when GEOSHAPE indexing for TPoints } @Test (expected=QueryExecutionException.class) @@ -110,7 +110,7 @@ public class ElasticSearchSpatialQueryTestUsingGeoPointIndexing public void script02b() throws EntityFinderException { - super.script02b(); + super.script02b(); // <- no ST_Disjoint when GEOSHAPE indexing for TPoints } @Test (expected=QueryExecutionException.class) @@ -118,7 +118,7 @@ public class ElasticSearchSpatialQueryTestUsingGeoPointIndexing public void script02c() throws EntityFinderException { - super.script02c(); + super.script02c(); // <- no ST_Disjoint when GEOSHAPE indexing for TPoints } @Test (expected=QueryExecutionException.class) @@ -126,7 +126,7 @@ public class ElasticSearchSpatialQueryTestUsingGeoPointIndexing public void script02d() throws EntityFinderException { - super.script02d(); + super.script02d(); // <- no ST_Disjoint when GEOSHAPE indexing for TPoints } @Test (expected=QueryExecutionException.class) @@ -134,7 +134,7 @@ public class ElasticSearchSpatialQueryTestUsingGeoPointIndexing public void script02e() throws EntityFinderException { - super.script02e(); + super.script02e(); // <- no ST_Disjoint when GEOSHAPE indexing for TPoints } @Test (expected=QueryExecutionException.class) @@ -142,7 +142,7 @@ public class ElasticSearchSpatialQueryTestUsingGeoPointIndexing public void script02f() throws EntityFinderException { - super.script02f(); + super.script02f(); // <- no ST_Disjoint when GEOSHAPE indexing for TPoints } @Test (expected=QueryExecutionException.class) @@ -150,7 +150,7 @@ public class ElasticSearchSpatialQueryTestUsingGeoPointIndexing public void script03a() throws EntityFinderException { - super.script03a(); + super.script03a(); // <- no ST_Disjoint when GEOSHAPE indexing for TPoints } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/503532e9/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/ElasticSearchSpatialRegressionQueryClusterTest.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/ElasticSearchSpatialRegressionQueryClusterTest.java b/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/ElasticSearchSpatialRegressionQueryClusterTest.java deleted file mode 100644 index 7fd00bf..0000000 --- a/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/ElasticSearchSpatialRegressionQueryClusterTest.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.qi4j.index.elasticsearch.extension.spatial; - -import org.junit.BeforeClass; -import org.junit.Rule; -import org.qi4j.api.common.Visibility; -import org.qi4j.api.query.Query; -import org.qi4j.bootstrap.AssemblyException; -import org.qi4j.bootstrap.ModuleAssembly; -import org.qi4j.index.elasticsearch.ElasticSearchConfiguration; -import org.qi4j.index.elasticsearch.assembly.ESClusterIndexQueryAssembler; -import org.qi4j.index.elasticsearch.extensions.spatial.configuration.SpatialConfiguration; -import org.qi4j.library.fileconfig.FileConfigurationOverride; -import org.qi4j.library.fileconfig.FileConfigurationService; -import org.qi4j.library.spatial.assembly.TGeometryAssembler; -import org.qi4j.test.EntityTestAssembler; -import org.qi4j.test.indexing.AbstractSpatialRegressionTest; -import org.qi4j.test.util.DelTreeAfter; - -import java.io.File; - -import static org.qi4j.test.util.Assume.assumeNoIbmJdk; - -/** - * Created by jj on 21.12.14. - */ -public class ElasticSearchSpatialRegressionQueryClusterTest - extends AbstractSpatialRegressionTest -{ - private static final File DATA_DIR = new File( "build/tmp/es-spatial-query-test" ); - @Rule - public final DelTreeAfter delTreeAfter = new DelTreeAfter( DATA_DIR ); - - @BeforeClass - public static void beforeClass_IBMJDK() - { - assumeNoIbmJdk(); - } - - protected boolean isExpressionSupported(Query<?> expression) - { - return true; - } - - - @Override - public void assemble( ModuleAssembly module ) - throws AssemblyException - { - super.assemble( module ); - - // Geometry support - new TGeometryAssembler().assemble(module); - - - - // Config module - ModuleAssembly config = module.layer().module( "config" ); - new EntityTestAssembler().assemble( config ); - - config.values(SpatialConfiguration.Configuration.class, - SpatialConfiguration.FinderConfiguration.class, - SpatialConfiguration.IndexerConfiguration.class, - SpatialConfiguration.IndexingMethod.class, - SpatialConfiguration.ProjectionSupport.class). - visibleIn(Visibility.application); - - // Index/Query - new ESClusterIndexQueryAssembler(). - withConfig(config, Visibility.layer). - identifiedBy("ElasticSearchConfigurationVariant1"). - assemble(module); - ElasticSearchConfiguration esConfig = config.forMixin(ElasticSearchConfiguration.class).declareDefaults(); - esConfig.indexNonAggregatedAssociations().set(Boolean.TRUE); - - - // FileConfig - FileConfigurationOverride override = new FileConfigurationOverride(). - withData(new File(DATA_DIR, "qi4j-data")). - withLog(new File(DATA_DIR, "qi4j-logs")). - withTemporary(new File(DATA_DIR, "qi4j-temp")); - module.services(FileConfigurationService.class). - setMetaInfo(override); - - - config.services(FileConfigurationService.class) - // .identifiedBy("ElasticSearchConfigurationVariant1") - .setMetaInfo(override) - .visibleIn(Visibility.application); - } -} http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/503532e9/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/model/VerifyStatialTypes.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/model/VerifyStatialTypes.java b/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/model/VerifyStatialTypes.java deleted file mode 100644 index 31d8595..0000000 --- a/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/model/VerifyStatialTypes.java +++ /dev/null @@ -1,36 +0,0 @@ -package org.qi4j.index.elasticsearch.extension.spatial.model; - -import com.vividsolutions.jts.geom.MultiLineString; -import org.qi4j.api.common.Optional; -import org.qi4j.api.geometry.*; -import org.qi4j.api.property.Property; - -/** - * Created by jj on 01.12.14. - */ -public interface VerifyStatialTypes { - - @Optional - Property<String> foo(); - - @Optional - Property<TPoint> point(); - - @Optional - Property<TMultiPoint> mPoint(); - - @Optional - Property<TLineString> line(); - - @Optional - Property<TPolygon> polygon(); - - @Optional - Property<TMultiPolygon> mPolygon(); - - @Optional - Property<TFeature> feature(); - - @Optional - Property<TFeatureCollection> collection(); -} http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/503532e9/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/model/entity/SpatialEntity.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/model/entity/SpatialEntity.java b/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/model/entity/SpatialEntity.java deleted file mode 100644 index 0146bc5..0000000 --- a/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/model/entity/SpatialEntity.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.qi4j.index.elasticsearch.extension.spatial.model.entity; - -import org.qi4j.api.entity.EntityComposite; -import org.qi4j.index.elasticsearch.extension.spatial.model.VerifyStatialTypes; - -/** - * Created by jj on 01.12.14. - */ -public interface SpatialEntity extends EntityComposite, - VerifyStatialTypes -{} http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/503532e9/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/utils/RandomUtils.java ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/utils/RandomUtils.java b/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/utils/RandomUtils.java deleted file mode 100644 index 34b1cd9..0000000 --- a/extensions/indexing-elasticsearch/src/test/java/org/qi4j/index/elasticsearch/extension/spatial/utils/RandomUtils.java +++ /dev/null @@ -1,438 +0,0 @@ -package org.qi4j.index.elasticsearch.extension.spatial.utils; - -import java.io.Serializable; -import java.util.Random; - -/** - * This class generates pseudorandom numbers. It uses the same - * algorithm as the original JDK-class, so that your programs behave - * exactly the same way, if started with the same seed. - * - * The algorithm is described in <em>The Art of Computer Programming, - * Volume 2</em> by Donald Knuth in Section 3.2.1. It is a 48-bit seed, - * linear congruential formula. - * - * If two instances of this class are created with the same seed and - * the same calls to these classes are made, they behave exactly the - * same way. This should be even true for foreign implementations - * (like this), so every port must use the same algorithm as described - * here. - * - * If you want to implement your own pseudorandom algorithm, you - * should extend this class and overload the <code>next()</code> and - * <code>setSeed(long)</code> method. In that case the above - * paragraph doesn't apply to you. - * - * This class shouldn't be used for security sensitive purposes (like - * generating passwords or encryption keys. See <code>SecureRandom</code> - * in package <code>java.security</code> for this purpose. - * - * For simple random doubles between 0.0 and 1.0, you may consider using - * Math.random instead. - * - * @see java.security.SecureRandom - * @see Math#random() - * @author Jochen Hoenicke - * @author Eric Blake ([email protected]) - * @status updated to 1.4 - */ -public class RandomUtils implements Serializable, Cloneable -{ - public Random clone() { - try { - return (Random)super.clone(); - } catch (Exception e) { - return null; - } - } - - - /** - * Randomizes all elements of an array. - * - * @param data the array to be randomized - */ - public void randomizeArray(int[] data) { - int len = data.length; - for (int i = 0; i < len-1; i++) { - int r = i + nextInt(len-i); - // swap data at indices i and r - int temp = data[r]; - data[r] = data[i]; - data[i] = temp; - } - } - - - /** - * True if the next nextGaussian is available. This is used by - * nextGaussian, which generates two gaussian numbers by one call, - * and returns the second on the second call. - * - * @serial whether nextNextGaussian is available - * @see #nextGaussian() - * @see #nextNextGaussian - */ - private boolean haveNextNextGaussian; - - /** - * The next nextGaussian, when available. This is used by nextGaussian, - * which generates two gaussian numbers by one call, and returns the - * second on the second call. - * - * @serial the second gaussian of a pair - * @see #nextGaussian() - * @see #haveNextNextGaussian - */ - private double nextNextGaussian; - - /** - * The seed. This is the number set by setSeed and which is used - * in next. - * - * @serial the internal state of this generator - * - */ - private long seed; - - /** - * Compatible with JDK 1.0+. - */ - private static final long serialVersionUID = 3905348978240129619L; - - /** - * Creates a new pseudorandom number generator. The seed is initialized - * to the current time, as if by - * <code>setSeed(System.currentTimeMillis());</code>. - * - * @see System#currentTimeMillis() - */ - public RandomUtils() - { - this(System.currentTimeMillis()); - } - - /** - * Creates a new pseudorandom number generator, starting with the - * specified seed, using <code>setSeed(seed);</code>. - * - * @param seed the initial seed - */ - public RandomUtils(long seed) - { - setSeed(seed); - } - - /** - * Sets the seed for this pseudorandom number generator. As described - * above, two instances of the same random class, starting with the - * same seed, should produce the same results, if the same methods - * are called. The implementation for java.util.Random is: - * - <pre>public synchronized void setSeed(long seed) - { - this.seed = (seed ^ 0x5DEECE66DL) & ((1L << 48) - 1); - haveNextNextGaussian = false; - }</pre> - * - * @param seed the new seed - */ - public synchronized void setSeed(long seed) - { - this.seed = (seed ^ 0x5DEECE66DL) & ((1L << 48) - 1); - haveNextNextGaussian = false; - } - - /** - * Generates the next pseudorandom number. This returns - * an int value whose <code>bits</code> low order bits are - * independent chosen random bits (0 and 1 are equally likely). - * The implementation for java.util.Random is: - * - <pre>protected synchronized int next(int bits) - { - seed = (seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1); - return (int) (seed >>> (48 - bits)); - }</pre> - * - * @param bits the number of random bits to generate, in the range 1..32 - * @return the next pseudorandom value - * @since 1.1 - */ - protected synchronized int next(int bits) - { - seed = (seed * 0x5DEECE66DL + 0xBL) & ((1L << 48) - 1); - return (int) (seed >>> (48 - bits)); - } - - /** - * Fills an array of bytes with random numbers. All possible values - * are (approximately) equally likely. - * The JDK documentation gives no implementation, but it seems to be: - * - <pre>public void nextBytes(byte[] bytes) - { - for (int i = 0; i < bytes.length; i += 4) - { - int random = next(32); - for (int j = 0; i + j < bytes.length && j < 4; j++) - { - bytes[i+j] = (byte) (random & 0xff) - random >>= 8; - } - } - }</pre> - * - * @param bytes the byte array that should be filled - * @throws NullPointerException if bytes is null - * @since 1.1 - */ - public void nextBytes(byte[] bytes) - { - int random; - // Do a little bit unrolling of the above algorithm. - int max = bytes.length & ~0x3; - for (int i = 0; i < max; i += 4) - { - random = next(32); - bytes[i] = (byte) random; - bytes[i + 1] = (byte) (random >> 8); - bytes[i + 2] = (byte) (random >> 16); - bytes[i + 3] = (byte) (random >> 24); - } - if (max < bytes.length) - { - random = next(32); - for (int j = max; j < bytes.length; j++) - { - bytes[j] = (byte) random; - random >>= 8; - } - } - } - - /** - * Generates the next pseudorandom number. This returns - * an int value whose 32 bits are independent chosen random bits - * (0 and 1 are equally likely). The implementation for - * java.util.Random is: - * - <pre>public int nextInt() - { - return next(32); - }</pre> - * - * @return the next pseudorandom value - */ - public int nextInt() - { - return next(32); - } - - /** - * Generates the next pseudorandom number. This returns - * a value between 0(inclusive) and <code>n</code>(exclusive), and - * each value has the same likelihodd (1/<code>n</code>). - * (0 and 1 are equally likely). The implementation for - * java.util.Random is: - * - <pre> - public int nextInt(int n) - { - if (n <= 0) - throw new IllegalArgumentException("n must be positive"); - - if ((n & -n) == n) // i.e., n is a power of 2 - return (int)((n * (long) next(31)) >> 31); - - int bits, val; - do - { - bits = next(31); - val = bits % n; - } - while(bits - val + (n-1) < 0); - - return val; - }</pre> - * - * <p>This algorithm would return every value with exactly the same - * probability, if the next()-method would be a perfect random number - * generator. - * - * The loop at the bottom only accepts a value, if the random - * number was between 0 and the highest number less then 1<<31, - * which is divisible by n. The probability for this is high for small - * n, and the worst case is 1/2 (for n=(1<<30)+1). - * - * The special treatment for n = power of 2, selects the high bits of - * the random number (the loop at the bottom would select the low order - * bits). This is done, because the low order bits of linear congruential - * number generators (like the one used in this class) are known to be - * ``less random'' than the high order bits. - * - * @param n the upper bound - * @throws IllegalArgumentException if the given upper bound is negative - * @return the next pseudorandom value - * @since 1.2 - */ - public int nextInt(int n) - { - if (n <= 0) - throw new IllegalArgumentException("n must be positive"); - if ((n & -n) == n) // i.e., n is a power of 2 - return (int) ((n * (long) next(31)) >> 31); - int bits, val; - do - { - bits = next(31); - val = bits % n; - } - while (bits - val + (n - 1) < 0); - return val; - } - - /** - * Generates the next pseudorandom long number. All bits of this - * long are independently chosen and 0 and 1 have equal likelihood. - * The implementation for java.util.Random is: - * - <pre>public long nextLong() - { - return ((long) next(32) << 32) + next(32); - }</pre> - * - * @return the next pseudorandom value - */ - public long nextLong() - { - return ((long) next(32) << 32) + next(32); - } - - /** - * Generates the next pseudorandom boolean. True and false have - * the same probability. The implementation is: - * - <pre>public boolean nextBoolean() - { - return next(1) != 0; - }</pre> - * - * @return the next pseudorandom boolean - * @since 1.2 - */ - public boolean nextBoolean() - { - return next(1) != 0; - } - - /** - * Generates the next pseudorandom float uniformly distributed - * between 0.0f (inclusive) and 1.0f (exclusive). The - * implementation is as follows. - * - <pre>public float nextFloat() - { - return next(24) / ((float)(1 << 24)); - }</pre> - * - * @return the next pseudorandom float - */ - public float nextFloat() - { - return next(24) / (float) (1 << 24); - } - - /** - * Generates the next pseudorandom double uniformly distributed - * between 0.0 (inclusive) and 1.0 (exclusive). The - * implementation is as follows. - * - <pre>public double nextDouble() - { - return (((long) next(26) << 27) + next(27)) / (double)(1L << 53); - }</pre> - * - * @return the next pseudorandom double - */ - public double nextDouble() - { - return (((long) next(26) << 27) + next(27)) / (double) (1L << 53); - } - - /** - * Generates the next pseudorandom, Gaussian (normally) distributed - * double value, with mean 0.0 and standard deviation 1.0. - * The algorithm is as follows. - * - <pre>public synchronized double nextGaussian() - { - if (haveNextNextGaussian) - { - haveNextNextGaussian = false; - return nextNextGaussian; - } - else - { - double v1, v2, s; - do - { - v1 = 2 * nextDouble() - 1; // between -1.0 and 1.0 - v2 = 2 * nextDouble() - 1; // between -1.0 and 1.0 - s = v1 * v1 + v2 * v2; - } - while (s >= 1); - - double norm = Math.sqrt(-2 * Math.log(s) / s); - nextNextGaussian = v2 * norm; - haveNextNextGaussian = true; - return v1 * norm; - } - }</pre> - * - * <p>This is described in section 3.4.1 of <em>The Art of Computer - * Programming, Volume 2</em> by Donald Knuth. - * - * @return the next pseudorandom Gaussian distributed double - */ - public synchronized double nextGaussian() - { - if (haveNextNextGaussian) - { - haveNextNextGaussian = false; - return nextNextGaussian; - } - double v1, v2, s; - do - { - v1 = 2 * nextDouble() - 1; // Between -1.0 and 1.0. - v2 = 2 * nextDouble() - 1; // Between -1.0 and 1.0. - s = v1 * v1 + v2 * v2; - } - while (s >= 1); - double norm = Math.sqrt(-2 * Math.log(s) / s); - nextNextGaussian = v2 * norm; - haveNextNextGaussian = true; - return v1 * norm; - } - - - - /** - * Generates the next pseudorandom, Poisson distributed - * integer value k which is distributed according to: P(k, lambda) = (lambda^k exp(-lambda) / k!) - * Note that <k> = <k^2>-<k>^2 = lambda - * - * A simple algorithm is used which has complexity linear in lambda (Knuth). - */ - public int nextPoisson(double lambda) { - double l = Math.exp(-lambda); - double p = 1; - int k = 0; - do { - k++; - p *= nextDouble(); - } while (p >= l); - return k-1; - } -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/503532e9/extensions/indexing-elasticsearch/src/test/resources/ElasticSearchBenchmark.properties ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/test/resources/ElasticSearchBenchmark.properties b/extensions/indexing-elasticsearch/src/test/resources/ElasticSearchBenchmark.properties deleted file mode 100644 index dd67ab3..0000000 --- a/extensions/indexing-elasticsearch/src/test/resources/ElasticSearchBenchmark.properties +++ /dev/null @@ -1,30 +0,0 @@ -nodes=localhost:9300 - -spatial = { \ - \ - Enabled : true, \ - \ - Indexer=\ - { \ - Method=\ - { \ - Type = "GEO_POINT", \ - Precision = 1m, \ - }, \ - Projection=\ - { \ - ConversionEnabled = true, \ - ConversionAccuracy = 2m, \ - }, \ - }, \ - \ - \ - Finder=\ - { \ - Projection=\ - { \ - ConversionEnabled = true, \ - ConversionAccuracy = 2m, \ - } \ - } \ - } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/503532e9/extensions/indexing-elasticsearch/src/test/resources/ElasticSearchGeoShapeIndexing.properties ---------------------------------------------------------------------- diff --git a/extensions/indexing-elasticsearch/src/test/resources/ElasticSearchGeoShapeIndexing.properties b/extensions/indexing-elasticsearch/src/test/resources/ElasticSearchGeoShapeIndexing.properties index 3837000..7a20c60 100644 --- a/extensions/indexing-elasticsearch/src/test/resources/ElasticSearchGeoShapeIndexing.properties +++ b/extensions/indexing-elasticsearch/src/test/resources/ElasticSearchGeoShapeIndexing.properties @@ -12,7 +12,7 @@ spatial = { \ Projection=\ { \ ConversionEnabled = true, \ - ConversionAccuracy = 1m, \ + ConversionAccuracy = 2m, \ }, \ }, \ \ @@ -22,7 +22,7 @@ spatial = { \ Projection=\ { \ ConversionEnabled = true, \ - ConversionAccuracy = 1m, \ + ConversionAccuracy = 2m, \ } \ } \ } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/503532e9/libraries/spatial/src/main/java/org/qi4j/library/spatial/assembly/TGeometryAssembler.java ---------------------------------------------------------------------- diff --git a/libraries/spatial/src/main/java/org/qi4j/library/spatial/assembly/TGeometryAssembler.java b/libraries/spatial/src/main/java/org/qi4j/library/spatial/assembly/TGeometryAssembler.java index 178d838..815e198 100644 --- a/libraries/spatial/src/main/java/org/qi4j/library/spatial/assembly/TGeometryAssembler.java +++ b/libraries/spatial/src/main/java/org/qi4j/library/spatial/assembly/TGeometryAssembler.java @@ -28,17 +28,17 @@ import org.qi4j.api.geometry.internal.TLinearRing; import org.qi4j.bootstrap.Assemblers; import org.qi4j.bootstrap.AssemblyException; import org.qi4j.bootstrap.ModuleAssembly; -import org.qi4j.library.spatial.projection.ProjectionsRegistry; +import org.qi4j.library.spatial.projections.ProjectionsRegistry; public class TGeometryAssembler extends Assemblers.VisibilityIdentity<TGeometryAssembler> { - private static final String CRS_EPSG_4326 = "EPSG:4326"; - private static String DEFAULT_CRS = CRS_EPSG_4326; + private static final String CRS_EPSG_4326 = "EPSG:4326"; + private static String DEFAULT_CRS = CRS_EPSG_4326; @Override - public void assemble( ModuleAssembly module ) + public void assemble(ModuleAssembly module) throws AssemblyException { // internal values @@ -69,7 +69,7 @@ public class TGeometryAssembler throw new AssemblyException("Projection CRS " + crs + " invalid."); } - } catch(CRSException _ex) + } catch (CRSException _ex) { throw new AssemblyException("Projection CRS " + crs + " invalid.", _ex); } http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/503532e9/libraries/spatial/src/main/java/org/qi4j/library/spatial/conversions/TConversions.java ---------------------------------------------------------------------- diff --git a/libraries/spatial/src/main/java/org/qi4j/library/spatial/conversions/TConversions.java b/libraries/spatial/src/main/java/org/qi4j/library/spatial/conversions/TConversions.java deleted file mode 100644 index 1037b2d..0000000 --- a/libraries/spatial/src/main/java/org/qi4j/library/spatial/conversions/TConversions.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2014 Jiri Jetmar. - * - * 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.qi4j.library.spatial.conversions; - -import org.qi4j.api.structure.Module; -import org.qi4j.library.spatial.conversions.from.FromHelper; - -public class TConversions { - - public static FromHelper Convert(Module module) - { - return new FromHelper(module); - } -} http://git-wip-us.apache.org/repos/asf/zest-qi4j/blob/503532e9/libraries/spatial/src/main/java/org/qi4j/library/spatial/conversions/from/FromHelper.java ---------------------------------------------------------------------- diff --git a/libraries/spatial/src/main/java/org/qi4j/library/spatial/conversions/from/FromHelper.java b/libraries/spatial/src/main/java/org/qi4j/library/spatial/conversions/from/FromHelper.java deleted file mode 100644 index 3f1d399..0000000 --- a/libraries/spatial/src/main/java/org/qi4j/library/spatial/conversions/from/FromHelper.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright 2014 Jiri Jetmar. - * - * 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.qi4j.library.spatial.conversions.from; - -import org.geojson.GeoJsonObject; -import org.qi4j.api.geometry.internal.TGeometry; -import org.qi4j.api.structure.Module; -import org.qi4j.library.spatial.conversions.to.ToHelper; - - -public class FromHelper { - - private Module module; - - public FromHelper(Module module) - { - this.module = module; - } - - public ToHelper from(TGeometry tGeometry) - { - return new ToHelper(module, new TGeometryFromConverter(module).convert(tGeometry)); - } - - public ToHelper from(GeoJsonObject geoJsonObject) - { - return new ToHelper(module, new GeoJsonFromConverter(module).convert(geoJsonObject)); - - } - - public ToHelper from(String wkt) throws Exception - { - return new ToHelper(module, new WKTFromConverter(module).convert(wkt, null)); - } - - public ToHelper from(String wkt, String crs) throws Exception - { - return new ToHelper(module, new WKTFromConverter(module).convert(wkt, crs)); - } - - private FromHelper() {} -}
