org.citygml4j.model.module.citygml.CityGMLModule Java Examples

The following examples show how to use org.citygml4j.model.module.citygml.CityGMLModule. 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: CityGMLUnmarshaller.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
private CityGMLModule getCityGMLModule(Object src) {
	if (src != null) {
		moduleMatcher.reset(src.getClass().getPackage().getName());
		
		if (moduleMatcher.matches()) {
			String moduleString = moduleMatcher.group(1);
			if (moduleString == null)
				moduleString = "core";
			
			CityGMLModuleVersion version = moduleMatcher.group(2).equals("_2") ? CityGMLModuleVersion.v2_0_0 : CityGMLModuleVersion.v1_0_0;
			for (CityGMLModule module : Modules.getCityGMLModules()) {
				if (module.getVersion() == version && module.getType().toString().toLowerCase().equals(moduleString))
					return module;
			}	
		}
	}

	return null;
}
 
Example #2
Source File: CoreUnmarshaller.java    From citygml4j with Apache License 2.0 6 votes vote down vote up
private boolean satisfiesCityGMLNameFilter(AbstractFeature cityObject) {
	boolean accept = false;

	for (Module module : Modules.getModules()) {
		if (!(module instanceof CityGMLModule) && !(module instanceof ADEModule))
			continue;

		QName name = module.getFeatureName(cityObject.getClass());
		if (name != null && json.getCityGMLNameFilter().accept(name)) {
			accept = true;
			break;
		}
	}

	return accept;
}
 
Example #3
Source File: FeatureTypeTree.java    From importer-exporter with Apache License 2.0 5 votes vote down vote up
private DefaultMutableTreeNode getCityGMLModuleNode(CityGMLModule module) {
	DefaultMutableTreeNode node = new DefaultMutableTreeNode(module.getType());

	AppSchema schema = schemaMapping.getSchema(module.getNamespaceURI());
	if (schema != null) {
		for (FeatureType featureType : schema.listTopLevelFeatureTypes(true)) {
			DefaultMutableTreeNode child = new DefaultMutableTreeNode(featureType);
			node.add(child);
			leafs.add(child);
		}
	}

	return node;
}
 
Example #4
Source File: ProjectionFilter.java    From importer-exporter with Apache License 2.0 5 votes vote down vote up
public boolean containsProperty(String name, String namespaceURI) {
	if (properties == null && genericAttributes == null)
		return TRUE;

	if (properties != null) {
		for (AbstractProperty property : properties) {
			if (property.getPath().equals(name) 
					&& property.isSetSchema()
					&& property.getSchema().matchesNamespaceURI(namespaceURI))
				return TRUE;
		}
	}

	if (genericAttributes != null) {
		boolean isGenericAttribute = false;
		for (CityGMLModule module : Modules.getCityGMLModules(CityGMLModuleType.GENERICS)) {
			if (module.getNamespaceURI().equals(namespaceURI)) {
				isGenericAttribute = true;
				break;
			}
		}

		if (isGenericAttribute) {
			for (GenericAttribute genericAttribute : genericAttributes) {					
				String attrName = getGenericAttributeName(genericAttribute.getType());
				if (name.equals(attrName))
					return TRUE;
			}
		}
	}

	return FALSE;
}
 
Example #5
Source File: SchemaHandler.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public Source getSchemaSource(CityGMLModule module) {
	String systemId = visited.get(module.getNamespaceURI());
	if (systemId != null)
		return new StreamSource(systemId);

	return null;
}
 
Example #6
Source File: AbstractJAXBWriter.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public void setSchemaLocations(CityGMLVersion version) {
	for (CityGMLModule module : version.getCityGMLModules()) {
		if (module instanceof CoreModule)
			continue;

		setSchemaLocation(module);
	}
}
 
Example #7
Source File: AbstractJAXBWriter.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
public void setSchemaLocations(ModuleContext moduleContext) {
	for (CityGMLModule module : moduleContext.getCityGMLModules()) {
		if (module instanceof CoreModule)
			continue;

		setSchemaLocation(module);
	}

	for (ADEModule adeModule : moduleContext.getADEModules())
		setSchemaLocation(adeModule);
}
 
Example #8
Source File: XMLElementChecker.java    From citygml4j with Apache License 2.0 5 votes vote down vote up
private ElementInfo getCityGMLFeatureProperty(QName name) {
	ElementInfo elementInfo = null;
	String localName = name.getLocalPart();
	String namespaceURI = name.getNamespaceURI();

	boolean isFeatureProperty = false;
	boolean skipNestedElements = false;

	if (featureReadMode == FeatureReadMode.SPLIT_PER_COLLECTION_MEMBER) {
		HashSet<String> properties = cityGMLFeatureProperties.get(namespaceURI);
		isFeatureProperty = properties != null && properties.contains(localName);
	} else {
		Module module = Modules.getModule(namespaceURI);
		if (module instanceof CityGMLModule) {
			CityGMLModule cityGMLModule = (CityGMLModule)module;
			isFeatureProperty = cityGMLModule.hasFeatureProperty(localName);					
			if (localName.equals("appearance"))
				skipNestedElements = keepInlineAppearance;
		}
	}

	if (isFeatureProperty) {
		elementInfo = new ElementInfo();
		elementInfo.isFeatureProperty = true;
		elementInfo.hasXLink = true;
		elementInfo.skipNestedElements = skipNestedElements;
	}

	return elementInfo;
}
 
Example #9
Source File: StoredQueryManager.java    From web-feature-service with Apache License 2.0 4 votes vote down vote up
private StoredQuery createDefaultStoredQuery() throws ParserConfigurationException, SAXException {
	// GetFeatureById query according to the WFS 2.0 spec
	StoredQueryDescriptionType description = new StoredQueryDescriptionType();

	description.setId(!Constants.DEFAULT_WFS_VERSION.equals("2.0.0") ?
			GET_FEATURE_BY_ID_NAME : DEPRECATED_GET_FEATURE_BY_ID_NAME);

	Title queryTitle = new Title();
	queryTitle.setLang("en");
	queryTitle.setValue("Get feature by identifier");
	description.getTitle().add(queryTitle);
	Abstract queryAbstract = new Abstract();
	queryAbstract.setLang("en");
	queryAbstract.setValue("Retrieves a feature by its gml:id.");
	description.getAbstract().add(queryAbstract);

	ParameterExpressionType parameter = new ParameterExpressionType();
	parameter.setName("id");
	parameter.setType(XSDataType.XS_STRING.getName());
	Title parameterTitle = new Title();
	parameterTitle.setLang("en");
	parameterTitle.setValue("Identifier");
	parameter.getTitle().add(parameterTitle);
	Abstract parameterAbstract = new Abstract();
	parameterAbstract.setLang("en");
	parameterAbstract.setValue("The gml:id of the feature to be retrieved.");
	parameter.getAbstract().add(parameterAbstract);
	description.getParameter().add(parameter);

	Document document = documentBuilderFactory.newDocumentBuilder().newDocument();
	Element query = document.createElementNS(Constants.WFS_NAMESPACE_URI, Constants.WFS_NAMESPACE_PREFIX + ":Query");
	query.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:" + Constants.WFS_NAMESPACE_PREFIX, Constants.WFS_NAMESPACE_URI);

	NamespaceFilter namespaceFilter = new NamespaceFilter();
	CityGMLVersion version = wfsConfig.getFeatureTypes().getDefaultVersion();
	boolean multipleVersions = wfsConfig.getFeatureTypes().getVersions().size() > 1;
	CityGMLModule module = version.getCityGMLModule(CityGMLModuleType.CORE);		
	String prefix = module.getNamespacePrefix();
	if (multipleVersions)
		prefix += (version == CityGMLVersion.v2_0_0) ? "2" : "1";

	namespaceFilter.startPrefixMapping(prefix, module.getNamespaceURI());
	namespaceFilter.startPrefixMapping("xs", XMLConstants.W3C_XML_SCHEMA_NS_URI);
	query.setAttribute("typeNames", "schema-element(" + prefix + ':' + "_CityObject)");
	query.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:" + prefix, module.getNamespaceURI());

	Element filter = document.createElementNS(Constants.FES_NAMESPACE_URI, Constants.FES_NAMESPACE_PREFIX + ":Filter");
	filter.setAttributeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "xmlns:" + Constants.FES_NAMESPACE_PREFIX, Constants.FES_NAMESPACE_URI);
	Element resourceId = document.createElementNS(Constants.FES_NAMESPACE_URI, Constants.FES_NAMESPACE_PREFIX + ":ResourceId");
	resourceId.setAttribute("rid", "${id}");
	filter.appendChild(resourceId);
	query.appendChild(filter);

	QueryExpressionTextType queryExpression = new QueryExpressionTextType();
	queryExpression.getContent().add(query);		
	queryExpression.setIsPrivate(false);
	queryExpression.setLanguage("en");
	queryExpression.setReturnFeatureTypes(new ArrayList<QName>());
	queryExpression.setLanguage(StoredQuery.DEFAULT_LANGUAGE);
	description.getQueryExpressionText().add(queryExpression);

	return new StoredQuery(description, namespaceFilter, this);
}
 
Example #10
Source File: ModuleContext.java    From citygml4j with Apache License 2.0 4 votes vote down vote up
public List<CityGMLModule> getCityGMLModules() {
	return getModules(CityGMLModule.class);
}
 
Example #11
Source File: Modules.java    From citygml4j with Apache License 2.0 4 votes vote down vote up
public static List<CityGMLModule> getCityGMLModules() {
	return getModules(CityGMLModule.class);
}
 
Example #12
Source File: Modules.java    From citygml4j with Apache License 2.0 4 votes vote down vote up
public static CityGMLModule getCityGMLModule(String namespaceURI) {
	return getModule(CityGMLModule.class, namespaceURI);
}
 
Example #13
Source File: Modules.java    From citygml4j with Apache License 2.0 4 votes vote down vote up
public static List<CityGMLModule> getCityGMLModules(CityGMLModuleType type) {
	return getModules(CityGMLModule.class, type);
}
 
Example #14
Source File: CityGMLNamespaceMapper.java    From citygml4j with Apache License 2.0 4 votes vote down vote up
public int next() throws XMLStreamException {
	int event = reader.next();
	
	if (event == XMLStreamConstants.START_ELEMENT) {
		String localPart = reader.getLocalName();
		String namespaceURI = reader.getNamespaceURI();
		depth++;

		if (namespaceURI.startsWith("http://www.citygml.org/citygml")) {
			isCityGML = true;

			if (localPart.equals("creationDate") ||
					localPart.equals("terminationDate") ||
					localPart.equals("generalizesTo")) {
				namespaceURI = CoreModule.v1_0_0.getNamespaceURI();
			}

			else if (localPart.equals("externalReference")) {
				parents.push(parent);
				parent = new ParentFeatureElement(localPart, CoreModule.v1_0_0.getNamespaceURI(), depth);
				namespaceURI = CoreModule.v1_0_0.getNamespaceURI();
			} 

			else if (localPart.equals("stringAttribute") ||
					localPart.equals("intAttribute") ||
					localPart.equals("doubleAttribute") ||
					localPart.equals("dateAttribute") ||
					localPart.equals("uriAttribute")) {
				parents.push(parent);
				parent = new ParentFeatureElement(localPart, GenericsModule.v1_0_0.getNamespaceURI(), depth);
				namespaceURI = GenericsModule.v1_0_0.getNamespaceURI();
			}

			else if (localPart.equals("appearanceMember")) {
				if (parent != null && !parent.localPart.equals("CityModel"))
					localPart = "appearance";

				namespaceURI = AppearanceModule.v1_0_0.getNamespaceURI();					
			}
			
			else if (localPart.equals("TexturedSurface") ||
					localPart.equals("SimpleTexture") ||
					localPart.equals("Material")) {
				namespaceURI = TexturedSurfaceModule.v1_0_0.getNamespaceURI();
			}

			else {
				for (CityGMLModule module : CityGMLVersion.v1_0_0.getCityGMLModules()) {
					if (module.getType() == CityGMLModuleType.BRIDGE || module.getType() == CityGMLModuleType.TUNNEL)
						continue;

					if (module.hasFeature(localPart)) {
						parents.push(parent);
						parent = new ParentFeatureElement(localPart, module.getNamespaceURI(), depth);
						break;
					}		
				}

				namespaceURI = parent.namespaceURI;
			}

		} else
			isCityGML = false;
		
		currentName = new QName(namespaceURI, localPart);

	} else if (event == XMLStreamConstants.END_ELEMENT) {
		if (parent != null && parent.depth == depth)
			parent = parents.pop();

		depth--;
	}

	return event;
}
 
Example #15
Source File: CityGMLMarshaller.java    From citygml4j with Apache License 2.0 4 votes vote down vote up
private CityGMLModule getCityGMLModule(Object src) {

		if (src instanceof ModelObject) {
			ModuleContext moduleContext = jaxb.getModuleContext();

			if (src instanceof AppearanceModuleComponent)
				return (AppearanceModule)moduleContext.getModule(CityGMLModuleType.APPEARANCE);
			else if (src instanceof BridgeModuleComponent)
				return (BridgeModule)moduleContext.getModule(CityGMLModuleType.BRIDGE);
			else if (src instanceof BuildingModuleComponent)
				return (BuildingModule)moduleContext.getModule(CityGMLModuleType.BUILDING);
			else if (src instanceof CityFurnitureModuleComponent)
				return (CityFurnitureModule)moduleContext.getModule(CityGMLModuleType.CITY_FURNITURE);
			else if (src instanceof CityObjectGroupModuleComponent)
				return (CityObjectGroupModule)moduleContext.getModule(CityGMLModuleType.CITY_OBJECT_GROUP);
			else if (src instanceof GenericsModuleComponent)
				return (GenericsModule)moduleContext.getModule(CityGMLModuleType.GENERICS);
			else if (src instanceof LandUseModuleComponent)
				return (LandUseModule)moduleContext.getModule(CityGMLModuleType.LAND_USE);
			else if (src instanceof ReliefModuleComponent)
				return (ReliefModule)moduleContext.getModule(CityGMLModuleType.RELIEF);
			else if (src instanceof TexturedSurfaceModuleComponent)
				return (TexturedSurfaceModule)moduleContext.getModule(CityGMLModuleType.TEXTURED_SURFACE);
			else if (src instanceof TransportationModuleComponent)
				return (TransportationModule)moduleContext.getModule(CityGMLModuleType.TRANSPORTATION);
			else if (src instanceof TunnelModuleComponent)
				return (TunnelModule)moduleContext.getModule(CityGMLModuleType.TUNNEL);
			else if (src instanceof VegetationModuleComponent)
				return (VegetationModule)moduleContext.getModule(CityGMLModuleType.VEGETATION);
			else if (src instanceof WaterBodyModuleComponent)
				return (WaterBodyModule)moduleContext.getModule(CityGMLModuleType.WATER_BODY);
			else
				return (CoreModule)moduleContext.getModule(CityGMLModuleType.CORE);		
		}

		else if (src != null) {
			moduleMatcher.reset(src.getClass().getPackage().getName());

			if (moduleMatcher.matches()) {
				String moduleString = moduleMatcher.group(1);
				if (moduleString == null)
					moduleString = "core";

				CityGMLModuleVersion version = moduleMatcher.group(2).equals("_2") ? CityGMLModuleVersion.v2_0_0 : CityGMLModuleVersion.v1_0_0;
				for (CityGMLModule module : Modules.getCityGMLModules()) {
					if (module.getVersion() == version && module.getType().toString().toLowerCase().equals(moduleString))
						return module;
				}	
			}		
		}

		return null;
	}