parent
7acd11096b
commit
a8ffcf856d
@ -132,9 +132,9 @@ class Geometry(BaseResource):
|
|||||||
lock_id = f"parcel_calc-lock-{flr_id}"
|
lock_id = f"parcel_calc-lock-{flr_id}"
|
||||||
with cache_lock(lock_id) as acquired:
|
with cache_lock(lock_id) as acquired:
|
||||||
while not acquired:
|
while not acquired:
|
||||||
print(f"Am locked. Need to rest. Calculating: {parcel_properties}")
|
|
||||||
sleep(0.5)
|
sleep(0.5)
|
||||||
acquired = cache_lock(lock_id)
|
acquired = cache_lock(lock_id)
|
||||||
|
|
||||||
district = District.objects.get_or_create(
|
district = District.objects.get_or_create(
|
||||||
key=parcel_properties["kreisschl"],
|
key=parcel_properties["kreisschl"],
|
||||||
name=parcel_properties["kreis"],
|
name=parcel_properties["kreis"],
|
||||||
|
@ -86,13 +86,14 @@ class ParcelWFSFetcher(AbstractWFSFetcher):
|
|||||||
from konova.models import Geometry
|
from konova.models import Geometry
|
||||||
if filter_srid is None:
|
if filter_srid is None:
|
||||||
filter_srid = DEFAULT_SRID_RLP
|
filter_srid = DEFAULT_SRID_RLP
|
||||||
geom_gml = Geometry.objects.filter(
|
geom = Geometry.objects.filter(
|
||||||
id=self.geometry_id
|
id=self.geometry_id
|
||||||
).annotate(
|
).annotate(
|
||||||
transformed=Transform(srid=filter_srid, expression="geom")
|
transformed=Transform(srid=filter_srid, expression="geom")
|
||||||
).annotate(
|
).annotate(
|
||||||
gml=AsGML(MakeValid('transformed'))
|
gml=AsGML(MakeValid('transformed'))
|
||||||
).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
|
||||||
|
|
||||||
@ -163,7 +164,28 @@ class ParcelWFSFetcher(AbstractWFSFetcher):
|
|||||||
if rerun_on_exception:
|
if rerun_on_exception:
|
||||||
# Wait a second before another try
|
# Wait a second before another try
|
||||||
sleep(1)
|
sleep(1)
|
||||||
self.get_features(
|
return self.get_features(
|
||||||
|
typenames,
|
||||||
|
spatial_operator,
|
||||||
|
filter_srid,
|
||||||
|
start_index,
|
||||||
|
rerun_on_exception=False
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
e.msg += content
|
||||||
|
raise e
|
||||||
|
|
||||||
|
try:
|
||||||
|
fetched_features = content.get(
|
||||||
|
"features",
|
||||||
|
{},
|
||||||
|
)
|
||||||
|
except AttributeError as e:
|
||||||
|
# Might occur if returned content is no json but something different (maybe an error message)
|
||||||
|
if rerun_on_exception:
|
||||||
|
# Wait a second before another try
|
||||||
|
sleep(1)
|
||||||
|
return self.get_features(
|
||||||
typenames,
|
typenames,
|
||||||
spatial_operator,
|
spatial_operator,
|
||||||
filter_srid,
|
filter_srid,
|
||||||
@ -173,10 +195,6 @@ class ParcelWFSFetcher(AbstractWFSFetcher):
|
|||||||
else:
|
else:
|
||||||
e.msg += content
|
e.msg += content
|
||||||
raise e
|
raise e
|
||||||
fetched_features = content.get(
|
|
||||||
"features",
|
|
||||||
{},
|
|
||||||
)
|
|
||||||
|
|
||||||
found_features += fetched_features
|
found_features += fetched_features
|
||||||
|
|
||||||
@ -187,4 +205,7 @@ class ParcelWFSFetcher(AbstractWFSFetcher):
|
|||||||
# If a 'full' response returned, there might be more to fetch. Increase the start_index!
|
# If a 'full' response returned, there might be more to fetch. Increase the start_index!
|
||||||
start_index += self.count
|
start_index += self.count
|
||||||
|
|
||||||
|
if not found_features:
|
||||||
|
print(f"No features found. Fetched content: {content}\nUsed POST body: {post_body}")
|
||||||
|
|
||||||
return found_features
|
return found_features
|
||||||
|
Loading…
Reference in New Issue
Block a user