cjio package¶
Submodules¶
cjio.cityjson module¶
- class cjio.cityjson.CityJSON(file=None, j=None, ignore_duplicate_keys=False)[source]¶
Bases:
object
- add_lineage_item(description: str, features: Optional[list] = None, source: Optional[list] = None, processor: Optional[dict] = None)[source]¶
Adds a lineage item in metadata.
- Parameters
description – A string with the description of the process
features – A list of object ids that are affected by it
source – A list of sources. Every source is a dict with the respective info (description, sourceReferenceSystem etc.)
processor – A dict with contact information for the person that conducted the processing
- compute_metadata(overwrite=False, new_uuid=False)[source]¶
Returns the metadata of this CityJSON file
- copy_textures(new_loc, json_path)[source]¶
Copy the texture files to a new location :param new_loc: path to new texture directory :type new_loc: string :param json_path: path to the CityJSON file directory :type json_path: string :returns: None – modifies the CityJSON :raises: InvalidOperation, IOError
- get_cityobjects(type=None, id=None)[source]¶
Return a subset of CityObjects
- Parameters
type – CityObject type. If a list of types are given, then all types in the list are returned.
id – CityObject ID. If a list of IDs are given, then all objects matching the IDs in the list are returned.
- get_identifier()[source]¶
Returns the identifier of this file.
If there is one in metadata, it will be returned. Otherwise, the filename will.
- get_metadata()[source]¶
Returns the “metadata” property of this CityJSON file
Raises a KeyError exception if metadata is missing
- get_textures_location()[source]¶
Get the location of the texture files
Assumes that all textures are in the same location. Relative paths are expanded to absolute paths.
- Returns
path to the directory or URL of the texture files
- Return type
string (path) or None (on failure)
- Raises
NotADirectoryError
- get_title()[source]¶
Returns the description of this file from metadata.
If there is none, the identifier will be returned, instead.
- load_from_j(transform: bool = True)[source]¶
Populates the CityJSON API members from the json schema member ‘j’.
If the CityJSON API members have values, they are removed and updated.
- reference_geometry()[source]¶
Build a coordinate list and index the vertices for writing out to CityJSON.
- set_cityobjects(cityobjects)[source]¶
Creates or updates CityObjects
Note
If a CityObject with the same ID already exists in the model, it will be overwritten
- Parameters
cityobjects – Dictionary of CityObjects, where keys are the CityObject IDs. Same structure as returned by get_cityobjects()
- to_dataframe()[source]¶
Converts the city model to a Pandas data frame where fields are CityObject attributes
- update_bbox()[source]¶
Update the bbox ([“metadata”][“bbox”]) of the CityJSON. If there is none then it is added.
- update_metadata(overwrite=False, new_uuid=False)[source]¶
Computes and updates the “metadata” property of this CityJSON file
- update_textures_location(new_loc, relative=True)[source]¶
Updates the location of the texture files
If the new location is a directory in the local file system, it is expected to exists with the texture files in it.
- Parameters
new_loc (string) – path to new texture directory
relative (boolean) – create texture links relative to the CityJSON file
- Returns
None – modifies the CityJSON
- Raises
InvalidOperation, NotADirectoryError
cjio.cjio module¶
cjio.metadata module¶
Module containing metadata related functions
- cjio.metadata.generate_metadata(citymodel: dict, filename: Optional[str] = None, reference_date: Optional[str] = None, overwrite_values: bool = False, recompute_uuid: bool = False)[source]¶
Returns a tuple containing a dictionary of the metadata and a list of errors.
Keyword arguments: citymodel – Dictionary containing the city model filename – String with the name of the original file overwrite_values – Boolean that forces to overwrite existing values if True (default: False)
cjio.models module¶
Demonstrate what is when we define the CityModel-objects in a top-down approach
- class cjio.models.CityObject(id, type: Optional[str] = None, geometry: Optional[Iterable] = None, attributes: Optional[Mapping] = None, children: Optional[Iterable] = None, parents: Optional[Iterable] = None)[source]¶
Bases:
object
CityObject class
- class cjio.models.Geometry(type: Optional[str] = None, lod: Optional[str] = None, boundaries: Optional[Iterable] = None, semantics_obj: Optional[Mapping] = None, vertices=None, transform=None, texture_obj=None, appearance=None)[source]¶
Bases:
object
CityJSON Geometry object
- build_index(vtx_lookup: Optional[Mapping] = None, vtx_idx: int = 0)[source]¶
Build a coordinate list and index the vertices in the boundary.
This method is used when converting the Geometry to the JSON output.
- get_surface_boundaries(surface)[source]¶
Get the surface at the index location from the Geometry boundary
Note
Interior surfaces don’t have semantics and they are returned with the exterior.
- Parameters
surface – A semantic surface
- Returns
Surfaces from the boundary that correspond to the index.
- get_surfaces(type: Optional[str] = None, lod: Optional[str] = None)[source]¶
Get the semantic surfaces of the given type
The whole boundary is returned if a geometry does not have semantics, or has a LoD < 2, or the surface type is not provided.
- Parameters
type – Semantic Surface type. If not provided, the whole boundary is returned.
lod – Level of Detail
- Returns
Return a subset of the specific surfaces of the geometry
- transform(transform: dict)[source]¶
Apply coordinate transformation to the boundary
- Parameters
transform – Transform object from CityJSON
- Returns
A copy of the Geometry object with a boundary with transformed coordinates