org.citygml4j.model.citygml.appearance.Appearance Java Examples

The following examples show how to use org.citygml4j.model.citygml.appearance.Appearance. 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: GMLFunctionWalker.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
public T apply(Appearance appearance) {
	T object = apply((AbstractFeature)appearance);
	if (object != null)
		return object;

	if (appearance.isSetSurfaceDataMember())
		for (SurfaceDataProperty surfaceDataProperty : new ArrayList<SurfaceDataProperty>(appearance.getSurfaceDataMember())) {
			object = apply(surfaceDataProperty);
			if (object != null)
				return object;
		}

	if (appearance.isSetGenericApplicationPropertyOfAppearance()) {
		for (ADEComponent ade : new ArrayList<ADEComponent>(appearance.getGenericApplicationPropertyOfAppearance())) {
			object = apply(ade);
			if (object != null)
				return object;
		}
	}

	return null;
}
 
Example #2
Source File: Appearance200Unmarshaller.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
public void unmarshalAppearance(AppearanceType src, Appearance dest) throws MissingADESchemaException {
	jaxb.getGMLUnmarshaller().unmarshalAbstractFeature(src, dest);

	if (src.isSetTheme())
		dest.setTheme(src.getTheme());

	if (src.isSetSurfaceDataMember()) {
		for (SurfaceDataPropertyType surfaceDataMember : src.getSurfaceDataMember())
			dest.addSurfaceDataMember(unmarshalSurfaceDataProperty(surfaceDataMember));
	}

	if (src.isSet_GenericApplicationPropertyOfAppearance()) {
		for (JAXBElement<Object> elem : src.get_GenericApplicationPropertyOfAppearance()) {
			ADEModelObject ade = jaxb.getADEUnmarshaller().unmarshal(elem);
			if (ade != null)
				dest.addGenericApplicationPropertyOfAppearance(ade);
		}
	}
}
 
Example #3
Source File: Appearance100Unmarshaller.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
public void unmarshalAppearance(AppearanceType src, Appearance dest) throws MissingADESchemaException {
	jaxb.getGMLUnmarshaller().unmarshalAbstractFeature(src, dest);

	if (src.isSetTheme())
		dest.setTheme(src.getTheme());

	if (src.isSetSurfaceDataMember()) {
		for (SurfaceDataPropertyType surfaceDataMember : src.getSurfaceDataMember())
			dest.addSurfaceDataMember(unmarshalSurfaceDataProperty(surfaceDataMember));
	}

	if (src.isSet_GenericApplicationPropertyOfAppearance()) {
		for (JAXBElement<Object> elem : src.get_GenericApplicationPropertyOfAppearance()) {
			ADEModelObject ade = jaxb.getADEUnmarshaller().unmarshal(elem);
			if (ade != null)
				dest.addGenericApplicationPropertyOfAppearance(ade);
		}
	}
}
 
Example #4
Source File: Appearance200Marshaller.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
public void marshalAppearance(Appearance src, AppearanceType dest) {
	jaxb.getGMLMarshaller().marshalAbstractFeature(src, dest);

	if (src.isSetTheme())
		dest.setTheme(src.getTheme());

	if (src.isSetSurfaceDataMember()) {
		for (SurfaceDataProperty surfaceDataMember : src.getSurfaceDataMember())
			dest.getSurfaceDataMember().add(marshalSurfaceDataProperty(surfaceDataMember));
	}

	if (src.isSetGenericApplicationPropertyOfAppearance()) {
		for (ADEComponent adeComponent : src.getGenericApplicationPropertyOfAppearance()) {
			JAXBElement<Object> jaxbElement = jaxb.getADEMarshaller().marshalJAXBElement(adeComponent);
			if (jaxbElement != null)
				dest.get_GenericApplicationPropertyOfAppearance().add(jaxbElement);
		}
	}
}
 
Example #5
Source File: Appearance200Marshaller.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
private TypeMapper<JAXBElement<?>> getElementMapper() {
	if (elementMapper == null) {
		lock.lock();
		try {
			if (elementMapper == null) {
				elementMapper = TypeMapper.<JAXBElement<?>>create()
						.with(Appearance.class, this::createAppearance)
						.with(AppearanceMember.class, this::createAppearanceMember)
						.with(GeoreferencedTexture.class, this::createGeoreferencedTexture)
						.with(ParameterizedTexture.class, this::createParameterizedTexture)
						.with(TexCoordGen.class, this::createTexCoordGen)
						.with(TexCoordList.class, this::createTexCoordList)
						.with(X3DMaterial.class, this::createX3DMaterial);
			}
		} finally {
			lock.unlock();
		}
	}

	return elementMapper;
}
 
Example #6
Source File: DBGlobalAppearance.java    From importer-exporter with Apache License 2.0 6 votes vote down vote up
protected Appearance doExport(long appearanceId) throws CityGMLExportException, SQLException {
	ps.setLong(1, appearanceId);

	try (ResultSet rs = ps.executeQuery()) {
		Appearance appearance = new Appearance();
		boolean isInited = false;

		while (rs.next()) {
			if (!isInited) {
				getAppearanceProperties(appearance, appearanceId, rs);
				clearTextureImageCache();
				isInited = true;
			}

			// add surface data to appearance
			addSurfaceData(appearance, rs, false);
		}

		return appearance.isSetSurfaceDataMember() ? appearance : null;
	}
}
 
Example #7
Source File: Appearance100Marshaller.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
public void marshalAppearance(Appearance src, AppearanceType dest) {
	jaxb.getGMLMarshaller().marshalAbstractFeature(src, dest);

	if (src.isSetTheme())
		dest.setTheme(src.getTheme());

	if (src.isSetSurfaceDataMember()) {
		for (SurfaceDataProperty surfaceDataMember : src.getSurfaceDataMember())
			dest.getSurfaceDataMember().add(marshalSurfaceDataProperty(surfaceDataMember));
	}

	if (src.isSetGenericApplicationPropertyOfAppearance()) {
		for (ADEComponent adeComponent : src.getGenericApplicationPropertyOfAppearance()) {
			JAXBElement<Object> jaxbElement = jaxb.getADEMarshaller().marshalJAXBElement(adeComponent);
			if (jaxbElement != null)
				dest.get_GenericApplicationPropertyOfAppearance().add(jaxbElement);
		}
	}
}
 
Example #8
Source File: FeatureFunctionWalker.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
public T apply(Appearance appearance) {
	T object = apply((AbstractFeature)appearance);
	if (object != null)
		return object;

	if (appearance.isSetSurfaceDataMember())
		for (SurfaceDataProperty surfaceDataProperty : new ArrayList<SurfaceDataProperty>(appearance.getSurfaceDataMember())) {
			object = apply(surfaceDataProperty);
			if (object != null)
				return object;
		}

	if (appearance.isSetGenericApplicationPropertyOfAppearance()) {
		for (ADEComponent ade : new ArrayList<ADEComponent>(appearance.getGenericApplicationPropertyOfAppearance())) {
			object = apply(ade);
			if (object != null)
				return object;
		}
	}

	return null;
}
 
Example #9
Source File: AppearanceUnmarshaller.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
private ParameterizedTexture getOrCreateParameterizedTexture(TextureType src, int surfaceDataId, Appearance appearance) {
	ParameterizedTexture dest = null;

	for (SurfaceDataProperty property : appearance.getSurfaceDataMember()) {
		AbstractSurfaceData surfaceData = property.getSurfaceData();
		if (!(surfaceData instanceof ParameterizedTexture))
			continue;

		ParameterizedTexture texture = (ParameterizedTexture)surfaceData;
		if ((int)texture.getLocalProperty(CityJSONUnmarshaller.SURFACE_DATA_ID) == surfaceDataId) {
			dest = texture;
			break;
		}
	}

	if (dest == null) {
		dest = unmarshalParameterizedTexture(src);
		if (!dest.isSetImageURI())
			return null;
		
		dest.setLocalProperty(CityJSONUnmarshaller.SURFACE_DATA_ID, surfaceDataId);
		appearance.addSurfaceDataMember(new SurfaceDataProperty(dest));
	}

	return dest;
}
 
Example #10
Source File: AbstractAppearanceExporter.java    From importer-exporter with Apache License 2.0 6 votes vote down vote up
protected void getAppearanceProperties(Appearance appearance, long appearanceId, ResultSet rs) throws CityGMLExportException, SQLException {
	appearance.setId(rs.getString(2));

	for (SplitValue splitValue : valueSplitter.split(rs.getString(3), rs.getString(4))) {
		Code name = new Code(splitValue.result(0));
		name.setCodeSpace(splitValue.result(1));
		appearance.addName(name);
	}

	String description = rs.getString(5);
	if (!rs.wasNull())
		appearance.setDescription(new StringOrRef(description));

	appearance.setTheme(rs.getString(6));

	// delegate export of generic ADE properties
	if (appearanceADEHookTables != null) {
		List<String> adeHookTables = retrieveADEHookTables(appearanceADEHookTables, rs);
		if (adeHookTables != null) {
			FeatureType featureType = exporter.getFeatureType(appearance);
			exporter.delegateToADEExporter(adeHookTables, appearance, appearanceId, featureType, exporter.getProjectionFilter(featureType));
		}
	}
}
 
Example #11
Source File: AppearanceUnmarshaller.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
private X3DMaterial getOrCreateX3DMaterial(MaterialType src, int surfaceDataId, Appearance appearance) {
	X3DMaterial dest = null;

	for (SurfaceDataProperty property : appearance.getSurfaceDataMember()) {
		AbstractSurfaceData surfaceData = property.getSurfaceData();
		if (!(surfaceData instanceof X3DMaterial))
			continue;

		X3DMaterial material = (X3DMaterial)surfaceData;
		if ((int)material.getLocalProperty(CityJSONUnmarshaller.SURFACE_DATA_ID) == surfaceDataId) {
			dest = material;
			break;
		}
	}

	if (dest == null) {
		dest = unmarshalMaterial(src);			
		dest.setLocalProperty(CityJSONUnmarshaller.SURFACE_DATA_ID, surfaceDataId);
		appearance.addSurfaceDataMember(new SurfaceDataProperty(dest));
	}

	return dest;
}
 
Example #12
Source File: CityJSONReader.java    From importer-exporter with Apache License 2.0 6 votes vote down vote up
private void process(Iterator<? extends FeatureProperty<?>> iter, WorkerPool<CityGML> workerPool) {
    while (shouldRun && iter.hasNext()) {
        AbstractFeature feature = iter.next().getFeature();

        // unset parent to mark the feature as top-level
        feature.unsetParent();

        // remove feature from feature collection
        iter.remove();

        if (feature instanceof CityGML) {
            if (counterFilter != null && !(feature instanceof Appearance)) {
                if (!counterFilter.isStartIndexSatisfied()) {
                    counterFilter.incrementStartIndex();
                    continue;
                }

                counterFilter.incrementCount();
                if (!counterFilter.isCountSatisfied())
                    continue;
            }

            workerPool.addWork((CityGML) feature);
        }
    }
}
 
Example #13
Source File: AppearanceUnmarshaller.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
public void unmarshalMaterial(AbstractMaterialObject src, Map<Integer, List<AbstractSurface>> surfaces, AbstractCityObject parent) {
	Appearance appearance = getOrCreateAppearance(src.getTheme(), parent);

	for (Entry<Integer, List<AbstractSurface>> entry : surfaces.entrySet()) {
		MaterialType materialType = materials != null ? materials.get(entry.getKey()) : null;
		if (materialType == null)
			continue;

		X3DMaterial material = getOrCreateX3DMaterial(materialType, entry.getKey(), appearance);
		for (AbstractSurface surface : entry.getValue()) {
			if (!surface.isSetId())
				surface.setId(gmlIdManager.generateUUID());
			
			material.addTarget("#" + surface.getId());
		}
	}
}
 
Example #14
Source File: Appearance100Marshaller.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
private TypeMapper<Object> getTypeMapper() {
	if (typeMapper == null) {
		lock.lock();
		try {
			if (typeMapper == null) {
				typeMapper = TypeMapper.create()
						.with(Appearance.class, this::marshalAppearance)
						.with(AppearanceMember.class, this::marshalAppearanceProperty)
						.with(AppearanceProperty.class, this::marshalAppearanceProperty)
						.with(GeoreferencedTexture.class, this::marshalGeoreferencedTexture)
						.with(ParameterizedTexture.class, this::marshalParameterizedTexture)
						.with(SurfaceDataProperty.class, this::marshalSurfaceDataProperty)
						.with(TexCoordGen.class, this::marshalTexCoordGen)
						.with(TexCoordList.class, this::marshalTexCoordList)
						.with(TextureAssociation.class, this::marshalTextureAssociation)
						.with(TextureCoordinates.class, this::marshalTextureCoordinates)
						.with(TextureType.class, this::marshalTextureType)
						.with(WorldToTexture.class, this::marshalWorldToTexture)
						.with(WrapMode.class, this::marshalWrapMode)
						.with(X3DMaterial.class, this::marshalX3DMaterial);
			}
		} finally {
			lock.unlock();
		}
	}

	return typeMapper;
}
 
Example #15
Source File: Appearance100Unmarshaller.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public boolean assignGenericProperty(ADEGenericElement genericProperty, QName substitutionGroup, AbstractGML dest) {
	String name = substitutionGroup.getLocalPart();
	boolean success = true;

	if (dest instanceof AbstractSurfaceData && name.equals("_GenericApplicationPropertyOfSurfaceData"))
		((AbstractSurfaceData)dest).addGenericApplicationPropertyOfSurfaceData(genericProperty);
	else if (dest instanceof AbstractTexture && name.equals("_GenericApplicationPropertyOfTexture"))
		((AbstractTexture)dest).addGenericApplicationPropertyOfTexture(genericProperty);
	else if (dest instanceof AbstractTextureParameterization && name.equals("_GenericApplicationPropertyOfTextureParameterization"))
		((AbstractTextureParameterization)dest).addGenericApplicationPropertyOfTextureParameterization(genericProperty);
	else if (dest instanceof Appearance && name.equals("_GenericApplicationPropertyOfAppearance"))
		((Appearance)dest).addGenericApplicationPropertyOfAppearance(genericProperty);
	else if (dest instanceof GeoreferencedTexture && name.equals("_GenericApplicationPropertyOfGeoreferencedTexture"))
		((GeoreferencedTexture)dest).addGenericApplicationPropertyOfGeoreferencedTexture(genericProperty);
	else if (dest instanceof ParameterizedTexture && name.equals("_GenericApplicationPropertyOfParameterizedTexture"))
		((ParameterizedTexture)dest).addGenericApplicationPropertyOfParameterizedTexture(genericProperty);
	else if (dest instanceof TexCoordGen && name.equals("_GenericApplicationPropertyOfTexCoordGen"))
		((TexCoordGen)dest).addGenericApplicationPropertyOfTexCoordGen(genericProperty);
	else if (dest instanceof TexCoordList && name.equals("_GenericApplicationPropertyOfTexCoordList"))
		((TexCoordList)dest).addGenericApplicationPropertyOfTexCoordList(genericProperty);
	else if (dest instanceof X3DMaterial && name.equals("_GenericApplicationPropertyOfX3DMaterial"))
		((X3DMaterial)dest).addGenericApplicationPropertyOfX3DMaterial(genericProperty);
	else
		success = false;

	return success;
}
 
Example #16
Source File: Appearance100Unmarshaller.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public void unmarshalAppearanceProperty(AppearancePropertyType src, AppearanceProperty dest) throws MissingADESchemaException {
	jaxb.getGMLUnmarshaller().unmarshalFeatureProperty(src, dest);

	if (src.isSetAppearance())
		dest.setAppearance(unmarshalAppearance(src.getAppearance()));

	if (src.isSet_Feature()) {
		ModelObject abstractFeature = jaxb.unmarshal(src.get_Feature());
		if (abstractFeature instanceof Appearance)
			dest.setFeature((Appearance)abstractFeature);
	}
}
 
Example #17
Source File: Appearance200Unmarshaller.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public AppearanceMember unmarshalAppearanceMember(FeaturePropertyType src) throws MissingADESchemaException {
	AppearanceMember dest = new AppearanceMember();
	jaxb.getGMLUnmarshaller().unmarshalFeatureProperty(src, dest);

	if (src.isSet_Feature()) {
		ModelObject abstractFeature = jaxb.unmarshal(src.get_Feature());
		if (abstractFeature instanceof Appearance)
			dest.setAppearance((Appearance)abstractFeature);
	}

	return dest;
}
 
Example #18
Source File: Appearance200Unmarshaller.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public void unmarshalAppearanceProperty(AppearancePropertyType src, AppearanceProperty dest) throws MissingADESchemaException {
	if (src.isSet_Feature()) {
		ModelObject object = jaxb.unmarshal(src.get_Feature());
		if (object instanceof Appearance)
			dest.setAppearance((Appearance)object);
	}

	if (!jaxb.isSkipGenericADEContent() && src.isSet_ADEComponent())
		dest.setGenericADEElement(jaxb.getADEUnmarshaller().unmarshal(src.get_ADEComponent()));

	if (src.isSetRemoteSchema())
		dest.setRemoteSchema(src.getRemoteSchema());

	if (src.isSetType())
		dest.setType(XLinkType.fromValue(src.getType().value()));

	if (src.isSetHref())
		dest.setHref(src.getHref());

	if (src.isSetRole())
		dest.setRole(src.getRole());

	if (src.isSetArcrole())
		dest.setArcrole(src.getArcrole());

	if (src.isSetTitle())
		dest.setTitle(src.getTitle());

	if (src.isSetShow())
		dest.setShow(XLinkShow.fromValue(src.getShow().value()));

	if (src.isSetActuate())
		dest.setActuate(XLinkActuate.fromValue(src.getActuate().value()));
}
 
Example #19
Source File: Appearance200Unmarshaller.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public AppearanceProperty unmarshalAppearanceProperty(FeaturePropertyType src) throws MissingADESchemaException {
	AppearanceProperty dest = new AppearanceProperty();
	jaxb.getGMLUnmarshaller().unmarshalFeatureProperty(src, dest);

	if (src.isSet_Feature()) {
		ModelObject abstractFeature = jaxb.unmarshal(src.get_Feature());
		if (abstractFeature instanceof Appearance)
			dest.setAppearance((Appearance)abstractFeature);
	}

	return dest;
}
 
Example #20
Source File: Appearance200Marshaller.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
private TypeMapper<Object> getTypeMapper() {
	if (typeMapper == null) {
		lock.lock();
		try {
			if (typeMapper == null) {
				typeMapper = TypeMapper.create()
						.with(Appearance.class, this::marshalAppearance)
						.with(AppearanceMember.class, this::marshalAppearanceMember)
						.with(AppearanceProperty.class, this::marshalAppearanceProperty)
						.with(GeoreferencedTexture.class, this::marshalGeoreferencedTexture)
						.with(ParameterizedTexture.class, this::marshalParameterizedTexture)
						.with(SurfaceDataProperty.class, this::marshalSurfaceDataProperty)
						.with(TexCoordGen.class, this::marshalTexCoordGen)
						.with(TexCoordList.class, this::marshalTexCoordList)
						.with(TextureAssociation.class, this::marshalTextureAssociation)
						.with(TextureCoordinates.class, this::marshalTextureCoordinates)
						.with(TextureType.class, this::marshalTextureType)
						.with(WorldToTexture.class, this::marshalWorldToTexture)
						.with(WrapMode.class, this::marshalWrapMode)
						.with(X3DMaterial.class, this::marshalX3DMaterial);
			}
		} finally {
			lock.unlock();
		}
	}

	return typeMapper;
}
 
Example #21
Source File: TexturedSurfaceConverter.java    From importer-exporter with Apache License 2.0 5 votes vote down vote up
protected void convertTexturedSurfaceXlink(String href, long surfaceGeometryId, long parentId) throws CityGMLImportException, SQLException {
	Appearance appearance = new Appearance();
	appearance.setTheme(theme);

	long appearanceId = appearanceImporter.doImport(appearance, parentId, true);
	importer.propagateXlink(new DBXlinkDeprecatedMaterial(
			appearanceId,
			href,
			surfaceGeometryId));
}
 
Example #22
Source File: DBAppearance.java    From importer-exporter with Apache License 2.0 5 votes vote down vote up
protected void importLocalAppearance() throws CityGMLImportException, SQLException {
	LocalAppearanceHandler handler = importer.getLocalAppearanceHandler();

	if (handler != null) {
		if (handler.hasAppearances()) {
			for (Entry<Long, List<Appearance>> entry : handler.getAppearances().entrySet()) {
				for (Appearance appearance : entry.getValue())
					doImport(appearance, entry.getKey(), true);
			}
		}

		// reset appearance handler
		handler.reset();
	}
}
 
Example #23
Source File: FeatureWalker.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public void visit(Appearance appearance) {
	visit((AbstractFeature)appearance);

	if (appearance.isSetSurfaceDataMember())
		for (SurfaceDataProperty surfaceDataProperty : new ArrayList<SurfaceDataProperty>(appearance.getSurfaceDataMember()))
			visit(surfaceDataProperty);

	if (appearance.isSetGenericApplicationPropertyOfAppearance())
		for (ADEComponent ade : new ArrayList<ADEComponent>(appearance.getGenericApplicationPropertyOfAppearance()))
			visit(ade);
}
 
Example #24
Source File: GMLWalker.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public void visit(Appearance appearance) {
	visit((AbstractFeature)appearance);

	if (appearance.isSetSurfaceDataMember())
		for (SurfaceDataProperty surfaceDataProperty : new ArrayList<SurfaceDataProperty>(appearance.getSurfaceDataMember()))
			visit(surfaceDataProperty);

	if (appearance.isSetGenericApplicationPropertyOfAppearance())
		for (ADEComponent ade : new ArrayList<ADEComponent>(appearance.getGenericApplicationPropertyOfAppearance()))
			visit(ade);
}
 
Example #25
Source File: SimpleBoundingBoxCalculator.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public static BoundingShape calcBoundedBy(AbstractFeature feature, BoundingBoxOptions options) {
	if (options.isUseExistingEnvelopes() && feature.isSetBoundedBy() && !feature.getBoundedBy().isEmpty())
		return feature.getBoundedBy();
	
	ChildInfo info = new ChildInfo();
	BoundingShape boundedBy = new BoundingShape();
	
	feature.accept(new GMLWalker() {

		@Override
		public void visit(AbstractGeometry geometry) {
			if (!options.isAssignResultToFeatures() || info.getParentFeature(geometry) == feature)
				boundedBy.updateEnvelope(geometry.calcBoundingBox());
		}

		@Override
		public void visit(AbstractFeature nested) {
			if (nested != feature && options.isAssignResultToFeatures()) {
				BoundingShape tmp = SimpleBoundingBoxCalculator.calcBoundedBy(nested, options);
				boundedBy.updateEnvelope(tmp.getEnvelope());
				nested.setBoundedBy(tmp);
			}
		}

		@Override
		public void visit(Appearance appearance) {
			// skip appearance
		}
		
	});
	
	if (options.isAssignResultToFeatures())
		feature.setBoundedBy(boundedBy);
	
	return boundedBy;
}
 
Example #26
Source File: FeatureSplitter.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
@Override
public void visit(Appearance appearance) {
	if (keepInlineAppearance && childInfo.getParentCityObject(appearance) != null)
		return;

	super.visit(appearance);
}
 
Example #27
Source File: Appearance200Unmarshaller.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public boolean assignGenericProperty(ADEGenericElement genericProperty, QName substitutionGroup, AbstractGML dest) {
	String name = substitutionGroup.getLocalPart();
	boolean success = true;

	if (dest instanceof AbstractSurfaceData && name.equals("_GenericApplicationPropertyOfSurfaceData"))
		((AbstractSurfaceData)dest).addGenericApplicationPropertyOfSurfaceData(genericProperty);
	else if (dest instanceof AbstractTexture && name.equals("_GenericApplicationPropertyOfTexture"))
		((AbstractTexture)dest).addGenericApplicationPropertyOfTexture(genericProperty);
	else if (dest instanceof AbstractTextureParameterization && name.equals("_GenericApplicationPropertyOfTextureParameterization"))
		((AbstractTextureParameterization)dest).addGenericApplicationPropertyOfTextureParameterization(genericProperty);
	else if (dest instanceof Appearance && name.equals("_GenericApplicationPropertyOfAppearance"))
		((Appearance)dest).addGenericApplicationPropertyOfAppearance(genericProperty);
	else if (dest instanceof GeoreferencedTexture && name.equals("_GenericApplicationPropertyOfGeoreferencedTexture"))
		((GeoreferencedTexture)dest).addGenericApplicationPropertyOfGeoreferencedTexture(genericProperty);
	else if (dest instanceof ParameterizedTexture && name.equals("_GenericApplicationPropertyOfParameterizedTexture"))
		((ParameterizedTexture)dest).addGenericApplicationPropertyOfParameterizedTexture(genericProperty);
	else if (dest instanceof TexCoordGen && name.equals("_GenericApplicationPropertyOfTexCoordGen"))
		((TexCoordGen)dest).addGenericApplicationPropertyOfTexCoordGen(genericProperty);
	else if (dest instanceof TexCoordList && name.equals("_GenericApplicationPropertyOfTexCoordList"))
		((TexCoordList)dest).addGenericApplicationPropertyOfTexCoordList(genericProperty);
	else if (dest instanceof X3DMaterial && name.equals("_GenericApplicationPropertyOfX3DMaterial"))
		((X3DMaterial)dest).addGenericApplicationPropertyOfX3DMaterial(genericProperty);
	else
		success = false;

	return success;
}
 
Example #28
Source File: CityJSONChunkWriter.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public void registerGlobalAppearance(Appearance appearance) {
	switch (documentState) {
	case START_DOCUMENT:
	case END_DOCUMENT:
		throw new IllegalStateException("Global appearances cannot be registered after document has been initialized.");
	case INITIAL:
		break;
	}

	marshaller.getAppearanceResolver().registerGlobalAppearance(appearance);
}
 
Example #29
Source File: AppearanceResolver.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public void registerGlobalAppearance(Appearance appearance) {
	Walker walker = new Walker();
	appearance.accept(walker);
	
	if (!walker.surfaceDatas.isEmpty()) {
		globalSurfaceDatas.putAll(walker.surfaceDatas);
		hasGlobalAppearance = true;
	}
}
 
Example #30
Source File: LocalAppearanceHandler.java    From importer-exporter with Apache License 2.0 5 votes vote down vote up
public void registerAppearances(AbstractCityObject cityObject, long cityObjectId) throws CityGMLImportException {
	if (cityObject.isSetAppearance()) {
		List<Appearance> appearances = new ArrayList<>();
		
		for (AppearanceProperty property : cityObject.getAppearance()) {
			Appearance appearance = property.getAppearance();
			
			if (appearance != null) {
				// unlink parent to be able to free memory
				appearance.unsetParent();
				appearances.add(appearance);

				// check whether we have to deal with textures
				if (!hasParameterizedTextures) {
					for (SurfaceDataProperty surfaceDataProperty : appearance.getSurfaceDataMember()) {
						if (surfaceDataProperty.getSurfaceData() instanceof ParameterizedTexture)
							hasParameterizedTextures = true;
					}
				}
			} else {					
				String href = property.getHref();
				if (href != null && href.length() != 0)
					importer.logOrThrowUnsupportedXLinkMessage(cityObject, Appearance.class, href);
			}
		}
		
		if (!appearances.isEmpty())
			this.appearances.put(cityObjectId, appearances);
	}
}