Search in sources :

Example 1 with LatitudeField

use of org.locationtech.geowave.core.geotime.store.dimension.LatitudeField in project geowave by locationtech.

the class IndexOptimizationUtils method hasAtLeastSpatial.

public static boolean hasAtLeastSpatial(final Index index) {
    if ((index == null) || (index.getIndexModel() == null) || (index.getIndexModel().getDimensions() == null)) {
        return false;
    }
    boolean hasLatitude = false;
    boolean hasLongitude = false;
    for (final NumericDimensionField dimension : index.getIndexModel().getDimensions()) {
        if (dimension instanceof LatitudeField) {
            hasLatitude = true;
        }
        if (dimension instanceof LongitudeField) {
            hasLongitude = true;
        }
        if (dimension instanceof CustomCRSSpatialField) {
            if (((CustomCRSSpatialDimension) dimension.getBaseDefinition()).getAxis() == 0) {
                hasLongitude = true;
            } else {
                hasLatitude = true;
            }
        }
    }
    return hasLatitude && hasLongitude;
}
Also used : NumericDimensionField(org.locationtech.geowave.core.store.dimension.NumericDimensionField) LatitudeField(org.locationtech.geowave.core.geotime.store.dimension.LatitudeField) LongitudeField(org.locationtech.geowave.core.geotime.store.dimension.LongitudeField) CustomCRSSpatialField(org.locationtech.geowave.core.geotime.store.dimension.CustomCRSSpatialField)

Example 2 with LatitudeField

use of org.locationtech.geowave.core.geotime.store.dimension.LatitudeField in project geowave by locationtech.

the class MigrationTest method testLegacySpatialFields.

@Test
public void testLegacySpatialFields() throws NoSuchAuthorityCodeException, FactoryException {
    LegacyLatitudeField latitudeFullRange = new LegacyLatitudeField(4, false);
    byte[] fieldBytes = PersistenceUtils.toBinary(latitudeFullRange);
    latitudeFullRange = (LegacyLatitudeField) PersistenceUtils.fromBinary(fieldBytes);
    LatitudeField updatedLatitudeField = latitudeFullRange.getUpdatedField(null);
    assertEquals(GeometryUtils.getDefaultCRS(), updatedLatitudeField.getCRS());
    assertEquals(SpatialField.DEFAULT_GEOMETRY_FIELD_NAME, updatedLatitudeField.getFieldName());
    assertEquals(180, updatedLatitudeField.getRange(), 0.0001);
    assertEquals(-90, updatedLatitudeField.getFullRange().getMin(), 0.0001);
    assertEquals(90, updatedLatitudeField.getFullRange().getMax(), 0.0001);
    assertEquals(4, (int) updatedLatitudeField.getGeometryPrecision());
    LegacyLatitudeField latitudeHalfRange = new LegacyLatitudeField(4, true);
    fieldBytes = PersistenceUtils.toBinary(latitudeHalfRange);
    latitudeHalfRange = (LegacyLatitudeField) PersistenceUtils.fromBinary(fieldBytes);
    updatedLatitudeField = latitudeHalfRange.getUpdatedField(null);
    assertEquals(GeometryUtils.getDefaultCRS(), updatedLatitudeField.getCRS());
    assertEquals(SpatialField.DEFAULT_GEOMETRY_FIELD_NAME, updatedLatitudeField.getFieldName());
    assertEquals(360, updatedLatitudeField.getRange(), 0.0001);
    assertEquals(-180, updatedLatitudeField.getFullRange().getMin(), 0.0001);
    assertEquals(180, updatedLatitudeField.getFullRange().getMax(), 0.0001);
    assertEquals(4, (int) updatedLatitudeField.getGeometryPrecision());
    LegacyLongitudeField longitudeField = new LegacyLongitudeField(4);
    fieldBytes = PersistenceUtils.toBinary(longitudeField);
    longitudeField = (LegacyLongitudeField) PersistenceUtils.fromBinary(fieldBytes);
    final LongitudeField updatedLongitudeField = longitudeField.getUpdatedField(null);
    assertEquals(GeometryUtils.getDefaultCRS(), updatedLongitudeField.getCRS());
    assertEquals(SpatialField.DEFAULT_GEOMETRY_FIELD_NAME, updatedLongitudeField.getFieldName());
    assertEquals(360, updatedLongitudeField.getRange(), 0.0001);
    assertEquals(-180, updatedLongitudeField.getFullRange().getMin(), 0.0001);
    assertEquals(180, updatedLongitudeField.getFullRange().getMax(), 0.0001);
    assertEquals(4, (int) updatedLongitudeField.getGeometryPrecision());
    final SpatialOptions options = new SpatialOptions();
    options.setCrs("EPSG:3257");
    options.setGeometryPrecision(4);
    final CoordinateReferenceSystem crs = CRS.decode("EPSG:3257", true);
    final Index index = SpatialDimensionalityTypeProvider.createIndexFromOptions(options);
    for (int i = 0; i < crs.getCoordinateSystem().getDimension(); i++) {
        final CoordinateSystemAxis csa = crs.getCoordinateSystem().getAxis(i);
        LegacyCustomCRSSpatialField customCRSField;
        if (i == 0) {
            customCRSField = new LegacyCustomCRSSpatialField(new CustomCRSBoundedSpatialDimensionX(csa.getMinimumValue(), csa.getMaximumValue()), 4);
        } else {
            customCRSField = new LegacyCustomCRSSpatialField(new CustomCRSBoundedSpatialDimensionY(csa.getMinimumValue(), csa.getMaximumValue()), 4);
        }
        fieldBytes = PersistenceUtils.toBinary(customCRSField);
        customCRSField = (LegacyCustomCRSSpatialField) PersistenceUtils.fromBinary(fieldBytes);
        final CustomCRSSpatialField updatedCRSField = customCRSField.getUpdatedField(index);
        assertEquals(crs, updatedCRSField.getCRS());
        assertEquals(SpatialField.DEFAULT_GEOMETRY_FIELD_NAME, updatedCRSField.getFieldName());
        assertEquals(csa.getMaximumValue() - csa.getMinimumValue(), updatedCRSField.getRange(), 0.0001);
        assertEquals(csa.getMinimumValue(), updatedCRSField.getFullRange().getMin(), 0.0001);
        assertEquals(csa.getMaximumValue(), updatedCRSField.getFullRange().getMax(), 0.0001);
        assertEquals(4, (int) updatedCRSField.getGeometryPrecision());
        if (i == 0) {
            assertTrue(CustomCRSBoundedSpatialDimensionX.class.isAssignableFrom(updatedCRSField.getBaseDefinition().getClass()));
        } else {
            assertTrue(CustomCRSBoundedSpatialDimensionY.class.isAssignableFrom(updatedCRSField.getBaseDefinition().getClass()));
        }
    }
}
Also used : LegacyLatitudeField(org.locationtech.geowave.migration.legacy.core.geotime.LegacyLatitudeField) LegacyLongitudeField(org.locationtech.geowave.migration.legacy.core.geotime.LegacyLongitudeField) CoordinateSystemAxis(org.opengis.referencing.cs.CoordinateSystemAxis) Index(org.locationtech.geowave.core.store.api.Index) LegacyLongitudeField(org.locationtech.geowave.migration.legacy.core.geotime.LegacyLongitudeField) LongitudeField(org.locationtech.geowave.core.geotime.store.dimension.LongitudeField) SpatialOptions(org.locationtech.geowave.core.geotime.index.SpatialOptions) CustomCRSSpatialField(org.locationtech.geowave.core.geotime.store.dimension.CustomCRSSpatialField) LegacyCustomCRSSpatialField(org.locationtech.geowave.migration.legacy.core.geotime.LegacyCustomCRSSpatialField) Point(org.locationtech.jts.geom.Point) LegacyLatitudeField(org.locationtech.geowave.migration.legacy.core.geotime.LegacyLatitudeField) LatitudeField(org.locationtech.geowave.core.geotime.store.dimension.LatitudeField) CustomCRSBoundedSpatialDimensionX(org.locationtech.geowave.core.geotime.store.dimension.CustomCRSBoundedSpatialDimensionX) CustomCRSBoundedSpatialDimensionY(org.locationtech.geowave.core.geotime.store.dimension.CustomCRSBoundedSpatialDimensionY) CoordinateReferenceSystem(org.opengis.referencing.crs.CoordinateReferenceSystem) LegacyCustomCRSSpatialField(org.locationtech.geowave.migration.legacy.core.geotime.LegacyCustomCRSSpatialField) Test(org.junit.Test)

Aggregations

CustomCRSSpatialField (org.locationtech.geowave.core.geotime.store.dimension.CustomCRSSpatialField)2 LatitudeField (org.locationtech.geowave.core.geotime.store.dimension.LatitudeField)2 LongitudeField (org.locationtech.geowave.core.geotime.store.dimension.LongitudeField)2 Test (org.junit.Test)1 SpatialOptions (org.locationtech.geowave.core.geotime.index.SpatialOptions)1 CustomCRSBoundedSpatialDimensionX (org.locationtech.geowave.core.geotime.store.dimension.CustomCRSBoundedSpatialDimensionX)1 CustomCRSBoundedSpatialDimensionY (org.locationtech.geowave.core.geotime.store.dimension.CustomCRSBoundedSpatialDimensionY)1 Index (org.locationtech.geowave.core.store.api.Index)1 NumericDimensionField (org.locationtech.geowave.core.store.dimension.NumericDimensionField)1 LegacyCustomCRSSpatialField (org.locationtech.geowave.migration.legacy.core.geotime.LegacyCustomCRSSpatialField)1 LegacyLatitudeField (org.locationtech.geowave.migration.legacy.core.geotime.LegacyLatitudeField)1 LegacyLongitudeField (org.locationtech.geowave.migration.legacy.core.geotime.LegacyLongitudeField)1 Point (org.locationtech.jts.geom.Point)1 CoordinateReferenceSystem (org.opengis.referencing.crs.CoordinateReferenceSystem)1 CoordinateSystemAxis (org.opengis.referencing.cs.CoordinateSystemAxis)1