Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving GetEGRID performance #1680

Merged
merged 1 commit into from
Jan 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 14 additions & 12 deletions pyramid_oereb/core/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def process(self, real_estate, params, sld_url):
return extract


def create_processor():
def create_processor(real_estate_only=False):
"""
Creates and returns a processor based on the application configuration.
You should use one (and only one) processor per request. Otherwise some results can be mixed or
Expand All @@ -311,23 +311,25 @@ def create_processor():
"""

real_estate_config = Config.get_real_estate_config()

plr_cadastre_authority = Config.get_plr_cadastre_authority()

real_estate_reader = RealEstateReader(
real_estate_config.get('source').get('class'),
**real_estate_config.get('source').get('params')
)

plr_sources = []
for plr in Config.get('plrs'):
plr_source_class = DottedNameResolver().maybe_resolve(plr.get('source').get('class'))
plr_sources.append(plr_source_class(**plr))
plr_sources = None
extract_reader = None

extract_reader = ExtractReader(
plr_sources,
plr_cadastre_authority
)
if not real_estate_only:
plr_cadastre_authority = Config.get_plr_cadastre_authority()
plr_sources = []
for plr in Config.get('plrs'):
plr_source_class = DottedNameResolver().maybe_resolve(plr.get('source').get('class'))
plr_sources.append(plr_source_class(**plr))

extract_reader = ExtractReader(
plr_sources,
plr_cadastre_authority
)

return Processor(
real_estate_reader=real_estate_reader,
Expand Down
6 changes: 3 additions & 3 deletions pyramid_oereb/core/views/webservice.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def _get_egrid_coord(self, params):
Config.get('srid'),
self.__parse_gnss__(gnss).wkt
)
processor = create_processor()
processor = create_processor(real_estate_only=True)
return processor.real_estate_reader.read(params, **{'geometry': geom_wkt})
else:
raise HTTPBadRequest('EN or GNSS must be defined.')
Expand All @@ -214,7 +214,7 @@ def _get_egrid_ident(self, params):
identdn = self._params.get('IDENTDN')
number = self._params.get('NUMBER')
if identdn and number:
processor = create_processor()
processor = create_processor(real_estate_only=True)
return processor.real_estate_reader.read(
params,
**{
Expand Down Expand Up @@ -251,7 +251,7 @@ def _get_egrid_address(self, params):
srid=Config.get('srid'),
wkt=addresses[0].geom.wkt
)
processor = create_processor()
processor = create_processor(real_estate_only=True)
return processor.real_estate_reader.read(params, **{'geometry': geometry})
else:
raise HTTPBadRequest('POSTALCODE, LOCALISATION and NUMBER must be defined.')
Expand Down