public GMLFeatureWriter getFeatureWriter() { if ( featureWriter == null ) { featureWriter = new GMLFeatureWriter( this ); } return featureWriter; }
@Override public int count() { int i = 0; for ( @SuppressWarnings("unused") Feature f : this ) { i++; } close(); return i; } }
/** * Returns a configured {@link GMLFeatureReader} instance for calling specific feature parsing methods. * * @return a configured {@link GMLFeatureReader} instance, never <code>null</code> */ public GMLFeatureReader getFeatureReader() { if ( featureReader == null ) { featureReader = new GMLFeatureReader( this ); } return featureReader; }
/** * Exports the given {@link Property}. * * @param prop * property to be exported, must not be <code>null</code> * @throws XMLStreamException * @throws UnknownCRSException * @throws TransformationException */ public void export( Property prop ) throws XMLStreamException, UnknownCRSException, TransformationException { export( prop, referenceExportStrategy.getResolveOptions() ); }
/** * Returns a {@link StreamFeatureCollection} that allows stream-based access to the members of the feature * collection that the cursor of the given <code>XMLStreamReader</code> points at. * * @param xmlStream * cursor must point at the <code>START_ELEMENT</code> event of a feature collection element * @param crs * default CRS for all descendant geometry properties, can be <code>null</code> * @return * @throws XMLStreamException */ public StreamFeatureCollection getFeatureStream( XMLStreamReaderWrapper xmlStream, ICRS crs ) throws XMLStreamException { if ( schema == null ) { schema = buildAppSchema( xmlStream ); gmlStreamReader.setApplicationSchema( schema ); } String fid = parseFeatureId( xmlStream ); QName featureName = xmlStream.getName(); FeatureCollectionType ft = (FeatureCollectionType) lookupFeatureType( xmlStream, featureName, true ); return new StreamFeatureCollection( fid, ft, this, xmlStream, crs ); }
private void exportFeaturePropertyByReference( QName propName, FeatureReference ref, boolean forceInclusionInDocument, GmlXlinkOptions resolveState ) throws XMLStreamException { writeEmptyElementWithNS( propName.getNamespaceURI(), propName.getLocalPart() ); String uri = null; if ( forceInclusionInDocument ) { resolveState = getResolveStateForNextLevel( resolveState ); uri = referenceExportStrategy.requireObject( ref, resolveState ); } else { uri = referenceExportStrategy.handleReference( ref ); } writeAttributeWithNS( XLNNS, "href", uri ); endEmptyElement(); }
private void exportEmptyProperty( final QName propName, final Map<QName,PrimitiveValue> attrs) throws XMLStreamException { writeEmptyElementWithNS( propName.getNamespaceURI(), propName.getLocalPart() ); writeAttributes( attrs ); endEmptyElement(); }
private void writeNilledElement( QName propName, Map<QName, PrimitiveValue> attributes ) throws XMLStreamException { writeEmptyElementWithNS( propName.getNamespaceURI(), propName.getLocalPart() ); writeNilAttributes( attributes ); endEmptyElement(); }
private void exportAlreadyExportedFeaturePropertyByReference( Feature ref, QName propName ) throws XMLStreamException { writeEmptyElementWithNS( propName.getNamespaceURI(), propName.getLocalPart() ); writeAttributeWithNS( XLNNS, "href", "#" + ref.getId() ); endEmptyElement(); }
/** * Returns the object representation for the feature (or feature collection) element event that the cursor of the * given <code>XMLStreamReader</code> points at. * * @param xmlStream * cursor must point at the <code>START_ELEMENT</code> event of the feature element, afterwards points at * the next event after the <code>END_ELEMENT</code> event of the feature element * @param crs * default CRS for all descendant geometry properties, can be <code>null</code> * @return object representation for the given feature element * @throws XMLStreamException * @throws UnknownCRSException * @throws XMLParsingException */ public Feature parseFeature( XMLStreamReaderWrapper xmlStream, ICRS crs ) throws XMLStreamException, XMLParsingException, UnknownCRSException { if ( schema == null ) { schema = buildAppSchema( xmlStream ); gmlStreamReader.setApplicationSchema( schema ); } if ( schema instanceof DynamicAppSchema ) { return parseFeatureDynamic( xmlStream, crs, (DynamicAppSchema) schema ); } return parseFeatureStatic( xmlStream, crs ); }
/** * Returns the deegree model representation for the GML feature element event that the cursor of the underlying xml * stream points to. * * @return deegree model representation for the current GML feature element, never <code>null</code> * @throws XMLStreamException * @throws XMLParsingException * @throws UnknownCRSException */ public Feature readFeature() throws XMLStreamException, XMLParsingException, UnknownCRSException { return getFeatureReader().parseFeature( xmlStream, defaultCRS ); }
@SuppressWarnings("unchecked") public Iterator<T> getMembers() { if ( fc != null ) { return (Iterator<T>) fc.iterator(); } return new Iterator<T>() { @Override public boolean hasNext() { return xmlStream.isStartElement() && WFS200_MEMBER.equals( xmlStream.getName() ); } @Override public T next() { if ( !hasNext() ) { throw new NoSuchElementException(); } T value = null; try { value = parse200MemberProperty(); } catch ( Throwable t ) { throw new RuntimeException( t.getMessage(), t ); } return value; } @Override public void remove() { throw new UnsupportedOperationException(); } }; }
@Override public Feature next() { if ( next == null ) { throw new NoSuchElementException(); } Feature currentFeature = next; try { next = read(); } catch ( IOException e ) { throw new RuntimeException(); } return currentFeature; }
/** * Returns a {@link StreamFeatureCollection} that allows stream-based access to the members of the feature * collection that the cursor of the given <code>XMLStreamReader</code> points at. * <p> * This method does not automatically consume all events from the underlying XML stream. Instead, it allows the * caller to control the consumption by iterating over the features in the returned collection. * </p> * * @return deegree model representation for the current GML feature collection element, never <code>null</code> * @throws XMLStreamException * @throws XMLParsingException * @throws UnknownCRSException */ public StreamFeatureCollection readFeatureCollectionStream() throws XMLStreamException, XMLParsingException, UnknownCRSException { return getFeatureReader().getFeatureStream( xmlStream, defaultCRS ); }
private void writeAttributes( final Map<QName, PrimitiveValue> attrs ) throws XMLStreamException { if ( attrs != null ) { for ( final Entry<QName, PrimitiveValue> attr : attrs.entrySet() ) { writeAttributeWithNS( attr.getKey().getNamespaceURI(), attr.getKey().getLocalPart(), attr.getValue().getAsText() ); } } }
/** * Exports the given {@link Feature} (or {@link FeatureCollection}). * * @param feature * feature to be exported, must not be <code>null</code> * @throws XMLStreamException * @throws UnknownCRSException * @throws TransformationException */ public void export( Feature feature ) throws XMLStreamException, UnknownCRSException, TransformationException { export( feature, referenceExportStrategy.getResolveOptions() ); }
/** * Returns the deegree model representation for the GML feature collection element event that the cursor of the * underlying xml stream points to. * <p> * Please note that {@link #readFeatureCollectionStream()} should be preferred (especially for large feature * collections), because it does not build and store all features in memory at once. * </p> * * @return deegree model representation for the current GML feature collection element, never <code>null</code> * @throws XMLStreamException * @throws XMLParsingException * @throws UnknownCRSException */ public FeatureCollection readFeatureCollection() throws XMLStreamException, XMLParsingException, UnknownCRSException { return (FeatureCollection) getFeatureReader().parseFeature( xmlStream, defaultCRS ); }
/** * Writes a GML representation of the given {@link Feature} to the stream. * * @param feature * feature to be written, must not be <code>null</code> * @throws XMLStreamException * @throws UnknownCRSException * @throws TransformationException */ public void write( Feature feature ) throws XMLStreamException, UnknownCRSException, TransformationException { getFeatureWriter().export( feature ); }
private Feature readFeatureArray() throws XMLParsingException, XMLStreamException, UnknownCRSException { Feature feature = null; if ( xmlStream.getEventType() == START_ELEMENT ) { feature = featureReader.parseFeature( xmlStream, activeCRS ); } if ( xmlStream.next() == END_ELEMENT ) { LOG.debug( "End of feature array property encountered." ); featureArrayMode = false; propOccurences++; } return feature; }
private void exportStandardProps( Geometry geom ) throws XMLStreamException, UnknownCRSException, TransformationException { if ( geom.getProperties() != null ) { for ( Property prop : geom.getProperties() ) { if ( isStandardProperty( prop.getName() ) ) { gmlStreamWriter.getFeatureWriter().export( prop ); } } } }