Java Code Examples for org.opengis.feature.type.AttributeDescriptor#getLocalName()
The following examples show how to use
org.opengis.feature.type.AttributeDescriptor#getLocalName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VectorIngestRunner.java From geowave with Apache License 2.0 | 6 votes |
public static void writeScene( final SimpleFeatureType sceneType, final SimpleFeature firstBandOfScene, final Writer sceneWriter) { final SimpleFeatureBuilder bldr = new SimpleFeatureBuilder(sceneType); String fid = null; for (int i = 0; i < sceneType.getAttributeCount(); i++) { final AttributeDescriptor attr = sceneType.getDescriptor(i); final String attrName = attr.getLocalName(); final Object attrValue = firstBandOfScene.getAttribute(attrName); if (attrValue != null) { bldr.set(i, attrValue); if (attrName.equals(SceneFeatureIterator.ENTITY_ID_ATTRIBUTE_NAME)) { fid = attrValue.toString(); } } } if (fid != null) { sceneWriter.write(bldr.buildFeature(fid)); } }
Example 2
Source File: FeatureUtilities.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
public static LinkedHashMap<String, String> feature2AlphanumericToHashmap( SimpleFeature feature ) { LinkedHashMap<String, String> attributes = new LinkedHashMap<>(); List<AttributeDescriptor> attributeDescriptors = feature.getFeatureType().getAttributeDescriptors(); int index = 0; for( AttributeDescriptor attributeDescriptor : attributeDescriptors ) { if (!(attributeDescriptor instanceof GeometryDescriptor)) { String fieldName = attributeDescriptor.getLocalName(); Object attribute = feature.getAttribute(index); if (attribute == null) { attribute = ""; } String value = attribute.toString(); attributes.put(fieldName, value); } index++; } return attributes; }
Example 3
Source File: VectorIngestRunner.java From geowave with Apache License 2.0 | 6 votes |
public static void writeScene( final SimpleFeatureType sceneType, final SimpleFeature firstBandOfScene, final Writer<SimpleFeature> sceneWriter) { final SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(sceneType); String fid = null; for (int i = 0; i < sceneType.getAttributeCount(); i++) { final AttributeDescriptor descriptor = sceneType.getDescriptor(i); final String name = descriptor.getLocalName(); final Object value = firstBandOfScene.getAttribute(name); if (value != null) { featureBuilder.set(i, value); if (name.equals(SceneFeatureIterator.ENTITY_ID_ATTRIBUTE_NAME)) { fid = value.toString(); } } } if (fid != null) { sceneWriter.write(featureBuilder.buildFeature(fid)); } }
Example 4
Source File: FeatureAttributeDimensionField.java From geowave with Apache License 2.0 | 6 votes |
public FeatureAttributeDimensionField( final AttributeDescriptor attributeDescriptor, final Range<Double> range) { super( range == null ? null : new BasicDimensionDefinition(range.getMinimum(), range.getMaximum())); writer = new FeatureAttributeWriterWrapper( (FieldWriter) FieldUtils.getDefaultWriterForClass( attributeDescriptor.getType().getBinding())); reader = new FeatureAttributeReaderWrapper( (FieldReader) FieldUtils.getDefaultReaderForClass( attributeDescriptor.getType().getBinding())); attributeName = attributeDescriptor.getLocalName(); }
Example 5
Source File: NwwUtilities.java From hortonmachine with GNU General Public License v3.0 | 6 votes |
public static LinkedHashMap<String, String> feature2AlphanumericToHashmap( SimpleFeature feature ) { LinkedHashMap<String, String> attributes = new LinkedHashMap<>(); List<AttributeDescriptor> attributeDescriptors = feature.getFeatureType().getAttributeDescriptors(); int index = 0; for( AttributeDescriptor attributeDescriptor : attributeDescriptors ) { if (!(attributeDescriptor instanceof GeometryDescriptor)) { String fieldName = attributeDescriptor.getLocalName(); Object attribute = feature.getAttribute(index); if (attribute == null) { attribute = ""; } String value = attribute.toString(); attributes.put(fieldName, value); } index++; } return attributes; }
Example 6
Source File: VisibilityConfiguration.java From geowave with Apache License 2.0 | 6 votes |
/** * {@inheritDoc} Configure this VisibilityConfiguration object based on the passed in * SimpleFeatureType. This includes setting the 'attributeName' to the attribute that has a key of * 'visiblity'. * * @param persistType - object used to configure this VisibilityConfiguration object */ @Override public void configureFromType(final SimpleFeatureType persistType) { // Search the list of attributes for one that has user data // with a key of 'visibility' and that the value of // it is Boolean.TRUE. If found, set this object's attributeName to // the found attribute. for (final AttributeDescriptor attrDesc : persistType.getAttributeDescriptors()) { if (attrDesc.getUserData().containsKey("visibility") && Boolean.TRUE.equals(attrDesc.getUserData().get("visibility"))) { attributeName = attrDesc.getLocalName(); } } configureManager(persistType); }
Example 7
Source File: FeatureDataAdapter.java From geowave with Apache License 2.0 | 6 votes |
private void initializePositionMaps() { if (positionMapsInitialized) { return; } try { for (int i = 0; i < reprojectedFeatureType.getAttributeCount(); i++) { final AttributeDescriptor ad = reprojectedFeatureType.getDescriptor(i); final String currFieldName = ad.getLocalName(); fieldToPositionMap.forcePut(currFieldName, i); } positionToFieldMap = fieldToPositionMap.inverse(); positionMapsInitialized = true; } catch (final Exception e) { LOGGER.error("Unable to initialize position map, continuing anyways", e); } }
Example 8
Source File: FeatureUtilities.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Find the name of an attribute, case insensitive. * * @param featureType the feature type to check. * @param field the case insensitive field name. * @return the real name of the field, or <code>null</code>, if none found. */ public static String findAttributeName( SimpleFeatureType featureType, String field ) { List<AttributeDescriptor> attributeDescriptors = featureType.getAttributeDescriptors(); for( AttributeDescriptor attributeDescriptor : attributeDescriptors ) { String name = attributeDescriptor.getLocalName(); if (name.toLowerCase().equals(field.toLowerCase())) { return name; } } return null; }
Example 9
Source File: FeatureDataUtils.java From geowave with Apache License 2.0 | 5 votes |
public static String getTimeField(final DataStorePluginOptions dataStore, final String typeName) { final PersistentAdapterStore adapterStore = dataStore.createAdapterStore(); final InternalAdapterStore internalAdapterStore = dataStore.createInternalAdapterStore(); final DataTypeAdapter<?> adapter = adapterStore.getAdapter(internalAdapterStore.getAdapterId(typeName)).getAdapter(); if ((adapter != null) && (adapter instanceof GeotoolsFeatureDataAdapter)) { final GeotoolsFeatureDataAdapter gtAdapter = (GeotoolsFeatureDataAdapter) adapter; final SimpleFeatureType featureType = gtAdapter.getFeatureType(); final TimeDescriptors timeDescriptors = gtAdapter.getTimeDescriptors(); // If not indexed, try to find a time field if ((timeDescriptors == null) || !timeDescriptors.hasTime()) { for (final AttributeDescriptor attrDesc : featureType.getAttributeDescriptors()) { final Class<?> bindingClass = attrDesc.getType().getBinding(); if (TimeUtils.isTemporal(bindingClass)) { return attrDesc.getLocalName(); } } } else { if (timeDescriptors.getTime() != null) { return timeDescriptors.getTime().getLocalName(); } else if (timeDescriptors.getStartRange() != null) { // give back start|stop string return timeDescriptors.getStartRange().getLocalName() + "|" + timeDescriptors.getEndRange().getLocalName(); } } } return null; }
Example 10
Source File: GeoWaveAvroFeatureUtils.java From geowave with Apache License 2.0 | 5 votes |
/** * Add the attributes, types and classifications for the SimpleFeatureType to the provided * FeatureDefinition * * @param fd - existing Feature Definition (or new one if null) * @param sft - SimpleFeatureType of the simpleFeature being serialized * @param defaultClassifications - map of attribute names to classification * @param defaultClassification - default classification if one could not be found in the map * @return the feature definition * @throws IOException */ public static AvroFeatureDefinition buildFeatureDefinition( AvroFeatureDefinition fd, final SimpleFeatureType sft, final Map<String, String> defaultClassifications, final String defaultClassification) throws IOException { if (fd == null) { fd = new AvroFeatureDefinition(); } fd.setFeatureTypeName(sft.getTypeName()); final List<String> attributes = new ArrayList<>(sft.getAttributeCount()); final List<String> types = new ArrayList<>(sft.getAttributeCount()); final List<String> classifications = new ArrayList<>(sft.getAttributeCount()); for (final AttributeDescriptor attr : sft.getAttributeDescriptors()) { final String localName = attr.getLocalName(); attributes.add(localName); types.add(attr.getType().getBinding().getCanonicalName()); classifications.add( getClassification(localName, defaultClassifications, defaultClassification)); } fd.setAttributeNames(attributes); fd.setAttributeTypes(types); fd.setAttributeDefaultClassifications(classifications); return fd; }
Example 11
Source File: ProfilePlotPanel.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private int getAttributeIndex(VectorDataNode pointDataSource, AttributeDescriptor dataField) { final String fieldName = dataField.getLocalName(); if (fieldName.equals(CorrelativeFieldSelector.NULL_NAME)) { return -1; } return pointDataSource.getFeatureType().indexOf(fieldName); }
Example 12
Source File: FeatureMate.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * Getter for the list of attribute names. * * @return the list of attribute names. */ public List<String> getAttributesNames() { SimpleFeatureType featureType = feature.getFeatureType(); List<AttributeDescriptor> attributeDescriptors = featureType.getAttributeDescriptors(); List<String> attributeNames = new ArrayList<String>(); for( AttributeDescriptor attributeDescriptor : attributeDescriptors ) { String name = attributeDescriptor.getLocalName(); attributeNames.add(name); } return attributeNames; }
Example 13
Source File: FeatureUtilities.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
public static String[] featureCollectionFieldNames( SimpleFeatureCollection feature ) { List<String> names = new ArrayList<>(); List<AttributeDescriptor> attributeDescriptors = feature.getSchema().getAttributeDescriptors(); for( AttributeDescriptor attributeDescriptor : attributeDescriptors ) { if (!(attributeDescriptor instanceof GeometryDescriptor)) { String fieldName = attributeDescriptor.getLocalName(); names.add(fieldName); } } return names.toArray(new String[0]); }
Example 14
Source File: FilterToElastic.java From elasticgeo with GNU General Public License v3.0 | 5 votes |
/** * Writes the FilterBuilder for the attribute Expression. * * @param expression the attribute. * */ @Override public Object visit(PropertyName expression, Object extraData) { LOGGER.finest("exporting PropertyName"); SimpleFeatureType featureType = this.featureType; Class<?> target = null; if(extraData instanceof Class) { target = (Class<?>) extraData; } //first evaluate expression against feature type get the attribute, AttributeDescriptor attType = (AttributeDescriptor) expression.evaluate(featureType); String encodedField; if ( attType != null ) { Map<Object, Object> userData = attType.getUserData(); if( userData != null && userData.containsKey("full_name") ) { encodedField = userData.get("full_name").toString(); } else { encodedField = attType.getLocalName(); } if(target != null && target.isAssignableFrom(attType.getType().getBinding())) { // no need for casting, it's already the right type target = null; } } else { // fall back to just encoding the property name encodedField = expression.getPropertyName(); } if (target != null) { LOGGER.fine("PropertyName type casting not implemented"); } field = encodedField; return extraData; }
Example 15
Source File: StatisticChartStyling.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
public static String getCorrelativeDataLabel(VectorDataNode pointDataSource, AttributeDescriptor dataField1) { final String vdsName = pointDataSource.getName(); final String dataFieldName = dataField1.getLocalName(); return vdsName + "/" + dataFieldName; }
Example 16
Source File: FeatureAttributeHandler.java From geowave with Apache License 2.0 | 4 votes |
public FeatureAttributeHandler(final AttributeDescriptor attrDesc) { this.attrDesc = attrDesc; fieldName = attrDesc.getLocalName(); }
Example 17
Source File: ScatterPlotPanel.java From snap-desktop with GNU General Public License v3.0 | 4 votes |
private void initParameters() { final PropertyChangeListener recomputeListener = evt -> computeChartDataIfPossible(); bindingContext.addPropertyChangeListener(RoiMaskSelector.PROPERTY_NAME_USE_ROI_MASK, recomputeListener); bindingContext.addPropertyChangeListener(RoiMaskSelector.PROPERTY_NAME_ROI_MASK, recomputeListener); bindingContext.addPropertyChangeListener(PROPERTY_NAME_BOX_SIZE, recomputeListener); bindingContext.addPropertyChangeListener(PROPERTY_NAME_DATA_FIELD, recomputeListener); final PropertyChangeListener computeLineDataListener = evt -> computeRegressionAndAcceptableDeviationData(); bindingContext.addPropertyChangeListener(PROPERTY_NAME_SHOW_ACCEPTABLE_DEVIATION, computeLineDataListener); bindingContext.addPropertyChangeListener(PROPERTY_NAME_ACCEPTABLE_DEVIATION, computeLineDataListener); bindingContext.addPropertyChangeListener(PROPERTY_NAME_SHOW_REGRESSION_LINE, computeLineDataListener); final PropertyChangeListener rangeLabelUpdateListener = evt -> { final VectorDataNode pointDataSource = scatterPlotModel.pointDataSource; final AttributeDescriptor dataField = scatterPlotModel.dataField; if (dataField != null && pointDataSource != null) { final String dataFieldName = dataField.getLocalName(); getPlot().getDomainAxis().setLabel(dataFieldName); xAxisRangeControl.setTitleSuffix(dataFieldName); } else { getPlot().getDomainAxis().setLabel(""); xAxisRangeControl.setTitleSuffix(""); } }; bindingContext.addPropertyChangeListener(PROPERTY_NAME_DATA_FIELD, rangeLabelUpdateListener); bindingContext.addPropertyChangeListener(PROPERTY_NAME_POINT_DATA_SOURCE, rangeLabelUpdateListener); bindingContext.addPropertyChangeListener(PROPERTY_NAME_X_AXIS_LOG_SCALED, evt -> updateScalingOfXAxis()); bindingContext.addPropertyChangeListener(PROPERTY_NAME_Y_AXIS_LOG_SCALED, evt -> updateScalingOfYAxis()); xAxisRangeControl.getBindingContext().addPropertyChangeListener( evt -> handleAxisRangeControlChanges(evt, xAxisRangeControl, getPlot().getDomainAxis(), xAutoRangeAxisRange)); yAxisRangeControl.getBindingContext().addPropertyChangeListener( evt -> handleAxisRangeControlChanges(evt, yAxisRangeControl, getPlot().getRangeAxis(), yAutoRangeAxisRange)); }
Example 18
Source File: FeatureAttributeDimensionField.java From geowave with Apache License 2.0 | 4 votes |
public FeatureAttributeDimensionField(final AttributeDescriptor attributeDescriptor) { this(attributeDescriptor, null); attributeName = attributeDescriptor.getLocalName(); }
Example 19
Source File: GeoWaveSparkKMeansIT.java From geowave with Apache License 2.0 | 4 votes |
private void queryFeatures(final DataTypeAdapter dataAdapter, final int expectedCount) { final DataStore featureStore = inputDataStore.createDataStore(); int count = 0; try (final CloseableIterator<?> iter = featureStore.query( QueryBuilder.newBuilder().addTypeName(dataAdapter.getTypeName()).indexName( TestUtils.DEFAULT_SPATIAL_INDEX.getName()).build())) { while (iter.hasNext()) { final Object maybeFeat = iter.next(); Assert.assertTrue( "Iterator should return simple feature in this test", maybeFeat instanceof SimpleFeature); final SimpleFeature isFeat = (SimpleFeature) maybeFeat; final Geometry geom = (Geometry) isFeat.getAttribute(0); count++; LOGGER.warn(count + ": " + isFeat.getID() + " - " + geom.toString()); for (final AttributeDescriptor attrDesc : isFeat.getFeatureType().getAttributeDescriptors()) { final Class<?> bindingClass = attrDesc.getType().getBinding(); if (TimeUtils.isTemporal(bindingClass)) { final String timeField = attrDesc.getLocalName(); final Date time = (Date) isFeat.getAttribute(timeField); LOGGER.warn(" time = " + time); } else { LOGGER.warn( attrDesc.getLocalName() + " = " + isFeat.getAttribute(attrDesc.getLocalName())); } } } LOGGER.warn("Counted " + count + " features in datastore for " + dataAdapter.getTypeName()); } catch (final Exception e) { e.printStackTrace(); } Assert.assertTrue( "Iterator should return " + expectedCount + " features in this test", count == expectedCount); }