Skip to content

Commit

Permalink
Merge pull request #4351 from geoadmin/develop-2024-03-13
Browse files Browse the repository at this point in the history
New Release 2024-03-13-rc1
  • Loading branch information
ltclm authored Mar 11, 2024
2 parents 17f1d75 + 0c9a16d commit 68242b7
Show file tree
Hide file tree
Showing 94 changed files with 585 additions and 185 deletions.
69 changes: 42 additions & 27 deletions chsdi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from distutils.util import strtobool
import datetime
from pyramid.config import Configurator
from pyramid.response import Response
from pyramid.renderers import JSONP
from pyramid.request import Request
from sqlalchemy.orm import scoped_session, sessionmaker
Expand Down Expand Up @@ -33,6 +34,16 @@ def __init__(self, environ, **kwargs):
super().__init__(environ, **kwargs)


# This is a wrapper function around all views. If OPTIONS is given, an empty string will be returned
# As HTTP OPTIONS is not cached, this wrapper will safe some power
def options_view(view, info):
def wrapper_view(context, request):
if request.method == 'OPTIONS':
return Response('')
return view(context, request)
return wrapper_view


def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
Expand All @@ -42,9 +53,13 @@ def main(global_config, **settings):

app_version = settings.get('app_version')
settings['app_version'] = app_version
# request_method is the type tuple: string->string without space->array->tuple
request_method = tuple(settings.get('request_method').replace(' ', '').split(','))
config = Configurator(settings=settings, request_factory=WsgiSchemeAdaptedRequest)
config.include('pyramid_mako')
config.include('akhet.static')
# wrapper around all views
config.add_view_deriver(options_view)

# configure 'locale' dir as the translation dir for chsdi app
config.add_translation_dirs('chsdi:locale/')
Expand All @@ -69,33 +84,33 @@ def datetime_adapter(obj, request):
initialize_sql(settings)

# route definitions
config.add_route('dev', '/dev')
config.add_route('ga_api', '/loader.js')
config.add_route('testi18n', '/testi18n')
config.add_route('topics', '/rest/services')
config.add_route('mapservice', '/rest/services/{map}/MapServer')
config.add_route('layersConfig', '/rest/services/{map}/MapServer/layersConfig')
config.add_route('catalog', '/rest/services/{map}/CatalogServer')
config.add_route('identify', '/rest/services/{map}/MapServer/identify')
config.add_route('find', '/rest/services/{map}/MapServer/find')
config.add_route('attribute_values', '/rest/services/{map}/MapServer/{layerId}/attributes/{attribute}')
config.add_route('legend', '/rest/services/{map}/MapServer/{layerId}/legend')
config.add_route('releases', '/rest/services/{map}/MapServer/{layerId}/releases')
config.add_route('cacheUpdate', '/rest/services/{map}/MapServer/{layerId}/cacheUpdate')
config.add_route('featureAttributes', '/rest/services/{map}/MapServer/{layerId}')
config.add_route('feature', '/rest/services/{map}/MapServer/{layerId}/{featureId}')
config.add_route('htmlPopup', '/rest/services/{map}/MapServer/{layerId}/{featureId}/htmlPopup')
config.add_route('iframeHtmlPopup', '/rest/services/{map}/MapServer/{layerId}/{featureId}/iframeHtmlPopup')
config.add_route('extendedHtmlPopup', '/rest/services/{map}/MapServer/{layerId}/{featureId}/extendedHtmlPopup')
config.add_route('luftbilder', '/luftbilder/viewer.html')
config.add_route('historicalmaps', '/historicalmaps/viewer.html')
config.add_route('checker', '/checker')
config.add_route('checker_dev', '/checker_dev')
config.add_route('translations', '/rest/services/translations')

config.add_route('stationboard', '/stationboard/stops/{id}')
config.add_route('faqlist', '/rest/services/{map}/faqlist')
config.add_route('color', '/color/{r},{g},{b}/{image}')
config.add_route('dev', '/dev', request_method=request_method)
config.add_route('ga_api', '/loader.js', request_method=request_method)
config.add_route('testi18n', '/testi18n', request_method=request_method)
config.add_route('topics', '/rest/services', request_method=request_method)
config.add_route('mapservice', '/rest/services/{map}/MapServer', request_method=request_method)
config.add_route('layersConfig', '/rest/services/{map}/MapServer/layersConfig', request_method=request_method)
config.add_route('catalog', '/rest/services/{map}/CatalogServer', request_method=request_method)
config.add_route('identify', '/rest/services/{map}/MapServer/identify', request_method=request_method)
config.add_route('find', '/rest/services/{map}/MapServer/find', request_method=request_method)
config.add_route('attribute_values', '/rest/services/{map}/MapServer/{layerId}/attributes/{attribute}', request_method=request_method)
config.add_route('legend', '/rest/services/{map}/MapServer/{layerId}/legend', request_method=request_method)
config.add_route('releases', '/rest/services/{map}/MapServer/{layerId}/releases', request_method=request_method)
config.add_route('cacheUpdate', '/rest/services/{map}/MapServer/{layerId}/cacheUpdate', request_method=request_method)
config.add_route('featureAttributes', '/rest/services/{map}/MapServer/{layerId}', request_method=request_method)
config.add_route('feature', '/rest/services/{map}/MapServer/{layerId}/{featureId}', request_method=request_method)
config.add_route('htmlPopup', '/rest/services/{map}/MapServer/{layerId}/{featureId}/htmlPopup', request_method=request_method)
config.add_route('iframeHtmlPopup', '/rest/services/{map}/MapServer/{layerId}/{featureId}/iframeHtmlPopup', request_method=request_method)
config.add_route('extendedHtmlPopup', '/rest/services/{map}/MapServer/{layerId}/{featureId}/extendedHtmlPopup', request_method=request_method)
config.add_route('luftbilder', '/luftbilder/viewer.html', request_method=request_method)
config.add_route('historicalmaps', '/historicalmaps/viewer.html', request_method=request_method)
config.add_route('checker', '/checker', request_method=request_method)
config.add_route('checker_dev', '/checker_dev', request_method=request_method)
config.add_route('translations', '/rest/services/translations', request_method=request_method)

config.add_route('stationboard', '/stationboard/stops/{id}', request_method=request_method)
config.add_route('faqlist', '/rest/services/{map}/faqlist', request_method=request_method)
config.add_route('color', '/color/{r},{g},{b}/{image}', request_method=request_method)

# Static route
static_max_age = int(settings['static_max_age']) if settings['static_max_age'] else None
Expand Down
1 change: 1 addition & 0 deletions chsdi/config/base.ini.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use = egg:chsdi
app_version = ${APP_VERSION}
available_languages = de fr it en rm
request_method = GET, HEAD, OPTIONS

pyramid.reload_templates = false
pyramid.debug_authorization = false
Expand Down
1 change: 0 additions & 1 deletion chsdi/models/vector/bafu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,6 @@ class Swissprtr(Base, Vector):
id = Column('prtrnr', Integer, primary_key=True)
betrieb = Column('betrieb', Unicode)
ort = Column('ort', Unicode)
jahr = Column('jahr', Integer)
the_geom = Column(Geometry2D)

register('ch.bafu.swissprtr', Swissprtr)
Expand Down
33 changes: 33 additions & 0 deletions chsdi/models/vector/dritte.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,3 +174,36 @@ class AsylPlanningRasterKraft(Base, AsylPlanning, Vector):
register('ch.sem.sachplan-asyl_anhoerung', AsylPlanningRasterAnhoerung)
register('ch.sem.sachplan-asyl_kraft', AsylPlanningKraft)
register('ch.sem.sachplan-asyl_kraft', AsylPlanningRasterKraft)


class ArmasuisseNaturLandschaftArmee(Base, Vector):
__bodId__ = 'ch.armasuisse.natur-landschaft_armee'
__table_args__ = ({'schema': 'armasuisse', 'autoload': False})
__tablename__ = 'natur_landschaft_armee_tooltip'
__template__ = 'templates/htmlpopup/armasuisse_natur_landschaft_armee.mako'
__label__ = 'standort'
id = Column('bgdi_id', Integer, primary_key=True)
standort = Column('standort', Unicode)
nla_name = Column('nla_name', Unicode)
lebr_de = Column('lebr_de', Unicode)
lebr_fr = Column('lebr_fr', Unicode)
lebr_it = Column('lebr_it', Unicode)
sublebr_de = Column('sublebr_de', Unicode)
sublebr_fr = Column('sublebr_fr', Unicode)
sublebr_it = Column('sublebr_it', Unicode)
schutz_de = Column('schutz_de', Unicode)
schutz_fr = Column('schutz_fr', Unicode)
schutz_it = Column('schutz_it', Unicode)
typ_de = Column('typ_de', Unicode)
typ_fr = Column('typ_fr', Unicode)
typ_it = Column('typ_it', Unicode)
link_nla_de = Column('link_nla_de', Unicode)
link_nla_fr = Column('link_nla_fr', Unicode)
link_nla_it = Column('link_nla_it', Unicode)
link_flyer_de = Column('link_flyer_de', Unicode)
link_flyer_fr = Column('link_flyer_fr', Unicode)
link_flyer_it = Column('link_flyer_it', Unicode)
geom_type = Column('geom_type', Unicode)
the_geom = Column(Geometry2D)

register('ch.armasuisse.natur-landschaft_armee', ArmasuisseNaturLandschaftArmee)
7 changes: 4 additions & 3 deletions chsdi/models/vector/lubis.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class LuftbilderBase:
__template__ = 'templates/htmlpopup/lubis.mako'
__returnedGeometry__ = 'the_geom_footprint'
__timeInstant__ = 'bgdi_flugjahr'
__extended_info__ = True
__label__ = 'flugdatum'
id = Column('ebkey', Unicode, primary_key=True)
filename = Column('filename', Unicode)
Expand Down Expand Up @@ -60,7 +59,8 @@ class LuftbilderSwisstopoFarbe(Base, LuftbilderBaseStac, Vector):
register('ch.swisstopo.lubis-luftbilder_farbe', LuftbilderSwisstopoFarbe)


class LuftbilderSwisstopoIr(Base, LuftbilderBase, Vector):
class LuftbilderSwisstopoIr(Base, LuftbilderBaseStac, Vector):
__extended_info__ = True
__tablename__ = 'luftbilder_swisstopo_ir'
__bodId__ = 'ch.swisstopo.lubis-luftbilder_infrarot'
image_height = Column('image_height', Integer)
Expand Down Expand Up @@ -143,6 +143,7 @@ class LuftbilderSchraegaufnahmen(Base, Vector):
# Composite labels
__label__ = 'flightdate'
id = Column('ebkey', Unicode, primary_key=True)
ebkey_old = Column('ebkey_old', Unicode)
inventory_number = Column('inventory_number', Unicode)
flightdate = Column('flightdate', Unicode)
medium_format = Column('medium_format', Unicode)
Expand All @@ -167,10 +168,10 @@ class LuftbilderTerrA(Base, Vector):
__bodId__ = 'ch.swisstopo.lubis-terrestrische_aufnahmen'
__timeInstant__ = 'bgdi_flugjahr'
__returnedGeometry__ = 'the_geom_footprint'
__timeInstant__ = 'bgdi_flugjahr'
__extended_info__ = True
__label__ = 'flugdatum'
id = Column('inventory_number', Unicode, primary_key=True)
inventarnummer_old = Column('inventarnummer_old', Unicode)
inventarnummer = Column('objectid', Integer)
image_number = Column('image_number', Integer)
flugdatum = Column('bgdi_flugdatum', Unicode)
Expand Down
6 changes: 4 additions & 2 deletions chsdi/models/vector/stopo.py
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ class GeologieHydroKarteGrundwasservulneabilitaet(Base, Vector):


class GeologieGeothermie(Base, Vector):
__tablename__ = 'geophysik_geothermie'
__tablename__ = 'view_geophysik_geothermie_tooltip'
__table_args__ = ({'schema': 'geol', 'autoload': False})
__template__ = 'templates/htmlpopup/geothermie.mako'
__bodId__ = 'ch.swisstopo.geologie-geophysik-geothermie'
Expand Down Expand Up @@ -1922,7 +1922,7 @@ class SwissmapOnlineWanderwege(Base, Vector):


class PLZOrtschaften(Base, Vector):
__tablename__ = 'gabmo_plz'
__tablename__ = 'amtovz_ortschaften'
__table_args__ = ({'schema': 'vd', 'autoload': False})
__template__ = 'templates/htmlpopup/gabmo_plz.mako'
__bodId__ = 'ch.swisstopo-vd.ortschaftenverzeichnis_plz'
Expand All @@ -1931,6 +1931,8 @@ class PLZOrtschaften(Base, Vector):
plz = Column('plz', Integer)
zusziff = Column('zusziff', Unicode)
langtext = Column('langtext', Unicode)
status = Column('status', Unicode)
modified = Column('modified', DateTimeChsdi)
bgdi_created = Column('bgdi_created', Unicode)
the_geom = Column(Geometry2D)

Expand Down
69 changes: 67 additions & 2 deletions chsdi/models/vector/uvek.py
Original file line number Diff line number Diff line change
Expand Up @@ -1716,8 +1716,9 @@ class HindernisbegrenzungsflaechenKataster:
__bodId__ = 'ch.bazl.hindernisbegrenzungsflaechen-kataster'
id = Column('bgdi_id', Integer, primary_key=True)
icaoloc = Column('icaoloc', Unicode)
validfrom = Column('validfrom', Unicode)
validuntil = Column('validuntil', Unicode)
surfacetype = Column('surfacetype', Unicode)
document = Column('document', Unicode)
geom_type = Column('geom_type', Unicode)
the_geom = Column(Geometry2D)


Expand Down Expand Up @@ -4062,3 +4063,67 @@ class LageStoerfallverordnungEisenbahnanlagen (Base, Vector):
the_geom = Column(Geometry2D)

register('ch.bav.lage-stoerfallverordnung_eisenbahnanlagen', LageStoerfallverordnungEisenbahnanlagen)


class BakomchStandorteMobilfunkanlagen (Base, Vector):
__table_args__ = ({'schema': 'bakom', 'autoload': False})
__tablename__ = 'standorte_mobilfunkanlagen'
__template__ = 'templates/htmlpopup/bakom_standorte_mobilfunkanlagen.mako'
__bodId__ = 'ch.bakom.standorte-mobilfunkanlagen'
__label__ = 'station'
id = Column('bgdi_id', Integer, primary_key=True)
station = Column('station', Unicode)
typ_de = Column('typ_de', Unicode)
typ_fr = Column('typ_fr', Unicode)
typ_it = Column('typ_it', Unicode)
typ_en = Column('typ_en', Unicode)
koord = Column('koord', Unicode)
power_de = Column('power_de', Unicode)
power_fr = Column('power_fr', Unicode)
power_it = Column('power_it', Unicode)
power_en = Column('power_en', Unicode)
techno_de = Column('techno_de', Unicode)
techno_fr = Column('techno_fr', Unicode)
techno_it = Column('techno_it', Unicode)
techno_en = Column('techno_en', Unicode)
adaptiv_de = Column('adaptiv_de', Unicode)
adaptiv_fr = Column('adaptiv_fr', Unicode)
adaptiv_it = Column('adaptiv_it', Unicode)
adaptiv_en = Column('adaptiv_en', Unicode)
bewilligung_de = Column('bewilligung_de', Unicode)
bewilligung_fr = Column('bewilligung_fr', Unicode)
bewilligung_it = Column('bewilligung_it', Unicode)
bewilligung_en = Column('bewilligung_en', Unicode)
agw_de = Column('agw_de', Unicode)
agw_fr = Column('agw_fr', Unicode)
agw_it = Column('agw_it', Unicode)
agw_en = Column('agw_en', Unicode)
the_geom = Column(Geometry2D)

register('ch.bakom.standorte-mobilfunkanlagen', BakomchStandorteMobilfunkanlagen)


class PhotovoltaikGrossanlagen (Base, Vector):
__table_args__ = ({'schema': 'bfe', 'autoload': False})
__tablename__ = 'photovoltaik_grossanlagen'
__template__ = 'templates/htmlpopup/bfe_photovoltaik_grossanlagen.mako'
__bodId__ = 'ch.bfe.photovoltaik-grossanlagen'
__label__ = 'projectname'
id = Column('bgdi_id', Integer, primary_key=True)
projectname = Column('projectname', Unicode)
projectmanagement = Column('projectmanagement', Unicode)
projectweb = Column('projectweb', Unicode)
elevation = Column('elevation', Integer)
power = Column('power', Unicode)
annualproduction = Column('annualproduction', Unicode)
winterproduction = Column('winterproduction', Unicode)
specificannualproduction = Column('specificannualproduction', Unicode)
specificwinterproduction = Column('specificwinterproduction', Unicode)
ref_status = Column('ref_status', Unicode)
statuscategory_de = Column('statuscategory_de', Unicode)
statuscategory_fr = Column('statuscategory_fr', Unicode)
statuscategory_it = Column('statuscategory_it', Unicode)
statuscategory_en = Column('statuscategory_en', Unicode)
the_geom = Column(Geometry2D)

register('ch.bfe.photovoltaik-grossanlagen', PhotovoltaikGrossanlagen)
2 changes: 1 addition & 1 deletion chsdi/response_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def add_default_cache_control(request, response):

def add_cors_header(request, response):
response.headers['Access-Control-Allow-Origin'] = "*"
response.headers['Access-Control-Allow-Methods'] = "POST, GET, OPTIONS"
response.headers['Access-Control-Allow-Methods'] = request.registry.settings['request_method']
response.headers['Access-Control-Allow-Headers'] = "*"


Expand Down
Loading

0 comments on commit 68242b7

Please sign in to comment.