Coverage for gws-app/gws/plugin/gekos/action.py: 0%
38 statements
« prev ^ index » next coverage.py v7.17.0, created at 2026-10-23 20:06 +0200
« prev ^ index » next coverage.py v7.17.0, created at 2026-10-23 20:06 +0200
1"""The ``gekos`` action."""
3from typing import Optional, cast
5import gws
6import gws.lib.crs
7import gws.base.feature
8import gws.lib.shape
9import gws.base.action
10import gws.base.database
12import gws.plugin.alkis.action as alkis_action
14from . import core, index
17class GetXyRequest(gws.Request):
18 """Request for the coordinates of a parcel or an address."""
20 fs: Optional[str]
21 """Combined parcel (Flurstueck) code."""
22 ad: Optional[str]
23 """Combined address code."""
26@gws.ext.config.action('gekos')
27class Config(gws.base.action.Config):
28 """Integration with the GekoS-Bau software."""
30 index: Optional[core.IndexConfig]
31 """Index of GekoS records loaded from gek-online."""
34@gws.ext.object.action('gekos')
35class Object(gws.base.action.Object):
36 """GekoS action."""
38 idx: index.Object
39 """The GekoS index, or ``None`` if not configured."""
41 def configure(self):
42 self.idx = self.create_child_if_configured(index.Object, self.cfg('index'))
44 @gws.ext.command.get('gekosGetXY')
45 def get_xy(self, req: gws.WebRequester, p: GetXyRequest) -> gws.ContentResponse:
46 """Return the coordinates of a parcel or an address."""
47 project = None
48 if p.projectUid:
49 project = req.user.require_project(p.projectUid)
51 alkis = cast(alkis_action.Object, self.root.app.actionMgr.find_action(project, 'alkis', req.user))
52 if not alkis:
53 gws.log.error(f'gekos: alkis action not found, {p.projectUid=}')
54 return gws.ContentResponse(mimeType='text/plain', content='error:')
56 lst = None
57 if p.fs:
58 lst, _ = alkis.find_flurstueck_objects(req, alkis_action.FindFlurstueckRequest(combinedFlurstueckCode=p.fs))
59 elif p.ad:
60 lst, _ = alkis.find_adresse_objects(req, alkis_action.FindAdresseRequest(combinedAdresseCode=p.ad))
62 if not lst:
63 gws.log.error(f'gekos: not found, {p.fs=} {p.ad=}')
64 return gws.ContentResponse(mimeType='text/plain', content='error:')
66 return gws.ContentResponse(mimeType='text/plain', content='{:.3f};{:.3f}'.format(lst[0].x, lst[0].y))