Building management with maps and VR, all in one Django app!
Add Buildings to your favourite city, add building Plans directly from CAD, add building Elements and Photo Stations. Manage Plans organizing them in Plansets, do the same with Elements adding hyerarchical Families. Add data sheets to Elements, download them in CSV format. Uses Leaflet as map engine and Three for VR.
This app relies on GeoDjango
, you will need PostGis
and extra libraries (see GeoDjango installation guide). Other external packages are djangorestframework, django-filebrowser, django-treebeard, django-colorful, ezdxf. For styling Bootstrap 4 is used. I develop this app inside my personal starter project that provides all the libraries you need. If you want to embed buildings
into your project you will need to make some tweaks. Hope to make the app as portable as possible in future versions.
In your project root type git clone https://github.com/andywar65/buildings
, add buildings.apps.BuildingsConfig
to INSTALLED_APPS
and path(_('buildings/'), include('buildings.urls', namespace = 'buildings'))
and path('build-api/', include('buildings.api_urls'))
, to your project urls.py
, migrate and collectstatic. You also need to add city settings to settings.py
:
CITY_LAT = 41.8988
CITY_LONG = 12.5451
CITY_ZOOM = 10
(these are the settings for Rome, change them to your city of choice). These settings provide
initial map defaults. On migration Building Manager
and Building Guest
groups will be created. Users assigned to first group will have full access to building management, those assigned
to the second will only be able to visit (some of) them.
With building view permissions, head to yoursite.com/buildings/
. Here you will interact with a map and a form for adding cities and buildings. City just represents your area of interest, but it's called only if there are no buildings. Last city added will be the active one. Zoom on your building and choose it's location clicking on the map. Complete the form, then click on the check. As you can see a marker representing your building is added to the map. Under the hood a new User
is created: the Building Visitor
. This user gets Building Guest
permissions, and can visit only his own building. Visitor's password is sent by email to site Administrator, so it may be shared on request. Visitors can be assigned to different buildings, and their permissions may be upgraded. Permission can_visit_other_buildings
allows them to be ubiquitous.
Click on the building marker, then on the popup title. Fill in the Visitor's password (unless you are a Building Manager
) and you will be redirected to the building main page. On the left of the screen you will find buttons to add features to the building: Plans
and Plansets
(a way to organize building plans), Elements
and Families
(a way to organize building elements) and finally Photo Stations
(a way to organize pictures). Under the map you will find four other panels, the first listing Plansets
, the second listing plans belonging to the active plan set, the third with a list of dates and the fourth with a list of journals (most should be empty by now). We will explore these panels further on. Try clicking on the StreetView
button: a marker will pinpoint user's location (depends on device capability).
Try adding a building Plan. A DXF file is requested but not mandatory. DXF is a very popular CAD exchange format, all lines and lwpolylines will be imported in the building Plan. Blocks will be transformed in Elements
. Rotation and origin of the entities depend on a block (static/buildings/dxf/simple_geodata.dxf
) that carries geographical data (use this procedure for buildings, not for vast areas). To import geometries, the Refresh geometry
checkbox must be active. Elevation
sets the altitude of the Plan, higher Plans will hide lower ones. Color of plan geometries will be imported from CAD, along with layer names.
Let's assume that you have saved a building Plan and you have staff permissions, head on to yoursite.com/admin/buildings/dxfimport/
and edit the newly created geometries. You will see that all geometries are editable, you can change their colors and the popup message that appears when the geometry is selected on the frontend maps (by default it's the original CAD layer name). WARNING! You will be able to edit only the 2D projection of an object with 3D features (in example a lwpoly rotated in space): 3D data is stored in a JSON field, and it will not be updated if you change the 2D projection.
If you must import DXF that represent vast areas, just pass through ESRI shape files (in example using QGIS). Shape files are in geographical coordinates, and they will be stored in the same DXFImport
model as DXF files, but with no 3D data. All ancillary files are required.
Go back to your building main page: you will see that the newly created Plan does not show up, this is because it must be associated to at least one Planset. When you add a building, a base Planset is created alongside, scroll down to the Planset
panel and click on the Modify Planset
button.
As you can see you can associate multiple Plans to the Planset. Save and go back to building main page, finally the Plan shows up, either in the map and in the second panel below the map. In this second panel you can also switch the Plan visibility on and off, but this operation requires a callup to the database. For client setting of plan visibility use the button on the top right corner of the map.
New Plansets will be nested inside the base Planset. Planset hierarchy may be useful to make order when you have multiple Plans, in example you can nest all structral or MEP plans along with the corresponding architectural plan. Child Planset inherits all Plans associated to it's parents and ancestors, but Plan visibility is recorded for each single Planset. WARNING! Planset directory may be changed only having staff permission. Careful not to associate a Planset to a different building, this may lead to malfunctions.
A Family is a hyerarchical folder where you can collect building Elements (see below). In example you can create a "Lamps" Family nesting a "Security Lamps" subfamily. Each Family comes with a data sheet composed of key-value pairs, and inherits those of it's ancestors. Parent Families will have data sheets holding informations common to all it's subfamilies, in our example it could be AC=220V, while subfamilies could have different Lumen values. If a key exists in both parent and child, child's value will override parent's. When you add a building, a base Family is created, all other Families belonging to this building will be children of the base Family. As in Plansets, Family directory may be changed only having staff permission. Careful not to associate a Family to a different building, this may lead to malfunctions.
Elements are localized features of a building (in example a security lamp) and must be associated to a Family. When importing a DXF to a Plan, CAD blocks will be transformed into Elements, losing all geometries. Block insertion point will become Element location, block name will become Element's Family (creating it if it doesn't exist), block attributes will be transformed into Element's data sheet. Go back to building main page and try to create an Element. As you will see it is required to assign a Family to the Element, and eventually a Plan the Element belongs to. You can edit the default data sheet and add new key-value pairs. Save the Element, make sure it's Plan is visible, click on the Element marker and on the title of the popup. You will be redirected to the Element Review/Modify page. As you can see all the key-value pairs of the data sheet are reported, along with those of Element's Family and eventual ancestors. In the building main page you can sort all Elements by Family and eventually download all Elements' data sheets in CSV format.
A Photo Station is a location where you can collect pictures. This can be useful when you have pictures taken in the same location but in different moments. Try adding a Photo Station, click on the map for location and eventually assign it to a building Plan. Once created, you will be able to add pictures to it. Landscape pictures are required, and don't forget to add a date of when the picture was taken (default is now). When you have more than one picture in a Photo Station a sliding carousel is activated. It is possible to toggle the sequence from backwards in time to forwards in time. Image caption acts as a link to image updating and to pictures by date view. In pictures by day you will have a slideshow of all pictures taken that day no matter the Photo Station. You can access pictures by day also from the building main page, scrolling down to the last panel.
When accessing a Photo Station, Virtual Reality may be activated (look for the StreetView
button). When in VR, you will be carried in the exact location of the Photo Station. All DXF entities with 3D data will be visible (excluding those imported via Shape files). It is possible to look around and use the keypad to jump and move. Lwpoly rotated in space and lines with endpoints at different levels will actually show up in 3D. Closed lwpoly with thickness will be treated as extruded solids. Surface colors, as always, are imported from original CAD color (TO DO: add materials).
Journals are daily reports. They can be useful in example to show progress of a construction site. All images with same date will be associated to the Journal. A PDF friendly
version of the Journal is available. At this moment you need staff permission to write Journals.