Bugfix Parcel calculation #206
@ -130,4 +130,4 @@ class SimpleGeomForm(BaseForm):
|
||||
)
|
||||
# Start the parcel update procedure in a background process
|
||||
celery_update_parcels.delay(geometry.id)
|
||||
return geometry
|
||||
return geometry
|
||||
|
@ -11,10 +11,11 @@ from json import JSONDecodeError
|
||||
from time import sleep
|
||||
|
||||
import requests
|
||||
from django.contrib.gis.db.models.functions import AsGML, Transform, MakeValid
|
||||
from django.contrib.gis.db.models.functions import AsGML, MakeValid
|
||||
from django.db.models import Func, F
|
||||
from requests.auth import HTTPDigestAuth
|
||||
|
||||
from konova.settings import DEFAULT_SRID_RLP, PARCEL_WFS_USER, PARCEL_WFS_PW, PROXIES
|
||||
from konova.settings import PARCEL_WFS_USER, PARCEL_WFS_PW, PROXIES
|
||||
|
||||
|
||||
class AbstractWFSFetcher:
|
||||
@ -72,33 +73,34 @@ class ParcelWFSFetcher(AbstractWFSFetcher):
|
||||
self.geometry_property_name = geometry_property_name
|
||||
|
||||
def _create_spatial_filter(self,
|
||||
geometry_operation: str,
|
||||
filter_srid: str = None):
|
||||
geometry_operation: str):
|
||||
""" Creates a xml spatial filter according to the WFS filter specification
|
||||
|
||||
The geometry needs to be shrinked by a very small factor (-0.01) before a GML can be created for intersection
|
||||
checking. Otherwise perfect parcel outline placement on top of a neighbouring parcel would result in an
|
||||
intersection hit, despite the fact they do not truly intersect just because their vertices match.
|
||||
|
||||
Args:
|
||||
geometry_operation (str): One of the WFS supported spatial filter operations (according to capabilities)
|
||||
filter_srid (str): Used to transform the geometry into the spatial reference system identified by this srid
|
||||
|
||||
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(
|
||||
|
||||
geom = Geometry.objects.filter(
|
||||
id=self.geometry_id
|
||||
).annotate(
|
||||
transformed=Transform(srid=filter_srid, expression="geom")
|
||||
smaller=Func(F('geom'), -0.001, function="ST_Buffer")
|
||||
).annotate(
|
||||
gml=AsGML(MakeValid('transformed'))
|
||||
).first().gml
|
||||
gml=AsGML(MakeValid('smaller'))
|
||||
).first()
|
||||
geom_gml = geom.gml
|
||||
spatial_filter = f"<Filter><{geometry_operation}><PropertyName>{self.geometry_property_name}</PropertyName>{geom_gml}</{geometry_operation}></Filter>"
|
||||
return spatial_filter
|
||||
|
||||
def _create_post_data(self,
|
||||
geometry_operation: str,
|
||||
filter_srid: str = None,
|
||||
typenames: str = None,
|
||||
start_index: int = 0,
|
||||
):
|
||||
@ -106,15 +108,13 @@ class ParcelWFSFetcher(AbstractWFSFetcher):
|
||||
|
||||
Args:
|
||||
geometry_operation (str): One of the WFS supported spatial filter operations (according to capabilities)
|
||||
filter_srid (str): Used to transform the geometry into the spatial reference system identified by this srid
|
||||
|
||||
Returns:
|
||||
_filter (str): A proper xml WFS filter
|
||||
"""
|
||||
start_index = str(start_index)
|
||||
spatial_filter = self._create_spatial_filter(
|
||||
geometry_operation,
|
||||
filter_srid
|
||||
geometry_operation
|
||||
)
|
||||
_filter = f'<wfs:GetFeature service="WFS" version="{self.version}" xmlns:wfs="http://www.opengis.net/wfs/2.0" xmlns:fes="http://www.opengis.net/fes/2.0" xmlns:myns="http://www.someserver.com/myns" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.opengis.net/wfs/2.0 http://schemas.opengis.net/wfs/2.0.0/wfs.xsd" count="{self.count}" startindex="{start_index}" outputFormat="application/json; subtype=geojson"><wfs:Query typeNames="{typenames}">{spatial_filter}</wfs:Query></wfs:GetFeature>'
|
||||
return _filter
|
||||
@ -144,7 +144,6 @@ class ParcelWFSFetcher(AbstractWFSFetcher):
|
||||
while start_index is not None:
|
||||
post_body = self._create_post_data(
|
||||
spatial_operator,
|
||||
filter_srid,
|
||||
typenames,
|
||||
start_index
|
||||
)
|
||||
|
@ -396,7 +396,7 @@ netgis.MapOpenLayers.prototype.clearAll = function()
|
||||
{
|
||||
if(this.layers[i] === this.editLayer){
|
||||
continue;
|
||||
};
|
||||
}
|
||||
this.map.removeLayer( this.layers[ i ] );
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user