diff options
Diffstat (limited to 'ishtar_common/utils.py')
| -rw-r--r-- | ishtar_common/utils.py | 23 | 
1 files changed, 21 insertions, 2 deletions
| diff --git a/ishtar_common/utils.py b/ishtar_common/utils.py index 6ffda0eb6..1d3c4d143 100644 --- a/ishtar_common/utils.py +++ b/ishtar_common/utils.py @@ -2141,8 +2141,27 @@ def create_osm_town(rel_id, name, numero_insee=None):      geom = GEOSGeometry(str(geojson))      if geom.geom_type == "GeometryCollection":          geom = geom[0] -    town.limit = geom -    town.center = town.limit.centroid + +    GeoVectorData = apps.get_model("ishtar_common", "GeoVectorData") +    GeoDataType = apps.get_model("ishtar_common", "GeoDataType") +    GeoProviderType = apps.get_model("ishtar_common", "GeoProviderType") +    town_content_type = ContentType.objects.get(app_label="ishtar_common", model="town") +    data_type, __ = GeoDataType.objects.get_or_create( +        txt_idx="town-limit", defaults={"label": "Limites commune"} +    ) +    provider, __ = GeoProviderType.objects.get_or_create( +        txt_idx="openstreetmap", defaults={"label": "OpenStreetMap"} +    ) +    data = GeoVectorData.objects.create( +        name="Limite de " + town.name, +        source_content_type=town_content_type, +        multi_polygon=geom, +        source_id=town.pk, +        data_type=data_type, +        provider=provider +    ) +    town.main_geodata = data +    town._post_save_geo_ok = False      town.save()      return town | 
