org.citygml4j.builder.cityjson.CityJSONBuilder Java Examples

The following examples show how to use org.citygml4j.builder.cityjson.CityJSONBuilder. 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: CityJSONReaderFactory.java    From importer-exporter with Apache License 2.0 6 votes vote down vote up
@Override
public void initializeContext(CityGMLFilter filter, Config config) throws FeatureReadException {
    CityJSONBuilder builder = CityGMLContext.getInstance().createCityJSONBuilder();
    try {
        factory = builder.createCityJSONInputFactory();
    } catch (CityJSONBuilderException e) {
        throw new FeatureReadException("Failed to initialize CityJSON input factory.", e);
    }

    // prepare feature filter
    typeFilter = name -> {
        Module module = Modules.getModule(name.getNamespaceURI());
        if (module != null && module.getType() == CityGMLModuleType.APPEARANCE && name.getLocalPart().equals("Appearance"))
            return config.getProject().getImporter().getAppearances().isSetImportAppearance();
        else
            return filter.getFeatureTypeFilter().isSatisfiedBy(name, true);
    };

    counterFilter = filter.getCounterFilter();
}
 
Example #2
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 CityJSON builder");
	CityGMLContext ctx = CityGMLContext.getInstance();
	CityJSONBuilder builder = ctx.createCityJSONBuilder();

	System.out.println(df.format(new Date()) + "reading only city furniture objects from CityJSON file LOD3_Railway.json");
	CityJSONInputFactory in = builder.createCityJSONInputFactory();

	CityJSONReader reader = in.createCityJSONReader(new File("datasets/LOD3_Railway.json"));
	reader = in.createFilteredCityJSONReader(reader, new CityObjectTypeFilter() {

		// return true if you want to consume the CityJSON feature of the given "type"
		public boolean accept(String type) {
			return type.equals("CityFurniture");
		}
	});

	CityModel cityModel = reader.read();
	reader.close();
	
	// iterate over all city objects of the city model
	for (CityObjectMember member : cityModel.getCityObjectMember()) {
		if (member.isSetCityObject()) {
			AbstractCityObject cityObject = member.getCityObject();
			System.out.println("Found " + cityObject.getCityGMLClass() + " feature");
			System.out.println("\tgml:id '" + cityObject.getId() + "'");
			
			// check and print LoD geometries
			LodRepresentation lods = cityObject.getLodRepresentation();
			for (int lod = 0; lod < 5; lod++) {
				if (lods.isSetGeometry(lod))
					System.out.println("\thas LoD " + lod + " geometry");
			}
		}
	}
	
	System.out.println(df.format(new Date()) + "sample citygml4j application successfully finished");
}
 
Example #3
Source File: CityGMLContext.java    From citygml4j with Apache License 2.0 4 votes vote down vote up
public CityJSONBuilder createCityJSONBuilder() {
	return new CityJSONBuilder();
}