• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java CityGMLInputFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.citygml4j.xml.io.CityGMLInputFactory的典型用法代码示例。如果您正苦于以下问题:Java CityGMLInputFactory类的具体用法?Java CityGMLInputFactory怎么用?Java CityGMLInputFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CityGMLInputFactory类属于org.citygml4j.xml.io包,在下文中一共展示了CityGMLInputFactory类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getProperty

import org.citygml4j.xml.io.CityGMLInputFactory; //导入依赖的package包/类
public Object getProperty(String name) {
	Objects.requireNonNull("property name may not be null.");

	if (name.equals(CityGMLInputFactory.FEATURE_READ_MODE))
		return featureReadMode;
	if (name.equals(CityGMLInputFactory.KEEP_INLINE_APPEARANCE))
		return keepInlineAppearance;
	if (name.equals(CityGMLInputFactory.PARSE_SCHEMA))
		return parseSchema;
	if (name.equals(CityGMLInputFactory.USE_VALIDATION))
		return useValidation;
	if (name.equals(CityGMLInputFactory.EXCLUDE_FROM_SPLITTING))
		return excludes;
	if (name.equals(CityGMLInputFactory.SPLIT_AT_FEATURE_PROPERTY))
		return splitAtFeatureProperties;
	if (name.equals(CityGMLInputFactory.FAIL_ON_MISSING_ADE_SCHEMA))
		return failOnMissingADESchema;
	if (name.equals(CityGMLInputFactory.SUPPORT_CITYGML_VERSION_0_4_0))
		return supportCityGML040;

	throw new IllegalArgumentException("the property '" + name + "' is not supported.");
}
 
开发者ID:citygml4j,项目名称:citygml4j,代码行数:23,代码来源:JAXBInputFactory.java


示例2: readCityGMLFile

import org.citygml4j.xml.io.CityGMLInputFactory; //导入依赖的package包/类
/**
 * Returns a list for BuildingCallable read by CityGML file
 * 
 * @param pathtocitygmlfile
 * @param options
 * @return List<BuildingCallable>
 * @throws Exception
 */
public List<BuildingCallable> readCityGMLFile(String pathtocitygmlfile, Options options) throws Exception {

	this.options = options;
	
	List<BuildingCallable> buildings = new ArrayList<BuildingCallable>();
	
	CityGMLContext ctx = new CityGMLContext();
	CityGMLBuilder builder = ctx.createCityGMLBuilder();
	CityGMLInputFactory in = builder.createCityGMLInputFactory();
	CityGMLReader reader = in.createCityGMLReader(new File(pathtocitygmlfile));
	
	while (reader.hasNext()) {
		CityGML citygml = reader.nextFeature();
		
		if (citygml.getCityGMLClass() == CityGMLClass.CITY_MODEL) {
			CityModel cityModel = (CityModel)citygml;
			
			for (CityObjectMember cityObjectMember : cityModel.getCityObjectMember()) {
				AbstractCityObject cityObject = cityObjectMember.getCityObject();
				if (cityObject.getCityGMLClass() == CityGMLClass.BUILDING){
					
					Building building = (Building)cityObject;
					String buildingID = building.getId();
					BuildingCallable buildingcallable = new BuildingCallable();
					buildingcallable.setBsp(building.getBoundedBySurface());
					buildingcallable.setBuildingId(buildingID);
					buildingcallable.setOptions(options);
					buildings.add(buildingcallable);
				}	
			}
		}	
	}			
	
	reader.close();
	return buildings;
}
 
开发者ID:SteuerHorst,项目名称:Voluminator,代码行数:45,代码来源:BuildingReader.java


示例3: AbstractJAXBReader

import org.citygml4j.xml.io.CityGMLInputFactory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public AbstractJAXBReader(XMLStreamReader reader, InputStream in, JAXBInputFactory factory, URI baseURI) throws CityGMLReadException {		
	if ((Boolean)factory.getProperty(CityGMLInputFactory.SUPPORT_CITYGML_VERSION_0_4_0))
		reader = new CityGMLNamespaceMapper(reader);

	this.reader = reader;
	this.in = in;
	this.factory = factory;
	this.baseURI = baseURI;

	transformerChainFactory = factory.getTransformerChainFactory();
	parseSchema = (Boolean)factory.getProperty(CityGMLInputFactory.PARSE_SCHEMA);
	useValidation = (Boolean)factory.getProperty(CityGMLInputFactory.USE_VALIDATION);
	failOnMissingADESchema = (Boolean)factory.getProperty(CityGMLInputFactory.FAIL_ON_MISSING_ADE_SCHEMA);

	schemaHandler = factory.getSchemaHandler();
	jaxbUnmarshaller = factory.builder.createJAXBUnmarshaller(schemaHandler);
	jaxbUnmarshaller.setThrowMissingADESchema(failOnMissingADESchema);

	elementChecker = new XMLElementChecker(schemaHandler, 
			(FeatureReadMode)factory.getProperty(CityGMLInputFactory.FEATURE_READ_MODE),
			(Boolean)factory.getProperty(CityGMLInputFactory.KEEP_INLINE_APPEARANCE),
			parseSchema,
			failOnMissingADESchema,
			(List<QName>)factory.getProperty(CityGMLInputFactory.EXCLUDE_FROM_SPLITTING),
			(List<QName>)factory.getProperty(CityGMLInputFactory.SPLIT_AT_FEATURE_PROPERTY));

	if (useValidation) {
		validationSchemaHandler = new ValidationSchemaHandler(schemaHandler);
		validationEventHandler = factory.getValidationEventHandler();
	}
}
 
开发者ID:citygml4j,项目名称:citygml4j,代码行数:33,代码来源:AbstractJAXBReader.java


示例4: main

import org.citygml4j.xml.io.CityGMLInputFactory; //导入依赖的package包/类
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");
}
 
开发者ID:citygml4j,项目名称:citygml4j,代码行数:36,代码来源:FilteredReader.java


示例5: main

import org.citygml4j.xml.io.CityGMLInputFactory; //导入依赖的package包/类
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.getCityGMLModule().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");
}
 
开发者ID:citygml4j,项目名称:citygml4j,代码行数:35,代码来源:SimpleReader.java


示例6: main

import org.citygml4j.xml.io.CityGMLInputFactory; //导入依赖的package包/类
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");
}
 
开发者ID:citygml4j,项目名称:citygml4j,代码行数:36,代码来源:FeatureChunkReader.java


示例7: main

import org.citygml4j.xml.io.CityGMLInputFactory; //导入依赖的package包/类
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");
}
 
开发者ID:citygml4j,项目名称:citygml4j,代码行数:28,代码来源:ValidatingSimpleReader.java


示例8: main

import org.citygml4j.xml.io.CityGMLInputFactory; //导入依赖的package包/类
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");
}
 
开发者ID:citygml4j,项目名称:citygml4j,代码行数:40,代码来源:ValidatingChunkReader.java


示例9: main

import org.citygml4j.xml.io.CityGMLInputFactory; //导入依赖的package包/类
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");
}
 
开发者ID:citygml4j,项目名称:citygml4j,代码行数:32,代码来源:MissingSchemaReference.java


示例10: main

import org.citygml4j.xml.io.CityGMLInputFactory; //导入依赖的package包/类
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");
}
 
开发者ID:citygml4j,项目名称:citygml4j,代码行数:35,代码来源:WrongSchemaLocation.java


示例11: main

import org.citygml4j.xml.io.CityGMLInputFactory; //导入依赖的package包/类
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");
}
 
开发者ID:citygml4j,项目名称:citygml4j,代码行数:32,代码来源:ReadingLocalADE.java


示例12: main

import org.citygml4j.xml.io.CityGMLInputFactory; //导入依赖的package包/类
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");
}
 
开发者ID:citygml4j,项目名称:citygml4j,代码行数:32,代码来源:ReadingRemoteADE.java


示例13: createCityGMLInputFactory

import org.citygml4j.xml.io.CityGMLInputFactory; //导入依赖的package包/类
public CityGMLInputFactory createCityGMLInputFactory() throws CityGMLBuilderException {
	return new JAXBInputFactory(this);
}
 
开发者ID:citygml4j,项目名称:citygml4j,代码行数:4,代码来源:CityGMLBuilder.java


示例14: main

import org.citygml4j.xml.io.CityGMLInputFactory; //导入依赖的package包/类
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();
	
	// create a fixed thread pool
	int nThreads = Runtime.getRuntime().availableProcessors() * 2;
	System.out.println(df.format(new Date()) + "setting up thread pool with " + nThreads + " threads");
	ExecutorService service = Executors.newFixedThreadPool(nThreads);
	
	System.out.println(df.format(new Date()) + "reading LOD3_Railway_v200.gml in a multithreaded fashion");
	
	// create a validating reader that chunks the input file on a per feature level
	CityGMLInputFactory in = builder.createCityGMLInputFactory();
	in.setProperty(CityGMLInputFactory.FEATURE_READ_MODE, FeatureReadMode.SPLIT_PER_FEATURE);
	in.setProperty(CityGMLInputFactory.USE_VALIDATION, true);
	
	CityGMLReader reader = in.createCityGMLReader(new File("datasets/LOD3_Railway_v200.gml"));
	
	while (reader.hasNext()) {
		// whereas the nextFeature() method of a CityGML reader completely unmarshals the 
		// XML chunk to an instance of the citygml4j object model and optionally validates
		// it before returning, the nextChunk() method returns faster but only provides a
		// set of SAX events.		
		final XMLChunk chunk = reader.nextChunk();
		
		// we forward every XML chunk to a separate thread of the thread pool
		// for unmarshalling and validation
		service.execute(() -> {
               try {
                   chunk.unmarshal();
               } catch (UnmarshalException | MissingADESchemaException e) {
                   //
               }

               // invoking the hasPassedXMLValidation() method prior to unmarshal()
               // or when using a non-validating CityGML reader will always yield false.
               boolean isValid = chunk.hasPassedXMLValidation();

               System.out.println("Thread '" + Thread.currentThread().getName() + "' unmarshalled " + chunk.getCityGMLClass() + "; valid: " + isValid);
           });
	}
	
	System.out.println(df.format(new Date()) + "shutting down threadpool");
	service.shutdown();
	service.awaitTermination(120, TimeUnit.SECONDS);
	
	reader.close();
	System.out.println(df.format(new Date()) + "sample citygml4j application successfully finished");
}
 
开发者ID:citygml4j,项目名称:citygml4j,代码行数:53,代码来源:MultithreadedReader.java


示例15: main

import org.citygml4j.xml.io.CityGMLInputFactory; //导入依赖的package包/类
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_Building_v100.gml");
	CityGMLInputFactory in = builder.createCityGMLInputFactory();
	CityGMLReader reader = in.createCityGMLReader(new File("datasets/LOD2_Building_v100.gml"));

	CityModel cityModel = (CityModel)reader.nextFeature();
	reader.close();
	
	System.out.println(df.format(new Date()) + "retrieving object with gml:id UUID_08371879-bde6-4ba6-9fc6-088ee2ce1913");
	XLinkResolver resolver = new XLinkResolver();
	AbstractGeometry geometry = resolver.getGeometry("UUID_08371879-bde6-4ba6-9fc6-088ee2ce1913", cityModel);
	System.out.println("gml:id 'UUID_08371879-bde6-4ba6-9fc6-088ee2ce1913' belongs to: " + geometry.getGMLClass());

	System.out.println(df.format(new Date()) + "retrieving direct and transitive parents");			
	ChildInfo info = new ChildInfo();
	
	System.out.println("Direct parent XML element: " + ((GML)geometry.getParent()).getGMLClass());
	
	AbstractGeometry parentGeometry = info.getParentGeometry(geometry);
	System.out.println("Direct parent geometry: " + parentGeometry.getGMLClass()
			+ ", gml:id='" + parentGeometry.getId() + "'");
	
	AbstractCityObject parentCityObject = info.getParentCityObject(geometry);
	System.out.println("Direct parent CityObject: " + parentCityObject.getCityGMLClass()
			+ ", gml:id='" + parentCityObject.getId() + "'");
	
	Building parentCityObjectByType = info.getParentCityObject(geometry, Building.class);
	System.out.println("Transitive parent CityObject of type Building: " + parentCityObjectByType.getCityGMLClass()
			+ ", gml:id='" + parentCityObjectByType.getId() + "'");

	LandUse noParent = info.getParentCityObject(geometry, LandUse.class);
	System.out.println("Transitive parent CityObject of type LandUse: " + noParent);

	AbstractCityObject rootCityObject = info.getRootCityObject(geometry);
	System.out.println("Root CityObject: " + rootCityObject.getCityGMLClass()
			+ ", gml:id='" + rootCityObject.getId() + "'");
	
	CityGML rootFeature = info.getRootCityGML(geometry);
	System.out.println("Root CityGML instance: " + rootFeature.getCityGMLClass());
	
	System.out.println(df.format(new Date()) + "sample citygml4j application successfully finished");
}
 
开发者ID:citygml4j,项目名称:citygml4j,代码行数:49,代码来源:AccessingParentElements.java


示例16: main

import org.citygml4j.xml.io.CityGMLInputFactory; //导入依赖的package包/类
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_CityObjectGroup_v100.gml");
	CityGMLInputFactory in = builder.createCityGMLInputFactory();
	CityGMLReader reader = in.createCityGMLReader(new File("datasets/LOD2_CityObjectGroup_v100.gml"));

	CityModel cityModel = (CityModel)reader.nextFeature();
	reader.close();
	
	System.out.println(df.format(new Date()) + "creating XLinkResolver");
	XLinkResolver xLinkResolver = new XLinkResolver();
	
	for (CityObjectMember member : cityModel.getCityObjectMember()) {
		if (member.isSetCityObject() && 
				member.getCityObject().getCityGMLClass() == CityGMLClass.CITY_OBJECT_GROUP) {
			CityObjectGroup group = (CityObjectGroup)member.getCityObject();
			
			for (CityObjectGroupMember groupMember : group.getGroupMember()) {
				System.out.println(df.format(new Date()) + "processing group member with role: " + groupMember.getGroupRole());					
				System.out.println(df.format(new Date()) + "resolving XLink to " + groupMember.getHref());
				AbstractCityObject cityObject = xLinkResolver.getAbstractGML(groupMember.getHref(), cityModel, AbstractCityObject.class);
				System.out.println("   Referenced city object: " + cityObject.getCityGMLClass() + 
						", gml:id='" + cityObject.getId() +"'");
				 
				if (cityObject.getId().equals("ID_76")) {
					Road road = (Road)cityObject;
					TrafficArea trafficArea = road.getTrafficArea().get(2).getTrafficArea();
					
					System.out.println(df.format(new Date()) + "resolving XLink to " + trafficArea.getLod2MultiSurface().getHref());
					ModelObject object = xLinkResolver.getObject(trafficArea.getLod2MultiSurface().getHref(), road);
					if (object instanceof MultiSurface) {
						MultiSurface multiSurface = (MultiSurface)object;
						System.out.println("   Referenced geometry: " + multiSurface.getGMLClass() + 
								", gml:id='" + multiSurface.getId() + "'");
					}
				}
			}
		}
	}
	
	System.out.println(df.format(new Date()) + "sample citygml4j application successfully finished");
}
 
开发者ID:citygml4j,项目名称:citygml4j,代码行数:48,代码来源:ResolvingInternalXlinks.java


示例17: main

import org.citygml4j.xml.io.CityGMLInputFactory; //导入依赖的package包/类
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");
}
 
开发者ID:citygml4j,项目名称:citygml4j,代码行数:64,代码来源:ObjectTreeValidationUsingSplitter.java


示例18: getCityGMLInputFactory

import org.citygml4j.xml.io.CityGMLInputFactory; //导入依赖的package包/类
private static CityGMLInputFactory getCityGMLInputFactory() throws JAXBException, CityGMLReadException {

		if (LoaderCityGML.in == null) {

			CityGMLContext ctx = new CityGMLContext();
			JAXBBuilder builder = ctx.createJAXBBuilder();

			LoaderCityGML.in = builder.createCityGMLInputFactory();

		}
		return LoaderCityGML.in;

	}
 
开发者ID:IGNF,项目名称:geoxygene,代码行数:14,代码来源:LoaderCityGML.java


示例19: convert

import org.citygml4j.xml.io.CityGMLInputFactory; //导入依赖的package包/类
/**
 * Converts all files of bliste from CityGML defined in inputfile to an OBJ-file in outputFolder.
 * @param inputfile
 * @param outputFolder
 * @param bliste
 * @throws Exception
 */
public static void convert(String inputfile, String outputFolder, String[] bliste ) throws Exception
{
	
	
	SimpleDateFormat df = new SimpleDateFormat("[HH:mm:ss] ");
	System.out.println(df.format(new Date()) + "setting up citygml4j context and JAXB builder");
	CityGMLContext ctx = new CityGMLContext();
	CityGMLBuilder builder = ctx.createCityGMLBuilder();
	System.out.println(df.format(new Date()) + "reading CityGML file " + inputfile + " completely into main memory");
	CityGMLInputFactory in = builder.createCityGMLInputFactory();
	CityGMLReader reader = in.createCityGMLReader(new File(inputfile));
	
	while (reader.hasNext()) {
		CityGML citygml = reader.nextFeature();
		
		System.out.println("Found " + citygml.getCityGMLClass() + 
				" version " + citygml.getCityGMLModule().getVersion());
		
		if (citygml.getCityGMLClass() == CityGMLClass.CITY_MODEL) {
			CityModel cityModel = (CityModel)citygml;

			System.out.println(df.format(new Date()) + "going through city model and counting building instances");
			
			for (CityObjectMember cityObjectMember : cityModel.getCityObjectMember()) {
				AbstractCityObject cityObject = cityObjectMember.getCityObject();
				if (cityObject.getCityGMLClass() == CityGMLClass.BUILDING)
				{
					
					Building building = (Building)cityObject;
					
					String buildingID = building.getId();

					if(bliste != null && isInList(bliste,buildingID ))
					{

							List<BoundarySurfaceProperty> bsp = building
									.getBoundedBySurface();

						PolygonConstructor pc = new PolygonConstructor();
				
						Polygon temp = new Polygon();
						
						
						String filename = outputFolder+ "/" + buildingID + ".obj";
						temp.saveObj(filename, pc.constructPolygons(bsp));
							
						
						}
				}
					}
						
				}
					
			}
	reader.close();
	System.out.println(df.format(new Date()) + "CityGMLToOBJ successfully finished");
}
 
开发者ID:SteuerHorst,项目名称:Voluminator,代码行数:65,代码来源:CityGMLToOBJ.java



注:本文中的org.citygml4j.xml.io.CityGMLInputFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java EntityOcelot类代码示例发布时间:2022-05-23
下一篇:
Java ReadLisener类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap