public FeatureEncoder(SimpleFeature feature) { this(feature.getType()); this.feature = feature; }
public SimpleFeatureType getType() { return delegate.getType(); }
public SimpleFeatureType getType() { return delegate.getType(); }
/** * Check whether the specified feature has the same schema of the catalog where we are adding * that feature. * * @param feature a sample SimpleFeature for compatibility check */ private void checkSchemaCompatibility(final SimpleFeature feature) { try { if (!feature.getType().equals(catalog.getType(typeName))) { throw new IllegalArgumentException( "The schema of the provided collection is not the same of the underlying catalog"); } } catch (IOException e) { throw new RuntimeException( "Exception occurred while getting the underlying catalog schema"); } }
/** * Utility method to transform feature ids based on the convention <type name>.<id>. * * <p>Should be invoked by classes using this Transformer instance to build transformed * features. * * @param sourceFeature the source feature * @return the transformed feature identifier */ String transformFid(SimpleFeature sourceFeature) { String origFid = sourceFeature.getID(); String origFidPrefix = sourceFeature.getType().getTypeName() + "."; if (origFid.startsWith(origFidPrefix)) { String id = origFid.substring(origFidPrefix.length()); return schema.getTypeName() + "." + id; } else { return origFid; } }
@Test public void testSimpleRename() throws IOException { SimpleFeatureSource fs = store.getFeatureSource(BUILDINGS.getLocalPart()); SimpleFeatureTypeBuilder tb = new SimpleFeatureTypeBuilder(); tb.init(fs.getSchema()); tb.setName("houses"); SimpleFeatureType target = tb.buildFeatureType(); SimpleFeatureSource retyped = RetypingFeatureSource.getRetypingSource(fs, target); assertTrue(retyped instanceof SimpleFeatureLocking); assertEquals(target, retyped.getSchema()); assertEquals(target, ((DataStore) retyped.getDataStore()).getSchema("houses")); assertEquals(target, retyped.getFeatures().getSchema()); SimpleFeatureIterator it = retyped.getFeatures().features(); SimpleFeature f = it.next(); it.close(); assertEquals(target, f.getType()); }
public boolean canHandle(Object object, String xpath, Class target) { xpath = stripPrefixIndex(xpath); if (object instanceof SimpleFeature) { return ((SimpleFeature) object).getType().getDescriptor(xpath) != null; } if (object instanceof SimpleFeatureType) { return ((SimpleFeatureType) object).getDescriptor(xpath) != null; } return false; }
private void addAttributeValues( SimpleFeature feature, List<String> retained, SimpleFeatureBuilder fb) { Iterator<AttributeDescriptor> firstIterator = feature.getType().getAttributeDescriptors().iterator(); while (firstIterator.hasNext()) { AttributeDescriptor ad = firstIterator.next(); Object firstAttribute = feature.getAttribute(ad.getLocalName()); if ((retained == null || retained.contains(ad.getLocalName())) && !(firstAttribute instanceof Geometry)) { fb.add(feature.getAttribute(ad.getLocalName())); } } }
static void loadData(MemoryDataStore mem, String name) throws Exception { WKTReader wkt = new WKTReader(); FeatureWriter w = mem.getFeatureWriter(name, Transaction.AUTO_COMMIT); BufferedReader r = new BufferedReader( new InputStreamReader( LabelObstacleTest.class.getResourceAsStream( "test-data/obstacles/" + name + ".txt"))); String line = null; while ((line = r.readLine()) != null) { String[] values = line.split(";"); SimpleFeature f = (SimpleFeature) w.next(); for (int i = 0; i < f.getAttributeCount(); i++) { AttributeDescriptor ad = f.getType().getDescriptor(i); if (ad instanceof GeometryDescriptor) { f.setAttribute(i, wkt.read(values[i])); } else { f.setAttribute(i, values[i]); } } w.write(); } r.close(); }
shapeType = JTSUtilities.getShapeType( currentFeature.getType().getGeometryDescriptor());
private boolean containsAttribute(SimpleFeature ft, String attName) { for (AttributeDescriptor att : ft.getType().getAttributeDescriptors()) { if (att.getLocalName().equals(attName)) { return true; } } return false; } };
public void testGetDescriptor() { assertNotNull(feature.getDescriptor()); assertSame(feature.getType(), feature.getDescriptor().getType()); assertTrue(feature.getDescriptor().isNillable()); assertEquals(0, feature.getDescriptor().getMinOccurs()); assertEquals(Integer.MAX_VALUE, feature.getDescriptor().getMaxOccurs()); }
@Override protected void map(final Key key, final Value value, final Context context) throws IOException, InterruptedException { final List<SimpleFeature> sf = sfg.mapOSMtoSimpleFeature(WholeRowIterator.decodeRow(key, value), osmProvider); if ((sf != null) && (sf.size() > 0)) { for (final SimpleFeature feat : sf) { final String name = feat.getType().getTypeName(); context.write(new GeoWaveOutputKey(name, indexName), feat); } } }
public boolean canHandle(Object object, String xpath, Class target) { xpath = stripPrefix(xpath); if ( object instanceof SimpleFeature ) { return ((SimpleFeature) object).getType().getDescriptor(xpath) != null; } if ( object instanceof SimpleFeatureType ) { return ((SimpleFeatureType) object).getDescriptor( xpath ) != null; } return false; }
private void setTimeAttribute(SimpleFeature feature, Date date) { FeatureType featureType = feature.getFeatureType(); FeatureTypeInfo featureTypeInfo = getFeatureTypeInfo(featureType); if (TimeVersioning.isEnabled(featureTypeInfo)) { String timePropertyName = TimeVersioning.getTimePropertyName(featureTypeInfo); AttributeDescriptor attributeDescriptor = feature.getType().getDescriptor(timePropertyName); Object timeValue = Converters.convert(date, attributeDescriptor.getType().getBinding()); feature.setAttribute(timePropertyName, timeValue); } }
@Override public void convert(SimpleFeature from, SimpleFeature to) { for (AttributeDescriptor att : from.getType().getAttributeDescriptors()) { Object obj = from.getAttribute(att.getLocalName()); if (att instanceof GeometryDescriptor) { to.setDefaultGeometry(obj); } else if (containsAttribute(to, attName(att.getLocalName()))) { to.setAttribute(attName(att.getLocalName()), obj); } } }
public TestData remove(SimpleFeature... features) { WorkingTree workingTree = getContext().workingTree(); for (SimpleFeature sf : features) { String parentTreePath = sf.getType().getName().getLocalPart(); workingTree.delete(parentTreePath, sf.getID()); } return this; }