String propName = prop.getName().toString(); if (propertyFields.contains(propName)) { Object binding = prop.getType().getBinding();
Class<?> providedClass = value.getType().getBinding();
public GeometryAttribute getDefaultGeometryProperty() { if (defaultGeometry != null) { return defaultGeometry; } synchronized (this) { if (defaultGeometry == null) { // look it up from the type if (((FeatureType) getType()).getGeometryDescriptor() == null) { return null; } GeometryType geometryType = (GeometryType) getType().getGeometryDescriptor().getType(); if (geometryType != null) { for (Iterator itr = getValue().iterator(); itr.hasNext(); ) { Property property = (Property) itr.next(); if (property instanceof GeometryAttribute) { if (property.getType().equals(geometryType)) { defaultGeometry = (GeometryAttribute) property; break; } } } } } } return defaultGeometry; }
} else { PropertyType simpleContentType = getSimpleContentType((AttributeType) simpleContent.getType()); Object convertedValue = FF.literal(value).evaluate(value, simpleContentType.getBinding());
/** * Perform the visitation of an individual Feature. * * @param feature The Feature to explore. */ protected void walker(Feature feature) { handler.handleFeature(feature); for (Property property : feature.getProperties()) { Class<?> binding = property.getType().getBinding(); // recurse if attribute type is another collection if (FeatureCollection.class.isAssignableFrom(binding)) { walker((FeatureCollection) property.getValue()); // } else if (type instanceof FeatureType) { } else if (Feature.class.isAssignableFrom(binding)) { // recurse if attribute type is another feature walker((Feature) property.getValue()); } else { // normal handling handler.handleAttribute(property.getDescriptor(), property.getValue()); } } handler.endFeature(feature); }
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); }
.allMatch( property -> property.getType().getName().equals(complex.getType().getName()))) {
/** Index the provided properties by their type, geometry property will be ignored. */ private Map<PropertyType, List<Property>> indexPropertiesByType( Property geometryAttribute, Collection<Property> properties) { Map<PropertyType, List<Property>> index = new HashMap<>(); for (Property property : properties) { if (geometryAttribute != null && property.equals(geometryAttribute)) { // ignore the geometry attribute that should have been encoded already continue; } // update the index with the current property List<Property> propertiesWithSameType = index.get(property.getType()); if (propertiesWithSameType == null) { // first time we see a property fo this type propertiesWithSameType = new ArrayList<>(); index.put(property.getType(), propertiesWithSameType); } propertiesWithSameType.add(property); } return index; }
private static final HashMap<Name, Class> getSignature(SimpleFeature f) { HashMap ftype = new HashMap(); Collection properties = f.getProperties(); for (Object op : properties) { Property p = (Property) op; Class c = p.getType().getBinding(); if ((c.isAssignableFrom(String.class)) || (c.isAssignableFrom(Boolean.class)) || (c.isAssignableFrom(Integer.class)) || (c.isAssignableFrom(Float.class)) || (c.isAssignableFrom(Double.class)) || (c.isAssignableFrom(Geometry.class))) { ftype.put(p.getName(), c); } } return ftype; }
private void encodeProperty(Feature f, Property p) { if (p.getType() == CSWRecordDescriptor.SIMPLE_LITERAL) { encodeSimpleLiteral(p); } else if (CSWRecordDescriptor.RECORD_BBOX_NAME.equals(p.getName())) { // skip it for the moment, it is constrained to be last } else { throw new IllegalArgumentException("Don't know how to encode property " + p + " in record " + f); } }
private void encodeProperty(Feature f, Property p) { if (p.getType() == CSWRecordDescriptor.SIMPLE_LITERAL) { encodeSimpleLiteral(p); } else if (CSWRecordDescriptor.RECORD_BBOX_NAME.equals(p.getName())) { // skip it for the moment, it is constrained to be last } else { throw new IllegalArgumentException( "Don't know how to encode property " + p + " in record " + f); } }
Property property = (Property) itr.next(); if (property instanceof GeometryAttribute) { if (property.getType().equals(geometryType)) { defaultGeometry = (GeometryAttribute)property; break;
private static void applyOriginalTagsTo(SimpleFeature feature, String geometryType, Primitive w, String prefix) { String prefixPlusColon = ""; if (!"".equals(prefix)) { prefixPlusColon = prefix + ":"; } Collection<Property> properties = feature.getProperties(); for (Property property : properties) { String name = property.getType().getName().toString(); if (!geometryType.equals(name)) { Object value = property.getValue(); if (value != null) { String dirtyOriginalValue = getDirtyValue(value); if (!StringUtils.isEmpty(dirtyOriginalValue)) { String escapedOriginalValue = StringEscapeUtils.escapeXml(dirtyOriginalValue); w.addTag(new Tag(prefixPlusColon + name, escapedOriginalValue)); } } } } }
Class<?> cls = magProp.getType().getBinding();
@Override public Feature next() { Feature original = delegate.next(); // this does not really work... // for (PropertyDescriptor pd : original.getType().getDescriptors()) { // Collection<Property> properties = original.getProperties(pd.getName()); // if(properties != null) { // for (Property p : properties) { // if (names.contains(p.getName()) || names.contains(p.getName().getLocalPart())) { // builder.append(pd.getName(), p); // } // } // } // } for (Property p : original.getProperties()) { if (names.contains(p.getName()) || names.contains(p.getName().getLocalPart())) { // this makes the thing type specific, but at least it works for the record case // TODO: eventually figure out how to make this for the general case... if (p.getType().equals(CSWRecordDescriptor.SIMPLE_LITERAL)) { builder.append(CSWRecordDescriptor.DC_ELEMENT_NAME, p); } else { builder.append(p.getName(), p); } } } return builder.buildFeature(original.getIdentifier().getID()); }
String srcKey = property.getType().getName().toString(); if (!geometryType.equals(srcKey)) {
/** * Perform the visitation of an individual Feature. * * @param feature The Feature to explore. */ protected void walker(Feature feature) { final FeatureType schema = feature.getType(); //final int cnt = schema.getAttributeCount(); handler.handleFeature(feature); for( Property property : feature.getProperties() ){ Class<?> binding = property.getType().getBinding(); // recurse if attribute type is another collection if (FeatureCollection.class.isAssignableFrom( binding )) { walker((FeatureCollection) property.getValue() ); // } else if (type instanceof FeatureType) { } else if (Feature.class.isAssignableFrom(binding)) { // recurse if attribute type is another feature walker((Feature) property.getValue() ); } else { // normal handling handler.handleAttribute(property.getDescriptor(), property.getValue() ); } } handler.endFeature(feature); }
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); }
@Override public Feature next() { Feature original = delegate.next(); // this does not really work... // for (PropertyDescriptor pd : original.getType().getDescriptors()) { // Collection<Property> properties = original.getProperties(pd.getName()); // if(properties != null) { // for (Property p : properties) { // if (names.contains(p.getName()) || // names.contains(p.getName().getLocalPart())) { // builder.append(pd.getName(), p); // } // } // } // } for (Property p : original.getProperties()) { if (names.contains(p.getName()) || names.contains(p.getName().getLocalPart())) { // this makes the thing type specific, but at least it works for the record case // TODO: eventually figure out how to make this for the general case... if (p.getType().equals(CSWRecordDescriptor.SIMPLE_LITERAL)) { builder.append(CSWRecordDescriptor.DC_ELEMENT_NAME, p); } else { builder.append(p.getName(), p); } } } return builder.buildFeature(original.getIdentifier().getID()); }
private String getAttributesJson(Feature feature) { JSONBuilder builder = new JSONStringer().object(); builder.key("id").value(feature.getIdentifier().toString()); if (feature instanceof SimpleFeature) { SimpleFeature sf = (SimpleFeature) feature; for (AttributeDescriptor ad : sf.getFeatureType().getAttributeDescriptors()) { if (ad instanceof GeometryDescriptor) { continue; } else { String name = ad.getLocalName(); Object value = sf.getAttribute(name); addAttribute(builder, name, value); } } } else { for (Property p : feature.getProperties()) { if (p.getType() instanceof GeometryPropertyType) { continue; } String name = p.getName().getLocalPart(); Object value = p.getValue(); addAttribute(builder, name, value); } } builder.endObject(); return builder.toString(); }