Java Code Examples for org.citygml4j.model.gml.geometry.AbstractGeometry#accept()

The following examples show how to use org.citygml4j.model.gml.geometry.AbstractGeometry#accept() . 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: DBSurfaceGeometry.java    From importer-exporter with Apache License 2.0 6 votes vote down vote up
private boolean retrieveIds(AbstractGeometry geometry) throws SQLException {
	clear();

	// count number of tuples to be inserted into database
	geometry.accept(this);
	if (count == 0)
		return false;

	// retrieve sequence values
	psNextSeqValues.setInt(1, count);
	try (ResultSet rs = psNextSeqValues.executeQuery()) {
		ids = new long[count];
		int i = 0;

		while (rs.next())
			ids[i++] = rs.getLong(1);

		return true;
	}
}
 
Example 2
Source File: GMLFunctionWalker.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public <E extends AbstractGeometry> T apply(GeometryArrayProperty<E> geometryArrayProperty) {
	if (geometryArrayProperty.isSetGeometry()) {
		for (AbstractGeometry abstractGeometry : new ArrayList<AbstractGeometry>(geometryArrayProperty.getGeometry())) {
			if (shouldWalk) {
				T object = abstractGeometry.accept(this);
				if (object != null)
					return object;
			}
		}
	}

	return null;
}
 
Example 3
Source File: GMLWalker.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public <T extends AbstractGeometry> void visit(GeometryArrayProperty<T> geometryArrayProperty) {
	if (geometryArrayProperty.isSetGeometry()) {
		for (AbstractGeometry abstractGeometry : new ArrayList<AbstractGeometry>(geometryArrayProperty.getGeometry()))
			if (shouldWalk)
				abstractGeometry.accept(this);
	}
}
 
Example 4
Source File: GeometryWalker.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public <T extends AbstractGeometry> void visit(GeometryArrayProperty<T> geometryArrayProperty) {
	if (geometryArrayProperty.isSetGeometry()) {
		for (AbstractGeometry abstractGeometry : new ArrayList<AbstractGeometry>(geometryArrayProperty.getGeometry()))
			if (shouldWalk)
				abstractGeometry.accept(this);
	}
}
 
Example 5
Source File: GeometryFunctionWalker.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public <E extends AbstractGeometry> T apply(GeometryArrayProperty<E> geometryArrayProperty) {
	if (geometryArrayProperty.isSetGeometry()) {
		for (AbstractGeometry abstractGeometry : new ArrayList<AbstractGeometry>(geometryArrayProperty.getGeometry())) {
			if (shouldWalk) {
				T object = abstractGeometry.accept(this);
				if (object != null)
					return object;
			}
		}
	}

	return null;
}
 
Example 6
Source File: GMLMarshaller.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public void process(AbstractGeometry src, AbstractSurfaceCollectionType dest, SemanticsBuilder semanticsBuilder, boolean collapseMaterialValues) {
	this.dest = dest;
	this.semanticsBuilder = semanticsBuilder;

	src.accept(this);
	postprocess(dest, index, collapseMaterialValues);
}
 
Example 7
Source File: GMLMarshaller.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public void process(AbstractGeometry src, AbstractSolidCollectionType dest, SemanticsBuilder semanticsBuilder) {
	this.dest = dest;
	this.semanticsBuilder = semanticsBuilder;
	
	src.accept(this);
	postprocess(dest, index, true);
}
 
Example 8
Source File: SemanticSurfaceCollector.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
@Override
public <T extends AbstractGeometry> void visit(GeometryProperty<T> property) {
	if (!property.isSetGeometry() && property.hasLocalProperty(CityJSONMarshaller.GEOMETRY_XLINK)) {
		// if the boundary surface references a remote geometry object, then the geometry object shall still
		// be classified as semantic surface. It therefore needs to be a child of this boundary surface.
		// In order to change its parent property, we create a shallow copy of the geometry.
		AbstractGeometry geometry = (AbstractGeometry) property.getLocalProperty(CityJSONMarshaller.GEOMETRY_XLINK);
		geometry = ((AbstractGeometry) geometry.copy(copyBuilder));
		geometry.setParent(property);
		geometry.accept(this);
	} else
		super.visit(property);
}
 
Example 9
Source File: LocalGeometryXlinkResolver.java    From importer-exporter with Apache License 2.0 4 votes vote down vote up
@Override
public <T extends AbstractGeometry> void visit(GeometryProperty<T> property) {
	if (!property.isSetGeometry() && property.isSetHref()) {
		if (state == ResolverState.RESOLVE_XLINKS && shouldWalk()) {
			final String target = clipGMLId(property.getHref());
			final AbstractGeometry geometry = geometries.get(target);

			if (geometry != null) {
				// check whether the type of the referenced geometry is allowed
				if (property.getAssociableClass().isInstance(geometry)) {

					// check whether we have already seen this target while 
					// iterating through the geometry tree.
					if (circularTargets.contains(target)) {
						setShouldWalk(false);
						hasCircularReference = true;
						circularTargets.clear();
						circularTargets.push(property.getHref());

						return;
					}

					// iterate through all parent geometries and get their
					// gml:ids to be able to detect circular references
					Child child = property;
					int parents = 0;

					while ((child = childInfo.getParentGeometry(child)) != null) {
						circularTargets.push(((AbstractGeometry)child).getId());
						parents++;
					}

					// recursively walk through the referenced geometry
					geometry.accept(this);

					if (!hasCircularReference) {
						// ok, we can replace the link by a shallow copy of the object
						T copy = property.getAssociableClass().cast(geometry.copy(copyBuilder));

						property.setGeometry(copy);
						property.unsetHref();
						copy.setLocalProperty(CoreConstants.GEOMETRY_XLINK, true);
						copy.setLocalProperty(CoreConstants.GEOMETRY_ORIGINAL, geometry);

						geometry.setLocalProperty(CoreConstants.GEOMETRY_XLINK, true);

						targets.remove(target);
						for (int i = 0; i < parents; ++i)
							circularTargets.pop();
					} else {
						// ups, circular reference detected
						if (!circularTargets.peek().equals(property.getHref()))
							circularTargets.push(property.getHref());
					}
				} else {
					if (importer != null) {
						log.error(importer.getObjectSignature(rootObject) +
								": Incompatible type of geometry referenced by '" +
								target + "'.");
					}
					
					property.unsetHref();
				}
			}
		}

		else if (state == ResolverState.GET_XLINKS)				
			targets.add(clipGMLId(property.getHref()));
	}

	super.visit(property);
}