Bugfix Parcel calculation #206
@ -11,10 +11,11 @@ from json import JSONDecodeError
|
|||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
import requests
|
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 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:
|
class AbstractWFSFetcher:
|
||||||
@ -72,33 +73,34 @@ class ParcelWFSFetcher(AbstractWFSFetcher):
|
|||||||
self.geometry_property_name = geometry_property_name
|
self.geometry_property_name = geometry_property_name
|
||||||
|
|
||||||
def _create_spatial_filter(self,
|
def _create_spatial_filter(self,
|
||||||
geometry_operation: str,
|
geometry_operation: str):
|
||||||
filter_srid: str = None):
|
|
||||||
""" Creates a xml spatial filter according to the WFS filter specification
|
""" 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:
|
Args:
|
||||||
geometry_operation (str): One of the WFS supported spatial filter operations (according to capabilities)
|
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:
|
Returns:
|
||||||
spatial_filter (str): The spatial filter element
|
spatial_filter (str): The spatial filter element
|
||||||
"""
|
"""
|
||||||
from konova.models import Geometry
|
from konova.models import Geometry
|
||||||
if filter_srid is None:
|
|
||||||
filter_srid = DEFAULT_SRID_RLP
|
geom = Geometry.objects.filter(
|
||||||
geom_gml = Geometry.objects.filter(
|
|
||||||
id=self.geometry_id
|
id=self.geometry_id
|
||||||
).annotate(
|
).annotate(
|
||||||
transformed=Transform(srid=filter_srid, expression="geom")
|
smaller=Func(F('geom'), -0.001, function="ST_Buffer")
|
||||||
).annotate(
|
).annotate(
|
||||||
gml=AsGML(MakeValid('transformed'))
|
gml=AsGML(MakeValid('smaller'))
|
||||||
).first().gml
|
).first()
|
||||||
|
geom_gml = geom.gml
|
||||||
spatial_filter = f"<Filter><{geometry_operation}><PropertyName>{self.geometry_property_name}</PropertyName>{geom_gml}</{geometry_operation}></Filter>"
|
spatial_filter = f"<Filter><{geometry_operation}><PropertyName>{self.geometry_property_name}</PropertyName>{geom_gml}</{geometry_operation}></Filter>"
|
||||||
return spatial_filter
|
return spatial_filter
|
||||||
|
|
||||||
def _create_post_data(self,
|
def _create_post_data(self,
|
||||||
geometry_operation: str,
|
geometry_operation: str,
|
||||||
filter_srid: str = None,
|
|
||||||
typenames: str = None,
|
typenames: str = None,
|
||||||
start_index: int = 0,
|
start_index: int = 0,
|
||||||
):
|
):
|
||||||
@ -106,15 +108,13 @@ class ParcelWFSFetcher(AbstractWFSFetcher):
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
geometry_operation (str): One of the WFS supported spatial filter operations (according to capabilities)
|
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:
|
Returns:
|
||||||
_filter (str): A proper xml WFS filter
|
_filter (str): A proper xml WFS filter
|
||||||
"""
|
"""
|
||||||
start_index = str(start_index)
|
start_index = str(start_index)
|
||||||
spatial_filter = self._create_spatial_filter(
|
spatial_filter = self._create_spatial_filter(
|
||||||
geometry_operation,
|
geometry_operation
|
||||||
filter_srid
|
|
||||||
)
|
)
|
||||||
_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>'
|
_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
|
return _filter
|
||||||
@ -144,7 +144,6 @@ class ParcelWFSFetcher(AbstractWFSFetcher):
|
|||||||
while start_index is not None:
|
while start_index is not None:
|
||||||
post_body = self._create_post_data(
|
post_body = self._create_post_data(
|
||||||
spatial_operator,
|
spatial_operator,
|
||||||
filter_srid,
|
|
||||||
typenames,
|
typenames,
|
||||||
start_index
|
start_index
|
||||||
)
|
)
|
||||||
|
@ -396,7 +396,7 @@ netgis.MapOpenLayers.prototype.clearAll = function()
|
|||||||
{
|
{
|
||||||
if(this.layers[i] === this.editLayer){
|
if(this.layers[i] === this.editLayer){
|
||||||
continue;
|
continue;
|
||||||
};
|
}
|
||||||
this.map.removeLayer( this.layers[ i ] );
|
this.map.removeLayer( this.layers[ i ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user