Java Code Examples for org.opengis.feature.simple.SimpleFeatureType#getAttributeDescriptors()
The following examples show how to use
org.opengis.feature.simple.SimpleFeatureType#getAttributeDescriptors() .
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: FeatureDataUtils.java From geowave with Apache License 2.0 | 6 votes |
public static SimpleFeature buildFeature( final SimpleFeatureType featureType, final Pair<String, Object>[] entries) { final List<AttributeDescriptor> descriptors = featureType.getAttributeDescriptors(); final Object[] defaults = new Object[descriptors.size()]; int p = 0; for (final AttributeDescriptor descriptor : descriptors) { defaults[p++] = descriptor.getDefaultValue(); } final SimpleFeature newFeature = SimpleFeatureBuilder.build(featureType, defaults, UUID.randomUUID().toString()); for (final Pair<String, Object> entry : entries) { newFeature.setAttribute(entry.getKey(), entry.getValue()); } return newFeature; }
Example 2
Source File: GeoToolsConverterServiceImpl.java From geomajas-project-server with GNU Affero General Public License v3.0 | 6 votes |
@Override public SimpleFeature toSimpleFeature(InternalFeature feature, SimpleFeatureType featureType) { SimpleFeatureBuilder builder = new SimpleFeatureBuilder(featureType); List<Object> attr = new ArrayList<Object>(); for (AttributeDescriptor ads : featureType.getAttributeDescriptors()) { if (!ads.equals(featureType.getGeometryDescriptor())) { Attribute a = feature.getAttributes().get(ads.getName().getLocalPart()); if (null != a) { attr.add(a.getValue()); } else { attr.add(null); } } else { attr.add(feature.getGeometry()); } } return builder.buildFeature(feature.getId(), attr.toArray()); }
Example 3
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 4
Source File: SimpleFeatureCentroidExractorTest.java From geowave with Apache License 2.0 | 6 votes |
@Test public void test() throws SchemaException { final SimpleFeatureType schema = DataUtilities.createType("testGeo", "location:Point:srid=4326,name:String"); final List<AttributeDescriptor> descriptors = schema.getAttributeDescriptors(); final Object[] defaults = new Object[descriptors.size()]; int p = 0; for (final AttributeDescriptor descriptor : descriptors) { defaults[p++] = descriptor.getDefaultValue(); } final SimpleFeature feature = SimpleFeatureBuilder.build(schema, defaults, UUID.randomUUID().toString()); final GeometryFactory geoFactory = new GeometryFactory(); feature.setAttribute("location", geoFactory.createPoint(new Coordinate(-45, 45))); final Point point = extractor.getCentroid(feature); assertEquals(4326, point.getSRID()); }
Example 5
Source File: CentroidManagerGeoWave.java From geowave with Apache License 2.0 | 6 votes |
private static SimpleFeatureType createFeatureType( final SimpleFeatureType featureType, final Class<? extends Geometry> shapeClass) { try { final SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.setName(featureType.getName().getLocalPart()); builder.setNamespaceURI(featureType.getName().getNamespaceURI()); builder.setCRS(featureType.getCoordinateReferenceSystem()); for (final AttributeDescriptor attr : featureType.getAttributeDescriptors()) { if (attr.getType() instanceof GeometryType) { builder.add(attr.getLocalName(), shapeClass); } else { builder.add(attr.getLocalName(), attr.getType().getBinding()); } } return builder.buildFeatureType(); } catch (final Exception e) { LOGGER.warn("Schema Creation Error. Hint: Check the SRID.", e); } return null; }
Example 6
Source File: ExportGeometryAction.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
static SimpleFeatureType changeGeometryType(SimpleFeatureType original, Class<?> geometryType) { SimpleFeatureTypeBuilder sftb = new SimpleFeatureTypeBuilder(); sftb.setCRS(original.getCoordinateReferenceSystem()); sftb.setDefaultGeometry(original.getGeometryDescriptor().getLocalName()); boolean defaultGeometryAdded = false; for (AttributeDescriptor descriptor : original.getAttributeDescriptors()) { if (original.getGeometryDescriptor().getLocalName().equals(descriptor.getLocalName())) { sftb.add(descriptor.getLocalName(), geometryType); defaultGeometryAdded = true; }else { sftb.add(descriptor); } } if(!defaultGeometryAdded) { sftb.add(original.getGeometryDescriptor().getLocalName(), geometryType); } sftb.setName("FT_" + geometryType.getSimpleName()); return sftb.buildFeatureType(); }
Example 7
Source File: FeatureSerializationTest.java From geowave with Apache License 2.0 | 5 votes |
@Test public void test() throws SchemaException { final Kryo kryo = new Kryo(); kryo.register(SimpleFeatureImpl.class, new FeatureSerializer()); final SimpleFeatureType schema = DataUtilities.createType("testGeo", "location:Point:srid=4326,name:String"); final List<AttributeDescriptor> descriptors = schema.getAttributeDescriptors(); final Object[] defaults = new Object[descriptors.size()]; int p = 0; for (final AttributeDescriptor descriptor : descriptors) { defaults[p++] = descriptor.getDefaultValue(); } final SimpleFeature feature = SimpleFeatureBuilder.build(schema, defaults, UUID.randomUUID().toString()); final GeometryFactory geoFactory = new GeometryFactory(); feature.setAttribute("location", geoFactory.createPoint(new Coordinate(-45, 45))); final Output output = new OutputChunked(); kryo.getSerializer(SimpleFeatureImpl.class).write(kryo, output, feature); final Input input = new InputChunked(); input.setBuffer(output.getBuffer()); final SimpleFeature f2 = (SimpleFeature) kryo.getSerializer(SimpleFeatureImpl.class).read( kryo, input, SimpleFeatureImpl.class); assertEquals(feature, f2); }
Example 8
Source File: StatsConfigurationCollection.java From geowave with Apache License 2.0 | 5 votes |
@Override public void configureFromType(final SimpleFeatureType type) { for (final AttributeDescriptor descriptor : type.getAttributeDescriptors()) { if (descriptor.getUserData().containsKey("stats")) { final Object configObj = descriptor.getUserData().get("stats"); if (!(configObj instanceof StatsConfigurationCollection)) { LOGGER.error("Invalid entry stats entry for " + descriptor.getLocalName()); continue; } attConfig.put(descriptor.getLocalName(), (StatsConfigurationCollection) configObj); } } }
Example 9
Source File: FeatureDataAdapter.java From geowave with Apache License 2.0 | 5 votes |
/** * Create List of NativeFieldHandlers based on the SimpleFeature type passed as parameter. * * @param featureType - SFT to be used to determine handlers * @return List of NativeFieldHandlers that correspond to attributes in featureType */ protected List<NativeFieldHandler<SimpleFeature, Object>> getFieldHandlersFromFeatureType( final SimpleFeatureType featureType) { final List<NativeFieldHandler<SimpleFeature, Object>> nativeHandlers = new ArrayList<>(featureType.getAttributeCount()); for (final AttributeDescriptor attrDesc : featureType.getAttributeDescriptors()) { nativeHandlers.add(new FeatureAttributeHandler(attrDesc)); } return nativeHandlers; }
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: 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 12
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 13
Source File: FeatureExtender.java From hortonmachine with GNU General Public License v3.0 | 5 votes |
/** * @param oldFeatureType the {@link FeatureType} of the existing features. * @param fieldArray the list of the names of new fields. * @param classesArray the list of classes of the new fields. * @throws FactoryRegistryException * @throws SchemaException */ public FeatureExtender( SimpleFeatureType oldFeatureType, String[] fieldArray, Class<?>[] classesArray ) throws FactoryRegistryException, SchemaException { List<AttributeDescriptor> oldAttributeDescriptors = oldFeatureType .getAttributeDescriptors(); List<AttributeDescriptor> addedAttributeDescriptors = new ArrayList<AttributeDescriptor>(); for( int i = 0; i < fieldArray.length; i++ ) { AttributeTypeBuilder build = new AttributeTypeBuilder(); build.setNillable(true); build.setBinding(classesArray[i]); AttributeDescriptor descriptor = build.buildDescriptor(fieldArray[i]); addedAttributeDescriptors.add(descriptor); } List<AttributeDescriptor> newAttributesTypesList = new ArrayList<AttributeDescriptor>(); for( AttributeDescriptor attributeDescriptor : oldAttributeDescriptors ) { newAttributesTypesList.add(attributeDescriptor); } newAttributesTypesList.addAll(addedAttributeDescriptors); // create the feature type SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); b.setName(oldFeatureType.getName()); b.setCRS(oldFeatureType.getCoordinateReferenceSystem()); b.addAll(newAttributesTypesList); newFeatureType = b.buildFeatureType(); }
Example 14
Source File: SLDEditorBufferedImageLegendGraphicBuilder.java From sldeditor with GNU General Public License v3.0 | 5 votes |
/** * Clones the given schema, changing the geometry attribute to match the given dimensionality. * * @param schema schema to clone * @param dimensionality dimensionality for the geometry 1= points, 2= lines, 3= polygons */ private FeatureType cloneWithDimensionality(FeatureType schema, int dimensionality) { SimpleFeatureType simpleFt = (SimpleFeatureType) schema; SimpleFeatureTypeBuilder builder = new SimpleFeatureTypeBuilder(); builder.setName(schema.getName()); builder.setCRS(schema.getCoordinateReferenceSystem()); for (AttributeDescriptor desc : simpleFt.getAttributeDescriptors()) { if (isMixedGeometry(desc)) { GeometryDescriptor geomDescriptor = (GeometryDescriptor) desc; GeometryType geomType = geomDescriptor.getType(); Class<?> geometryClass = getGeometryForDimensionality(dimensionality); GeometryType gt = new GeometryTypeImpl( geomType.getName(), geometryClass, geomType.getCoordinateReferenceSystem(), geomType.isIdentified(), geomType.isAbstract(), geomType.getRestrictions(), geomType.getSuper(), geomType.getDescription()); builder.add( new GeometryDescriptorImpl( gt, geomDescriptor.getName(), geomDescriptor.getMinOccurs(), geomDescriptor.getMaxOccurs(), geomDescriptor.isNillable(), geomDescriptor.getDefaultValue())); } else { builder.add(desc); } } schema = builder.buildFeatureType(); return schema; }
Example 15
Source File: GeoToolsLayerBeanFactory.java From geomajas-project-server with GNU Affero General Public License v3.0 | 4 votes |
private void setFeatureInfo(VectorLayerInfo info, SimpleFeatureType schema) { FeatureInfo featureInfo = new FeatureInfo(); GeometryAttributeInfo geomInfo = new GeometryAttributeInfo(); geomInfo.setEditable(true); geomInfo.setName(schema.getGeometryDescriptor().getLocalName()); featureInfo.setGeometryType(geomInfo); featureInfo.setDataSourceName(schema.getTypeName()); List<AttributeDescriptor> attrs = schema.getAttributeDescriptors(); for (AttributeDescriptor attributeDescriptor : attrs) { if (attributeDescriptor != schema.getGeometryDescriptor()) { Class<?> binding = attributeDescriptor.getType().getBinding(); PrimitiveAttributeInfo attrInfo = new PrimitiveAttributeInfo(); if (binding == Boolean.class) { attrInfo.setType(PrimitiveType.BOOLEAN); } else if (binding == Short.class) { attrInfo.setType(PrimitiveType.SHORT); } else if (binding == Integer.class) { attrInfo.setType(PrimitiveType.INTEGER); } else if (binding == Long.class) { attrInfo.setType(PrimitiveType.LONG); } else if (binding == Float.class) { attrInfo.setType(PrimitiveType.FLOAT); } else if (binding == Double.class) { attrInfo.setType(PrimitiveType.DOUBLE); } else if (binding == Date.class) { attrInfo.setType(PrimitiveType.DATE); } else if (binding == String.class) { attrInfo.setType(PrimitiveType.STRING); } attrInfo.setEditable(true); attrInfo.setIdentifying(attributeDescriptor.getType().isIdentified()); attrInfo.setLabel(attributeDescriptor.getLocalName()); attrInfo.setName(attributeDescriptor.getLocalName()); if (attributeDescriptor.getType().isIdentified() && featureInfo.getIdentifier() == null) { featureInfo.setIdentifier(attrInfo); } else { featureInfo.getAttributes().add(attrInfo); } } } info.setFeatureInfo(featureInfo); }
Example 16
Source File: ElasticFeatureReader.java From elasticgeo with GNU General Public License v3.0 | 4 votes |
private String nextHit() { final ElasticHit hit = searchHitIterator.next(); final SimpleFeatureType type = getFeatureType(); final Map<String, Object> source = hit.getSource(); final Float score; final Float relativeScore; if (hit.getScore() != null && !Float.isNaN(hit.getScore()) && maxScore>0) { score = hit.getScore(); relativeScore = score / maxScore; } else { score = null; relativeScore = null; } for (final AttributeDescriptor descriptor : type.getAttributeDescriptors()) { final String name = descriptor.getType().getName().getLocalPart(); final String sourceName = (String) descriptor.getUserData().get(FULL_NAME); List<Object> values = hit.field(sourceName); if (values == null && source != null) { // read field from source values = parserUtil.readField(source, sourceName); } if (values == null && sourceName.equals("_id")) { builder.set(name, hit.getId()); } else if (values == null && sourceName.equals("_index")) { builder.set(name, hit.getIndex()); } else if (values == null && sourceName.equals("_type")) { builder.set(name, hit.getType()); } else if (values == null && sourceName.equals("_score")) { builder.set(name, score); } else if (values == null && sourceName.equals("_relative_score")) { builder.set(name, relativeScore); } else if (values != null && Geometry.class.isAssignableFrom(descriptor.getType().getBinding())) { if (values.size() == 1) { builder.set(name, parserUtil.createGeometry(values.get(0))); } else { builder.set(name, parserUtil.createGeometry(values)); } } else if (values != null && Date.class.isAssignableFrom(descriptor.getType().getBinding())) { Object dataVal = values.get(0); if (dataVal instanceof Double) { builder.set(name, new Date(Math.round((Double) dataVal))); } else if (dataVal instanceof Integer) { builder.set(name, new Date((Integer) dataVal)); } else if (dataVal instanceof Long) { builder.set(name, new Date((long) dataVal)); } else { final String format = (String) descriptor.getUserData().get(DATE_FORMAT); final DateTimeFormatter dateFormatter = Joda.forPattern(format).parser(); Date date = dateFormatter.parseDateTime((String) dataVal).toDate(); builder.set(name, date); } } else if (values != null && values.size() == 1) { builder.set(name, values.get(0)); } else if (values != null && !name.equals("_aggregation")) { final Object value; if (arrayEncoding == ArrayEncoding.CSV) { // only include first array element when using CSV array encoding value = values.get(0); } else { value = values; } builder.set(name, value); } } return state.getEntry().getTypeName() + "." + hit.getId(); }
Example 17
Source File: InLineFeatureModel.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Removes the column. * * @param columnName the column name */ public void removeColumn(String columnName) { if (featureCollection != null) { if (columnList.contains(columnName)) { columnList.remove(columnName); // Find field name to remote SimpleFeatureTypeBuilder featureTypeBuilder = new SimpleFeatureTypeBuilder(); featureTypeBuilder.init(featureCollection.getSchema()); featureTypeBuilder.remove(columnName); SimpleFeatureType newFeatureType = featureTypeBuilder.buildFeatureType(); int attributeToRemoveIndex = 0; for (AttributeDescriptor descriptor : newFeatureType.getAttributeDescriptors()) { if (descriptor.getLocalName().compareTo(columnName) == 0) { break; } attributeToRemoveIndex++; } String typeName = userLayer.getInlineFeatureType().getTypeName(); try { SimpleFeatureSource featureSource = userLayer.getInlineFeatureDatastore().getFeatureSource(typeName); SimpleFeatureBuilder sfb = new SimpleFeatureBuilder(newFeatureType); ArrayList<SimpleFeature> featureList = new ArrayList<>(); SimpleFeatureIterator it = featureSource.getFeatures().features(); try { while (it.hasNext()) { SimpleFeature sf = it.next(); List<Object> attributes = sf.getAttributes(); attributes.remove(attributeToRemoveIndex); sfb.addAll(attributes); featureList.add(sfb.buildFeature(null)); } } finally { it.close(); } SimpleFeatureCollection collection = new ListFeatureCollection(newFeatureType, featureList); featureCollection = collection; cachedFeature = null; lastRow = -1; DataStore dataStore = DataUtilities.dataStore(collection); userLayer.setInlineFeatureDatastore(dataStore); userLayer.setInlineFeatureType(newFeatureType); } catch (IOException e) { ConsoleManager.getInstance().exception(this, e); } this.fireTableStructureChanged(); this.fireTableDataChanged(); if (parentObj != null) { parentObj.inlineFeatureUpdated(); } } } }
Example 18
Source File: CreateSampleData.java From sldeditor with GNU General Public License v3.0 | 4 votes |
/** * Creates the attributes. * * @param fieldList the field list * @param fieldMap the field map * @param featureType the feature type * @param builder the builder * @param feature the feature */ private void createAttributes( List<DataSourceAttributeData> fieldList, Map<String, DataSourceAttributeData> fieldMap, SimpleFeatureType featureType, SimpleFeatureBuilder builder, SimpleFeature feature) { builder.init((SimpleFeature) feature); int index = 0; for (AttributeDescriptor descriptor : featureType.getAttributeDescriptors()) { AttributeType attributeType = descriptor.getType(); Object value = null; Class<?> fieldType = attributeType.getBinding(); if (attributeType instanceof GeometryTypeImpl) { geometryType = GeometryTypeMapping.getGeometryType(fieldType); switch (geometryType) { case POLYGON: ExamplePolygonInterface examplePolygon = DataSourceFactory.createExamplePolygon(null); value = examplePolygon.getPolygon(); break; case LINE: ExampleLineInterface exampleLine = DataSourceFactory.createExampleLine(null); value = exampleLine.getLine(); break; case POINT: default: ExamplePointInterface examplePoint = DataSourceFactory.createExamplePoint(null); value = examplePoint.getPoint(); break; } } else { if ((fieldList != null) && (index < fieldList.size())) { DataSourceAttributeData attrData = fieldMap.get(descriptor.getLocalName()); if (attrData != null) { value = attrData.getValue(); } } value = getFieldTypeValue( index, attributeType.getName().getLocalPart(), fieldType, value); } builder.add(value); index++; } }
Example 19
Source File: AnalyticFeature.java From geowave with Apache License 2.0 | 4 votes |
public static SimpleFeature createGeometryFeature( final SimpleFeatureType featureType, final String batchId, final String dataId, final String name, final String groupID, final double weight, final Geometry geometry, final String[] extraDimensionNames, final double[] extraDimensions, final int zoomLevel, final int iteration, final long count) { if (extraDimensionNames.length != extraDimensions.length) { LOGGER.error( "The number of extraDimension names does not equal the number of extraDimensions"); throw new IllegalArgumentException( "The number of extraDimension names does not equal the number of extraDimensions"); } final List<AttributeDescriptor> descriptors = featureType.getAttributeDescriptors(); final Object[] defaults = new Object[descriptors.size()]; int p = 0; for (final AttributeDescriptor descriptor : descriptors) { defaults[p++] = descriptor.getDefaultValue(); } final SimpleFeature newFeature = SimpleFeatureBuilder.build(featureType, defaults, dataId); newFeature.setAttribute(ClusterFeatureAttribute.NAME.attrName(), name); newFeature.setAttribute(ClusterFeatureAttribute.GROUP_ID.attrName(), groupID); newFeature.setAttribute(ClusterFeatureAttribute.ITERATION.attrName(), iteration); newFeature.setAttribute(ClusterFeatureAttribute.WEIGHT.attrName(), weight); newFeature.setAttribute(ClusterFeatureAttribute.BATCH_ID.attrName(), batchId); newFeature.setAttribute(ClusterFeatureAttribute.COUNT.attrName(), count); newFeature.setAttribute(ClusterFeatureAttribute.GEOMETRY.attrName(), geometry); newFeature.setAttribute(ClusterFeatureAttribute.ZOOM_LEVEL.attrName(), zoomLevel); int i = 0; for (final String dimName : extraDimensionNames) { newFeature.setAttribute(dimName, new Double(extraDimensions[i++])); } return newFeature; }
Example 20
Source File: FeatureDataAdapterTest.java From geowave with Apache License 2.0 | 4 votes |
@Test public void testInferredRange() throws SchemaException { final SimpleFeatureType schema = DataUtilities.createType( "http://foo", "sp.geostuff", "geometry:Geometry:srid=4326,pop:java.lang.Long,start:Date,end:Date,pid:String"); final List<AttributeDescriptor> descriptors = schema.getAttributeDescriptors(); final Object[] defaults = new Object[descriptors.size()]; int p = 0; for (final AttributeDescriptor descriptor : descriptors) { defaults[p++] = descriptor.getDefaultValue(); } final SimpleFeature newFeature = SimpleFeatureBuilder.build(schema, defaults, UUID.randomUUID().toString()); newFeature.setAttribute("pop", Long.valueOf(100)); newFeature.setAttribute("pid", UUID.randomUUID().toString()); newFeature.setAttribute("start", time1); newFeature.setAttribute("end", time2); newFeature.setAttribute("geometry", factory.createPoint(new Coordinate(27.25, 41.25))); final FeatureDataAdapter dataAdapter = new FeatureDataAdapter( schema, new GlobalVisibilityHandler<SimpleFeature, Object>("default")); final Index spatialIndex = new SpatialDimensionalityTypeProvider().createIndex(new SpatialOptions()); dataAdapter.init(spatialIndex); final byte[] binary = dataAdapter.toBinary(); final FeatureDataAdapter dataAdapterCopy = new FeatureDataAdapter(); dataAdapterCopy.fromBinary(binary); assertEquals("http://foo", dataAdapterCopy.getFeatureType().getName().getNamespaceURI()); assertEquals(dataAdapterCopy.getTypeName(), dataAdapter.getTypeName()); assertEquals(dataAdapterCopy.getFeatureType(), dataAdapter.getFeatureType()); assertEquals( Boolean.TRUE, dataAdapterCopy.getFeatureType().getDescriptor("end").getUserData().get("end")); assertEquals( Boolean.TRUE, dataAdapterCopy.getFeatureType().getDescriptor("start").getUserData().get("start")); final List<IndexFieldHandler<SimpleFeature, ? extends CommonIndexValue, Object>> handlers = dataAdapterCopy.getDefaultTypeMatchingHandlers(schema); boolean found = false; for (final IndexFieldHandler<SimpleFeature, ? extends CommonIndexValue, Object> handler : handlers) { found |= ((handler instanceof FeatureTimeRangeHandler) && ((((FeatureTimeRangeHandler) handler).toIndexValue( newFeature).toNumericData().getMin() - time1.getTime()) < 0.001) && ((((FeatureTimeRangeHandler) handler).toIndexValue( newFeature).toNumericData().getMax() - time2.getTime()) < 0.001)); } assertTrue(found); }