use of org.locationtech.geowave.core.index.dimension.NumericDimensionDefinition in project geowave by locationtech.
the class SpatialDimensionalityTypeProvider method createIndexFromOptions.
public static Index createIndexFromOptions(final SpatialOptions options) {
NumericDimensionDefinition[] dimensions;
boolean isDefaultCRS;
String crsCode = null;
NumericDimensionField<?>[] fields = null;
NumericDimensionField<?>[] fields_temporal = null;
final Integer geometryPrecision = options.getGeometryPrecision();
if ((options.crs == null) || options.crs.isEmpty() || options.crs.equalsIgnoreCase(GeometryUtils.DEFAULT_CRS_STR)) {
dimensions = SPATIAL_DIMENSIONS;
fields = getSpatialFields(geometryPrecision);
isDefaultCRS = true;
crsCode = "EPSG:4326";
} else {
final CoordinateReferenceSystem crs = GeometryUtils.decodeCRS(options.crs);
final CoordinateSystem cs = crs.getCoordinateSystem();
isDefaultCRS = false;
crsCode = options.crs;
dimensions = new NumericDimensionDefinition[cs.getDimension()];
if (options.storeTime) {
fields_temporal = new NumericDimensionField[dimensions.length + 1];
for (int d = 0; d < dimensions.length; d++) {
final CoordinateSystemAxis csa = cs.getAxis(d);
if (!isUnbounded(csa)) {
dimensions[d] = new CustomCRSBoundedSpatialDimension((byte) d, csa.getMinimumValue(), csa.getMaximumValue());
fields_temporal[d] = new CustomCRSSpatialField((CustomCRSBoundedSpatialDimension) dimensions[d], geometryPrecision, crs);
} else {
dimensions[d] = new CustomCRSUnboundedSpatialDimension(DEFAULT_UNBOUNDED_CRS_INTERVAL, (byte) d);
fields_temporal[d] = new CustomCRSSpatialField((CustomCRSUnboundedSpatialDimension) dimensions[d], geometryPrecision, crs);
}
}
fields_temporal[dimensions.length] = new TimeField(Unit.YEAR);
} else {
fields = new NumericDimensionField[dimensions.length];
for (int d = 0; d < dimensions.length; d++) {
final CoordinateSystemAxis csa = cs.getAxis(d);
if (!isUnbounded(csa)) {
if (d == 0) {
dimensions[d] = new CustomCRSBoundedSpatialDimensionX(csa.getMinimumValue(), csa.getMaximumValue());
fields[d] = new CustomCRSSpatialField((CustomCRSBoundedSpatialDimensionX) dimensions[d], geometryPrecision, crs);
}
if (d == 1) {
dimensions[d] = new CustomCRSBoundedSpatialDimensionY(csa.getMinimumValue(), csa.getMaximumValue());
fields[d] = new CustomCRSSpatialField((CustomCRSBoundedSpatialDimensionY) dimensions[d], geometryPrecision, crs);
}
} else {
if (d == 0) {
dimensions[d] = new CustomCRSUnboundedSpatialDimensionX(DEFAULT_UNBOUNDED_CRS_INTERVAL, (byte) d);
fields[d] = new CustomCRSSpatialField((CustomCRSUnboundedSpatialDimensionX) dimensions[d], geometryPrecision, crs);
}
if (d == 1) {
dimensions[d] = new CustomCRSUnboundedSpatialDimensionY(DEFAULT_UNBOUNDED_CRS_INTERVAL, (byte) d);
fields[d] = new CustomCRSSpatialField((CustomCRSUnboundedSpatialDimensionY) dimensions[d], geometryPrecision, crs);
}
}
}
}
}
BasicIndexModel indexModel = null;
if (isDefaultCRS) {
indexModel = new BasicIndexModel(options.storeTime ? getSpatialTemporalFields(geometryPrecision) : getSpatialFields(geometryPrecision));
} else {
indexModel = new CustomCrsIndexModel(options.storeTime ? fields_temporal : fields, crsCode);
}
return new CustomNameIndex(XZHierarchicalIndexFactory.createFullIncrementalTieredStrategy(dimensions, new int[] { // flexible enough to handle n-dimensions
LONGITUDE_BITS, LATITUDE_BITS }, SFCType.HILBERT), indexModel, // TODO append CRS code to ID if its overridden
isDefaultCRS ? (options.storeTime ? DEFAULT_SPATIAL_ID + "_TIME" : DEFAULT_SPATIAL_ID) : (options.storeTime ? DEFAULT_SPATIAL_ID + "_TIME" : DEFAULT_SPATIAL_ID) + "_" + crsCode.substring(crsCode.indexOf(":") + 1));
}
use of org.locationtech.geowave.core.index.dimension.NumericDimensionDefinition in project geowave by locationtech.
the class SpatialDimensionalityTypeProvider method isSpatial.
public static boolean isSpatial(final NumericIndexStrategy indexStrategy) {
if ((indexStrategy == null) || (indexStrategy.getOrderedDimensionDefinitions() == null)) {
return false;
}
final NumericDimensionDefinition[] dimensions = indexStrategy.getOrderedDimensionDefinitions();
if (dimensions.length < 2) {
return false;
}
boolean hasLat = false, hasLon = false;
for (final NumericDimensionDefinition definition : dimensions) {
if (SpatialIndexUtils.isLatitudeDimension(definition)) {
hasLat = true;
} else if (SpatialIndexUtils.isLongitudeDimension(definition)) {
hasLon = true;
}
}
return hasLat && hasLon;
}
use of org.locationtech.geowave.core.index.dimension.NumericDimensionDefinition in project geowave by locationtech.
the class TemporalDimensionalityTypeProvider method createIndexFromOptions.
public static Index createIndexFromOptions(final TemporalOptions options) {
if (!options.noTimeRanges) {
final NumericDimensionDefinition[] dimensions = TEMPORAL_DIMENSIONS;
final NumericDimensionField<?>[] fields = TEMPORAL_FIELDS;
dimensions[dimensions.length - 1] = new TimeDefinition(options.periodicity);
fields[dimensions.length - 1] = new TimeField(options.periodicity);
final BasicIndexModel indexModel = new BasicIndexModel(fields);
final String combinedArrayID = DEFAULT_TEMPORAL_ID_STR + "_" + options.periodicity;
return new CustomNameIndex(XZHierarchicalIndexFactory.createFullIncrementalTieredStrategy(dimensions, new int[] { 63 }, SFCType.HILBERT, options.maxDuplicates), indexModel, combinedArrayID);
}
final BasicIndexModel indexModel = new BasicIndexModel(new NumericDimensionField[] { new BasicNumericDimensionField<>(TimeField.DEFAULT_FIELD_ID, Long.class) });
return new CustomNameIndex(new SimpleTimeIndexStrategy(), indexModel, DEFAULT_TEMPORAL_ID_STR);
}
use of org.locationtech.geowave.core.index.dimension.NumericDimensionDefinition in project geowave by locationtech.
the class GeometryUtils method basicConstraintSetFromEnvelope.
/**
* This utility method will convert a JTS envelope to contraints that can be used in a GeoWave
* query.
*
* @return Constraints as a mapping of NumericData objects representing ranges for a latitude
* dimension and a longitude dimension
*/
public static ConstraintSet basicConstraintSetFromEnvelope(final Envelope env) {
// Create a NumericRange object using the x axis
final NumericRange rangeLongitude = new NumericRange(env.getMinX(), env.getMaxX());
// Create a NumericRange object using the y axis
final NumericRange rangeLatitude = new NumericRange(env.getMinY(), env.getMaxY());
final Map<Class<? extends NumericDimensionDefinition>, ConstraintData> constraintsPerDimension = new HashMap<>();
// Create and return a new IndexRange array with an x and y axis
// range
final ConstraintData xRange = new ConstraintData(rangeLongitude, false);
final ConstraintData yRange = new ConstraintData(rangeLatitude, false);
constraintsPerDimension.put(CustomCRSUnboundedSpatialDimensionX.class, xRange);
constraintsPerDimension.put(CustomCRSUnboundedSpatialDimensionY.class, yRange);
constraintsPerDimension.put(CustomCRSBoundedSpatialDimensionX.class, xRange);
constraintsPerDimension.put(CustomCRSBoundedSpatialDimensionY.class, yRange);
constraintsPerDimension.put(LongitudeDefinition.class, xRange);
constraintsPerDimension.put(LatitudeDefinition.class, yRange);
return new ConstraintSet(constraintsPerDimension);
}
use of org.locationtech.geowave.core.index.dimension.NumericDimensionDefinition in project geowave by locationtech.
the class GeometryUtils method basicConstraintsFromPoint.
/**
* This utility method will convert a JTS envelope to that can be used in a GeoWave query.
*
* @return Constraints as a mapping of NumericData objects representing ranges for a latitude
* dimension and a longitude dimension
*/
public static ConstraintSet basicConstraintsFromPoint(final double latitudeDegrees, final double longitudeDegrees) {
// Create a NumericData object using the x axis
final NumericData latitude = new NumericValue(latitudeDegrees);
// Create a NumericData object using the y axis
final NumericData longitude = new NumericValue(longitudeDegrees);
final Map<Class<? extends NumericDimensionDefinition>, ConstraintData> constraintsPerDimension = new HashMap<>();
// Create and return a new IndexRange array with an x and y axis
// range
constraintsPerDimension.put(LongitudeDefinition.class, new ConstraintData(longitude, false));
constraintsPerDimension.put(LatitudeDefinition.class, new ConstraintData(latitude, false));
return new ConstraintSet(constraintsPerDimension);
}
Aggregations