#49 Parcels and Districts

* fixes bug in GeometryConflict conflict checking
* WIP: introduces new konova/utils/wfs/spatial holding SpatialWFSFetcher, which can be fed any geometry and it returns found features
* WIP: adds tests for wfs fetching
* updates requirements.txt
This commit is contained in:
2021-12-17 17:30:12 +01:00
parent 93d1cb9330
commit 46e237f0e2
5 changed files with 131 additions and 9 deletions

View File

@@ -9,7 +9,7 @@ from django.contrib.gis.db.models.functions import Translate
from konova.models import Geometry, GeometryConflict
from konova.tests.test_views import BaseTestCase
from user.models import UserActionLogEntry
from konova.utils.wfs.spatial import SpatialWFSFetcher
class GeometryTestCase(BaseTestCase):
@@ -17,14 +17,11 @@ class GeometryTestCase(BaseTestCase):
def setUpTestData(cls):
super().setUpTestData()
geom = cls.create_dummy_geometry()
action = UserActionLogEntry.get_created_action(cls.superuser)
cls.geom_1 = Geometry.objects.create(
geom=geom,
created=action,
)
cls.geom_2 = Geometry.objects.create(
geom=geom,
created=action,
)
def test_geometry_conflict(self):
@@ -34,8 +31,9 @@ class GeometryTestCase(BaseTestCase):
Returns:
"""
self.geom_1.check_for_conflicts()
conflict = GeometryConflict.objects.all().first()
conflict = GeometryConflict.objects.all()
self.assertEqual(1, conflict.count())
conflict = conflict.first()
self.assertEqual(conflict.conflicting_geometry, self.geom_2)
self.assertEqual(conflict.affected_geometry, self.geom_1)
@@ -47,3 +45,21 @@ class GeometryTestCase(BaseTestCase):
self.geom_1.check_for_conflicts()
num_conflict = GeometryConflict.objects.all().count()
self.assertEqual(0, num_conflict)
def test_wfs_fetch(self):
""" Tests the fetching functionality of SpatialWFSFetcher
+++ Test relies on the availability of the RLP Gemarkung WFS +++
Returns:
"""
fetcher = SpatialWFSFetcher(
base_url="http://geo5.service24.rlp.de/wfs/verwaltungsgrenzen_rp.fcgi",
version="1.1.0",
geometry=self.geom_1
)
features = fetcher.get_features(
"vermkv:fluren_rlp"
)
self.assertNotEqual(0, len(features), msg="Spatial wfs get feature did not work!")