Search in sources :

Example 1 with TemporalFieldDescriptorBuilder

use of org.locationtech.geowave.core.geotime.adapter.TemporalFieldDescriptorBuilder in project geowave by locationtech.

the class FeatureDataAdapter method initializeFieldDescriptors.

private void initializeFieldDescriptors() {
    final List<AttributeDescriptor> attributes = featureType.getAttributeDescriptors();
    fieldDescriptors = new FieldDescriptor[attributes.size()];
    for (int i = 0; i < attributes.size(); i++) {
        final AttributeDescriptor attribute = attributes.get(i);
        if (attribute instanceof GeometryDescriptor) {
            final SpatialFieldDescriptorBuilder<?> builder = new SpatialFieldDescriptorBuilder<>(attribute.getType().getBinding());
            builder.fieldName(attribute.getName().getLocalPart());
            builder.crs(((GeometryDescriptor) attribute).getCoordinateReferenceSystem());
            if ((featureType.getGeometryDescriptor() != null) && featureType.getGeometryDescriptor().equals(attribute)) {
                builder.spatialIndexHint();
            }
            fieldDescriptors[i] = builder.build();
        } else if ((timeDescriptors != null) && attribute.equals(timeDescriptors.getTime())) {
            fieldDescriptors[i] = new TemporalFieldDescriptorBuilder<>(attribute.getType().getBinding()).fieldName(attribute.getName().getLocalPart()).timeIndexHint().build();
        } else if ((timeDescriptors != null) && attribute.equals(timeDescriptors.getStartRange())) {
            fieldDescriptors[i] = new TemporalFieldDescriptorBuilder<>(attribute.getType().getBinding()).fieldName(attribute.getName().getLocalPart()).startTimeIndexHint().build();
        } else if ((timeDescriptors != null) && attribute.equals(timeDescriptors.getEndRange())) {
            fieldDescriptors[i] = new TemporalFieldDescriptorBuilder<>(attribute.getType().getBinding()).fieldName(attribute.getName().getLocalPart()).endTimeIndexHint().build();
        } else {
            fieldDescriptors[i] = new FieldDescriptorBuilder<>(attribute.getType().getBinding()).fieldName(attribute.getName().getLocalPart()).build();
        }
    }
    // this assumes attribute names are unique, which *should* be a fair assumption
    descriptorsMap = Arrays.stream(fieldDescriptors).collect(Collectors.toMap(FieldDescriptor::fieldName, descriptor -> descriptor));
}
Also used : GeometryDescriptor(org.opengis.feature.type.GeometryDescriptor) TemporalFieldDescriptorBuilder(org.locationtech.geowave.core.geotime.adapter.TemporalFieldDescriptorBuilder) SpatialFieldDescriptorBuilder(org.locationtech.geowave.core.geotime.adapter.SpatialFieldDescriptorBuilder) AttributeDescriptor(org.opengis.feature.type.AttributeDescriptor) TemporalFieldDescriptorBuilder(org.locationtech.geowave.core.geotime.adapter.TemporalFieldDescriptorBuilder) SpatialFieldDescriptorBuilder(org.locationtech.geowave.core.geotime.adapter.SpatialFieldDescriptorBuilder) FieldDescriptorBuilder(org.locationtech.geowave.core.store.adapter.FieldDescriptorBuilder) FieldDescriptor(org.locationtech.geowave.core.store.adapter.FieldDescriptor) SpatialFieldDescriptor(org.locationtech.geowave.core.geotime.adapter.SpatialFieldDescriptor)

Example 2 with TemporalFieldDescriptorBuilder

use of org.locationtech.geowave.core.geotime.adapter.TemporalFieldDescriptorBuilder in project geowave by locationtech.

the class TemporalAnnotatedFieldDescriptorBuilder method buildFieldDescriptor.

@Override
public FieldDescriptor<?> buildFieldDescriptor(Field field) {
    if (field.isAnnotationPresent(GeoWaveTemporalField.class)) {
        final GeoWaveTemporalField fieldAnnotation = field.getAnnotation(GeoWaveTemporalField.class);
        final String fieldName;
        if (fieldAnnotation.name().isEmpty()) {
            fieldName = field.getName();
        } else {
            fieldName = fieldAnnotation.name();
        }
        final String[] indexHints = fieldAnnotation.indexHints();
        final TemporalFieldDescriptorBuilder<?> builder = new TemporalFieldDescriptorBuilder<>(BasicDataTypeAdapter.normalizeClass(field.getType()));
        for (final String hint : indexHints) {
            builder.indexHint(new IndexDimensionHint(hint));
        }
        if (fieldAnnotation.timeIndexHint()) {
            builder.timeIndexHint();
        }
        if (fieldAnnotation.startTimeIndexHint()) {
            builder.startTimeIndexHint();
        }
        if (fieldAnnotation.endTimeIndexHint()) {
            builder.endTimeIndexHint();
        }
        return builder.fieldName(fieldName).build();
    }
    throw new RuntimeException("Field is missing GeoWaveTemporalField annotation.");
}
Also used : TemporalFieldDescriptorBuilder(org.locationtech.geowave.core.geotime.adapter.TemporalFieldDescriptorBuilder) IndexDimensionHint(org.locationtech.geowave.core.index.IndexDimensionHint)

Aggregations

TemporalFieldDescriptorBuilder (org.locationtech.geowave.core.geotime.adapter.TemporalFieldDescriptorBuilder)2 SpatialFieldDescriptor (org.locationtech.geowave.core.geotime.adapter.SpatialFieldDescriptor)1 SpatialFieldDescriptorBuilder (org.locationtech.geowave.core.geotime.adapter.SpatialFieldDescriptorBuilder)1 IndexDimensionHint (org.locationtech.geowave.core.index.IndexDimensionHint)1 FieldDescriptor (org.locationtech.geowave.core.store.adapter.FieldDescriptor)1 FieldDescriptorBuilder (org.locationtech.geowave.core.store.adapter.FieldDescriptorBuilder)1 AttributeDescriptor (org.opengis.feature.type.AttributeDescriptor)1 GeometryDescriptor (org.opengis.feature.type.GeometryDescriptor)1