Skip to content

Commit

Permalink
Merge pull request #4285 from geoadmin/data-BGDIDIC-541-enable-time-s…
Browse files Browse the repository at this point in the history
…wisboundaries3d-gemeinden

BGDIDIC-541: enable time for swissbouncaries3d-gemeinden
  • Loading branch information
rebert authored Nov 23, 2023
2 parents e68ee2b + 2542178 commit 3b9d9c1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 11 deletions.
12 changes: 8 additions & 4 deletions chsdi/models/vector/stopo.py
Original file line number Diff line number Diff line change
Expand Up @@ -440,17 +440,21 @@ class SwissboundariesBezirk(Base, Vector):


class SwissboundariesGemeinde(Base, Vector):
__tablename__ = 'swissboundaries_gemeinden'
__tablename__ = 'swissboundaries_gemeinden_hist_chsdi'
__table_args__ = ({'schema': 'tlm', 'autoload': False})
__template__ = 'templates/htmlpopup/swissboundaries_gemeinde.mako'
__bodId__ = 'ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill'
__timeInstant__ = 'jahr'
__label__ = 'gemname'
id = Column('id', Integer, primary_key=True)
gemname = Column('gemname', Unicode)
gemflaeche = Column('gemflaeche', Float)
id = Column('object_id', Integer, primary_key=True)
gemname = Column('gde_name', Unicode)
jahr = Column('jahr', Integer)
gemflaeche = Column('flaeche_ha', Float)
perimeter = Column('perimeter', Float)
kanton = Column('kanton', Unicode)
objektart = Column('objektart', Integer)
is_current_jahr = Column('is_current_jahr', Boolean)
objektart_lookup = Column('objektart_lookup', Unicode)
the_geom = Column(Geometry2D)

register('ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill', SwissboundariesGemeinde)
Expand Down
13 changes: 7 additions & 6 deletions chsdi/templates/htmlpopup/swissboundaries_gemeinde.mako
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,18 @@
<%
linkeddatahost = request.registry.settings['linkeddatahost']
ldlink = linkeddatahost + '/boundaries/municipality/' + str(c['id'])
arr_obj_art = ['gemeindegebiet', 'kantonsgebiet', 'kommunanz']
obj_art = arr_obj_art[c['attributes']['objektart']]
%>
<% c['stable_id'] = True %>
<% c['stable_id'] = True %>
<tr>
<td class="cell-left">${_('ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill.id')}</td>
% if c['featureId']:
<td>${int(round(c['featureId']))}</td>
<td>${c['featureId']}</td>
% else:
<td>-</td>
% endif
</tr>
<tr><td class="cell-left">${_('ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill.gemname')}</td><td>${c['attributes']['gemname']}</td></tr>
<tr><td class="cell-left">${_('ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill.typ')}</td><td>${_('ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill.%s' % obj_art)}</td></tr>
<tr><td class="cell-left">${_('ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill.typ')}</td><td>${_('ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill.%s' % c['attributes']['objektart'])}</td></tr>
<tr>
<td class="cell-left">${_('flaeche_ha')}</td>
% if c['attributes']['gemflaeche']:
Expand All @@ -34,5 +32,8 @@ obj_art = arr_obj_art[c['attributes']['objektart']]
<td>-</td>
% endif
</tr>
<tr><td class="cell-left">${_('link')}</td><td><a href="${ldlink}" target="_blank">Linked Data URI</a></td></tr>
% if c['attributes']['is_current_jahr']:
<tr><td class="cell-left">${_('link')}</td><td><a href="${ldlink}" target="_blank">Linked Data URI</a></td></tr>
% endif
</%def>
21 changes: 20 additions & 1 deletion tests/integration/test_identify_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test_identify_trivial(self):
def test_trivial_from_doc(self):
params = {'lang': 'fr',
'sr': '2056',
'layers': 'all:ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill,ch.swisstopo-vd.ortschaftenverzeichnis_plz',
'layers': 'all:ch.swisstopo.swissboundaries3d-bezirk-flaeche.fill,ch.swisstopo-vd.ortschaftenverzeichnis_plz',
'imageDisplay': '0,0,0',
'mapExtent': '0,0,0,0',
'geometry': '2585438.308,1220677.966',
Expand Down Expand Up @@ -630,6 +630,25 @@ def test_identify_timeinstant_zeitreihen(self):

self.assertEqual(resp_1.json['results'][0]['id'], resp_2.json['results'][0]['id'])

def test_identify_timeinstant_swissboundaries3d_gemeinden(self):
# without timeInstant a lot of features should be returned
params = {'geometryFormat': 'geojson',
'geometryType': 'esriGeometryPoint',
'geometry': '614277,188148',
'imageDisplay': '1920,573,96',
'mapExtent': '570727,172398,666727,201048',
'tolerance': '10',
'returnGeometry': 'true',
'layers': 'all:ch.swisstopo.swissboundaries3d-gemeinde-flaeche.fill'}
resp_1 = self.testapp.get('/rest/services/all/MapServer/identify', params=params, headers=accept_headers, status=200)
self.assertEqual(resp_1.content_type, 'application/geo+json')
self.assertGreater(len(resp_1.json['results']), 1)

# with timeInstant one single feature should be returned
params['timeInstant'] = '1888'
resp_2 = self.testapp.get('/rest/services/ech/MapServer/identify', params=params, headers=accept_headers, status=200)
self.assertEqual(len(resp_2.json['results']), 1)

def test_identify_one_timeinstant_several_layers(self):
params = {'geometryType': 'esriGeometryPoint',
'geometry': '630853.8,170647.9',
Expand Down

0 comments on commit 3b9d9c1

Please sign in to comment.