@Override public GMLObjectType getGeometryType( QName gtName ) { final GMLObjectType gmlObjectType = typeNameToType.get( gtName ); if ( gmlObjectType == null || gmlObjectType.getCategory() != GEOMETRY ) { return null; } return gmlObjectType; }
private FeatureType buildFeatureType( XSElementDeclaration elDecl ) { final GMLObjectType type = objectTypeFactory.build( elDecl ); final List<XSElementDeclaration> fcDecls = gmlSchema.getFeatureCollectionElementDeclarations( null, false ); if ( fcDecls.contains( elDecl ) ) { return new GenericFeatureCollectionType( type.getName(), type.getPropertyDeclarations(), elDecl.getAbstract() ); } return new GenericFeatureType( type.getName(), type.getPropertyDeclarations(), elDecl.getAbstract() ); }
private Set<QName> getConcreteSubstitutions( AppSchema appSchema, QName elName ) { Set<QName> elNames = new HashSet<QName>(); GMLObjectType type = appSchema.getGeometryType( elName ); if ( type != null ) { if ( !type.isAbstract() ) { elNames.add( type.getName() ); } for ( GMLObjectType substitution : appSchema.getSubstitutions( type.getName() ) ) { if ( !substitution.isAbstract() ) { elNames.add( substitution.getName() ); } } } return elNames; }
private List<Property> readAdditionalProperties( XMLStreamReaderWrapper xmlStream, GMLObjectType type, ICRS crs ) throws XMLParsingException, XMLStreamException, UnknownCRSException { List<Property> props = new ArrayList<Property>(); if ( type != null ) { while ( xmlStream.isStartElement() ) { QName propName = xmlStream.getName(); // TODO cope with order, cardinality and substitutable properties PropertyType pt = type.getPropertyDeclaration( propName ); if ( pt == null ) { String msg = "Geometry property element '" + propName + "' is not defined in application schema."; throw new XMLParsingException( xmlStream, msg ); } props.add( parseProperty( xmlStream, pt, crs ) ); XMLStreamUtils.nextElement( xmlStream ); } } return props; } }
if ( gmlObjectTypes != null ) { for ( final GMLObjectType gmlObjectType : gmlObjectTypes ) { typeNameToType.put( gmlObjectType.getName(), gmlObjectType ); if ( gmlObjectType.getCategory() == GEOMETRY ) { geometryTypes.add( gmlObjectType );
@Override public List<GMLObjectType> getSubstitutions( QName name ) { List<GMLObjectType> directSubtypes = getDirectSubstitutions( name ); List<GMLObjectType> result = new ArrayList<GMLObjectType>( typeNameToType.size() ); if ( directSubtypes != null && !directSubtypes.isEmpty() ) { for ( GMLObjectType son : directSubtypes ) { if ( son != null ) { result.add( son ); List<GMLObjectType> sons = getSubstitutions( son.getName() ); if ( sons != null ) { result.addAll( sons ); } } } } return result; }
private List<Property> readStandardProperties( XMLStreamReaderWrapper xmlStream, GMLObjectType type, ICRS crs ) throws XMLParsingException, XMLStreamException, UnknownCRSException { List<Property> props = new ArrayList<Property>(); nextElement( xmlStream ); while ( xmlStream.isStartElement() && isStandardProperty( xmlStream.getName() ) ) { if ( type != null ) { QName propName = xmlStream.getName(); // TODO check order, cardinality and substitutable properties PropertyType pt = type.getPropertyDeclaration( propName ); if ( pt == null ) { String msg = "GML standard property element '" + propName + "' is not defined in application schema!?"; throw new XMLParsingException( xmlStream, msg ); } Property prop = parseProperty( xmlStream, pt, crs ); props.add( prop ); } else { // handle without schema assistance -> skip skipElement( xmlStream ); } nextElement( xmlStream ); } return props; }
private static QName getName( GMLObject object ) { if ( object.getType() != null ) { return object.getType().getName(); } if ( object instanceof Feature ) { return ( (Feature) object ).getName(); } else if ( object instanceof Geometry ) { // TODO should be covered by the type return new QName( "GEOMETRY" ); } else if ( object instanceof TimeInstant ) { return new QName( GML3_2_NS, "TimeInstant" ); } else if ( object instanceof TimePeriod ) { return new QName( GML3_2_NS, "TimePeriod" ); } throw new IllegalArgumentException( "Creating GMLObjectNode from " + object.getClass() + " needs implementation." ); }
} else if ( child instanceof GenericXMLElement ) { GenericXMLElement xmlEl = (GenericXMLElement) child; PropertyType pt = ot.getPropertyDeclaration( xmlEl.getName() ); props.add( new GenericProperty( pt, xmlEl.getName(), null, xmlEl.getAttributes(), xmlEl.getChildren() ) ); } else {
private List<Property> parseProperties( XMLStreamReaderWrapper xmlStream, ICRS crs, GMLObjectType type ) throws XMLStreamException, UnknownCRSException { Iterator<PropertyType> declIter = type.getPropertyDeclarations().iterator(); PropertyType activeDecl = declIter.next(); int propOccurences = 0; activeDecl.getMaxOccurs(), type.getName() ); throw new XMLParsingException( xmlStream, msg ); String msg = null; if ( activeDecl.getMinOccurs() == 1 ) { msg = Messages.getMessage( "ERROR_PROPERTY_MANDATORY", activeDecl.getName(), type.getName() ); } else { msg = Messages.getMessage( "ERROR_PROPERTY_TOO_FEW_OCCURENCES", activeDecl.getName(), activeDecl.getMinOccurs(), type.getName() ); String msg = Messages.getMessage( "ERROR_PROPERTY_UNEXPECTED", propName, type.getName() ); throw new XMLParsingException( xmlStream, msg );
final GMLObjectType type = buildGenericObjectType( elDecl ); genericGmlObjectTypes.add( type ); typeNameToType.put( type.getName(), type ); final GMLObjectType type = buildGenericObjectType( elDecl ); genericGmlObjectTypes.add( type ); typeNameToType.put( type.getName(), type ); typeNameToType.put( type.getName(), type );
@Override public List<GMLObjectType> getGmlObjectTypes( final GMLObjectCategory category ) { final List<GMLObjectType> types = new ArrayList<GMLObjectType>(); for ( final GMLObjectType type : typeNameToType.values() ) { if ( type.getCategory() == category ) { types.add( type ); } } return types; }
public void export( final TimeSlice timeSlice, final GmlXlinkOptions resolveState ) throws XMLStreamException, UnknownCRSException, TransformationException { if ( timeSlice.getId() != null ) { referenceExportStrategy.addExportedId( timeSlice.getId() ); } final QName featureName = timeSlice.getType().getName(); LOG.debug( "Exporting TimeSlice {} with ID {}", featureName, timeSlice.getId() ); final String namespaceURI = featureName.getNamespaceURI(); final String localName = featureName.getLocalPart(); writeStartElementWithNS( namespaceURI, localName ); if ( timeSlice.getId() != null ) { if ( fidAttr.getNamespaceURI() == "" ) { writer.writeAttribute( fidAttr.getLocalPart(), timeSlice.getId() ); } else { writeAttributeWithNS( fidAttr.getNamespaceURI(), fidAttr.getLocalPart(), timeSlice.getId() ); } } for ( final Property prop : timeSlice.getProperties() ) { export( prop, resolveState ); } writer.writeEndElement(); }
final QName elName = xmlStream.getName(); final GMLObjectType type = schema.getGmlObjectType( elName ); if ( type == null || type.getCategory() != TIME_SLICE ) { final String msg = elName + " is not a valid TimeSlice element."; throw new XMLStreamException( msg );
private void startGeometry( String localName, Geometry geometry ) throws XMLStreamException, UnknownCRSException, TransformationException { GMLObjectType gmlType = geometry.getType(); if ( gmlType == null ) { writeStartElementWithNS( gmlNs, localName ); } else { QName elName = gmlType.getName(); writeStartElementWithNS( elName.getNamespaceURI(), elName.getLocalPart() ); } if ( geometry.getId() != null ) { referenceExportStrategy.addExportedId( geometry.getId() ); writeAttributeWithNS( gmlNs, "id", geometry.getId() ); } else if ( version == GML_32 && geometry.getId() == null ) { // in GML 3.2, a gml:id is required for every geometry writeAttributeWithNS( gmlNs, "id", "GEOMETRY_" + generateNewId() ); } if ( outputCRS != null ) { writer.writeAttribute( "srsName", outputCRS.getAlias() ); } else if ( geometry.getCoordinateSystem() != null ) { writer.writeAttribute( "srsName", geometry.getCoordinateSystem().getAlias() ); } exportStandardProps( geometry ); }