org.citygml4j.cityjson.feature.AbstractCityObjectType Java Examples

The following examples show how to use org.citygml4j.cityjson.feature.AbstractCityObjectType. 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: CityJSONChunkWriter.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
private void write(AbstractCityObjectType cityObject) throws CityJSONWriteException {
	try {
		for (AbstractGeometryType geometry : cityObject.getGeometry()) {
			if (geometry instanceof AbstractGeometryObjectType) {
				LoDType lod = LoDType.fromLoD(((AbstractGeometryObjectType) geometry).getLod());
				if (lod != null)
					lods.merge(lod, 1, Integer::sum);
			}
		}

		writer.name(cityObject.getGmlId());
		gson.toJson(cityObject, AbstractCityObjectType.class, writer);
	} catch (IOException e) {
		throw new CityJSONWriteException("Caused by: ", e);
	}
}
 
Example #2
Source File: BuildingMarshaller.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
private BiFunctionTypeMapper<CityJSON, AbstractCityObjectType> getTypeMapper() {
	if (typeMapper == null) {
		lock.lock();
		try {
			if (typeMapper == null) {
				typeMapper = BiFunctionTypeMapper.<CityJSON, AbstractCityObjectType>create()
						.with(Building.class, this::marshalBuilding)
						.with(BuildingPart.class, this::marshalBuildingPart)
						.with(BuildingInstallation.class, this::marshalBuildingInstallation);
			}
		} finally {
			lock.unlock();
		}
	}

	return typeMapper;
}
 
Example #3
Source File: TransportationMarshaller.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
private BiFunctionTypeMapper<CityJSON, AbstractCityObjectType> getTypeMapper() {
	if (typeMapper == null) {
		lock.lock();
		try {
			if (typeMapper == null) {
				typeMapper = BiFunctionTypeMapper.<CityJSON, AbstractCityObjectType>create()
						.with(Road.class, this::marshalRoad)
						.with(Railway.class, this::marshalRailway)
						.with(Square.class, this::marshalSquare);
			}
		} finally {
			lock.unlock();
		}
	}

	return typeMapper;
}
 
Example #4
Source File: TunnelMarshaller.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
private BiFunctionTypeMapper<CityJSON, AbstractCityObjectType> getTypeMapper() {
	if (typeMapper == null) {
		lock.lock();
		try {
			if (typeMapper == null) {
				typeMapper = BiFunctionTypeMapper.<CityJSON, AbstractCityObjectType>create()
						.with(Tunnel.class, this::marshalTunnel)
						.with(TunnelPart.class, this::marshalTunnelPart)
						.with(TunnelInstallation.class, this::marshalTunnelInstallation);
			}
		} finally {
			lock.unlock();
		}
	}

	return typeMapper;
}
 
Example #5
Source File: ReliefMarshaller.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
private BiFunctionTypeMapper<CityJSON, AbstractCityObjectType> getTypeMapper() {
	if (typeMapper == null) {
		lock.lock();
		try {
			if (typeMapper == null) {
				typeMapper = BiFunctionTypeMapper.<CityJSON, AbstractCityObjectType>create()
						.with(ReliefFeature.class, this::marshalReliefFeature)
						.with(TINRelief.class, this::marshalTINRelief);
			}
		} finally {
			lock.unlock();
		}
	}

	return typeMapper;
}
 
Example #6
Source File: CityJSONWriter.java    From web-feature-service with Apache License 2.0 6 votes vote down vote up
public CityJSONWriter(CityJSONChunkWriter writer, GeometryStripper geometryStripper, UIDCacheManager uidCacheManager, Object eventChannel, Config config) {
	this.writer = writer;
	this.geometryStripper = geometryStripper;
	this.uidCacheManager = uidCacheManager;
	this.config = config;

	marshaller = writer.getCityJSONMarshaller();
	int queueSize = config.getProject().getExporter().getResources().getThreadPool().getDefaultPool().getMaxThreads() * 2;

	writerPool = new SingleWorkerPool<AbstractCityObjectType>(
			"cityjson_writer_pool", 
			new CityJSONWriterWorkerFactory(writer, ObjectRegistry.getInstance().getEventDispatcher()), 
			queueSize, 
			false);

	writerPool.setEventSource(eventChannel);
	writerPool.prestartCoreWorkers();
}
 
Example #7
Source File: VegetationMarshaller.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
private BiFunctionTypeMapper<CityJSON, AbstractCityObjectType> getTypeMapper() {
	if (typeMapper == null) {
		lock.lock();
		try {
			if (typeMapper == null) {
				typeMapper = BiFunctionTypeMapper.<CityJSON, AbstractCityObjectType>create()
						.with(PlantCover.class, this::marshalPlantCover)
						.with(SolitaryVegetationObject.class, this::marshalSolitaryVegetationObject);
			}
		} finally {
			lock.unlock();
		}
	}

	return typeMapper;
}
 
Example #8
Source File: BridgeMarshaller.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
private BiFunctionTypeMapper<CityJSON, AbstractCityObjectType> getTypeMapper() {
	if (typeMapper == null) {
		lock.lock();
		try {
			if (typeMapper == null) {
				typeMapper = BiFunctionTypeMapper.<CityJSON, AbstractCityObjectType>create()
						.with(Bridge.class, this::marshalBridge)
						.with(BridgePart.class, this::marshalBridgePart)
						.with(BridgeConstructionElement.class, this::marshalBridgeConstructionElement)
						.with(BridgeInstallation.class, this::marshalBridgeInstallation);
			}
		} finally {
			lock.unlock();
		}
	}

	return typeMapper;
}
 
Example #9
Source File: CityJSONChunkWriter.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
public void writeCityObject(AbstractCityObject cityObject) throws CityJSONWriteException {
	switch (documentState) {
	case END_DOCUMENT:
		throw new IllegalStateException("CityJSON document is already complete.");
	case INITIAL:
		writeStartDocument();
		break;
	case START_DOCUMENT:
		break;
	}

	CityJSON cityJSON = new CityJSON();
	AbstractCityObjectType dest = marshaller.marshal(cityObject, cityJSON);

	for (AbstractCityObjectType child : cityJSON.getCityObjects())
		write(child);

	if (cityJSON.isSetExtensionProperties())
		extensionProperties.putAll(cityJSON.getExtensionProperties());

	write(dest);
}
 
Example #10
Source File: DuplicateGeometryRemover.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
public void removeDuplicateGeometries(AbstractCityObjectType child) {
    for (Iterator<AbstractGeometryType> iter = child.getGeometry().iterator(); iter.hasNext(); ) {
        AbstractGeometryType geometry = iter.next();

        boolean isDuplicate = true;
        for (String mapping : mapGeometry(geometry)) {
            if (!mappings.contains(mapping)) {
                isDuplicate = false;
                break;
            }
        }

        if (isDuplicate)
            iter.remove();
    }
}
 
Example #11
Source File: ADEUnmarshaller.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
public AbstractFeature unmarshalCityObject(AbstractCityObjectType src, CityJSON cityJSON, AbstractFeature parent) {
    if (unmarshallersByType != null) {
        CityJSONExtensionUnmarshaller unmarshaller = unmarshallersByType.get(src.getType());
        if (unmarshaller != null)
            return unmarshaller.unmarshalCityObject(src, new CityObjectContext(parent, cityJSON));
    }

    else if (src.hasLocalProperty(CityObjectTypeAdapter.UNKNOWN_EXTENSION) && src instanceof GenericCityObjectType) {
        // map unknown extension
        GenericCityObject dest = json.getCityGMLUnmarshaller().getGenericsUnmarshaller().unmarshalGenericCityObject((GenericCityObjectType) src, cityJSON);

        String type = src.getType();
        if (type.startsWith("+"))
            type = type.substring(1);

        dest.setClazz(new Code(type));

        dest.setLocalProperty(CityObjectTypeAdapter.UNKNOWN_EXTENSION, true);
        json.getCityGMLUnmarshaller().getCoreUnmarshaller().unmarshalAsGlobalFeature(dest);

        return dest;
    }

    return null;
}
 
Example #12
Source File: CityJSONWriterWorker.java    From importer-exporter with Apache License 2.0 6 votes vote down vote up
private void doWork(AbstractCityObjectType work) {
	final ReentrantLock runLock = this.runLock;
	runLock.lock();

	try {
		if (!shouldWork)
			return;
		
		writer.writeCityObject(work);
	} catch (CityJSONWriteException e) {
		eventDispatcher.triggerSyncEvent(new InterruptEvent("Failed to write CityJSON content.", LogLevel.ERROR, e, eventChannel, this));
		shouldWork = false;
	} finally {
		runLock.unlock();
	}
}
 
Example #13
Source File: CityJSONWriterWorker.java    From importer-exporter with Apache License 2.0 6 votes vote down vote up
@Override
public void run() {
	if (firstWork != null) {
		doWork(firstWork);
		firstWork = null;
	}

	while (shouldRun) {
		try {
			AbstractCityObjectType work = workQueue.take();
			doWork(work);
		} catch (InterruptedException ie) {
			// re-check state
		}
	}
}
 
Example #14
Source File: CityJSONWriter.java    From web-feature-service with Apache License 2.0 6 votes vote down vote up
@Override
public void write(AbstractFeature feature, long sequenceId) throws FeatureWriteException {
	if (feature instanceof AbstractCityObject) {
		if (checkForDuplicates && isFeatureAlreadyExported(feature))
			return;

		// security feature: strip geometry from features
		if (geometryStripper != null)
			feature.accept(geometryStripper);

		CityJSON cityJSON = new CityJSON();
		AbstractCityObjectType dest = marshaller.marshal((AbstractCityObject) feature, cityJSON);

		for (AbstractCityObjectType child : cityJSON.getCityObjects())
			writerPool.addWork(child);

		if (cityJSON.isSetExtensionProperties())
			cityJSON.getExtensionProperties().forEach(writer::addRootExtensionProperty);

		writerPool.addWork(dest);
	}
}
 
Example #15
Source File: CityJSONMarshaller.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public AbstractCityObjectType marshal(AbstractCityObject src, CityJSON cityJSON) {
	xlinkResolver.resolve(src);
	appearanceResolver.resolve(src);

	AbstractCityObjectType dest = citygml.marshal(src, cityJSON);

	// remove local properties from input objects
	src.accept(new LocalPropertiesCleaner());

	return dest;
}
 
Example #16
Source File: ReliefMarshaller.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public AbstractCityObjectType marshalReliefFeature(ReliefFeature src, CityJSON cityJSON) {
	if (src.isSetReliefComponent()) {
		for (ReliefComponentProperty property : src.getReliefComponent()) {
			if (property.isSetReliefComponent() && property.getReliefComponent() instanceof TINRelief)
				cityJSON.addCityObject(marshalTINRelief((TINRelief) property.getReliefComponent(), cityJSON));
		}
	}
	
	return null;
}
 
Example #17
Source File: CoreMarshaller.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public void marshalAbstractCityObject(AbstractCityObject src, AbstractCityObjectType dest, CityJSON cityJSON) {
	dest.setGmlId(src.isSetId() && !src.getId().isEmpty() ? src.getId() : DefaultGMLIdManager.getInstance().generateUUID());

	if (src.isSetBoundedBy() && src.getBoundedBy().isSetEnvelope())
		dest.setGeographicalExtent(src.getBoundedBy().getEnvelope().toBoundingBox().toList());

	Attributes attributes = dest.getAttributes();
	if (src.isSetDescription() && src.getDescription().isSetValue())
		attributes.setDescription(src.getDescription().getValue());

	if (src.isSetName()) {
		for (Code name : src.getName()) {
			if (name.isSetValue()) {
				attributes.setName(name.getValue());
				break;
			}
		}
	}

	if (src.isSetCreationDate())
		attributes.setCreationDate(src.getCreationDate());

	if (src.isSetTerminationDate())
		attributes.setTerminationDate(src.getTerminationDate());

	if (src.isSetGenericAttribute())
		citygml.getGenericsMarshaller().marshalGenericAttributes(src, attributes);

	if (src.isSetGenericApplicationPropertyOfCityObject())
		json.getADEMarshaller().marshal(src.getGenericApplicationPropertyOfCityObject(), dest, cityJSON);
}
 
Example #18
Source File: CityGMLUnmarshaller.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public AbstractCityObject unmarshal(AbstractCityObjectType src, CityJSON cityJSON) {
	AbstractCityObject dest = null;
	
	if (src instanceof BridgeType)
		dest = brid.unmarshal(src, cityJSON);
	else if (src instanceof BuildingType)
		dest = bldg.unmarshal(src, cityJSON);
	else if (src instanceof CityFurnitureType)
		dest = frn.unmarshalCityFurniture((CityFurnitureType) src, cityJSON);
	else if (src instanceof CityObjectGroupType)
		dest = grp.unmarshalCityObjectGroup((CityObjectGroupType) src, cityJSON);
	else if (src instanceof GenericCityObjectType)
		dest = gen.unmarshalGenericCityObject((GenericCityObjectType) src, cityJSON);
	else if (src instanceof LandUseType)
		dest = luse.unmarshalLandUse((LandUseType) src, cityJSON);
	else if (src instanceof TINReliefType)
		dest = dem.unmarshalTINRelief((TINReliefType) src, cityJSON);
	else if (src instanceof AbstractTransportationComplexType)
		dest = tran.unmarshal(src, cityJSON);
	else if (src instanceof TunnelType)
		dest = tun.unmarshal(src, cityJSON);
	else if (src instanceof AbstractVegetationObjectType)
		dest = veg.unmarshal(src, cityJSON);
	else if (src instanceof WaterBodyType)
		dest = wtr.unmarshalWaterBody((WaterBodyType) src, cityJSON);
	
	return dest;
}
 
Example #19
Source File: ADEMarshaller.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public AbstractCityObjectType marshalCityObject(ADEModelObject src, CityJSON cityJSON) {
    if (marshallers != null) {
        CityJSONExtensionMarshaller marshaller = marshallers.get(src.getClass().getPackage().getName());
        if (marshaller != null)
            return marshaller.marshalCityObject(src, cityJSON);
    }

    return null;
}
 
Example #20
Source File: ADEMarshaller.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public void marshal(List<ADEComponent> src, ExtensibleType parent, CityJSON cityJSON) {
    for (ADEComponent ade : src) {
        if (ade instanceof ADEModelObject && marshallers != null) {
            CityJSONExtensionMarshaller marshaller = marshallers.get(ade.getClass().getPackage().getName());
            if (marshaller != null) {
                Extension extension = marshaller.marshalGenericApplicationProperty((ADEModelObject) ade, new ADEPropertyContext(parent, cityJSON));

                if (extension instanceof AbstractCityObjectType) {
                    AbstractCityObjectType cityObject = (AbstractCityObjectType) extension;
                    if (parent instanceof AbstractCityObjectType) {
                        if (json.isRemoveDuplicateChildGeometries()) {
                            DuplicateGeometryRemover remover = new DuplicateGeometryRemover((AbstractCityObjectType) parent);
                            remover.removeDuplicateGeometries(cityObject);
                            if (!cityObject.isSetGeometry())
                                continue;
                        }

                        cityJSON.addCityObject(cityObject);
                    }

                    parent.addChild(cityObject);
                }

                else if (extension instanceof ExtensionAttribute && parent instanceof AbstractCityObjectType) {
                    ExtensionAttribute attribute = (ExtensionAttribute) extension;
                    ((AbstractCityObjectType) parent).getAttributes().addExtensionAttribute(attribute.getName(), attribute.getValue());
                }

                else if (extension instanceof ExtensionProperty) {
                    ExtensionProperty property = (ExtensionProperty) extension;
                    if (parent instanceof AbstractCityObjectType)
                        ((AbstractCityObjectType) parent).addExtensionProperty(property.getName(), property.getValue());
                    else if (parent instanceof CityJSON)
                        ((CityJSON) parent).addExtensionProperty(property.getName(), property.getValue());
                }
            }
        }
    }
}
 
Example #21
Source File: CoreUnmarshaller.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
private void releaseObjectHierarchy(AbstractCityObjectType parent, CityJSON src) {
	if (parent.isSetChildren()) {
		for (String gmlId : parent.getChildren()) {
			AbstractCityObjectType child = src.getCityObject(gmlId);
			if (child.isSetParents() && child.getParents().size() == 1) {
				releaseObjectHierarchy(child, src);
				src.removeCityObject(gmlId);
			}
		}
	}
}
 
Example #22
Source File: CityJSONChunkWriter.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public void writeCityObject(AbstractCityObjectType cityObject) throws CityJSONWriteException {
	switch (documentState) {
	case END_DOCUMENT:
		throw new IllegalStateException("CityJSON document is already complete.");
	case INITIAL:
		writeStartDocument();
		break;
	case START_DOCUMENT:
		break;
	}

	write(cityObject);
}
 
Example #23
Source File: CityGMLMarshaller.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public AbstractCityObjectType marshal(ModelObject src, CityJSON cityJSON) {
	AbstractCityObjectType dest = null;

	if (src instanceof ADEModelObject)
		dest = json.getADEMarshaller().marshalCityObject((ADEModelObject) src, cityJSON);
	else if (src instanceof BridgeModuleComponent)
		dest = brid.marshal(src, cityJSON);
	else if (src instanceof BuildingModuleComponent)
		dest = bldg.marshal(src, cityJSON);
	else if (src instanceof CityFurnitureModuleComponent)
		dest = frn.marshal(src, cityJSON);
	else if (src instanceof GenericsModuleComponent)
		dest = gen.marshal(src, cityJSON);
	else if (src instanceof LandUseModuleComponent)
		dest = luse.marshal(src, cityJSON);
	else if (src instanceof ReliefModuleComponent)
		dest = dem.marshal(src, cityJSON);
	else if (src instanceof TransportationModuleComponent)
		dest = tran.marshal(src, cityJSON);
	else if (src instanceof TunnelModuleComponent)
		dest = tun.marshal(src, cityJSON);
	else if (src instanceof VegetationModuleComponent)
		dest = veg.marshal(src, cityJSON);
	else if (src instanceof WaterBodyModuleComponent)
		dest = wtr.marshal(src, cityJSON);
	else if (src instanceof CityObjectGroupModuleComponent)
		dest = grp.marshal(src, cityJSON);
	else if (src instanceof CoreModuleComponent)
		dest = core.marshal(src, cityJSON);

	return dest;
}
 
Example #24
Source File: TunnelUnmarshaller.java    From citygml4j with Apache License 2.0 4 votes vote down vote up
public void unmarshalAbstractTunnel(AbstractTunnelType src, AbstractTunnel dest, CityJSON cityJSON) {
	citygml.getCoreUnmarshaller().unmarshalAbstractCityObject(src, dest, cityJSON);

	if (src.isSetAttributes()) {
		TunnelAttributes attributes = src.getAttributes();

		if (attributes.isSetClazz())
			dest.setClazz(new Code(attributes.getClazz()));

		if (attributes.isSetFunction())
			dest.addFunction(new Code(attributes.getFunction()));

		if (attributes.isSetUsage())
			dest.addUsage(new Code(attributes.getUsage()));

		if (attributes.isSetYearOfConstruction())
			dest.setYearOfConstruction(LocalDate.of(attributes.getYearOfConstruction(), 1, 1));

		if (attributes.isSetYearOfDemolition())
			dest.setYearOfConstruction(LocalDate.of(attributes.getYearOfDemolition(), 1, 1));
	}

	for (AbstractGeometryType geometryType : src.getGeometry()) {
		AbstractGeometry geometry = null;
		int lod = 0;

		if (geometryType instanceof AbstractGeometryObjectType) {
			AbstractGeometryObjectType geometryObject = (AbstractGeometryObjectType) geometryType;
			geometry = json.getGMLUnmarshaller().unmarshal(geometryObject, dest);
			lod = geometryObject.getLod().intValue();
		} else if (geometryType instanceof GeometryInstanceType) {
			GeometryInstanceType geometryInstance = (GeometryInstanceType) geometryType;
			geometry = citygml.getCoreUnmarshaller().unmarshalAndTransformGeometryInstance(geometryInstance, dest);
			lod = (int) geometry.getLocalProperty(CityJSONUnmarshaller.GEOMETRY_INSTANCE_LOD);
		}

		if (geometry != null) {
			if (geometry instanceof MultiSurface) {
				MultiSurface multiSurface = (MultiSurface) geometry;
				switch (lod) {
					case 1:
						dest.setLod1MultiSurface(new MultiSurfaceProperty(multiSurface));
						break;
					case 2:
						dest.setLod2MultiSurface(new MultiSurfaceProperty(multiSurface));
						break;
					case 3:
						dest.setLod3MultiSurface(new MultiSurfaceProperty(multiSurface));
						break;
				}
			} else if (geometry instanceof AbstractSolid) {
				AbstractSolid solid = (AbstractSolid) geometry;
				switch (lod) {
					case 1:
						dest.setLod1Solid(new SolidProperty(solid));
						break;
					case 2:
						dest.setLod2Solid(new SolidProperty(solid));
						break;
					case 3:
						dest.setLod3Solid(new SolidProperty(solid));
						break;
				}
			}
		}
	}

	if (src.isSetChildren()) {
		for (String gmlId : src.getChildren()) {
			AbstractCityObjectType cityObject = cityJSON.getCityObject(gmlId);
			if (cityObject == null || !json.getCityJSONRegistry().isCoreCityObject(cityObject.getType()))
				continue;

			if (cityObject instanceof TunnelInstallationType) {
				TunnelInstallation installation = unmarshalTunnelInstallation((TunnelInstallationType) cityObject, cityJSON);
				dest.addOuterTunnelInstallation(new TunnelInstallationProperty(installation));
			} else if (cityObject instanceof TunnelPartType && src instanceof TunnelType) {
				TunnelPart part = unmarshalTunnelPart((TunnelPartType) cityObject, cityJSON);
				dest.addConsistsOfTunnelPart(new TunnelPartProperty(part));
			}
		}
	}
}
 
Example #25
Source File: DuplicateGeometryRemover.java    From citygml4j with Apache License 2.0 4 votes vote down vote up
public DuplicateGeometryRemover(AbstractCityObjectType parent) {
    for (AbstractGeometryType geometry : parent.getGeometry())
        mappings.addAll(mapGeometry(geometry));
}
 
Example #26
Source File: CityFurnitureUnmarshaller.java    From citygml4j with Apache License 2.0 4 votes vote down vote up
public AbstractCityObject unmarshal(AbstractCityObjectType src, CityJSON cityJSON) {
	if (src instanceof CityFurnitureType)
		return unmarshalCityFurniture((CityFurnitureType) src, cityJSON);

	return null;
}
 
Example #27
Source File: BridgeUnmarshaller.java    From citygml4j with Apache License 2.0 4 votes vote down vote up
public AbstractCityObject unmarshal(AbstractCityObjectType src, CityJSON cityJSON) {
	return getTypeMapper().apply(src, cityJSON);
}
 
Example #28
Source File: BridgeUnmarshaller.java    From citygml4j with Apache License 2.0 4 votes vote down vote up
public void unmarshalAbstractBridge(AbstractBridgeType src, AbstractBridge dest, CityJSON cityJSON) {
	citygml.getCoreUnmarshaller().unmarshalAbstractCityObject(src, dest, cityJSON);

	if (src.isSetAttributes()) {
		BridgeAttributes attributes = src.getAttributes();

		if (attributes.isSetClazz())
			dest.setClazz(new Code(attributes.getClazz()));

		if (attributes.isSetFunction())
			dest.addFunction(new Code(attributes.getFunction()));

		if (attributes.isSetUsage())
			dest.addUsage(new Code(attributes.getUsage()));

		if (attributes.isSetYearOfConstruction())
			dest.setYearOfConstruction(LocalDate.of(attributes.getYearOfConstruction(), 1, 1));

		if (attributes.isSetYearOfDemolition())
			dest.setYearOfConstruction(LocalDate.of(attributes.getYearOfDemolition(), 1, 1));
		
		if (attributes.isSetIsMovable())
			dest.setIsMovable(attributes.getIsMovable());
	}

	for (AbstractGeometryType geometryType : src.getGeometry()) {
		AbstractGeometry geometry = null;
		int lod = 0;

		if (geometryType instanceof AbstractGeometryObjectType) {
			AbstractGeometryObjectType geometryObject = (AbstractGeometryObjectType) geometryType;
			geometry = json.getGMLUnmarshaller().unmarshal(geometryObject, dest);
			lod = geometryObject.getLod().intValue();
		} else if (geometryType instanceof GeometryInstanceType) {
			GeometryInstanceType geometryInstance = (GeometryInstanceType) geometryType;
			geometry = citygml.getCoreUnmarshaller().unmarshalAndTransformGeometryInstance(geometryInstance, dest);
			lod = (int) geometry.getLocalProperty(CityJSONUnmarshaller.GEOMETRY_INSTANCE_LOD);
		}

		if (geometry != null) {
			if (geometry instanceof MultiSurface) {
				MultiSurface multiSurface = (MultiSurface) geometry;
				switch (lod) {
					case 1:
						dest.setLod1MultiSurface(new MultiSurfaceProperty(multiSurface));
						break;
					case 2:
						dest.setLod2MultiSurface(new MultiSurfaceProperty(multiSurface));
						break;
					case 3:
						dest.setLod3MultiSurface(new MultiSurfaceProperty(multiSurface));
						break;
				}
			} else if (geometry instanceof AbstractSolid) {
				AbstractSolid solid = (AbstractSolid) geometry;
				switch (lod) {
					case 1:
						dest.setLod1Solid(new SolidProperty(solid));
						break;
					case 2:
						dest.setLod2Solid(new SolidProperty(solid));
						break;
					case 3:
						dest.setLod3Solid(new SolidProperty(solid));
						break;
				}
			}
		}
	}

	if (src.isSetChildren()) {
		for (String gmlId : src.getChildren()) {
			AbstractCityObjectType cityObject = cityJSON.getCityObject(gmlId);
			if (cityObject == null || !json.getCityJSONRegistry().isCoreCityObject(cityObject.getType()))
				continue;

			if (cityObject instanceof BridgeInstallationType) {
				BridgeInstallation installation = unmarshalBridgeInstallation((BridgeInstallationType) cityObject, cityJSON);
				dest.addOuterBridgeInstallation(new BridgeInstallationProperty(installation));
			} else if (cityObject instanceof  BridgeConstructionElementType) {
				BridgeConstructionElement element = unmarshalBridgeConstructionElement((BridgeConstructionElementType) cityObject, cityJSON);
				dest.addOuterBridgeConstructionElement(new BridgeConstructionElementProperty(element));
			} else if (cityObject instanceof BridgePartType && src instanceof BridgeType) {
				BridgePart part = unmarshalBridgePart((BridgePartType) cityObject, cityJSON);
				dest.addConsistsOfBridgePart(new BridgePartProperty(part));
			}
		}
	}

	if (src.isSetAddress())
		dest.addAddress(new AddressProperty(citygml.getCoreUnmarshaller().unmarshalAddress(src.getAddress())));
}
 
Example #29
Source File: GenericsUnmarshaller.java    From citygml4j with Apache License 2.0 4 votes vote down vote up
public AbstractCityObject unmarshal(AbstractCityObjectType src, CityJSON cityJSON) {
    if (src instanceof GenericCityObjectType)
        return unmarshalGenericCityObject((GenericCityObjectType) src, cityJSON);

    return null;
}
 
Example #30
Source File: CityObjectGroupUnmarshaller.java    From citygml4j with Apache License 2.0 4 votes vote down vote up
public AbstractCityObject unmarshal(AbstractCityObjectType src, CityJSON cityJSON) {
    if (src instanceof CityObjectGroupType)
        return unmarshalCityObjectGroup((CityObjectGroupType) src, cityJSON);

    return null;
}