GMLAppSchemaReader { public AppSchema extractAppSchema() { for ( QName ftName : ftNameToFtElement.keySet() ) { FeatureType ft = buildFeatureType( ftNameToFtElement.get( ftName ) ); ftNameToFt.put( ftName, ft ); } FeatureType[] fts = ftNameToFt.values().toArray( new FeatureType[ftNameToFt.size()] ); Map<FeatureType, FeatureType> ftSubstitution = new HashMap<FeatureType, FeatureType>(); for ( QName ftName : ftNameToSubstitutionGroupName.keySet() ) { QName substitutionFtName = ftNameToSubstitutionGroupName.get( ftName ); if ( substitutionFtName != null ) { ftSubstitution.put( ftNameToFt.get( ftName ), ftNameToFt.get( substitutionFtName ) ); } } final List<GMLObjectType> genericGmlObjectTypes = new ArrayList<GMLObjectType>(); for ( final XSElementDeclaration elDecl : gmlSchema.getGeometryElementDeclarations( null, false ) ) { final GMLObjectType type = buildGenericObjectType( elDecl ); genericGmlObjectTypes.add( type ); typeNameToType.put( type.getName(), type ); } Map<GMLObjectType, GMLObjectType> typeToSuperType = new HashMap<GMLObjectType, GMLObjectType>(); for ( QName ftName : geometryNameToSubstitutionGroupName.keySet() ) { QName substitutionFtName = geometryNameToSubstitutionGroupName.get( ftName ); if ( substitutionFtName != null ) { typeToSuperType.put( typeNameToType.get( ftName ), typeNameToType.get( substitutionFtName ) ); } } for ( final XSElementDeclaration elDecl : gmlSchema.getTimeObjectElementDeclarations( null, false ) ) { final GMLObjectType type = buildGenericObjectType( elDecl ); genericGmlObjectTypes.add( type ); typeNameToType.put( type.getName(), type ); } for ( final XSElementDeclaration elDecl : gmlSchema.getTimeSliceElementDeclarations( null, false ) ) { final GMLObjectType type = buildGenericObjectType( elDecl ); genericGmlObjectTypes.add( type ); typeNameToType.put( type.getName(), type ); } return new GenericAppSchema( fts, ftSubstitution, prefixToNs, gmlSchema, genericGmlObjectTypes, typeToSuperType ); } GMLAppSchemaReader( GMLVersion gmlVersion, Map<String, String> namespaceHints, File schemaFile );  GMLAppSchemaReader( GMLVersion gmlVersion, Map<String, String> namespaceHints, String... schemaUrls );  GMLAppSchemaReader( GMLVersion gmlVersion, Map<String, String> namespaceHints, LSInput... inputs ); private  GMLAppSchemaReader( final GMLSchemaInfoSet gmlSchema, final Map<String, String> namespaceHints ); AppSchema extractAppSchema();  }
@Test public void testParsingPhilosopher() throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException { String schemaURL = this.getClass().getResource( "../misc/schema/Philosopher.xsd" ).toString(); GMLAppSchemaReader adapter = new GMLAppSchemaReader( null, null, schemaURL ); AppSchema schema = adapter.extractAppSchema(); List<FeatureType> fts = schema.getFeatureTypes( "http: Assert.assertEquals( 4, fts.size() ); }
@Test public void testParsingPhilosopherAndWFS() throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException { String schemaURL = this.getClass().getResource( "../misc/schema/Philosopher.xsd" ).toString(); String schemaURL2 = "http: GMLAppSchemaReader adapter = new GMLAppSchemaReader( null, null, schemaURL, schemaURL2 ); List<FeatureType> fts = adapter.extractAppSchema().getFeatureTypes( "http: Assert.assertEquals( 4, fts.size() ); }
@Test public void testParsingCityGML() throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException { String schemaURL = "http: GMLAppSchemaReader adapter = new GMLAppSchemaReader( null, null, schemaURL ); AppSchema schema = adapter.extractAppSchema(); FeatureType[] fts = schema.getFeatureTypes(); Assert.assertEquals( 69, fts.length ); FeatureType buildingFt = schema.getFeatureType( QName.valueOf( "{http: PropertyType pt = buildingFt.getPropertyDeclaration( QName.valueOf( "{http: Assert.assertEquals( 8, pt.getSubstitutions().length ); }
@Test public void testParsingGeoSciML() throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException { String schemaURL = TestProperties.getProperty( "schema_geosciml" ); if ( schemaURL == null ) { return; } GMLAppSchemaReader adapter = new GMLAppSchemaReader( null, null, schemaURL ); AppSchema schema = adapter.extractAppSchema(); schema.getFeatureTypes(); }
@Test public void testParsingCite110SF0() throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException { String schemaURL = this.getClass().getResource( "../cite/schema/cite-gmlsf0.xsd" ).toString(); GMLAppSchemaReader adapter = new GMLAppSchemaReader( null, null, schemaURL ); List<FeatureType> fts = adapter.extractAppSchema().getFeatureTypes( "http: false, false ); Assert.assertEquals( 3, fts.size() ); }
@Test public void testParsingCite110SF1() throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException { String schemaURL = this.getClass().getResource( "../cite/schema/cite-gmlsf1.xsd" ).toString(); GMLAppSchemaReader adapter = new GMLAppSchemaReader( null, null, schemaURL ); FeatureType[] fts = adapter.extractAppSchema().getFeatureTypes(); Assert.assertEquals( 5, fts.length ); }
@Test public void testParsingCite110SF2() throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException { String schemaURL = this.getClass().getResource( "../cite/schema/cite-gmlsf2.xsd" ).toString(); GMLAppSchemaReader adapter = new GMLAppSchemaReader( null, null, schemaURL ); FeatureType[] fts = adapter.extractAppSchema().getFeatureTypes(); Assert.assertEquals( 6, fts.length ); }
@Test public void testParsingCite100DataFeatures() throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException { String schemaURL = this.getClass().getResource( "../cite/schema/all.xsd" ).toString(); GMLAppSchemaReader adapter = new GMLAppSchemaReader( null, null, schemaURL ); FeatureType[] fts = adapter.extractAppSchema().getFeatureTypes(); Assert.assertEquals( 21, fts.length ); }
@Test public void testCite100GeometryFeatureCollection() throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException { String schemaURL = this.getClass().getResource( "../cite/schema/all.xsd" ).toString(); GMLAppSchemaReader adapter = new GMLAppSchemaReader( null, null, schemaURL ); AppSchema schema = adapter.extractAppSchema(); FeatureCollectionType ft = (FeatureCollectionType) schema.getFeatureType( QName.valueOf( "{http: ft = (FeatureCollectionType) schema.getFeatureType( QName.valueOf( "{http: List<PropertyType> newPropertyDecls = schema.getNewPropertyDecls( ft ); }
@Test public void testParsingXPlanGML20() throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException { String schemaURL = TestProperties.getProperty( "schema_xplan2" ); if ( schemaURL == null ) { return; } GMLAppSchemaReader adapter = new GMLAppSchemaReader( GMLVersion.GML_31, null, schemaURL ); AppSchema schema = adapter.extractAppSchema(); Assert.assertEquals( 132, schema.getFeatureTypes().length ); }
@Test public void testParsingNAS511() throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException { String schemaURL = TestProperties.getProperty( "schema_nas511" ); if ( schemaURL == null ) { return; } GMLAppSchemaReader adapter = new GMLAppSchemaReader( GMLVersion.GML_30, null, schemaURL ); AppSchema schema = adapter.extractAppSchema(); Assert.assertEquals( 237, schema.getFeatureTypes().length ); QName ftName = new QName( "http: FeatureType ft = adapter.extractAppSchema().getFeatureType( ftName ); QName propName = new QName( "http: GeometryPropertyType pt = (GeometryPropertyType) ft.getPropertyDeclaration( propName ); assertEquals( 2, pt.getAllowedGeometryTypes().size() ); assertTrue( pt.getAllowedGeometryTypes().contains( GeometryPropertyType.GeometryType.CURVE ) ); assertTrue( pt.getAllowedGeometryTypes().contains( GeometryPropertyType.GeometryType.COMPOSITE_CURVE ) ); }
@Test public void testParsingINSPIREAddresses() throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException { String schemaURL = TestProperties.getProperty( "schema_inspire_addresses" ); if ( schemaURL == null ) { return; } GMLAppSchemaReader adapter = new GMLAppSchemaReader( GMLVersion.GML_32, null, schemaURL ); AppSchema schema = adapter.extractAppSchema(); FeatureType[] fts = schema.getFeatureTypes(); Assert.assertEquals( 75, fts.length ); for ( String ns : schema.getGMLSchema().getAppNamespaces() ) { System.out.println( ns ); } }
@Test public void testParsingCustomProperties() throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException { String schemaURL = this.getClass().getResource( "../misc/schema/CustomProperties.xsd" ).toString(); GMLAppSchemaReader adapter = new GMLAppSchemaReader( null, null, schemaURL ); List<FeatureType> fts = adapter.extractAppSchema().getFeatureTypes( "http: Assert.assertEquals( 1, fts.size() ); FeatureType ft = fts.get( 0 ); Assert.assertEquals( 9, ft.getPropertyDeclarations().size() ); }
@Test public void testAIXMNumberOfFeatureTypes() throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException { String schemaUrl = this.getClass().getResource( "../aixm/schema/message/AIXM_BasicMessage.xsd" ).toString(); GMLAppSchemaReader adapter = new GMLAppSchemaReader( null, null, schemaUrl ); AppSchema schema = adapter.extractAppSchema(); FeatureType[] fts = schema.getFeatureTypes(); Assert.assertEquals( 157, fts.length ); }
@Test public void testAIXMNumberOfGeometryTypes() throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException { String schemaUrl = this.getClass().getResource( "../aixm/schema/message/AIXM_BasicMessage.xsd" ).toString(); GMLAppSchemaReader adapter = new GMLAppSchemaReader( null, null, schemaUrl ); AppSchema schema = adapter.extractAppSchema(); Assert.assertEquals( 35, schema.getGeometryTypes().size() ); }
@Test public void testAIXMNumberOfTimeObjectTypes() throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException { final String schemaUrl = this.getClass().getResource( "../aixm/schema/message/AIXM_BasicMessage.xsd" ).toString(); final GMLAppSchemaReader adapter = new GMLAppSchemaReader( null, null, schemaUrl ); final AppSchema schema = adapter.extractAppSchema(); final List<GMLObjectType> objectTypes = schema.getGmlObjectTypes( TIME_OBJECT ); assertEquals( 10, objectTypes.size() ); }
@Test public void testAIXMNumberOfTimeSliceTypes() throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException { final String schemaUrl = this.getClass().getResource( "../aixm/schema/message/AIXM_BasicMessage.xsd" ).toString(); final GMLAppSchemaReader adapter = new GMLAppSchemaReader( null, null, schemaUrl ); final AppSchema schema = adapter.extractAppSchema(); final List<GMLObjectType> objectTypes = schema.getGmlObjectTypes( TIME_SLICE ); assertEquals( 127, objectTypes.size() ); }
@Test public void testAIXMCustomGeometryHierarchy() throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException { String schemaUrl = this.getClass().getResource( "../aixm/schema/message/AIXM_BasicMessage.xsd" ).toString(); GMLAppSchemaReader adapter = new GMLAppSchemaReader( null, null, schemaUrl ); AppSchema schema = adapter.extractAppSchema(); GMLObjectType pointType = schema.getGeometryType( valueOf( "{http: assertNotNull( pointType ); List<GMLObjectType> pointSubstitutions = schema.getSubstitutions( pointType.getName() ); assertEquals( 2, pointSubstitutions.size() ); GMLObjectType curveType = schema.getGeometryType( valueOf( "{http: assertNotNull( curveType ); List<GMLObjectType> curveSubstitutions = schema.getSubstitutions( curveType.getName() ); assertEquals( 2, curveSubstitutions.size() ); GMLObjectType surfaceType = schema.getGeometryType( valueOf( "{http: assertNotNull( surfaceType ); List<GMLObjectType> surfaceSubstitutions = schema.getSubstitutions( surfaceType.getName() ); assertEquals( 5, surfaceSubstitutions.size() ); }
@Test public void testAIXMCustomGeometryDeclarations() throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException { String schemaUrl = this.getClass().getResource( "../aixm/schema/message/AIXM_BasicMessage.xsd" ).toString(); GMLAppSchemaReader adapter = new GMLAppSchemaReader( null, null, schemaUrl ); AppSchema schema = adapter.extractAppSchema(); String aixmNs = "http: GMLObjectType gt = schema.getGeometryType( new QName( aixmNs, "Point" ) ); Assert.assertEquals( 9, gt.getPropertyDeclarations().size() ); assertPropertyType( gt, 0, new QName( GML3_2_NS, "metaDataProperty" ), 0, -1 ); assertPropertyType( gt, 1, new QName( GML3_2_NS, "description" ), 0, 1 ); assertPropertyType( gt, 2, new QName( GML3_2_NS, "descriptionReference" ), 0, 1 ); assertPropertyType( gt, 3, new QName( GML3_2_NS, "identifier" ), 0, 1 ); assertPropertyType( gt, 4, new QName( GML3_2_NS, "name" ), 0, -1 ); assertPropertyType( gt, 5, new QName( GML3_2_NS, "pos" ), 1, 1 ); assertPropertyType( gt, 6, new QName( GML3_2_NS, "coordinates" ), 1, 1 ); assertPropertyType( gt, 7, new QName( aixmNs, "horizontalAccuracy" ), 0, 1 ); assertPropertyType( gt, 8, new QName( aixmNs, "annotation" ), 0, -1 ); gt = schema.getGeometryType( new QName( aixmNs, "ElevatedPoint" ) ); Assert.assertEquals( 14, gt.getPropertyDeclarations().size() ); assertPropertyType( gt, 0, new QName( GML3_2_NS, "metaDataProperty" ), 0, -1 ); assertPropertyType( gt, 1, new QName( GML3_2_NS, "description" ), 0, 1 ); assertPropertyType( gt, 2, new QName( GML3_2_NS, "descriptionReference" ), 0, 1 ); assertPropertyType( gt, 3, new QName( GML3_2_NS, "identifier" ), 0, 1 ); assertPropertyType( gt, 4, new QName( GML3_2_NS, "name" ), 0, -1 ); assertPropertyType( gt, 5, new QName( GML3_2_NS, "pos" ), 1, 1 ); assertPropertyType( gt, 6, new QName( GML3_2_NS, "coordinates" ), 1, 1 ); assertPropertyType( gt, 7, new QName( aixmNs, "horizontalAccuracy" ), 0, 1 ); assertPropertyType( gt, 8, new QName( aixmNs, "annotation" ), 0, -1 ); assertPropertyType( gt, 9, new QName( aixmNs, "elevation" ), 0, 1 ); assertPropertyType( gt, 10, new QName( aixmNs, "geoidUndulation" ), 0, 1 ); assertPropertyType( gt, 11, new QName( aixmNs, "verticalDatum" ), 0, 1 ); assertPropertyType( gt, 12, new QName( aixmNs, "verticalAccuracy" ), 0, 1 ); assertPropertyType( gt, 13, new QName( aixmNs, "extension" ), 0, -1 ); gt = schema.getGeometryType( new QName( aixmNs, "Curve" ) ); Assert.assertEquals( 8, gt.getPropertyDeclarations().size() ); assertPropertyType( gt, 0, new QName( GML3_2_NS, "metaDataProperty" ), 0, -1 ); assertPropertyType( gt, 1, new QName( GML3_2_NS, "description" ), 0, 1 ); assertPropertyType( gt, 2, new QName( GML3_2_NS, "descriptionReference" ), 0, 1 ); assertPropertyType( gt, 3, new QName( GML3_2_NS, "identifier" ), 0, 1 ); assertPropertyType( gt, 4, new QName( GML3_2_NS, "name" ), 0, -1 ); assertPropertyType( gt, 5, new QName( GML3_2_NS, "segments" ), 1, 1 ); assertPropertyType( gt, 6, new QName( aixmNs, "horizontalAccuracy" ), 0, 1 ); assertPropertyType( gt, 7, new QName( aixmNs, "annotation" ), 0, -1 ); gt = schema.getGeometryType( new QName( aixmNs, "ElevatedCurve" ) ); Assert.assertEquals( 13, gt.getPropertyDeclarations().size() ); assertPropertyType( gt, 0, new QName( GML3_2_NS, "metaDataProperty" ), 0, -1 ); assertPropertyType( gt, 1, new QName( GML3_2_NS, "description" ), 0, 1 ); assertPropertyType( gt, 2, new QName( GML3_2_NS, "descriptionReference" ), 0, 1 ); assertPropertyType( gt, 3, new QName( GML3_2_NS, "identifier" ), 0, 1 ); assertPropertyType( gt, 4, new QName( GML3_2_NS, "name" ), 0, -1 ); assertPropertyType( gt, 5, new QName( GML3_2_NS, "segments" ), 1, 1 ); assertPropertyType( gt, 6, new QName( aixmNs, "horizontalAccuracy" ), 0, 1 ); assertPropertyType( gt, 7, new QName( aixmNs, "annotation" ), 0, -1 ); assertPropertyType( gt, 8, new QName( aixmNs, "elevation" ), 0, 1 ); assertPropertyType( gt, 9, new QName( aixmNs, "geoidUndulation" ), 0, 1 ); assertPropertyType( gt, 10, new QName( aixmNs, "verticalDatum" ), 0, 1 ); assertPropertyType( gt, 11, new QName( aixmNs, "verticalAccuracy" ), 0, 1 ); assertPropertyType( gt, 12, new QName( aixmNs, "extension" ), 0, -1 ); gt = schema.getGeometryType( new QName( aixmNs, "Surface" ) ); Assert.assertEquals( 8, gt.getPropertyDeclarations().size() ); assertPropertyType( gt, 0, new QName( GML3_2_NS, "metaDataProperty" ), 0, -1 ); assertPropertyType( gt, 1, new QName( GML3_2_NS, "description" ), 0, 1 ); assertPropertyType( gt, 2, new QName( GML3_2_NS, "descriptionReference" ), 0, 1 ); assertPropertyType( gt, 3, new QName( GML3_2_NS, "identifier" ), 0, 1 ); assertPropertyType( gt, 4, new QName( GML3_2_NS, "name" ), 0, -1 ); assertPropertyType( gt, 5, new QName( GML3_2_NS, "patches" ), 1, 1 ); assertPropertyType( gt, 6, new QName( aixmNs, "horizontalAccuracy" ), 0, 1 ); assertPropertyType( gt, 7, new QName( aixmNs, "annotation" ), 0, -1 ); gt = schema.getGeometryType( new QName( aixmNs, "ElevatedSurface" ) ); Assert.assertEquals( 13, gt.getPropertyDeclarations().size() ); assertPropertyType( gt, 0, new QName( GML3_2_NS, "metaDataProperty" ), 0, -1 ); assertPropertyType( gt, 1, new QName( GML3_2_NS, "description" ), 0, 1 ); assertPropertyType( gt, 2, new QName( GML3_2_NS, "descriptionReference" ), 0, 1 ); assertPropertyType( gt, 3, new QName( GML3_2_NS, "identifier" ), 0, 1 ); assertPropertyType( gt, 4, new QName( GML3_2_NS, "name" ), 0, -1 ); assertPropertyType( gt, 5, new QName( GML3_2_NS, "patches" ), 1, 1 ); assertPropertyType( gt, 6, new QName( aixmNs, "horizontalAccuracy" ), 0, 1 ); assertPropertyType( gt, 7, new QName( aixmNs, "annotation" ), 0, -1 ); assertPropertyType( gt, 8, new QName( aixmNs, "elevation" ), 0, 1 ); assertPropertyType( gt, 9, new QName( aixmNs, "geoidUndulation" ), 0, 1 ); assertPropertyType( gt, 10, new QName( aixmNs, "verticalDatum" ), 0, 1 ); assertPropertyType( gt, 11, new QName( aixmNs, "verticalAccuracy" ), 0, 1 ); assertPropertyType( gt, 12, new QName( aixmNs, "extension" ), 0, -1 ); }
@Test public void testAIXMTimeSliceDeclarations() throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException { String schemaUrl = this.getClass().getResource( "../aixm/schema/message/AIXM_BasicMessage.xsd" ).toString(); GMLAppSchemaReader adapter = new GMLAppSchemaReader( null, null, schemaUrl ); AppSchema schema = adapter.extractAppSchema(); GMLSchemaInfoSet gmlSchema = schema.getGMLSchema(); List<XSElementDeclaration> timeSliceElementDecls = gmlSchema.getTimeSliceElementDeclarations( null, true ); Assert.assertEquals( 126, timeSliceElementDecls.size() ); }
@Test public void testAIXMTimeSlicePropertyDeclarations() throws ClassCastException, ClassNotFoundException, InstantiationException, IllegalAccessException { String schemaUrl = this.getClass().getResource( "../aixm/schema/message/AIXM_BasicMessage.xsd" ).toString(); GMLAppSchemaReader adapter = new GMLAppSchemaReader( null, null, schemaUrl ); AppSchema schema = adapter.extractAppSchema(); GMLSchemaInfoSet gmlSchema = schema.getGMLSchema(); String aixmNs = "http: QName ftName = new QName( aixmNs, "Unit" ); FeatureType ft = schema.getFeatureType( ftName ); QName propName = new QName( aixmNs, "timeSlice" ); PropertyType pt = ft.getPropertyDeclaration( propName ); XSElementDeclaration propDecl = pt.getElementDecl(); GMLPropertySemantics propertySemantics = gmlSchema.getTimeSlicePropertySemantics( propDecl ); assertNotNull( propertySemantics ); propName = new QName( GML3_2_NS, "identifier" ); pt = ft.getPropertyDeclaration( propName ); propDecl = pt.getElementDecl(); propertySemantics = gmlSchema.getTimeSlicePropertySemantics( propDecl ); assertNull( propertySemantics ); }