Search in sources :

Example 1 with FieldDescriptorBuilder

use of org.locationtech.geowave.core.store.adapter.FieldDescriptorBuilder 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 FieldDescriptorBuilder

use of org.locationtech.geowave.core.store.adapter.FieldDescriptorBuilder in project geowave by locationtech.

the class BaseAnnotatedFieldDescriptorBuilder method buildFieldDescriptor.

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

Aggregations

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