Skip to content

Issue with non-spatial indexing and custom CRS spatial index #1756

@rfecher

Description

@rfecher

From gitter:

        SpatialIndexBuilder spIdxBldr = new SpatialIndexBuilder();
        spIdxBldr.setCrs("EPSG:32636");
        spatialIndex = spIdxBldr.createIndex();

        TemporalIndexBuilder tmpIdxBldr = new TemporalIndexBuilder();
        tmpIdxBldr.setName("TEMPORAL_IDX");
        tmpIdxBldr.setPeriodicity(TemporalBinningStrategy.Unit.HOUR);
        temporalIndex = tmpIdxBldr.createIndex();

       dataStore.addIndex(spatialIndex);
       dataStore.addIndex(temporalIndex);

       dataStore.addType(sfAdapter, spatialIndex,temporalIndex);

25 Oct 12:33:01 ERROR [vector.FeatureDataAdapter] - Multiple indices with different CRS is not supported
Exception in thread "main" java.lang.RuntimeException: Multiple indices with different CRS is not supported
at org.locationtech.geowave.adapter.vector.FeatureDataAdapter.init(FeatureDataAdapter.java:241)
at org.locationtech.geowave.core.store.base.BaseDataStore.internalAddIndices(BaseDataStore.java:1142)
at org.locationtech.geowave.core.store.base.BaseDataStore.addType(BaseDataStore.java:1167)
at com.uasis.geowaveapi.Geowave.ingestFromFile(Geowave.java:95)
at com.uasis.geowaveapi.Geowave.main(Geowave.java:82)

Muhammed Kalkan @Nymria Oct 25 06:11
Seems there is something wrong in FeatureDataAdapter.java:241

public boolean init(final Index... indices) throws RuntimeException {
    String indexCrsCode =
        reprojectedFeatureType == null ? null
            : GeometryUtils.getCrsCode(reprojectedFeatureType.getCoordinateReferenceSystem());
    for (final Index primaryindx : indices) {
      // for first iteration
      if (indexCrsCode == null) {
        if (primaryindx.getIndexModel() instanceof CustomCrsIndexModel) {
          indexCrsCode = ((CustomCrsIndexModel) primaryindx.getIndexModel()).getCrsCode();
        } else {
          indexCrsCode = GeometryUtils.DEFAULT_CRS_STR;
        }
      } else {
        if (primaryindx.getIndexModel() instanceof CustomCrsIndexModel) {
          // check if indexes have different CRS
          if (!indexCrsCode.equals(
              ((CustomCrsIndexModel) primaryindx.getIndexModel()).getCrsCode())) {
            LOGGER.error("Multiple indices with different CRS is not supported");
            throw new RuntimeException("Multiple indices with different CRS is not supported");
          }
        } else {
          if (!indexCrsCode.equals(GeometryUtils.DEFAULT_CRS_STR)) {
            LOGGER.error("Multiple indices with different CRS is not supported");
            throw new RuntimeException("Multiple indices with different CRS is not supported");
          }
        }
      }
    }

First index is Spatial. First iteration gets EPSG:32636 as indexCrsCode successfully. Second iteration it gets Temporal Index, which is not a CustomCrsIndexModel . Falls directly to DEAFULT_CRS_STR check and errors out.
There it checks first index, which is spatial, has the default CRS.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions