Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Django 5.0 & Python 3.12 #130

Merged
merged 21 commits into from
Jan 12, 2024
Merged
12 changes: 8 additions & 4 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,17 @@ jobs:
build:
runs-on: ubuntu-20.04
#TODO: Fix when github action do not show failed for the workflow with continue-on-error
#continue-on-error: ${{ matrix.experimental }}
continue-on-error: true
submarcos marked this conversation as resolved.
Show resolved Hide resolved
needs: [lint]
strategy:
matrix:
python-version: ['3.8', '3.10']
django-version: ['3.2.*', '4.2.*']
python-version: ['3.8', '3.10', '3.12']
django-version: ['3.2.*', '4.2.*', '5.0.*']
postgis-image: ['postgis/postgis:12-2.5']
exclude:
- python-version: '3.8'
django-version: '5.0.*'

services:
postgres:
image: ${{ matrix.postgis-image }}
Expand All @@ -59,7 +63,7 @@ jobs:

- name: Install dependencies
run: |
sudo apt update && sudo apt-get -yq install libproj-dev binutils gdal-bin libgdal-dev
sudo apt-get -q update && sudo apt-get -yqq install libproj-dev binutils gdal-bin libgdal-dev
python -m pip install --upgrade pip setuptools wheel
pip install .[dev] -U
if [[ ${{ matrix.django-version }} == dev ]]; then
Expand Down
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ CHANGELOG
---------------------------

* Works with fiona >= 1.9
* Add support for django 5.0
* Add support for python 3.12


0.7.3 (2023-04-17)
Expand Down
28 changes: 12 additions & 16 deletions geostore/__init__.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
from enum import IntEnum
from django.db.models import IntegerChoices

default_app_config = 'geostore.apps.GeostoreConfig'


class GeometryTypes(IntEnum):
Point = 0
LineString = 1
class GeometryTypes(IntegerChoices):
Point = 0, 'Point'
LineString = 1, 'LineString'
# LinearRing 2
Polygon = 3
MultiPoint = 4
MultiLineString = 5
MultiPolygon = 6
GeometryCollection = 7

@classmethod
def choices(cls):
return [(geom_type.value, str(geom_type).split('.')[-1]) for geom_type in cls]
Polygon = 3, 'Polygon'
MultiPoint = 4, 'MultiPoint'
MultiLineString = 5, 'MultiLineString'
MultiPolygon = 6, 'MultiPolygon'
GeometryCollection = 7, 'GeometryCollection'

@classmethod
def shape_allowed_types(cls):
"""
Types allowed in shapefile export
"""
excluded = [GeometryTypes.GeometryCollection]
return [geom_type for geom_type in cls if geom_type not in excluded]
return [cls.Point, cls.LineString, cls.Polygon, cls.MultiPoint,
cls.MultiLineString, cls.MultiPolygon]

@classmethod
def shape_allowed_type_names(cls):
"""
Name types allowed in shapefile export
"""
return [str(geom_type).split('.')[-1] for geom_type in cls.shape_allowed_types()]
return [geom_type.label for geom_type in cls.shape_allowed_types()]
2 changes: 1 addition & 1 deletion geostore/db/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class LayerBasedModelMixin(BaseUpdatableModel):
}
}
settings = JSONField(default=dict, blank=True)
geom_type = models.IntegerField(choices=GeometryTypes.choices(), null=True)
geom_type = models.IntegerField(choices=GeometryTypes.choices, null=True)

@property
def is_point(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Generated by Django 5.0.1 on 2024-01-12 11:26

import django.contrib.postgres.indexes
from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('geostore', '0047_alter_feature_properties'),
]

operations = [
migrations.RemoveIndex(
model_name='feature',
name='geostore_fe_layer_i_c3168f_gist',
),
migrations.RemoveIndex(
model_name='featureextrageom',
name='feg_geom_gist_index',
),
migrations.AddIndex(
model_name='feature',
index=django.contrib.postgres.indexes.GistIndex(fields=['geom'], name='geostore_fe_geom_cff9a1_gist'),
),
migrations.AddIndex(
model_name='featureextrageom',
index=django.contrib.postgres.indexes.GistIndex(fields=['geom'], name='feg_geom_gist_index'),
),
]
Loading