propertyFields = new ArrayList<String>(); for (Property p : protoFt.getProperties()) { propertyFields.add(p.getName().toString()); for(Property prop : feature.getProperties() ){ String propName = prop.getName().toString(); if (propertyFields.contains(propName)) {
public Collection<Property> getProperties(String arg0) { return delegate.getProperties(arg0); }
public Collection<Property> getProperties(Name name) { return delegate.getProperties(name); }
public Collection<Property> getProperties() { return delegate.getProperties(); }
public Collection<Property> getProperties(String name) { return delegate.getProperties(name); }
public Collection<Property> getProperties() { return delegate.getProperties(); }
public Collection<Property> getProperties(Name arg0) { return delegate.getProperties(arg0); }
private void applySingleUpdate( QName remoteTypeName, SimpleFeature feature, TransactionRequest transactionRequest) throws IOException { // so bad, this is going to update a lot of unnecessary properties. We'd need to make // DiffContentFeatureWriter's live and current attributes protected and extend write so that // it records the truly modified attributes instead Collection<Property> properties = feature.getProperties(); List<QName> propertyNames = new ArrayList<QName>(); List<Object> newValues = new ArrayList<Object>(); for (Property p : properties) { QName attName = new QName(remoteTypeName.getNamespaceURI(), p.getName().getLocalPart()); Object attValue = p.getValue(); propertyNames.add(attName); newValues.add(attValue); } Filter updateFilter = dataStore.getFilterFactory().id(Collections.singleton(feature.getIdentifier())); Update update = transactionRequest.createUpdate( remoteTypeName, propertyNames, newValues, updateFilter); transactionRequest.add(update); }
final Collection<Property> destProps = feature.getProperties(); final Set<Name> destAttributes = new HashSet<>(); for (Property prop : destProps) {
public void add(final SimpleFeature feature) { Name name = feature.getFeatureType().getName(); QName typeName = getTypeName(); if (!new NameImpl(typeName).equals(name)) { throw new IllegalArgumentException( "Type name does not match. Expected " + new NameImpl(typeName) + ", but got " + name); } WFSStrategy strategy = getStrategy(); FeatureTypeInfo typeInfo = strategy.getFeatureTypeInfo(typeName); CoordinateReferenceSystem crs = typeInfo.getCRS(); for (Property property : feature.getProperties()) { if (!(property instanceof GeometryAttribute)) { continue; } CoordinateReferenceSystem attCrs = ((GeometryType) property.getType()).getCoordinateReferenceSystem(); if (!CRS.equalsIgnoreMetadata(crs, attCrs)) { throw new IllegalArgumentException( "Added Features shall match the native CRS: " + typeInfo.getDefaultSRS() + ". Got " + attCrs); } } added.add(feature); }
public void testGetProperty() { assertEquals("ABC", feature.getProperty("name").getValue()); assertNull(feature.getProperty("NOWHERE")); assertEquals(0, feature.getProperties("NOWHERE").size()); }
@Override public Collection<Property> getProperties(Name name) { return simpleFeature.getProperties(name); }
Collection<Property> props = sourceFeature.getProperties(); Name propName = null; Object propValue = null;
public void testSetValue() { SimpleFeature myFeature = SimpleFeatureBuilder.build(schema, new Object[] {null, null, null}, "building.2"); myFeature.setValue(feature.getProperties()); for (int i = 0; i < feature.getAttributeCount(); i++) { assertEquals(feature.getAttribute(i), myFeature.getAttribute(i)); } }
/** * Perform a "deep copy" an existing feature resuling in a duplicate of any geometry attributes. * * <p>This method is scary, expensive and will result in a deep copy of Geometry which may take * a significant amount of memory/time to perform. * * @param original Content * @return copy */ public static SimpleFeature deep(SimpleFeature original) { if (original == null) return null; SimpleFeatureBuilder builder = new SimpleFeatureBuilder(original.getFeatureType()); for (Property property : original.getProperties()) { Object value = property.getValue(); try { Object copy = value; if (value instanceof Geometry) { Geometry geometry = (Geometry) value; copy = geometry.copy(); } builder.set(property.getName(), copy); } catch (Exception e) { throw new IllegalAttributeException( (AttributeDescriptor) property.getDescriptor(), value, e); } } return builder.buildFeature(original.getID()); }
private String getHTMLDescription(SimpleFeature simpleFeature) { StringBuilder str = new StringBuilder(); for (Property property : simpleFeature.getProperties()) { if (property.getName().toString() != GEOM) { str.append("<b>" + property.getName() + "</b>: "); if (property.getValue() != null) str.append(property.getValue().toString() + " <br />"); else str.append(" <br />"); } } return str.toString(); }
private void writeData(XMLStreamWriter writer, SimpleFeature f) throws XMLStreamException { writer.writeStartElement("extensions"); for (Property p : f.getProperties()) { Name name = p.getName(); if (!(p.getValue() instanceof Geometry) && p.getValue() != null) { writer.writeStartElement("att:" + name.getLocalPart()); writer.writeCharacters(p.getValue().toString()); writer.writeEndElement(); } } writer.writeEndElement(); } }
private Feature createFeature(String id, Geometry geometry, SimpleFeature bluePrint) { Feature feature = GTHelper.createFeature(id, geometry, bluePrint.getFeatureType(), bluePrint.getProperties()); return feature; }
private void writeAttributes(String layer, String ownerHandle, SimpleFeature f) throws IOException { // TODO Auto-generated method stub for ( Property p : f.getProperties()) { Name name = p.getName(); LOGGER.warning(" attr: " + name.getLocalPart() + " = " + p.getValue()); if (!(p.getValue() instanceof Geometry)) { writeAttribute(layer, ownerHandle, name.getLocalPart(), p.getValue()); } } }
@Test public void testBuildWithAddProperty() throws Exception { SimpleFeature f = (SimpleFeature) points1; RevFeature feature = RevFeature.builder().build(f); RevFeatureBuilder b = RevFeature.builder(); for (Property p : f.getProperties()) { b.addProperty(p); } RevFeature built = b.build(); assertEquals(feature, built); for (int i = 0; i < f.getAttributeCount(); i++) { assertEquals(f.getAttribute(i), built.getValues().get(i).orNull()); } }