{"id":34063754,"url":"https://github.com/andywar65/django-geocad","last_synced_at":"2026-04-07T06:32:08.363Z","repository":{"id":257460140,"uuid":"858334973","full_name":"andywar65/django-geocad","owner":"andywar65","description":"Django app that imports CAD drawings in Leaflet.js maps","archived":false,"fork":false,"pushed_at":"2026-03-10T12:21:00.000Z","size":307,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2026-03-10T19:13:24.627Z","etag":null,"topics":["django","ezdxf","leafletjs"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andywar65.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-09-16T18:05:05.000Z","updated_at":"2026-03-10T12:21:01.000Z","dependencies_parsed_at":"2025-08-12T11:46:49.277Z","dependency_job_id":null,"html_url":"https://github.com/andywar65/django-geocad","commit_stats":null,"previous_names":["andywar65/django-geocad"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/andywar65/django-geocad","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andywar65%2Fdjango-geocad","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andywar65%2Fdjango-geocad/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andywar65%2Fdjango-geocad/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andywar65%2Fdjango-geocad/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andywar65","download_url":"https://codeload.github.com/andywar65/django-geocad/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andywar65%2Fdjango-geocad/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31503382,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-07T03:10:19.677Z","status":"ssl_error","status_checked_at":"2026-04-07T03:10:13.982Z","response_time":105,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["django","ezdxf","leafletjs"],"created_at":"2025-12-14T05:43:57.575Z","updated_at":"2026-04-07T06:32:08.357Z","avatar_url":"https://github.com/andywar65.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# django-geocad\nDjango app that imports CAD drawings in Leaflet maps\n## Overview\nShow CAD drawings in interactive web maps, download previously uploaded files with geo location, download CSV files with extracted data.\n## Requirements\nThis app is tested on Django (4.2 to 6.0) and Python (3.10 to 3.14). It heavily relies on outstanding [ezdxf](https://ezdxf.mozman.at/) for handling DXF files, [pyproj](https://pyproj4.github.io/pyproj/stable/) for geographic projections, [shapely](https://shapely.readthedocs.io/en/stable/manual.html) for polygon verification, [django-leaflet](https://django-leaflet.readthedocs.io/en/latest/) for handling maps, [django-geojson](https://django-geojson.readthedocs.io/en/latest/) for storing geodata, [django-colorfield](https://github.com/fabiocaccamo/django-colorfield) for admin color fields. The library relies on [GDAL](https://gdal.org), which is system specific.\n## Installation from PyPI\nActivate your virtual environment and install with:\n```\npython -m pip install django-geocad\n```\nIn your Django project add:\n```python\nINSTALLED_APPS = [\n    # ...\n    \"easy_thumbnails\",\n    \"leaflet\",\n    \"djgeojson\",\n    \"colorfield\",\n    \"django_geocad\",\n]\n```\n```python\n# my_project/urls.py\nurlpatterns = [\n    # ...\n    path('geocad/', include('django_geocad.urls', namespace = 'django_geocad')),\n]\n```\nYou also need to add initial map defaults to `settings.py` (these are the settings for Rome, change them to your location of choice):\n```python\nLEAFLET_CONFIG = {\n    \"DEFAULT_CENTER\": (41.8988, 12.5451),\n    \"DEFAULT_ZOOM\": 10,\n    \"RESET_VIEW\": False\n}\n```\nAdd two lists to `my_project/settings.py` where you can store names of layers and blocks you don't want to be processed:\n```python\nCAD_LAYER_BLACKLIST = [\"name_of_unprocessed_layer\", ]\nCAD_BLOCK_BLACKLIST = [\"name_of_unprocessed_block\", ]\n```\nFinally run the following management commands:\n```\npython manage.py migrate\npython manage.py collectstatic\n```\n### Templates\nYou also need a `base.html` template with following template blocks (a sample `base.html` is provided among package templates).\n```\n{% block extra-head %}\n{% end block extra-head %}\n...\n{% block content %}\n{% endblock content %}\n```\nPackage comes with several templates in the `django_geocad/templates/` directory. All templates have no styles. If you want to add your own styles, copy the templates in a `my_project/templates/django_geocad/` directory and override them. You will have to set:\n```python\nTEMPLATES = [\n    {\n        \"BACKEND\": \"django.template.backends.django.DjangoTemplates\",\n        \"DIRS\": [BASE_DIR / \"my_project/templates\"],\n        # ...\n    },\n]\n```\n### Upgrading to version 0.7.0\nWARNING, breaking changes (app name change). Before upgrading download your models as fixtures: `python manage.py dumpdata djeocad -o somefile.json`, open the file and change all occourences of `djeocad.` into `django_geocad.`. Finally upgrade the package and reload the fixtures: `python manage.py loaddata somefile.json`\n### Moving from version 0.4.0 to 0.5.0 (or later)\nVersion `0.5.0` has some breaking changes. Once you upgrade run the following management commands:\n```\npython manage.py migrate\npython manage.py collectstatic\npython manage.py populate_block_field\n```\n## View drawings\nLocally browse to `127.1.1.0:8000/geocad/`to see a `List of all drawings`, where drawings are just markers on the map. Click on a marker and follow the link in the popup: you will land on the `Drawing Detail` page, with layers displayed on the map. Layers may be switched on and off.\n## Create drawings\nTo create a `Drawing` you must be able to access the `admin` with `GeoCAD Manager` permissions. You will also need a `DXF file` in ASCII format. `DXF` is a drawing exchange format widely used in `CAD` applications. Try uploading files with few entities at the building scale, as the conversion may be inaccurate for small items (units must be in meters).\n### Geodata \u0026 Reference Point\nIf `geodata` is embedded in the file, the drawing will be imported in the exact geographical location. If `geodata` is unavailable, you will have to insert it manually: to geolocate the drawing you need to define a Reference point on the drawing of known Latitude / Longitude.\n### Design Point\nMark the point on the map and eventually insert it's coordinates with respect to the DXF `World Coordinate System origin (0,0,0)`. A good position for the `Reference / Design point` could be the cornerstone of a building, or another geographic landmark.\n### Rotation\nCheck also the rotation of the drawing with respect to the `True North`: it is typical to orient the drawings most conveniently for drafting purposes, unrespectful of True North. Please note that in CAD counterclockwise rotations are positive, so if you have to rotate the drawing clockwise to orient it correctly, you will have to enter a negative angle.\n### Geodata from Parent\nAlternatively, you can select a `Parent` drawing, that will lend geolocation to uploaded file. This can be useful when you want to upload different floors of a single building.\n### Extraction\nPress the `Save` button. If all goes well the `DXF file` will be extracted and a list of `Layers` will be attached to your drawing. Each layer inherits the `Name` and color originally assigned in CAD. `POINT`, `ARC`, `CIRCLE`, `ELLIPSE`, `SPLINE`, `3DFACE`, `HATCH`, `LINE` and `LWPOLYLINE` entities are visible on the map panel, where they inherit layer color. If unnested `BLOCKS` are present in the drawing, they will be extracted and inserted on respective layer.\n## Downloading\nIn `Drawing Detail` view it is possible to download back the `DXF file`. `GeoData` will be associated to the `DXF`, so if you work on the file and upload it again, it will be automatically located on the map.\n### CSV\nYou can also download a `CSV` file that contains basic informations of some entities, notably `Polylines` and `Blocks`. Layer, surface (only if closed), perimeter, width and thickness are associated to `Polylines`, while block name, insertion point, scale, rotation and attribute key/values are associated to `Blocks`. If a `TEXT/MTEXT` is contained in a `Polyline` of the same layer, also the text content will be associated to the entity. This can be helpful if you want to label rooms.\n## Adding block instances\nIn `Drawing Detail` view it is possible to add `block instances` to the drawing (this works if blocks are actually present in the drawing). Click on the `Add insertions` link, you will be presented with a form and a map of the drawing. Choose the `Block` you want to instantiate and the `Layer` you want to place it on. Choose the `insertion point` by clicking on the map. Submit and you will be redirected to another page where you can modify the insertion or add `Attributes` to the block (Key/Value pairs attached to the block insertion). Submit and you will be redirected to the `Drawing Detail` view.\n## Modify drawings\nNot all changes in the `Drawing` will be mirrored into the `DXF`. Changes to and deletions of `Layers` will not be recorded. New `Layers` and new `Block` instances will pass into the downloaded `DXF`. Download it and use your favourite CAD application for further modifications, then upload it back again (it will be already geolocated!).\n## About Geodata\nGeodata can be stored in DXF, but `ezdxf` library can't deal with all kind of Coordinate Reference Systems (CRS). If Geodata is not found in the file (or if the CRS is not compatible) `django-geocad` asks for user input: the location of a point both on the map and on the drawing coordinates system, and the rotation with respect to True North. The `pyproj` library hands over the best Universal Transverse Mercator CRS for the location (UTM is compatible with `ezdxf`). Thanks to UTM, Reference / Design Point and rotation input, Geodata can be built from scratch and incorporated into the file.\n## Tests\nTests with unittest, 96% coverage, missing some special conditions in DXF extraction. Tested for Django 4.2 and 5.1 and Python 3.9, 3.10, 3.11, 3.12 versions. Tested for Django 5.2 on Python 3.13.1 and Django 6.0 on Python 3.14.2\n## Changelog\n- 0.9.0: Support for Django 6.0 and Python 3.14\n- 0.8.0: Download CSV directly from file, not from DB (experimental). Support for Django 5.2\n- 0.7.0: BREAKING CHANGES, new app name, see installation\n- 0.6.1: Changed a JSONField lookup that was treated differently by SQLite and Postgres\n- 0.6.0: Cannot have two `Layers` with the same name in the same `Drawing` (this is consistent with CAD programs). Newly created `Layers` and new `Block` insertions will be recorded into the downloaded `DXF`.\n- 0.5.0: Breaking changes, see installation instructions. Added a `Block` FK field to `Entity` model (previously this information was stored in the `data` JSONField). Added `EntityData` model to replace information previously stored in the `data` JSONField.\n- 0.4.0: First working version\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandywar65%2Fdjango-geocad","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandywar65%2Fdjango-geocad","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandywar65%2Fdjango-geocad/lists"}