#49 Calculation implementation
* implements update routine for Geometry model * reorganizes fields of Parcel and District * adds tests * simplifies usage of ParcelWFSFetcher
This commit is contained in:
@@ -10,11 +10,9 @@ from abc import abstractmethod
|
||||
import requests
|
||||
import xmltodict
|
||||
from django.contrib.gis.db.models.functions import AsGML, Transform
|
||||
from django.contrib.gis.geos import MultiPolygon
|
||||
from requests.auth import HTTPDigestAuth
|
||||
|
||||
from konova.models import Geometry
|
||||
from konova.settings import DEFAULT_SRID_RLP
|
||||
from konova.settings import DEFAULT_SRID_RLP, PARCEL_WFS_USER, PARCEL_WFS_PW
|
||||
|
||||
|
||||
class AbstractWFSFetcher:
|
||||
@@ -38,6 +36,9 @@ class AbstractWFSFetcher:
|
||||
self.auth_pw = auth_pw
|
||||
self.auth_user = auth_user
|
||||
|
||||
self._create_auth_obj()
|
||||
|
||||
def _create_auth_obj(self):
|
||||
if self.auth_pw is not None and self.auth_user is not None:
|
||||
self.auth_digest_obj = HTTPDigestAuth(
|
||||
self.auth_user,
|
||||
@@ -53,13 +54,20 @@ class ParcelWFSFetcher(AbstractWFSFetcher):
|
||||
""" Fetches features from a special parcel WFS
|
||||
|
||||
"""
|
||||
geometry = None
|
||||
geometry_id = None
|
||||
geometry_property_name = None
|
||||
count = 100
|
||||
|
||||
def __init__(self, geometry: MultiPolygon, geometry_property_name: str = "msGeometry", *args, **kwargs):
|
||||
super().__init__(*args, **kwargs)
|
||||
self.geometry = geometry
|
||||
def __init__(self, geometry_id: str, geometry_property_name: str = "msGeometry", *args, **kwargs):
|
||||
super().__init__(
|
||||
version="2.0.0",
|
||||
base_url="https://www.geoportal.rlp.de/registry/wfs/519",
|
||||
auth_user=PARCEL_WFS_USER,
|
||||
auth_pw=PARCEL_WFS_PW,
|
||||
*args,
|
||||
**kwargs
|
||||
)
|
||||
self.geometry_id = geometry_id
|
||||
self.geometry_property_name = geometry_property_name
|
||||
|
||||
def _create_spatial_filter(self,
|
||||
@@ -74,10 +82,11 @@ class ParcelWFSFetcher(AbstractWFSFetcher):
|
||||
Returns:
|
||||
spatial_filter (str): The spatial filter element
|
||||
"""
|
||||
from konova.models import Geometry
|
||||
if filter_srid is None:
|
||||
filter_srid = DEFAULT_SRID_RLP
|
||||
geom_gml = Geometry.objects.filter(
|
||||
id=self.geometry.id
|
||||
id=self.geometry_id
|
||||
).annotate(
|
||||
transformed=Transform(srid=filter_srid, expression="geom")
|
||||
).annotate(
|
||||
@@ -124,6 +133,7 @@ class ParcelWFSFetcher(AbstractWFSFetcher):
|
||||
typenames (str): References to parameter 'typenames' in a WFS GetFeature request
|
||||
spatial_operator (str): Defines the spatial operation for filtering
|
||||
filter_srid (str): Defines the spatial reference system, the geometry shall be transformed into for filtering
|
||||
start_index (str): References to parameter 'startindex' in a
|
||||
|
||||
Returns:
|
||||
features (list): A list of returned features
|
||||
|
||||
Reference in New Issue
Block a user