/** * @param node * @return null, if the node cannot be interpreted as geometry */ public static Geometry getGeometryValue( TypedObjectNode node ) { Geometry geom = null; if ( node instanceof Geometry ) { geom = (Geometry) node; } else if ( node instanceof Property && ( (Property) node ).getValue() instanceof Geometry ) { geom = (Geometry) ( (Property) node ).getValue(); } return geom; }
@Override public void serialize( FeatureInfoParams params, FeatureInfoContext context ) throws IOException, XMLStreamException { PrintWriter out = new PrintWriter( new OutputStreamWriter( context.getOutputStream(), "UTF-8" ) ); for ( Feature f : params.getFeatureCollection() ) { out.println( f.getName().getLocalPart() + ":" ); for ( Property p : f.getProperties() ) { out.println( " " + p.getName().getLocalPart() + ": " + p.getValue() ); } out.println(); } out.close(); } }
private Feature transformGeometries( Feature feature, GeometryTransformer transformer ) throws IllegalArgumentException, TransformationException, UnknownCRSException { // TODO Do not modify the incoming feature, but create a new one. for ( Property prop : feature.getProperties() ) { List<TypedObjectNode> children = prop.getChildren(); if ( children != null && !children.isEmpty() ) { List<TypedObjectNode> newChildren = new ArrayList<TypedObjectNode>( children.size() ); for ( TypedObjectNode child : children ) { newChildren.add( transformGeometries( child, transformer ) ); } prop.setChildren( newChildren ); } else { TypedObjectNode value = prop.getValue(); if ( value != null ) { prop.setValue( transformGeometries( value, transformer ) ); } } } feature.setEnvelope( feature.calcEnvelope() ); return feature; }
private void export( Property property, GmlXlinkOptions resolveState ) throws XMLStreamException, UnknownCRSException, TransformationException { QName propName = property.getName(); PropertyType pt = property.getType(); if ( pt.getMinOccurs() == 0 ) { LOG.debug( "Optional property '" + propName + "', checking if it is requested." ); TypedObjectNode value = property.getValue(); Map<QName, PrimitiveValue> attributes = property.getAttributes(); TypedObjectNode nil = attributes.get( XSI_NIL ); if ( nil instanceof PrimitiveValue ) { if ( property.getChildren() != null ) { for ( TypedObjectNode childNode : property.getChildren() ) { export( childNode, resolveState ); } else { writeStartElementWithNS( propName.getNamespaceURI(), propName.getLocalPart() ); export( property.getValue(), resolveState ); writer.writeEndElement();
private void validateProperties( final Feature feature, final List<Property> props ) { Map<PropertyType, Integer> ptToCount = new HashMap<PropertyType, Integer>(); for ( Property prop : props ) { if ( prop.getValue() instanceof Geometry ) { Geometry geom = (Geometry) prop.getValue(); if ( geom != null ) { Property current = feature.getProperties( prop.getType().getName() ).get( 0 ); Geometry currentGeom = current != null ? ( (Geometry) current.getValue() ) : null; String msg = "Cannot replace given geometry property '" + prop.getType().getName() + "' with given value (wrong dimension)."; throw new InvalidParameterValueException( msg ); if ( !( geom instanceof Surface ) && prop.getType().getName().equals( qname ) ) { String msg = "Cannot replace given geometry property '" + prop.getType().getName() + "' with given value (wrong type)."; throw new InvalidParameterValueException( msg ); Integer count = ptToCount.get( prop.getType() ); if ( count == null ) { count = 1; count++; ptToCount.put( prop.getType(), count );
Property p = (Property) o; if ( p.getValue() instanceof Geometry && !geometries ) { continue; if ( p.getValue() instanceof PrimitiveValue ) { String s = p.getValue().toString(); PropertyType pt = p.getType(); String nm = o2 instanceof Property ? ( (Property) o2 ).getName().getLocalPart() : ( (Feature) o2 ).getName().getLocalPart(); if ( negate ) {
Property prop = replacement.getNewValue(); UpdateAction updateAction = replacement.getUpdateAction(); GenericProperty newProp = new GenericProperty( prop.getType(), null ); if ( prop.getValue() != null ) { newProp.setValue( prop.getValue() ); } else if ( !prop.getChildren().isEmpty() && prop.getChildren().get( 0 ) != null ) { newProp.setChildren( prop.getChildren() ); } else if ( updateAction == null ) { updateAction = REMOVE; if ( iter.next().getType().getName().equals( prop.getType().getName() ) ) { --idx; if ( iter.next().getType().getName().equals( prop.getType().getName() ) ) { --idx; if ( iter.next().getType().getName().equals( prop.getType().getName() ) ) { --idx;
public PropertyNode( GMLObjectNode<? extends TypedObjectNode, ? extends TypedObjectNode> parent, final Property prop ) { super( prop.getName() ); this.parent = parent; this.prop = prop; }
PropertyNode propNode = (PropertyNode) node; Property prop = propNode.getValue(); if ( !prop.getChildren().isEmpty() ) { List<XPathNode> xpathNodes = new ArrayList<XPathNode>( prop.getChildren().size() ); for ( TypedObjectNode xmlNode : prop.getChildren() ) { if ( xmlNode instanceof org.deegree.commons.tom.ElementNode ) { xpathNodes.add( new XMLElementNode<Property>( propNode, final Object propValue = prop.getValue(); if ( propValue instanceof GMLObject ) { GMLObject castNode = (GMLObject) propValue;
TypedObjectNode propValue = prop.getValue(); if ( pt instanceof CustomPropertyType && propValue instanceof GenericXMLElement ) { prop = new GenericProperty( pt, propValue ); prop.setChildren( ( (GenericXMLElement) propValue ).getChildren() );
Object value = ( (PropertyNode) node ).getValue().getValue(); if ( value instanceof Measure && ( (Measure) value ).getUomUri() != null ) { PrimitiveValue uom = new PrimitiveValue( ( (Measure) value ).getUomUri() ); return getAttributeAxisIterator( n ); Map<QName, PrimitiveValue> attributes = ( (PropertyNode) node ).getValue().getAttributes(); if ( attributes != null ) { List<AttributeNode<?>> attrNodes = new ArrayList<AttributeNode<?>>( attributes.size() );
private TypedObjectNode transformGeometries( TypedObjectNode value, GeometryTransformer transformer ) throws IllegalArgumentException, TransformationException, UnknownCRSException { if ( value == null ) { // nothing to do } else if ( value instanceof GenericXMLElement ) { GenericXMLElement generic = (GenericXMLElement) value; List<TypedObjectNode> newChildren = new ArrayList<TypedObjectNode>( generic.getChildren().size() ); for ( int i = 0; i < generic.getChildren().size(); i++ ) { TypedObjectNode child = generic.getChildren().get( i ); TypedObjectNode transformed = transformGeometries( child, transformer ); newChildren.add( transformed ); } generic.setChildren( newChildren ); } else if ( value instanceof Property ) { Property generic = (Property) value; List<TypedObjectNode> newChildren = new ArrayList<TypedObjectNode>( generic.getChildren().size() ); for ( int i = 0; i < generic.getChildren().size(); i++ ) { TypedObjectNode child = generic.getChildren().get( i ); TypedObjectNode transformed = transformGeometries( child, transformer ); newChildren.add( transformed ); } generic.setChildren( newChildren ); } else if ( value instanceof Geometry ) { value = transformGeometry( (Geometry) value, transformer ); } else if ( value instanceof PrimitiveValue ) { // nothing to do } return value; }
private void exportGenericObjectProperty( final Property prop, final GMLObject object, final GmlXlinkOptions resolveState ) throws XMLStreamException, UnknownCRSException, TransformationException { final ObjectPropertyType pt = (ObjectPropertyType) prop.getType(); final QName propName = pt.getName(); LOG.debug( "Exporting object property '" + propName + "'" ); if ( object == null ) { exportEmptyProperty( propName, prop.getAttributes() ); } else { writeStartElementWithNS( propName.getNamespaceURI(), propName.getLocalPart() ); switch ( pt.getCategory() ) { case TIME_OBJECT: new GmlTimeGeometricPrimitiveWriter().write( writer, (TimeGeometricPrimitive) object ); break; case TIME_SLICE: export( (TimeSlice) object, resolveState ); break; default: throw new RuntimeException(); } writer.writeEndElement(); } }
for ( ParsedPropertyReplacement replacement : replacementProps ) { Property replacementProp = replacement.getNewValue(); QName propName = replacementProp.getType().getName(); Mapping mapping = ftMapping.getMapping( propName ); if ( mapping != null ) {
if ( propDecl == null ) { property = parsePropertyDynamic( propName, xmlStream, activeCRS, ft, lastPropDecl, appSchema ); propDecl = property.getType(); } else { property = parseProperty( xmlStream, propDecl, activeCRS ); Envelope bbox = (Envelope) property.getValue(); if ( bbox.getCoordinateSystem() != null ) { activeCRS = bbox.getCoordinateSystem();
@Override public List<Property> getProperties( final QName propName ) { final List<Property> namedProps = new ArrayList<Property>( props.size() ); for ( final Property property : props ) { if ( propName.equals( property.getName() ) ) { namedProps.add( property ); } } return namedProps; }
private TypedObjectNode getPropValue( TypedObjectNode prop ) { if ( prop instanceof Property ) { return ( (Property) prop ).getValue(); } return prop; }
QName propName = replacementProp.getType().getName(); Mapping mapping = ftMapping.getMapping( propName ); if ( mapping != null ) { Object value = replacementProp.getValue(); if ( value != null ) { ParticleConverter<TypedObjectNode> converter = (ParticleConverter<TypedObjectNode>) fs.getConverter( mapping );
@Override public List<Property> getProperties( final QName propName ) { final List<Property> namedProps = new ArrayList<Property>( props.size() ); for ( final Property property : props ) { if ( propName.equals( property.getName() ) ) { namedProps.add( property ); } } return namedProps; }