本文整理汇总了Java中org.citygml4j.model.citygml.core.CityObjectMember类的典型用法代码示例。如果您正苦于以下问题:Java CityObjectMember类的具体用法?Java CityObjectMember怎么用?Java CityObjectMember使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CityObjectMember类属于org.citygml4j.model.citygml.core包,在下文中一共展示了CityObjectMember类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getElementMapper
import org.citygml4j.model.citygml.core.CityObjectMember; //导入依赖的package包/类
private TypeMapper<JAXBElement<?>> getElementMapper() {
if (elementMapper == null) {
lock.lock();
try {
if (elementMapper == null) {
elementMapper = TypeMapper.<JAXBElement<?>>create()
.with(Address.class, this::createAddress)
.with(CityModel.class, this::createCityModel)
.with(CityObjectMember.class, this::createCityObjectMember)
.with(ImplicitGeometry.class, this::createImplicitGeometry);
}
} finally {
lock.unlock();
}
}
return elementMapper;
}
示例2: getTypeMapper
import org.citygml4j.model.citygml.core.CityObjectMember; //导入依赖的package包/类
private TypeMapper<Object> getTypeMapper() {
if (typeMapper == null) {
lock.lock();
try {
if (typeMapper == null) {
typeMapper = TypeMapper.create()
.with(Address.class, this::marshalAddress)
.with(AddressProperty.class, this::marshalAddressProperty)
.with(CityModel.class, this::marshalCityModel)
.with(CityObjectMember.class, this::marshalCityObjectMember)
.with(ExternalObject.class, this::marshalExternalObject)
.with(ExternalReference.class, this::marshalExternalReference)
.with(GeneralizationRelation.class, this::marshalGeneralizationRelation)
.with(ImplicitGeometry.class, this::marshalImplicitGeometry)
.with(ImplicitRepresentationProperty.class, this::marshalImplicitRepresentationProperty)
.with(XalAddressProperty.class, this::marshalXalAddressProperty);
}
} finally {
lock.unlock();
}
}
return typeMapper;
}
示例3: getTypeMapper
import org.citygml4j.model.citygml.core.CityObjectMember; //导入依赖的package包/类
private TypeMapper<Object> getTypeMapper() {
if (typeMapper == null) {
lock.lock();
try {
if (typeMapper == null) {
typeMapper = TypeMapper.create()
.with(Address.class, this::marshalAddress)
.with(AddressProperty.class, this::marshalAddressProperty)
.with(CityModel.class, this::marshalCityModel)
.with(CityObjectMember.class, this::marshalCityObjectMember)
.with(ExternalObject.class, this::marshalExternalObject)
.with(ExternalReference.class, this::marshalExternalReference)
.with(GeneralizationRelation.class, this::marshalGeneralizationRelation)
.with(ImplicitGeometry.class, this::marshalImplicitGeometry)
.with(ImplicitRepresentationProperty.class, this::marshalImplicitRepresentationProperty)
.with(RelativeToTerrain.class, this::marshalRelativeToTerrain)
.with(RelativeToWater.class, this::marshalRelativeToWater)
.with(XalAddressProperty.class, this::marshalXalAddressProperty);
}
} finally {
lock.unlock();
}
}
return typeMapper;
}
示例4: unmarshalCityModel
import org.citygml4j.model.citygml.core.CityObjectMember; //导入依赖的package包/类
public void unmarshalCityModel(CityJSON src, CityModel dest) {
for (AbstractCityObjectType type : src.getCityObjects()) {
AbstractCityObject cityObject = citygml.unmarshal(type, src);
if (cityObject != null)
dest.addCityObjectMember(new CityObjectMember(cityObject));
}
if (src.isSetMetadata()) {
MetadataType metadata = src.getMetadata();
if (metadata.isSetBBox()) {
List<Double> bbox = metadata.getBBox();
if (bbox.size() > 5) {
BoundingShape boundedBy = new BoundingShape(new BoundingBox(
new Point(bbox.get(0), bbox.get(1), bbox.get(2)),
new Point(bbox.get(3), bbox.get(4), bbox.get(5))));
if (metadata.isSetCRS())
boundedBy.getEnvelope().setSrsName("EPSG:" + metadata.getCRS().getEpsg());
dest.setBoundedBy(boundedBy);
}
}
}
}
示例5: readCityGMLFile
import org.citygml4j.model.citygml.core.CityObjectMember; //导入依赖的package包/类
/**
* Returns a list for BuildingCallable read by CityGML file
*
* @param pathtocitygmlfile
* @param options
* @return List<BuildingCallable>
* @throws Exception
*/
public List<BuildingCallable> readCityGMLFile(String pathtocitygmlfile, Options options) throws Exception {
this.options = options;
List<BuildingCallable> buildings = new ArrayList<BuildingCallable>();
CityGMLContext ctx = new CityGMLContext();
CityGMLBuilder builder = ctx.createCityGMLBuilder();
CityGMLInputFactory in = builder.createCityGMLInputFactory();
CityGMLReader reader = in.createCityGMLReader(new File(pathtocitygmlfile));
while (reader.hasNext()) {
CityGML citygml = reader.nextFeature();
if (citygml.getCityGMLClass() == CityGMLClass.CITY_MODEL) {
CityModel cityModel = (CityModel)citygml;
for (CityObjectMember cityObjectMember : cityModel.getCityObjectMember()) {
AbstractCityObject cityObject = cityObjectMember.getCityObject();
if (cityObject.getCityGMLClass() == CityGMLClass.BUILDING){
Building building = (Building)cityObject;
String buildingID = building.getId();
BuildingCallable buildingcallable = new BuildingCallable();
buildingcallable.setBsp(building.getBoundedBySurface());
buildingcallable.setBuildingId(buildingID);
buildingcallable.setOptions(options);
buildings.add(buildingcallable);
}
}
}
}
reader.close();
return buildings;
}
示例6: apply
import org.citygml4j.model.citygml.core.CityObjectMember; //导入依赖的package包/类
public T apply(CityModel cityModel) {
T object = apply((AbstractFeatureCollection)cityModel);
if (object != null)
return object;
if (cityModel.isSetCityObjectMember()) {
for (CityObjectMember cityObjectMember : new ArrayList<CityObjectMember>(cityModel.getCityObjectMember())) {
object = apply(cityObjectMember);
if (object != null)
return object;
}
}
if (cityModel.isSetAppearanceMember()) {
for (AppearanceMember appearanceMember : new ArrayList<AppearanceMember>(cityModel.getAppearanceMember())) {
object = apply(appearanceMember);
if (object != null)
return object;
}
}
if (cityModel.isSetGenericApplicationPropertyOfCityModel()) {
for (ADEComponent ade : new ArrayList<ADEComponent>(cityModel.getGenericApplicationPropertyOfCityModel())) {
object = apply(ade);
if (object != null)
return object;
}
}
return null;
}
示例7: unmarshalCityObjectMember
import org.citygml4j.model.citygml.core.CityObjectMember; //导入依赖的package包/类
public CityObjectMember unmarshalCityObjectMember(FeaturePropertyType src) throws MissingADESchemaException {
CityObjectMember dest = new CityObjectMember(module);
jaxb.getGMLUnmarshaller().unmarshalFeatureProperty(src, dest);
if (src.isSet_Feature()) {
ModelObject abstractFeature = jaxb.unmarshal(src.get_Feature());
if (abstractFeature instanceof AbstractCityObject)
dest.setFeature((AbstractCityObject)abstractFeature);
}
return dest;
}
示例8: marshalCityModel
import org.citygml4j.model.citygml.core.CityObjectMember; //导入依赖的package包/类
public List<AbstractCityObjectType> marshalCityModel(CityModel src) {
List<AbstractCityObjectType> dest = new ArrayList<>();
if (src.isSetCityObjectMember()) {
for (CityObjectMember property : src.getCityObjectMember()) {
if (property.isSetCityObject())
dest.addAll(citygml.marshal(property.getCityObject()));
}
}
return dest;
}
示例9: main
import org.citygml4j.model.citygml.core.CityObjectMember; //导入依赖的package包/类
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 CityGML builder");
CityGMLContext ctx = CityGMLContext.getInstance();
CityGMLBuilder builder = ctx.createCityGMLBuilder();
System.out.println(df.format(new Date()) + "reading CityGML file LOD2_Buildings_v100.gml completely into main memory");
CityGMLInputFactory in = builder.createCityGMLInputFactory();
CityGMLReader reader = in.createCityGMLReader(new File("datasets/LOD2_Buildings_v100.gml"));
while (reader.hasNext()) {
CityGML citygml = reader.nextFeature();
if (citygml.getCityGMLClass() == CityGMLClass.CITY_MODEL) {
CityModel cityModel = (CityModel)citygml;
System.out.println(df.format(new Date()) + "Found " + citygml.getCityGMLClass() + " version " + cityModel.getCityGMLModule().getVersion());
System.out.println(df.format(new Date()) + "going through city model and counting building instances");
int count = 0;
for (CityObjectMember cityObjectMember : cityModel.getCityObjectMember()) {
AbstractCityObject cityObject = cityObjectMember.getCityObject();
if (cityObject.getCityGMLClass() == CityGMLClass.BUILDING)
count++;
}
System.out.println(df.format(new Date()) + "The city model contains " + count + " building features");
}
}
reader.close();
System.out.println(df.format(new Date()) + "sample citygml4j application successfully finished");
}
示例10: main
import org.citygml4j.model.citygml.core.CityObjectMember; //导入依赖的package包/类
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 CityGML builder");
CityGMLContext ctx = CityGMLContext.getInstance();
CityGMLBuilder builder = ctx.createCityGMLBuilder();
// creating example (and simple) CityGML object tree
System.out.println(df.format(new Date()) + "creating simple city model with invalid content");
Building building = new Building();
// set invalid gml:id
building.setId("1st-Building");
// set empty and thus invalid generic attribute set
building.addGenericAttribute(new GenericAttributeSet());
CityModel cityModel = new CityModel();
cityModel.addCityObjectMember(new CityObjectMember(building));
System.out.println(df.format(new Date()) + "creating citygml4j Validator and validating city model against CityGML 2.0.0");
SchemaHandler schemaHandler = SchemaHandler.newInstance();
Validator validator = builder.createValidator(schemaHandler);
validator.setValidationEventHandler(new ValidationEventHandler() {
public boolean handleEvent(ValidationEvent event) {
System.out.println(event.getMessage());
return true;
}
});
validator.validate(cityModel, CityGMLVersion.v2_0_0);
System.out.println(df.format(new Date()) + "sample citygml4j application successfully finished");
}
示例11: print
import org.citygml4j.model.citygml.core.CityObjectMember; //导入依赖的package包/类
public void print(AbstractFeature abstractFeature) throws CityGMLWriteException {
FeatureProperty<? extends AbstractFeature> member = null;
// wrap feature with a feature property element
if (abstractFeature instanceof AbstractCityObject) {
member = new CityObjectMemberImpl();
((CityObjectMember)member).setCityObject((AbstractCityObject)abstractFeature);
}
else if (abstractFeature instanceof Appearance) {
member = new AppearanceMemberImpl();
((AppearanceMember)member).setAppearance((Appearance)abstractFeature);
}
else {
member = new FeatureMemberImpl();
((FeatureMember)member).setFeature(abstractFeature);
}
if (member != null) {
try {
SAXEventBuffer buffer = new SAXEventBuffer();
Marshaller marshaller = jaxbBuilder.getJAXBContext().createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
JAXBElement<?> jaxbElement = jaxbMarshaller.marshalJAXBElement(member);
if (jaxbElement != null)
marshaller.marshal(jaxbElement, buffer);
if (!buffer.isEmpty())
ioWriterPool.addWork(buffer);
} catch (JAXBException e) {
throw new CityGMLWriteException("Caused by: ", e);
}
}
}
示例12: marshalCityObjectMember
import org.citygml4j.model.citygml.core.CityObjectMember; //导入依赖的package包/类
public FeaturePropertyType marshalCityObjectMember(CityObjectMember src) {
return jaxb.getGMLMarshaller().marshalFeatureProperty(src);
}
示例13: createCityObjectMember
import org.citygml4j.model.citygml.core.CityObjectMember; //导入依赖的package包/类
private JAXBElement<?> createCityObjectMember(CityObjectMember src) {
return core.createCityObjectMember(marshalCityObjectMember(src));
}
示例14: main
import org.citygml4j.model.citygml.core.CityObjectMember; //导入依赖的package包/类
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 CityGML builder");
CityGMLContext ctx = CityGMLContext.getInstance();
CityGMLBuilder builder = ctx.createCityGMLBuilder();
System.out.println(df.format(new Date()) + "reading CityGML file LOD2_CityObjectGroup_v100.gml");
CityGMLInputFactory in = builder.createCityGMLInputFactory();
CityGMLReader reader = in.createCityGMLReader(new File("datasets/LOD2_CityObjectGroup_v100.gml"));
CityModel cityModel = (CityModel)reader.nextFeature();
reader.close();
System.out.println(df.format(new Date()) + "creating XLinkResolver");
XLinkResolver xLinkResolver = new XLinkResolver();
for (CityObjectMember member : cityModel.getCityObjectMember()) {
if (member.isSetCityObject() &&
member.getCityObject().getCityGMLClass() == CityGMLClass.CITY_OBJECT_GROUP) {
CityObjectGroup group = (CityObjectGroup)member.getCityObject();
for (CityObjectGroupMember groupMember : group.getGroupMember()) {
System.out.println(df.format(new Date()) + "processing group member with role: " + groupMember.getGroupRole());
System.out.println(df.format(new Date()) + "resolving XLink to " + groupMember.getHref());
AbstractCityObject cityObject = xLinkResolver.getAbstractGML(groupMember.getHref(), cityModel, AbstractCityObject.class);
System.out.println(" Referenced city object: " + cityObject.getCityGMLClass() +
", gml:id='" + cityObject.getId() +"'");
if (cityObject.getId().equals("ID_76")) {
Road road = (Road)cityObject;
TrafficArea trafficArea = road.getTrafficArea().get(2).getTrafficArea();
System.out.println(df.format(new Date()) + "resolving XLink to " + trafficArea.getLod2MultiSurface().getHref());
ModelObject object = xLinkResolver.getObject(trafficArea.getLod2MultiSurface().getHref(), road);
if (object instanceof MultiSurface) {
MultiSurface multiSurface = (MultiSurface)object;
System.out.println(" Referenced geometry: " + multiSurface.getGMLClass() +
", gml:id='" + multiSurface.getId() + "'");
}
}
}
}
}
System.out.println(df.format(new Date()) + "sample citygml4j application successfully finished");
}
示例15: main
import org.citygml4j.model.citygml.core.CityObjectMember; //导入依赖的package包/类
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 CityGML builder");
CityGMLContext ctx = CityGMLContext.getInstance();
CityGMLBuilder builder = ctx.createCityGMLBuilder();
System.out.println(df.format(new Date()) + "creating citygml4j JAXBUnmarshaller and JAXBMarshaller instances");
JAXBUnmarshaller unmarshaller = builder.createJAXBUnmarshaller();
JAXBMarshaller marshaller = builder.createJAXBMarshaller();
marshaller.setModuleContext(new ModuleContext(CityGMLVersion.v2_0_0));
// create DOM model from CityGML document
System.out.println(df.format(new Date()) + "reading CityGML file LOD2_Building_with_Placeholder_v200.gml as DOM tree");
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
docFactory.setNamespaceAware(true);
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document document = docBuilder.parse("datasets/LOD2_Building_with_Placeholder_v200.gml");
// create XPath factory
System.out.println(df.format(new Date()) + "creating XPath factory");
XPathFactory xpathFactory = XPathFactory.newInstance();
XPath xpath = xpathFactory.newXPath();
// get CityGML namespace context
CityGMLNamespaceContext nsContext = new CityGMLNamespaceContext();
nsContext.setPrefixes(CityGMLVersion.v2_0_0);
xpath.setNamespaceContext(nsContext);
// first: retrieve building node using XPath
System.out.println(df.format(new Date()) + "searching for bldg:Building node in DOM tree using an XPath expression");
Node buildingNode = (Node)xpath.evaluate("//bldg:Building", document, XPathConstants.NODE);
// unmarshal DOM node to citygml4j
System.out.println(df.format(new Date()) + "unmarshalling DOM node to citygml4j");
Building building = (Building)unmarshaller.unmarshal(buildingNode);
// add gml:id and gml:description to building
System.out.println(df.format(new Date()) + "processing content using citygml4j");
building.setId(DefaultGMLIdManager.getInstance().generateUUID());
StringOrRef description = new StringOrRef();
description.setValue("processed by citygml4j using DOM and XPath");
building.setDescription(description);
// marshal to DOM and put into document
System.out.println(df.format(new Date()) + "marshalling back to DOM");
Element newBuildingNode = marshaller.marshalDOMElement(building, document);
buildingNode.getParentNode().replaceChild(newBuildingNode, buildingNode);
// second: get placeholder using XPath
System.out.println(df.format(new Date()) + "searching for 'Placeholder' in DOM tree using an XPath expression");
Node memberNode = (Node)xpath.evaluate("//core:cityObjectMember[comment()='Placeholder']", document, XPathConstants.NODE);
// create simple citygml4j object to insert into placeholder
System.out.println(df.format(new Date()) + "inserting CityFurniture instance at placeholder using citygml4j");
CityFurniture cityFurniture = new CityFurniture();
cityFurniture.setDescription(description);
CityObjectMember member = new CityObjectMember(cityFurniture);
// marshal to DOM and put into document
System.out.println(df.format(new Date()) + "marshalling back to DOM");
Element newMemberNode = marshaller.marshalDOMElement(member, document);
memberNode.getParentNode().replaceChild(newMemberNode, memberNode);
// write DOM to file
System.out.println(df.format(new Date()) + "writing DOM tree");
TransformerFactory transFactory = TransformerFactory.newInstance();
Transformer trans = transFactory.newTransformer();
trans.setOutputProperty(OutputKeys.INDENT, "yes");
trans.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "2");
Files.createDirectory(Paths.get("output"));
DOMSource source = new DOMSource(document);
StreamResult result = new StreamResult(new FileOutputStream("output/LOD2_DOM_result_v200.gml"));
trans.transform(source, result);
System.out.println(df.format(new Date()) + "CityGML file LOD2_DOM_result_v200.gml written");
System.out.println(df.format(new Date()) + "sample citygml4j application successfully finished");
}