private TypedObjectNode getPropValue( TypedObjectNode prop ) { if ( prop instanceof Property ) { return ( (Property) prop ).getValue(); } return prop; }
/** * @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 List<Property> getGeometryProperties() { List<Property> geoProps = new ArrayList<Property>(); if ( props != null ) { for ( Property property : props ) { if ( property.getValue() instanceof Geometry && !( property.getValue() instanceof Envelope ) ) { geoProps.add( property ); } } } return geoProps; } }
@Override public List<Property> getGeometryProperties() { List<Property> geoProps = new ArrayList<Property>( props.size() ); for ( Property property : props ) { if ( property.getValue() instanceof Geometry && !( property.getValue() instanceof Envelope ) ) { geoProps.add( property ); } } return geoProps; } }
private PrimitiveValue getPrimitiveValue( TypedObjectNode value ) { if ( value instanceof Property ) { value = ( (Property) value ).getValue(); } if ( value instanceof GenericXMLElement ) { value = ( (GenericXMLElement) value ).getValue(); } return (PrimitiveValue) value; }
private Geometry tryProperty( TypedObjectNode n ) { if ( n instanceof Property ) { TypedObjectNode val = ( (Property) n ).getValue(); if ( val instanceof Geometry ) { return (Geometry) val; } return tryCustomXML( val ); } return null; }
/** * Creates a pair of {@link PrimitiveValue} instances from the given {@link TypedObjectNode} while trying to * preserve primitive type information. * * @param value1 * @param value2 * @throws FilterEvaluationException */ private static Pair<Object, Object> getPrimitives( Object value1, Object value2 ) throws FilterEvaluationException { if ( value1 instanceof Property ) { value1 = ( (Property) value1 ).getValue(); } if ( !( value1 instanceof PrimitiveValue ) ) { value1 = value1.toString(); } if ( value2 instanceof Property ) { value2 = ( (Property) value2 ).getValue(); } if ( !( value2 instanceof PrimitiveValue ) ) { value2 = value2.toString(); } return PrimitiveValue.makeComparable( value1, value2 ); }
/** * Creates a new {@link GenericFeatureCollection} instance with type information and content specified using * properties. * * @param ft * feature collection type, must not be <code>null</code> * @param fid * feature id, may be <code>null</code> * @param props * properties (including feature member/feature member array properties), must not be <code>null</code> */ public GenericFeatureCollection( FeatureCollectionType ft, String fid, List<Property> props, ExtraProps extraProps ) { super( fid, ft, extraProps ); this.props = props; // extract member features for ( Property prop : props ) { Object propValue = prop.getValue(); if ( propValue instanceof Feature ) { memberFeatures.add( (Feature) prop.getValue() ); } else if ( propValue instanceof TypedObjectNodeArray<?> ) { for ( TypedObjectNode member : ( (TypedObjectNodeArray<?>) propValue ).getElements() ) { if ( member instanceof Feature ) { memberFeatures.add( (Feature) member ); } } } } }
/** * @param sb * @param o */ public void eval( StringBuilder sb, Object o ) { if ( o instanceof Property ) { try { sb.append( ( (Property) o ).getValue() ); } catch ( UnsupportedOperationException e ) { LOG.error( "The error '{}' occurred while converting a property to a string, " + "probably the WKT writer cannot convert a geometry.", e.getLocalizedMessage() ); LOG.debug( "Stack trace:", e ); } } else { LOG.warn( "Trying to get value while current object is a feature." ); } }
/** * @param sb * @param o */ public void eval( StringBuilder sb, Object o ) { if ( !( o instanceof Property ) ) { LOG.warn( "Trying to get value as link while current object is a feature." ); return; } String val = ( (Property) o ).getValue().toString(); if ( val == null || val.isEmpty() ) { return; } // TODO: what is wanted is a real check for validity. org.apache.xerces.util.URI.isWellFormedAddress has been // tried and seems not to work if ( !val.startsWith( "http://" ) && !val.startsWith( "https://" ) && !val.startsWith( "ftp://" ) ) { val = prefix == null ? val : ( prefix + val ); } // TODO price question: what's the Java Way to sgml-quote? val = val.replace( "&", "&" ); sb.append( "<a target='_blank' href='" ).append( val ).append( "'>" ); sb.append( text == null ? val : text ); sb.append( "</a>" ); }
/** * Returns the string value of an element node. * * @param node * the target node * @return the text inside the node and its descendants if the node is an element, null otherwise */ @Override public String getElementStringValue( Object node ) { String value = null; if ( node instanceof PropertyNode ) { Property prop = ( (PropertyNode) node ).getValue(); Object propValue = prop.getValue(); // TODO check if conversion is feasible (e.g. Geometry.toString() may be expensive) value = propValue.toString(); } return value; }
@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 boolean excludeByTimeSliceFilter( Property property ) { final TimeSlice timeSlice = (TimeSlice) property.getValue(); for ( final Filter timeSliceFilter : timeSliceFilters ) { TypedObjectNodeXPathEvaluator evaluator = new TypedObjectNodeXPathEvaluator(); try { if ( !timeSliceFilter.evaluate( timeSlice, evaluator ) ) { return true; } } catch ( FilterEvaluationException e ) { LOG.warn( "Unable to evaluate time slice projection filter: " + e.getMessage() ); } } return false; }
private TimeGeometricPrimitive getTimePrimitiveValue( final TypedObjectNode node ) { if ( node == null ) { return null; } if ( node instanceof TimeGeometricPrimitive ) { return (TimeGeometricPrimitive) node; } if ( node instanceof Property ) { return getTimePrimitiveValue( ( (Property) node ).getValue() ); } if ( node instanceof ElementNode ) { final ElementNode elNode = (ElementNode) node; final List<TypedObjectNode> children = elNode.getChildren(); if ( children == null || children.isEmpty() ) { return null; } return getTimePrimitiveValue( children.get( 0 ) ); } return null; } }
if ( o instanceof PropertyNode ) { Property prop = ( (PropertyNode) o ).getValue(); GMLObject gmlObject = (GMLObject) prop.getValue(); GMLObjectNode elNode = new GMLObjectNode( ( (PropertyNode) o ), gmlObject ); values.add( elNode ); GMLObject gmlObject = (GMLObject) prop.getValue(); GMLObjectNode elNode = new GMLObjectNode( ( (PropertyNode) arg ), gmlObject ); values.add( elNode );
private PrimitiveValue getPrimitiveValue( TypedObjectNode node ) { if ( node == null ) { return new PrimitiveValue( "null" ); } if ( node instanceof PrimitiveValue ) { return (PrimitiveValue) node; } if ( node instanceof Property ) { return getPrimitiveValue( ( (Property) node ).getValue() ); } if ( node instanceof ElementNode ) { ElementNode elNode = (ElementNode) node; List<TypedObjectNode> children = elNode.getChildren(); if ( children == null || children.isEmpty() ) { return new PrimitiveValue( "null" ); } return getPrimitiveValue( children.get( 0 ) ); } return new PrimitiveValue( node.toString() ); }
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; }
if ( value instanceof Geometry ) { geom = (Geometry) value; } else if ( value instanceof Property && ( (Property) value ).getValue() instanceof Geometry ) { geom = (Geometry) ( (Property) value ).getValue(); } else if ( value instanceof GenericXMLElement ) { GenericXMLElement xml = (GenericXMLElement) value;