py4design.shp2citygml module

py4design.shp2citygml.map_osm2citygml_landuse_function(landuse)

This function maps these landuse to the gml function codes.

Parameters:

landuse : str

The landuse to be mapped. Options: “residential”, “transport”, “recreation_ground”, “education”, “commercial”, “civic”, “mixed”, “place_of_worship”, “reserve”, “utility”, “health”.

Returns:

gml function code : str

The code of the gml landuse function.

py4design.shp2citygml.map_osm2citygml_building_class(bldg_class)

This function maps these building class to the gml function codes.

Parameters:

bldg_class : str

The class to be mapped. Options: “residential”, “transport”, “recreation_ground”, “education”, “commercial”, “civic”, “mixed”, “place_of_worship”, “reserve”, “utility”, “health”.

Returns:

gml function code : str

The code of the gml class.

py4design.shp2citygml.map_osm2citygml_building_function(bldg_function)

This function maps these building function to the gml function codes.

Parameters:

bldg_function : str

The function to be mapped. Options: “residential”, “transport”, “recreation_ground”, “education”, “commercial”, “civic”, “mixed”, “place_of_worship”, “reserve”, “utility”, “health”.

Returns:

gml function code : str

The code of the gml function.

py4design.shp2citygml.map_osm2citygml_building_amenity_function(amenity)

This function maps these amenity to the gml function codes.

Parameters:

amenity : str

The amenity to be mapped. Options: “parking”.

Returns:

gml function code : str

The code of the gml amenity function.

py4design.shp2citygml.map_osm2citygml_trpst_complex_class(trpst)

This function maps these transportation to the gml function codes.

Parameters:

trpst : str

The transport to be mapped. Options: “subway”, “light_rail”, “unclassified”, “tertiary”, “service”, “secondary_link”, “secondary”, “residential”, “primary”, “motoway_link”, “motorway”, “construction”.

Returns:

gml function code : str

The code of the gml amenity function.

py4design.shp2citygml.map_osm2citygml_trpst_complex_function(trpst)

This function maps these transportation complex to the gml function codes.

Parameters:

trpst : str

The transport to be mapped. Options: “subway”, “light_rail”, “unclassified”, “tertiary”, “service”, “secondary_link”, “secondary”, “residential”, “primary”, “motoway_link”, “motorway”, “construction”, “track”, “steps”, “path”, “footway”, “cycleway”.

Returns:

gml function code : str

The code of the gml amenity function.

py4design.shp2citygml.calc_residential_parking_area(total_build_up)

This function calculates the parking area required based on the built up area.

Parameters:

total_build_up : float

The total built up area.

Returns:

the parking area : float

The calculated parking area.

py4design.shp2citygml.get_buildings(shpfile)

This function get all the building polygons in this shapefile and convert them into a dictionary format.

Parameters:

shpfile : str

The file path of the shape file.

Returns:

list of building dictionary : list of dictionary

The list of building dictionary that documents all the information from the shape file. Each dictionary has this information: building_dictionary = {“building”: string describing the building, “geometry”: OCCface list, “amenity”: amenity string, “parking”: parking string, “name”: building name string, “building_l”: number of building level int}

py4design.shp2citygml.terrain2d23d_tin(terrain_shpfile, elev_attrib_name)

This function generate a TIN from a terrain shpfile that is polygonised.

Parameters:

terrain_shpfile : str

The file path of the terrain shape file.

elev_attrib_name : str

The name of the attribute that documents the height of each polygon.

Returns:

triangle surfaces : list of OCCfaces

The triangle TIN faces.

py4design.shp2citygml.terrain2d23d_contour_line(terrain_shpfile, elev_attrib_name)

This function extrude each polygon according to its elevation attribute.

Parameters:

terrain_shpfile : str

The file path of the terrain shape file.

elev_attrib_name : str

The name of the attribute that documents the height of each polygon.

Returns:

solids : list of OCCsolids

The extruded polygons.

faces : list of OCCfaces

The faces of the polygons.

py4design.shp2citygml.building2d23d(building_shpfile, height_attrib_name, terrain_surface_list)

This function extrude each building and place them on the terrain.

Parameters:

building_shpfile : str

The file path of the building shape file.

height_attrib_name : str

The name of the attribute that documents the building height.

terrain_surface_list : list of OCCfaces

The TIN of the terrain. Each OCCface is triangular.

Returns:

list of extruded buildings : list of OCCsolids

The extruded buildings.

py4design.shp2citygml.get_shpfile_epsg(shpfile)

This function gets the epsg of the shape file.

Parameters:

shpfile : str

The file path of the shape file.

Returns:

epsg : str

The epsg of the shape file.

py4design.shp2citygml.get_field_name_list(sf)

This function gets all the attribute names of the shapefile.

Parameters:

sf : shapefile.Reader() class instance

The reader class instance of a shape file.

Returns:

list of attribute names : list of str

The list of attribute names in the shape file.

py4design.shp2citygml.get_geometry(shape_record)

This function gets all the geometry in the shape record.

Parameters:

shape_record : list of shapefile.Reader().shapeRecords()

The shape records for extraction of geometry.

Returns:

list of geometries : pypolygonlist (polygon and polylines shape file) or pyptlist (point shape file)

Pypolygon_list is a 2d list of tuples. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z). A pypolygon or pyptlist is a list of pypt e.g. [(x1,y1,z1), (x2,y2,z2), …]. A pypolygon_list is a 2d list of tuples e.g. [[(x11,y11,z11), (x12,y12,z12), …], [(x21,y21,z21), (x22,y22,z22), …], …]

py4design.shp2citygml.buildings_on_plot(plot_rec, building_dict_list)

This function identify the buildings that is on this landuse plot.

Parameters:

plot_rec : shapefile.Reader().shapeRecords()

The plot shape record.

building_dict_list : list of dictionaries

The building to be identified. The list of dictionary is generated from the function get_buildings().

Returns:

buildings on plot : list of dictionaries

The building dictionary that are on the plot.

py4design.shp2citygml.get_plot_area(plot_rec)

This function calculate the plot area.

Parameters:

plot_rec : A shapefile.Reader().shapeRecords()

The plot shape record.

Returns:

area : float

The plot area (m2).

py4design.shp2citygml.trpst2citygml(trpt_type, rec, name, trpst_attrib, generic_attrib_dict, citygml_writer)

This function converts records from the shapefile into transportation GML.

Parameters:

trpt_type : str

The transportation type. The options are: “Road”, “Railway”, “Track”, “Square”.

plot_rec : A shapefile.Reader().shapeRecords()

The shape record of the roads, must be a polyline shape file.

name : str

The name of the transportation object.

trpst_attrib : str

The class/function of the transportation. Options: “subway”, “light_rail”, “unclassified”, “tertiary”, “service”, “secondary_link”, “secondary”, “residential”, “primary”, “motoway_link”, “motorway”, “construction”.

generic_attrib_dict : dictionary, optional

Extra attributes to be appended to the object, Default = None. The dictionary must have a string key which will be the name of the generic attributes, and either an int, float or str value.

citygml_writer : Pycitygml.Writer() class instance

The writer is used to write information to the GML transportation.

py4design.shp2citygml.building2citygml(building_dict, height, citygml_writer, building_function, storey)

This function converts the building dictionariesinto building GML.

Parameters:

building_dict : dictionary

The building to be converted. The dictionary is generated from the function get_buildings().

height : float

The building height.

citygml_writer : Pycitygml.Writer() class instance

The writer is used to write information to the GML transportation.

name : str

The name of the transportation object.

building_function : str

The class/function of the building. Options: Options: “residential”, “transport”, “recreation_ground”, “education”, “commercial”, “civic”, “mixed”, “place_of_worship”, “reserve”, “utility”, “health”.

storey : int

The number of storeys of the building.

py4design.shp2citygml.pypt2d_2_3d(pypt2d, z)

This function converts the pypt 2d to pypt 3d.

Parameters:

pypt2d : pypt2d

The pypt2d to be converted. A pypt2d is a tuple that documents the xy coordinates of a pt e.g. (x,y).

z : float

The z-value of pypt3d

Returns:

pypt3d : pypt

A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z).

py4design.shp2citygml.pypt_list2d_2_3d(pypt_list2d, z)

This function converts a list of pypt 2d to a list of pypt 3d.

Parameters:

pypt_list2d : pypt2d

The list pypt2d to be converted. A pypt2d is a tuple that documents the xy coordinates of a pt e.g. (x,y). A list of pypt2d is [(x1,y1), (x2,y2), …]

z : float

The z-value of pypt3d

Returns:

list of pypt3d : pyptlist

A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z). A pyptlist is a list of pypt e.g. [(x1,y1,z1), (x2,y2,z2), …].

py4design.shp2citygml.pypolygon_list2d_2_3d(pypolygon_list2d, z)

This function converts a list of pypolygon 2d to a list of pypolygon 3d.

Parameters:

pypolygon_list2d : pypolygon_list2d

The list pypolgon 2d to be converted. A pypolygon_list2d is a 2d list of tuples e.g. [[(x11,y11), (x12,y12), …], [(x21,y21), (x22,y22), …], …]

z : float

The z-value of pypolygon3d

Returns:

list of pypolygon3d : pypolygon_list

A pypolygon_list is a 2d list of tuples e.g. [[(x11,y11,z11), (x12,y12,z12), …], [(x21,y21,z21), (x22,y22,z22), …], …]

py4design.shp2citygml.shp_pypolygon_list3d_2_occface_list(pypolygon_list)

This function converts a pypolygon_list to list of OCCfaces.

Parameters:

pypolygon_list : pypolygon_list

Pypolygon_list is a 2d list of tuples. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z). A pypolygon or pyptlist is a list of pypt e.g. [(x1,y1,z1), (x2,y2,z2), …]. A pypolygon_list is a 2d list of tuples e.g. [[(x11,y11,z11), (x12,y12,z12), …], [(x21,y21,z21), (x22,y22,z22), …], …]

Returns:

list of faces : list of OCCfaces

A list of OCCfaces.

py4design.shp2citygml.extrude_building_n_fetch_faces(building_footprint, height)

This function extrudes a building and returns all its faces.

Parameters:

building_footprint : OCCface

The building footprint to be extruded.

height : float

The building height.

Returns:

list of faces : list of OCCfaces

A list of OCCfaces of the extruded building.

py4design.shp2citygml.face_almost_inside(occface, boundary_occface)

This functions measures if occ_face is almost inside the boundary face. Almost inside is define as 50% of the occ face is inside the boundary face

Parameters:

occface : OCCface

The face to analyse.

boundary_occface : OCCface

The boundary face.

Returns:

is almost inside : bool

True or False, if True face is almost inside, if False face is not almost inside.

py4design.shp2citygml.create_transit_stop_geometry(transit_occsolid, location_pt)

This functions creates the geometry for the transit stop.

Parameters:

transit_occsolid : OCCsolid

The geometry of the transit stop.

location_pt : pypt

The location of the transit box. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z).

Returns:

the box moved to the location point : OCCsolid

The box that is moved to the transit stop.