-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This creates a table containing the same areas as the Geometry table, but split using ST_Subdivide. This is updated on save, and is used for postcode/point lookups, as well as geometry intersection.
- Loading branch information
Showing
4 changed files
with
89 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Generated by Django 3.2.18 on 2023-05-23 09:21 | ||
|
||
import django.contrib.gis.db.models.fields | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
from django.conf import settings | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('mapit', '0004_add_country_m2m'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='GeometrySubdivided', | ||
fields=[ | ||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), | ||
('division', django.contrib.gis.db.models.fields.PolygonField(srid=settings.MAPIT_AREA_SRID)), | ||
('geometry', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='subdivided', to='mapit.geometry')), | ||
], | ||
options={ | ||
'verbose_name_plural': 'subdivided geometries', | ||
}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Generated by Django 3.2.18 on 2023-05-23 09:40 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('mapit', '0005_geometrysubdivided'), | ||
] | ||
|
||
operations = [ | ||
migrations.RunSQL( | ||
sql="""INSERT INTO mapit_geometrysubdivided (geometry_id, division) | ||
SELECT id,ST_Subdivide(polygon) FROM mapit_geometry""", | ||
reverse_sql="TRUNCATE mapit_geometrysubdivided RESTART IDENTITY" | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters