Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
allkeys = set(self.j["CityObjects"].keys())
re = allkeys ^ re
#-- also add the parent-children
for theid in re2:
if "children" in self.j['CityObjects'][theid]:
for child in self.j['CityObjects'][theid]['children']:
re.add(child)
if "parents" in self.j['CityObjects'][theid]:
for each in self.j['CityObjects'][theid]['parents']:
re.add(self.j['CityObjects'][each])
for each in re:
cm2.j["CityObjects"][each] = self.j["CityObjects"][each]
#-- geometry
subset.process_geometry(self.j, cm2.j)
#-- templates
subset.process_templates(self.j, cm2.j)
#-- appearance
if ("appearance" in self.j):
cm2.j["appearance"] = {}
subset.process_appearance(self.j, cm2.j)
#-- metadata
if ("metadata" in self.j):
cm2.j["metadata"] = self.j["metadata"]
cm2.update_bbox()
return cm2
def get_subset_ids(self, lsIDs, exclude=False):
#-- new sliced CityJSON object
cm2 = CityJSON()
cm2.j["version"] = self.j["version"]
cm2.path = self.path
if "transform" in self.j:
cm2.j["transform"] = self.j["transform"]
#-- copy selected CO to the j2
re = subset.select_co_ids(self.j, lsIDs)
if exclude == True:
allkeys = set(self.j["CityObjects"].keys())
re = allkeys ^ re
for each in re:
cm2.j["CityObjects"][each] = self.j["CityObjects"][each]
#-- geometry
subset.process_geometry(self.j, cm2.j)
#-- templates
subset.process_templates(self.j, cm2.j)
#-- appearance
if ("appearance" in self.j):
cm2.j["appearance"] = {}
subset.process_appearance(self.j, cm2.j)
#-- metadata
if ("metadata" in self.j):
cm2.j["metadata"] = self.j["metadata"]
cm2.update_bbox()
return cm2
#-- new sliced CityJSON object
cm2 = CityJSON()
cm2.j["version"] = self.j["version"]
cm2.path = self.path
if "transform" in self.j:
cm2.j["transform"] = self.j["transform"]
#-- copy selected CO to the j2
for theid in self.j["CityObjects"]:
if exclude == False:
if self.j["CityObjects"][theid]["type"] in lsCOtypes:
cm2.j["CityObjects"][theid] = self.j["CityObjects"][theid]
else:
if self.j["CityObjects"][theid]["type"] not in lsCOtypes:
cm2.j["CityObjects"][theid] = self.j["CityObjects"][theid]
#-- geometry
subset.process_geometry(self.j, cm2.j)
#-- templates
subset.process_templates(self.j, cm2.j)
#-- appearance
if ("appearance" in self.j):
cm2.j["appearance"] = {}
subset.process_appearance(self.j, cm2.j)
#-- metadata
if ("metadata" in self.j):
cm2.j["metadata"] = self.j["metadata"]
cm2.update_bbox()
return cm2