org.citygml4j.builder.jaxb.CityGMLBuilder Java Examples

The following examples show how to use org.citygml4j.builder.jaxb.CityGMLBuilder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JAXBInputFactory.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
public JAXBInputFactory(CityGMLBuilder builder, SchemaHandler schemaHandler) {
	this.builder = builder;
	this.schemaHandler = schemaHandler;

	xmlInputFactory = XMLInputFactory.newInstance();
	xmlInputFactory.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE);

	gmlIdManager = DefaultGMLIdManager.getInstance();
	validationEventHandler = null;
	featureReadMode = FeatureReadMode.NO_SPLIT;
	excludes = new ArrayList<>();
	splitAtFeatureProperties = new ArrayList<>();
	keepInlineAppearance = true;
	parseSchema = true;
	failOnMissingADESchema = true;
}
 
Example #2
Source File: QueryExecuter.java    From web-feature-service with Apache License 2.0 6 votes vote down vote up
public QueryExecuter(GetFeatureType wfsRequest,
		FeatureWriter writer,
		WorkerPool<DBSplittingResult> databaseWorkerPool,
		Object eventChannel,
		DatabaseConnectionPool connectionPool,
		CityGMLBuilder cityGMLBuilder,
		WFSConfig wfsConfig,
		Config config) {
	this.writer = writer;
	this.databaseWorkerPool = databaseWorkerPool;
	this.eventChannel = eventChannel;
	this.connectionPool = connectionPool;
	this.cityGMLBuilder = cityGMLBuilder;
	this.config = config;

	// get standard request parameters
	long maxFeatureCount = wfsConfig.getConstraints().getCountDefault();
	count = wfsRequest.isSetCount() && wfsRequest.getCount().longValue() < maxFeatureCount ? wfsRequest.getCount().longValue() : maxFeatureCount;		
	resultType = wfsRequest.getResultType();

	schemaMapping = ObjectRegistry.getInstance().getSchemaMapping();
	queryBuilder = new QueryBuilder(connectionPool.getActiveDatabaseAdapter(), schemaMapping);

	eventDispatcher = ObjectRegistry.getInstance().getEventDispatcher();
	eventDispatcher.addEventHandler(EventType.INTERRUPT, this);
}
 
Example #3
Source File: DBExportWorkerFactory.java    From importer-exporter with Apache License 2.0 6 votes vote down vote up
public DBExportWorkerFactory(OutputFile outputFile,
		SchemaMapping schemaMapping,
		CityGMLBuilder cityGMLBuilder,
		FeatureWriter featureWriter,
		WorkerPool<DBXlink> xlinkExporterPool,
		UIDCacheManager uidCacheManager,
		CacheTableManager cacheTableManager,
		Query query,
		Config config,
		EventDispatcher eventDispatcher) {
	this.outputFile = outputFile;
	this.schemaMapping = schemaMapping;
	this.cityGMLBuilder = cityGMLBuilder;
	this.featureWriter = featureWriter;
	this.xlinkExporterPool = xlinkExporterPool;
	this.uidCacheManager = uidCacheManager;
	this.cacheTableManager = cacheTableManager;
	this.query = query;
	this.config = config;
	this.eventDispatcher = eventDispatcher;
}
 
Example #4
Source File: DBImportWorkerFactory.java    From importer-exporter with Apache License 2.0 5 votes vote down vote up
public DBImportWorkerFactory(InputFile inputFile,
		ConnectionManager connectionManager,
		boolean isManagedTransaction,
		AbstractDatabaseAdapter databaseAdapter,
		SchemaMapping schemaMapping,
		CityGMLBuilder cityGMLBuilder,
		WorkerPool<DBXlink> xlinkWorkerPool,
		UIDCacheManager uidCacheManager,
		CityGMLFilter filter,
		AffineTransformer affineTransformer,
		ImportLogger importLogger,
		Config config,
		EventDispatcher eventDispatcher) {
	this.inputFile = inputFile;
	this.connectionManager = connectionManager;
	this.isManagedTransaction = isManagedTransaction;
	this.databaseAdapter = databaseAdapter;
	this.schemaMapping = schemaMapping;
	this.cityGMLBuilder = cityGMLBuilder;
	this.xlinkWorkerPool = xlinkWorkerPool;
	this.uidCacheManager = uidCacheManager;
	this.filter = filter;
	this.affineTransformer = affineTransformer;
	this.importLogger = importLogger;
	this.config = config;
	this.eventDispatcher = eventDispatcher;
}
 
Example #5
Source File: JAXBUnmarshaller.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public JAXBUnmarshaller(CityGMLBuilder builder, SchemaHandler schemaHandler) {
	this.builder = builder;
	this.schemaHandler = schemaHandler;

	citygml = new CityGMLUnmarshaller(this);
	gml = new GMLUnmarshaller(this);
	xal = new XALUnmarshaller();
	ade = new ADEUnmarshaller(this);

	try {
		dataTypeFactory = DatatypeFactory.newInstance();
	} catch (DatatypeConfigurationException e) {
		throw new RuntimeException("Failed to create DatatypeFactory.", e);
	}
}
 
Example #6
Source File: JAXBMarshaller.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public JAXBMarshaller(CityGMLBuilder builder, ModuleContext moduleContext) {
	this.builder = builder;
	this.moduleContext = moduleContext;

	citygml = new CityGMLMarshaller(this);
	gml = new GMLMarshaller(this);
	xal = new XALMarshaller();
	ade = new ADEMarshaller(this);
	
	try {
		dataTypeFactory = DatatypeFactory.newInstance();
	} catch (DatatypeConfigurationException e) {
		throw new RuntimeException("Failed to create DatatypeFactory.", e);
	}
}
 
Example #7
Source File: FilteredReader.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
	SimpleDateFormat df = new SimpleDateFormat("[HH:mm:ss] "); 

	System.out.println(df.format(new Date()) + "setting up citygml4j context and CityGML builder");
	CityGMLContext ctx = CityGMLContext.getInstance();
	CityGMLBuilder builder = ctx.createCityGMLBuilder();

	System.out.println(df.format(new Date()) + "reading only roads from CityGML file LOD2_CityObjectGroup_v100.gml");
	CityGMLInputFactory in = builder.createCityGMLInputFactory();
	in.setProperty(CityGMLInputFactory.FEATURE_READ_MODE, FeatureReadMode.SPLIT_PER_FEATURE);

	CityGMLReader reader = in.createCityGMLReader(new File("datasets/LOD2_CityObjectGroup_v100.gml"));
	reader = in.createFilteredCityGMLReader(reader, new CityGMLInputFilter() {

		// return true if you want to consume the CityGML feature
		// of the given qualified XML name, false otherwise
		public boolean accept(QName name) {
			return Modules.isModuleNamespace(name.getNamespaceURI(), CityGMLModuleType.TRANSPORTATION)
					&& name.getLocalPart().equals("Road");
		}
		
	});

	System.out.println(df.format(new Date()) + "printing road features");
	while (reader.hasNext()) {
		Road road = (Road)reader.nextFeature();
		System.out.println(df.format(new Date()) + "found Road with gml:id " + road.getId());	
		
		System.out.println(df.format(new Date()) + "\t" + road.getTrafficArea().size() + " traffic area(s)");	
		System.out.println(df.format(new Date()) + "\t" + road.getAuxiliaryTrafficArea().size() + " auxiliary traffic area(s)");	
	}

	reader.close();
	System.out.println(df.format(new Date()) + "sample citygml4j application successfully finished");
}
 
Example #8
Source File: SimpleReader.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
	SimpleDateFormat df = new SimpleDateFormat("[HH:mm:ss] "); 

	System.out.println(df.format(new Date()) + "setting up citygml4j context and CityGML builder");
	CityGMLContext ctx = CityGMLContext.getInstance();
	CityGMLBuilder builder = ctx.createCityGMLBuilder();
	
	System.out.println(df.format(new Date()) + "reading CityGML file LOD2_Buildings_v100.gml completely into main memory");
	CityGMLInputFactory in = builder.createCityGMLInputFactory();
	CityGMLReader reader = in.createCityGMLReader(new File("datasets/LOD2_Buildings_v100.gml"));
	
	while (reader.hasNext()) {
		CityGML citygml = reader.nextFeature();

		if (citygml.getCityGMLClass() == CityGMLClass.CITY_MODEL) {
			CityModel cityModel = (CityModel)citygml;

			System.out.println(df.format(new Date()) + "Found " + citygml.getCityGMLClass() + " version " + cityModel.getModule().getVersion());
			System.out.println(df.format(new Date()) + "going through city model and counting building instances");

			int count = 0;
			for (CityObjectMember cityObjectMember : cityModel.getCityObjectMember()) {
				AbstractCityObject cityObject = cityObjectMember.getCityObject();
				if (cityObject.getCityGMLClass() == CityGMLClass.BUILDING)
					count++;
			}

			System.out.println(df.format(new Date()) + "The city model contains " + count + " building features");
		}	
	}			
	
	reader.close();
	System.out.println(df.format(new Date()) + "sample citygml4j application successfully finished");
}
 
Example #9
Source File: FeatureChunkReader.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
	SimpleDateFormat df = new SimpleDateFormat("[HH:mm:ss] "); 

	System.out.println(df.format(new Date()) + "setting up citygml4j context and CityGML builder");
	CityGMLContext ctx = CityGMLContext.getInstance();
	CityGMLBuilder builder = ctx.createCityGMLBuilder();
	
	System.out.println(df.format(new Date()) + "reading CityGML file LOD3_Building_v200.gml feature by feature");
	CityGMLInputFactory in = builder.createCityGMLInputFactory();
	in.setProperty(CityGMLInputFactory.FEATURE_READ_MODE, FeatureReadMode.SPLIT_PER_FEATURE);
	in.setProperty(CityGMLInputFactory.EXCLUDE_FROM_SPLITTING, new QName[]{new QName("Door"), new QName("Address")});

	// see difference when setting to true
	in.setProperty(CityGMLInputFactory.KEEP_INLINE_APPEARANCE, false);
	
	CityGMLReader reader = in.createCityGMLReader(new File("datasets/LOD3_Building_v200.gml"));
	
	System.out.println(df.format(new Date()) + "printing feature currently read and its (transitive) parents");
	while (reader.hasNext()) {
		CityGML chunk = reader.nextFeature();	
		System.out.println("found: " + chunk.getCityGMLClass());
		
		if (reader.isSetParentInfo()) {
			ParentInfo parentInfo = reader.getParentInfo();
			System.out.println(" --parent: " + parentInfo.getCityGMLClass());
			
			while ((parentInfo = parentInfo.getParentInfo()) != null)
				System.out.println(" --transitive parent: " + parentInfo.getCityGMLClass());
		}
		
	}

	reader.close();
	System.out.println(df.format(new Date()) + "sample citygml4j application successfully finished");
}
 
Example #10
Source File: JAXBOutputFactory.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public JAXBOutputFactory(CityGMLBuilder builder, ModuleContext moduleContext, SchemaHandler schemaHandler) {
	this.builder = builder;
	this.schemaHandler = schemaHandler;
	this.moduleContext = moduleContext;

	gmlIdManager = DefaultGMLIdManager.getInstance();
	featureWriteMode = FeatureWriteMode.NO_SPLIT;
	excludes = new HashSet<>();
	keepInlineAppearance = true;
	splitCopy = true;
}
 
Example #11
Source File: ObjectTreeValidation.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
	SimpleDateFormat df = new SimpleDateFormat("[HH:mm:ss] "); 

	System.out.println(df.format(new Date()) + "setting up citygml4j context and CityGML builder");
	CityGMLContext ctx = CityGMLContext.getInstance();
	CityGMLBuilder builder = ctx.createCityGMLBuilder();
	
	// creating example (and simple) CityGML object tree
	System.out.println(df.format(new Date()) + "creating simple city model with invalid content");
	Building building = new Building();
	
	// set invalid gml:id
	building.setId("1st-Building");
	
	// set empty and thus invalid generic attribute set
	building.addGenericAttribute(new GenericAttributeSet());
	
	CityModel cityModel = new CityModel();
	cityModel.addCityObjectMember(new CityObjectMember(building));
	
	System.out.println(df.format(new Date()) + "creating citygml4j Validator and validating city model against CityGML 2.0.0");
	SchemaHandler schemaHandler = SchemaHandler.newInstance();
	Validator validator = builder.createValidator(schemaHandler);
	
	validator.setValidationEventHandler(new ValidationEventHandler() {			
		public boolean handleEvent(ValidationEvent event) {
			System.out.println(event.getMessage());
			return true;
		}
	});		
	
	validator.validate(cityModel, CityGMLVersion.v2_0_0);
	System.out.println(df.format(new Date()) + "sample citygml4j application successfully finished");
}
 
Example #12
Source File: ValidatingSimpleReader.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
	SimpleDateFormat df = new SimpleDateFormat("[HH:mm:ss] "); 

	System.out.println(df.format(new Date()) + "setting up citygml4j context and CityGML builder");
	CityGMLContext ctx = CityGMLContext.getInstance();
	CityGMLBuilder builder = ctx.createCityGMLBuilder();
	
	System.out.println(df.format(new Date()) + "reading ADE-enriched CityGML file LOD2_SubsurfaceStructureADE_invalid_v100.gml");
	System.out.println(df.format(new Date()) + "ADE schema file is read from xsi:schemaLocation attribute on root XML element");
	CityGMLInputFactory in = builder.createCityGMLInputFactory();
	in.setProperty(CityGMLInputFactory.FEATURE_READ_MODE, FeatureReadMode.NO_SPLIT);
	in.parseSchema(new File("datasets/schemas/CityGML-SubsurfaceADE-0_9_0.xsd"));

	in.setProperty(CityGMLInputFactory.USE_VALIDATION, true);	
	in.setValidationEventHandler(event -> {
           System.out.print("[" + event.getLocator().getLineNumber() + "," + event.getLocator().getColumnNumber() + "] ");
           System.out.println(event.getMessage());
           return true;
       });
	
	System.out.println(df.format(new Date()) + "validating ADE-enriched CityGML document whilst reading");
	CityGMLReader reader = in.createCityGMLReader(new File("datasets/LOD2_SubsurfaceStructureADE_invalid_v100.gml"));
	reader.nextFeature();

	reader.close();
	System.out.println(df.format(new Date()) + "sample citygml4j application successfully finished");
}
 
Example #13
Source File: DBImportWorker.java    From importer-exporter with Apache License 2.0 5 votes vote down vote up
public DBImportWorker(InputFile inputFile,
		Connection connection,
		boolean isManagedTransaction,
		AbstractDatabaseAdapter databaseAdapter,
		SchemaMapping schemaMapping,
		CityGMLBuilder cityGMLBuilder,
		WorkerPool<DBXlink> xlinkPool,
		UIDCacheManager uidCacheManager,
		CityGMLFilter filter,
		AffineTransformer affineTransformer,
		ImportLogger importLogger,
		Config config,
		EventDispatcher eventDispatcher) throws SQLException {
	this.connection = connection;
	this.isManagedTransaction = isManagedTransaction;
	this.filter = filter;
	this.importLogger = importLogger;
	this.eventDispatcher = eventDispatcher;

	importer = new CityGMLImportManager(inputFile,
			connection,
			databaseAdapter,
			schemaMapping,
			cityGMLBuilder,
			xlinkPool,
			uidCacheManager,
			affineTransformer,
			config);

	Integer commitAfterProp = config.getProject().getDatabase().getUpdateBatching().getFeatureBatchValue();
	if (commitAfterProp != null && commitAfterProp > 0)
		commitAfter = commitAfterProp;

	bboxOptions = BoundingBoxOptions.defaults()				
			.useExistingEnvelopes(true)
			.assignResultToFeatures(true)
			.useReferencePointAsFallbackForImplicitGeometries(true);

	eventDispatcher.addEventHandler(EventType.INTERRUPT, this);
}
 
Example #14
Source File: DBImportWorkerFactory.java    From importer-exporter with Apache License 2.0 5 votes vote down vote up
public DBImportWorkerFactory(InputFile inputFile,
		ConnectionManager connectionManager,
		AbstractDatabaseAdapter databaseAdapter,
		SchemaMapping schemaMapping,
		CityGMLBuilder cityGMLBuilder,
		WorkerPool<DBXlink> xlinkWorkerPool,
		UIDCacheManager uidCacheManager,
		CityGMLFilter filter,
		AffineTransformer affineTransformer,
		ImportLogger importLogger,
		Config config,
		EventDispatcher eventDispatcher) {
	this(inputFile, connectionManager, true, databaseAdapter, schemaMapping, cityGMLBuilder, xlinkWorkerPool, uidCacheManager,
			filter, affineTransformer, importLogger, config, eventDispatcher);
}
 
Example #15
Source File: DBImportWorkerFactory.java    From importer-exporter with Apache License 2.0 5 votes vote down vote up
public DBImportWorkerFactory(InputFile inputFile,
		SchemaMapping schemaMapping,
		CityGMLBuilder cityGMLBuilder,
		WorkerPool<DBXlink> xlinkWorkerPool,
		UIDCacheManager uidCacheManager,
		CityGMLFilter filter,
		AffineTransformer affineTransformer,
		ImportLogger importLogger,
		Config config,
		EventDispatcher eventDispatcher) {
	this(inputFile, DatabaseConnectionPool.getInstance(), false, DatabaseConnectionPool.getInstance().getActiveDatabaseAdapter(), schemaMapping,
			cityGMLBuilder, xlinkWorkerPool, uidCacheManager, filter, affineTransformer, importLogger, config, eventDispatcher);
}
 
Example #16
Source File: Importer.java    From importer-exporter with Apache License 2.0 5 votes vote down vote up
public Importer(CityGMLBuilder cityGMLBuilder, 
		SchemaMapping schemaMapping,
		Config config, 
		EventDispatcher eventDispatcher) {
	this.cityGMLBuilder = cityGMLBuilder;
	this.schemaMapping = schemaMapping;
	this.config = config;
	this.eventDispatcher = eventDispatcher;

	databaseAdapter = DatabaseConnectionPool.getInstance().getActiveDatabaseAdapter();
	objectCounter = new HashMap<>();
	geometryCounter = new EnumMap<>(GMLClass.class);
}
 
Example #17
Source File: MissingSchemaReference.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
	SimpleDateFormat df = new SimpleDateFormat("[HH:mm:ss] "); 

	System.out.println(df.format(new Date()) + "setting up citygml4j context and CityGML builder");
	CityGMLContext ctx = CityGMLContext.getInstance();
	CityGMLBuilder builder = ctx.createCityGMLBuilder();

	System.out.println(df.format(new Date()) + "setting up schema handler");
	SchemaHandler schemaHandler = SchemaHandler.newInstance();
	schemaHandler.setSchemaEntityResolver(new SchemaEntityResolver());
	schemaHandler.setErrorHandler(new SchemaParseErrorHandler());

	System.out.println(df.format(new Date()) + "reading ADE-enriched CityGML file LOD0_Railway_NoiseADE_missing_ADE_reference_v200.gml");
	System.out.println(df.format(new Date()) + "note: the input document is lacking a reference to the ADE schema document");
	CityGMLInputFactory in = builder.createCityGMLInputFactory(schemaHandler);
	in.setProperty(CityGMLInputFactory.FEATURE_READ_MODE, FeatureReadMode.SPLIT_PER_FEATURE);
	
	CityGMLReader reader = in.createCityGMLReader(new File("datasets/LOD0_Railway_NoiseADE_missing_ADE_reference_v200.gml"));
	
	while (reader.hasNext()) {
		CityGML citygml = reader.nextFeature();
		
		if (citygml instanceof AbstractFeature)
			System.out.println("Found CityGML: " + citygml.getCityGMLClass());
		else if (citygml instanceof ADEGenericElement)
			System.out.println("Found ADE: " + ((ADEGenericElement)citygml).getContent().getLocalName());
	}
	
	reader.close();
	System.out.println(df.format(new Date()) + "sample citygml4j application successfully finished");
}
 
Example #18
Source File: StoredQueryManager.java    From web-feature-service with Apache License 2.0 5 votes vote down vote up
public StoredQueryManager(CityGMLBuilder cityGMLBuilder, WFSConfig wfsConfig) throws ParserConfigurationException, SAXException, NoSuchAlgorithmException, IOException {
	this.cityGMLBuilder = cityGMLBuilder;
	this.wfsConfig = wfsConfig;

	wfsFactory = new ObjectFactory();
	transformerFactory = TransformerFactory.newInstance();
	xmlOutputFactory = XMLOutputFactory.newInstance();
	documentBuilderFactory = DocumentBuilderFactory.newInstance();
	documentBuilderFactory.setNamespaceAware(true);

	DEFAULT_QUERY = createDefaultStoredQuery();
}
 
Example #19
Source File: ListStoredQueriesHandler.java    From web-feature-service with Apache License 2.0 5 votes vote down vote up
public ListStoredQueriesHandler(CityGMLBuilder cityGMLBuilder, WFSConfig wfsConfig) throws JAXBException {
	baseRequestHandler = new BaseRequestHandler(wfsConfig);
	storedQueryManager = (StoredQueryManager)ObjectRegistry.getInstance().lookup(StoredQueryManager.class.getName());
	
	wfsFactory = storedQueryManager.getObjectFactory();
	marshaller = cityGMLBuilder.getJAXBContext().createMarshaller();
}
 
Example #20
Source File: GetCapabilitiesHandler.java    From web-feature-service with Apache License 2.0 5 votes vote down vote up
public GetCapabilitiesHandler(CityGMLBuilder cityGMLBuilder, WFSConfig wfsConfig) throws JAXBException {
	this.wfsConfig = wfsConfig;

	conformance = new Conformance(wfsConfig);
	wfsFactory = new net.opengis.wfs._2.ObjectFactory();
	owsFactory = new net.opengis.ows._1.ObjectFactory();
	marshaller = cityGMLBuilder.getJAXBContext().createMarshaller();
	databaseAdapter = DatabaseConnectionPool.getInstance().getActiveDatabaseAdapter();
}
 
Example #21
Source File: ExportController.java    From web-feature-service with Apache License 2.0 5 votes vote down vote up
public ExportController(CityGMLBuilder cityGMLBuilder, WFSConfig wfsConfig, Config config) {
	this.cityGMLBuilder = cityGMLBuilder;
	this.wfsConfig = wfsConfig;
	this.config = config;

	connectionPool = DatabaseConnectionPool.getInstance();
	eventDispatcher = ObjectRegistry.getInstance().getEventDispatcher();
}
 
Example #22
Source File: AdditionalObjectsHandler.java    From web-feature-service with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
protected AdditionalObjectsHandler(SAXWriter saxWriter, CityGMLVersion version, CityGMLBuilder cityGMLBuilder, TransformerChainFactory transformerChainFactory, Object eventChannel) {
    this.saxWriter = saxWriter;
    this.version = version;
    this.cityGMLBuilder = cityGMLBuilder;
    this.transformerChainFactory = transformerChainFactory;
    this.eventChannel = eventChannel;

    cacheCleanerPool = (WorkerPool<CacheCleanerWork>) ObjectRegistry.getInstance().lookup(CacheCleanerWorker.class.getName());
    eventDispatcher = ObjectRegistry.getInstance().getEventDispatcher();
}
 
Example #23
Source File: GetFeatureHandler.java    From web-feature-service with Apache License 2.0 5 votes vote down vote up
public GetFeatureHandler(CityGMLBuilder cityGMLBuilder, WFSConfig wfsConfig, Config config) {
	this.wfsConfig = wfsConfig;

	databaseAdapter = DatabaseConnectionPool.getInstance().getActiveDatabaseAdapter();
	controller = new ExportController(cityGMLBuilder, wfsConfig, config);
	baseRequestHandler = new BaseRequestHandler(wfsConfig);
	featureTypeHandler = new FeatureTypeHandler();
	storedQueryManager = (StoredQueryManager)ObjectRegistry.getInstance().lookup(StoredQueryManager.class.getName());
	filterHandler = new FilterHandler();
}
 
Example #24
Source File: ReadingRemoteADE.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
	SimpleDateFormat df = new SimpleDateFormat("[HH:mm:ss] "); 

	System.out.println(df.format(new Date()) + "setting up citygml4j context and CityGML builder");
	CityGMLContext ctx = CityGMLContext.getInstance();
	CityGMLBuilder builder = ctx.createCityGMLBuilder();

	System.out.println(df.format(new Date()) + "reading ADE-enriched CityGML file LOD0_Railway_NoiseADE_from_Web_v200.gml");
	System.out.println(df.format(new Date()) + "remote ADE schema file is read from xsi:schemaLocation attribute on root XML element");
	CityGMLInputFactory in = builder.createCityGMLInputFactory();

	CityGMLReader reader = in.createCityGMLReader(new File("datasets/LOD0_Railway_NoiseADE_from_Web_v200.gml"));
	CityGML citygml = reader.nextFeature();
	reader.close();

	System.out.println(df.format(new Date()) + "exploring ADE content of Railway element");
	CityModel cityModel = (CityModel)citygml;
	Railway railway = (Railway)cityModel.getCityObjectMember().get(0).getCityObject();
	
	if (railway.isSetGenericApplicationPropertyOfRailway()) {
		System.out.println("Found ADE content for Railway instance:\n");

		List<ADEComponent> ades = railway.getGenericApplicationPropertyOfRailway();
		for (ADEComponent ade : ades) {
			if (ade.getADEClass() == ADEClass.GENERIC_ELEMENT)
				checkADE(in.getSchemaHandler(), ((ADEGenericElement)ade).getContent(), null, 0);
		}
	}
	
	System.out.println(df.format(new Date()) + "sample citygml4j application successfully finished");
}
 
Example #25
Source File: ReadingLocalADE.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
	SimpleDateFormat df = new SimpleDateFormat("[HH:mm:ss] "); 

	System.out.println(df.format(new Date()) + "setting up citygml4j context and CityGML builder");
	CityGMLContext ctx = CityGMLContext.getInstance();
	CityGMLBuilder builder = ctx.createCityGMLBuilder();

	System.out.println(df.format(new Date()) + "reading ADE-enriched CityGML file LOD0_Railway_NoiseADE_v200.gml");
	System.out.println(df.format(new Date()) + "ADE schema file is read from xsi:schemaLocation attribute on root XML element");
	CityGMLInputFactory in = builder.createCityGMLInputFactory();

	CityGMLReader reader = in.createCityGMLReader(new File("datasets/LOD0_Railway_NoiseADE_v200.gml"));
	CityGML citygml = reader.nextFeature();
	reader.close();

	System.out.println(df.format(new Date()) + "exploring ADE content of Railway element");
	CityModel cityModel = (CityModel)citygml;
	Railway railway = (Railway)cityModel.getCityObjectMember().get(0).getCityObject();
	
	if (railway.isSetGenericApplicationPropertyOfRailway()) {
		System.out.println("Found ADE content for Railway instance:\n");

		List<ADEComponent> ades = railway.getGenericApplicationPropertyOfRailway();
		for (ADEComponent ade : ades) {
			if (ade.getADEClass() == ADEClass.GENERIC_ELEMENT)
				checkADE(in.getSchemaHandler(), ((ADEGenericElement)ade).getContent(), null, 0);
		}
	}
	
	System.out.println(df.format(new Date()) + "sample citygml4j application successfully finished");
}
 
Example #26
Source File: WrongSchemaLocation.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
	SimpleDateFormat df = new SimpleDateFormat("[HH:mm:ss] "); 

	System.out.println(df.format(new Date()) + "setting up citygml4j context and CityGML builder");
	CityGMLContext ctx = CityGMLContext.getInstance();
	CityGMLBuilder builder = ctx.createCityGMLBuilder();

	System.out.println(df.format(new Date()) + "setting up schema handler");
	SchemaHandler schemaHandler = SchemaHandler.newInstance();
	schemaHandler.setSchemaEntityResolver(new SchemaEntityResolver());
	schemaHandler.setErrorHandler(new SchemaParseErrorHandler());
	
	// register false schema location in order to provoke a schema parse error
	schemaHandler.registerSchemaLocation("http://www.citygml.org/ade/noise_de/2.0", 
			new File("/nowhere/nofile.xsd"));

	System.out.println(df.format(new Date()) + "reading ADE-enriched CityGML file LOD0_Railway_NoiseADE_v200.gml");
	CityGMLInputFactory in = builder.createCityGMLInputFactory(schemaHandler);
	in.setProperty(CityGMLInputFactory.FEATURE_READ_MODE, FeatureReadMode.SPLIT_PER_FEATURE);

	CityGMLReader reader = in.createCityGMLReader(new File("datasets/LOD0_Railway_NoiseADE_v200.gml"));
	
	while (reader.hasNext()) {
		CityGML citygml = reader.nextFeature();
		
		if (citygml instanceof AbstractFeature)
			System.out.println("Found CityGML: " + citygml.getCityGMLClass());
		else if (citygml instanceof ADEGenericElement)
			System.out.println("Found ADE: " + ((ADEGenericElement)citygml).getContent().getLocalName());
	}
	
	reader.close();
	System.out.println(df.format(new Date()) + "sample citygml4j application successfully finished");
}
 
Example #27
Source File: Exporter.java    From importer-exporter with Apache License 2.0 5 votes vote down vote up
public Exporter(CityGMLBuilder cityGMLBuilder, 
		SchemaMapping schemaMapping, 
		Config config, 
		EventDispatcher eventDispatcher) {
	this.cityGMLBuilder = cityGMLBuilder;
	this.schemaMapping = schemaMapping;
	this.config = config;
	this.eventDispatcher = eventDispatcher;

	databaseAdapter = DatabaseConnectionPool.getInstance().getActiveDatabaseAdapter();
	objectCounter = new HashMap<>();
	geometryCounter = new EnumMap<>(GMLClass.class);
	totalObjectCounter = new HashMap<>();
	totalGeometryCounter = new EnumMap<>(GMLClass.class);
}
 
Example #28
Source File: DBExportWorker.java    From importer-exporter with Apache License 2.0 5 votes vote down vote up
public DBExportWorker(OutputFile outputFile,
		Connection connection,
		AbstractDatabaseAdapter databaseAdapter,
		SchemaMapping schemaMapping,
		CityGMLBuilder cityGMLBuilder,
		FeatureWriter featureWriter,
		WorkerPool<DBXlink> xlinkPool,
		UIDCacheManager uidCacheManager,
		CacheTableManager cacheTableManager,
		Query query,
		Config config,
		EventDispatcher eventDispatcher) throws CityGMLExportException {
	this.connection = connection;
	this.featureWriter = featureWriter;
	this.eventDispatcher = eventDispatcher;
	this.config = config;

	exporter = new CityGMLExportManager(
			outputFile,
			connection,
			query,
			databaseAdapter,
			schemaMapping, 
			cityGMLBuilder,
			featureWriter,
			xlinkPool,
			uidCacheManager,
			cacheTableManager,
			config);

	plugins = PluginManager.getInstance().getExternalPlugins(CityGMLExportExtension.class);
	eventDispatcher.addEventHandler(EventType.INTERRUPT, this);
}
 
Example #29
Source File: ValidatingChunkReader.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
	SimpleDateFormat df = new SimpleDateFormat("[HH:mm:ss] "); 

	System.out.println(df.format(new Date()) + "setting up citygml4j context and CityGML builder");
	CityGMLContext ctx = CityGMLContext.getInstance();
	CityGMLBuilder builder = ctx.createCityGMLBuilder();
	
	System.out.println(df.format(new Date()) + "reading ADE-enriched CityGML file LOD2_SubsurfaceStructureADE_invalid_v100.gml feature by feature");
	System.out.println(df.format(new Date()) + "ADE schema file is read from xsi:schemaLocation attribute on root XML element");
	CityGMLInputFactory in = builder.createCityGMLInputFactory();
	in.setProperty(CityGMLInputFactory.FEATURE_READ_MODE, FeatureReadMode.SPLIT_PER_FEATURE);
	in.setProperty(CityGMLInputFactory.USE_VALIDATION, true);
	in.registerSchemaLocation("http://www.citygml.org/ade/sub/0.9.0", new File("datasets/schemas/CityGML-SubsurfaceADE-0_9_0.xsd"));
		
	ValidationEventHandlerImpl validationEventHandler = new ValidationEventHandlerImpl();
	in.setValidationEventHandler(validationEventHandler);
	
	CityGMLReader reader = in.createCityGMLReader(new File("datasets/LOD2_SubsurfaceStructureADE_invalid_v100.gml"));
	
	System.out.println(df.format(new Date()) + "validating features whilst reading from file");
	while (reader.hasNext()) {
		CityGML chunk = reader.nextFeature();			

		String type;
		if (chunk instanceof ADEGenericElement){
			Element element = ((ADEGenericElement)chunk).getContent();
			type = element.getPrefix() + ':' + element.getLocalName();
		} else
			type = chunk.getCityGMLClass().toString();
		
		System.out.print(type + ": ");
		System.out.println(validationEventHandler.isValid ? "valid" : "invalid (see error messages above)");

		validationEventHandler.isValid = true;
	}

	reader.close();
	System.out.println(df.format(new Date()) + "sample citygml4j application successfully finished");
}
 
Example #30
Source File: ObjectTreeValidationUsingSplitter.java    From citygml4j with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
	/*
	 * PLEASE NOTE, that you receive less errors if the in-memory objects
	 * derived from the input document are validated than if the input document
	 * itself is validated.
	 * reason: citygml4j tries to reconstruct a valid object tree from the
	 * input document. Generally, this means
	 * 1) Invalid order of XML elements will be corrected automatically (see ADDRESS element)
	 * 2) Invalid text values of XML elements cannot be automatically corrected
	 *    and thus will be reported (see, e.g., gml:id of BUILDING element)
	 * 3) Invalid XML child elements will be omitted in the object tree (see CLOSURESURFACE element)
	 * 
	 * Due to 3) you should always make sure to generate object trees from 
	 * valid CityGML documents!
	 */
	
	SimpleDateFormat df = new SimpleDateFormat("[HH:mm:ss] "); 

	System.out.println(df.format(new Date()) + "setting up citygml4j context and CityGML builder");
	CityGMLContext ctx = CityGMLContext.getInstance();
	CityGMLBuilder builder = ctx.createCityGMLBuilder();
	
	System.out.println(df.format(new Date()) + "parsing ADE schema file CityGML-SubsurfaceADE-0_9_0.xsd");
	SchemaHandler schemaHandler = SchemaHandler.newInstance();
	schemaHandler.parseSchema(new File("datasets/schemas/CityGML-SubsurfaceADE-0_9_0.xsd"));

	System.out.println(df.format(new Date()) + "reading ADE-enriched CityGML file LOD2_SubsurfaceStructureADE_invalid_v100.gml");
	CityGMLInputFactory in = builder.createCityGMLInputFactory(schemaHandler);
	in.setProperty(CityGMLInputFactory.FEATURE_READ_MODE, FeatureReadMode.NO_SPLIT);

	CityGMLReader reader = in.createCityGMLReader(new File("datasets/LOD2_SubsurfaceStructureADE_invalid_v100.gml"));
	CityGML citygml = reader.nextFeature();		
	reader.close();
	
	System.out.println(df.format(new Date()) + "creating citygml4j Validator");
	Validator validator = builder.createValidator(schemaHandler);		
	validator.setValidationEventHandler(event -> {
           System.out.println("\t" + event.getMessage());
           return true;
       });
	
	System.out.println(df.format(new Date()) + "creating citygml4j FeatureSplitter and splitting document into single features");
	FeatureSplitter splitter = new FeatureSplitter()
			.setSchemaHandler(schemaHandler)
			.setSplitMode(FeatureSplitMode.SPLIT_PER_FEATURE)
			.splitCopy(true);
	
	System.out.println(df.format(new Date()) + "iterating over splitting result and validating features against CityGML 1.0.0");
	for (CityGML feature : splitter.split(citygml)) {
		
		String type;
		if (feature instanceof ADEGenericElement){
			Element element = ((ADEGenericElement)feature).getContent();
			type = element.getPrefix() + ':' + element.getLocalName();
		} else
			type = feature.getCityGMLClass().toString();
		
		System.out.println("Validating " + type);
		validator.validate(feature, CityGMLVersion.v1_0_0);
	}
	
	System.out.println(df.format(new Date()) + "sample citygml4j application successfully finished");
}