diff --git a/chsdi/__init__.py b/chsdi/__init__.py index f077842087..a7eff37a58 100644 --- a/chsdi/__init__.py +++ b/chsdi/__init__.py @@ -105,7 +105,6 @@ def datetime_adapter(obj, request): 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) diff --git a/chsdi/models/vector/lubis.py b/chsdi/models/vector/lubis.py index 50a5b1fc75..0b2833e67c 100644 --- a/chsdi/models/vector/lubis.py +++ b/chsdi/models/vector/lubis.py @@ -10,75 +10,70 @@ class LuftbilderBase: __table_args__ = ({'schema': 'public', 'autoload': False}) - __template__ = 'templates/htmlpopup/lubis.mako' __returnedGeometry__ = 'the_geom_footprint' __timeInstant__ = 'bgdi_flugjahr' __label__ = 'flugdatum' id = Column('ebkey', Unicode, primary_key=True) filename = Column('filename', Unicode) - inventarnummer = Column('inventarnummer', Integer) - bildnummer = Column('bildnummer', Unicode) flugdatum = Column('flugdatum', Unicode) firma = Column('firma', Unicode) filmart = Column('filmart', Unicode) bgdi_flugjahr = Column('bgdi_flugjahr', Integer) - orientierung = Column('orientierung', Boolean) - rotation = Column('rotation', Integer) orthophoto = Column('orthophoto', Unicode) originalsize = Column('originalsize', Unicode) x = Column('x', Integer) y = Column('y', Integer) flughoehe = Column('flughoehe', Integer) - ort = Column('ort', Unicode) - massstab = Column('massstab', Integer) - filesize_mb = Column('filesize_mb', Unicode) bgdi_imagemode = Column('bgdi_imagemode', Unicode) the_geom_footprint = Column('the_geom_footprint', Geometry2D) the_geom = Column(Geometry2D) -class LuftbilderBaseStac(LuftbilderBase): +class LuftbilderBaseDritte(LuftbilderBase): + __template__ = 'templates/htmlpopup/lubis.mako' + inventarnummer = Column('inventarnummer', Integer) + bildnummer = Column('bildnummer', Unicode) + orientierung = Column('orientierung', Boolean) + rotation = Column('rotation', Integer) + ort = Column('ort', Unicode) + massstab = Column('massstab', Integer) + filesize_mb = Column('filesize_mb', Unicode) + + +class LuftbilderBaseSwisstopo(LuftbilderBase): __template__ = 'templates/htmlpopup/lubis_stac.mako' ebkey_old = Column('ebkey_old', Unicode) feature_id = Column('feature_id', Unicode) acquired = Column('acquired', Date) film_type = Column('film_type', Unicode) orthofilename = Column('orthofilename', Unicode) - filename = Column('filename', Unicode) e = Column('e', Numeric) n = Column('n', Numeric) z = Column('z', Numeric) -class LuftbilderSwisstopoFarbe(Base, LuftbilderBaseStac, Vector): +class LuftbilderSwisstopoFarbe(Base, LuftbilderBaseSwisstopo, Vector): __tablename__ = 'luftbilder_swisstopo_color' __bodId__ = 'ch.swisstopo.lubis-luftbilder_farbe' - image_height = Column('image_height', Integer) - image_width = Column('image_width', Integer) register('ch.swisstopo.lubis-luftbilder_farbe', LuftbilderSwisstopoFarbe) -class LuftbilderSwisstopoIr(Base, LuftbilderBaseStac, Vector): - __extended_info__ = True +class LuftbilderSwisstopoIr(Base, LuftbilderBaseSwisstopo, Vector): __tablename__ = 'luftbilder_swisstopo_ir' __bodId__ = 'ch.swisstopo.lubis-luftbilder_infrarot' - image_height = Column('image_height', Integer) - image_width = Column('image_width', Integer) register('ch.swisstopo.lubis-luftbilder_infrarot', LuftbilderSwisstopoIr) -class LuftbilderSwisstopoSw(Base, LuftbilderBaseStac, Vector): +class LuftbilderSwisstopoSw(Base, LuftbilderBaseSwisstopo, Vector): __tablename__ = 'luftbilder_swisstopo_bw' __bodId__ = 'ch.swisstopo.lubis-luftbilder_schwarzweiss' - image_height = Column('image_height', Integer) - image_width = Column('image_width', Integer) register('ch.swisstopo.lubis-luftbilder_schwarzweiss', LuftbilderSwisstopoSw) -class LuftbilderDritteFirmen(Base, LuftbilderBase, Vector): +class LuftbilderDritteFirmen(Base, LuftbilderBaseDritte, Vector): __tablename__ = 'luftbilder_dritte_firmen' __bodId__ = 'ch.swisstopo.lubis-luftbilder-dritte-firmen' contact = Column('contact', Unicode) @@ -89,7 +84,7 @@ class LuftbilderDritteFirmen(Base, LuftbilderBase, Vector): register('ch.swisstopo.lubis-luftbilder-dritte-firmen', LuftbilderDritteFirmen) -class LuftbilderDritteKantone(Base, LuftbilderBase, Vector): +class LuftbilderDritteKantone(Base, LuftbilderBaseDritte, Vector): __tablename__ = 'luftbilder_dritte_kantone' __bodId__ = 'ch.swisstopo.lubis-luftbilder-dritte-kantone' contact = Column('contact', Unicode) @@ -139,23 +134,16 @@ class LuftbilderSchraegaufnahmen(Base, Vector): __template__ = 'templates/htmlpopup/lubis_schraegaufnahmen.mako' __bodId__ = 'ch.swisstopo.lubis-luftbilder_schraegaufnahmen' __timeInstant__ = 'bgdi_flugjahr' - __extended_info__ = True - # 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) - filesize_mb = Column('filesize_mb', Unicode) filename = Column('filename', Unicode) filmart = Column('filmart', Unicode) stereo_couple = Column('stereo_couple', Unicode) bgdi_flugjahr = Column('bgdi_flugjahr', Integer) x = Column('x', Integer) y = Column('y', Integer) - contact = Column('contact', Unicode) - contact_email = Column('contact_email', Unicode) the_geom = Column(Geometry2D) register('ch.swisstopo.lubis-luftbilder_schraegaufnahmen', LuftbilderSchraegaufnahmen) @@ -168,12 +156,10 @@ class LuftbilderTerrA(Base, Vector): __bodId__ = 'ch.swisstopo.lubis-terrestrische_aufnahmen' __timeInstant__ = 'bgdi_flugjahr' __returnedGeometry__ = 'the_geom_footprint' - __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) bgdi_flugjahr = Column('year', Integer) filmart = Column('filmart', Unicode) @@ -182,12 +168,8 @@ class LuftbilderTerrA(Base, Vector): base_uuid = Column('base_uuid', Unicode) x = Column('easting', Numeric) y = Column('northing', Numeric) - medium_format = Column('format', Unicode) - filesize_mb = Column('filesize_mb', Unicode) filename = Column('filename', Unicode) bgdi_imagemode = Column('bgdi_imagemode', Unicode) - image_height = Column('image_height', Integer) - image_width = Column('image_width', Integer) smapshot_id = Column('smapshot_id', Integer) the_geom_footprint = Column('the_geom_footprint', Geometry2D) the_geom = Column(Geometry2D) diff --git a/chsdi/templates/htmlpopup/lubis.mako b/chsdi/templates/htmlpopup/lubis.mako index 57b302a007..728a672a81 100644 --- a/chsdi/templates/htmlpopup/lubis.mako +++ b/chsdi/templates/htmlpopup/lubis.mako @@ -1,5 +1,4 @@ <%inherit file="base.mako"/> -<%namespace name="lubis_map" file="../luftbilder/lubis_map.mako"/> <%! import datetime @@ -15,43 +14,11 @@ except ImportError: def br(text): return text.replace('\n', markupsafe.Markup('
')) -def determinePreviewUrl(tileUrlBasePath, ebkey): - - tileUrlBasePath = tileUrlBasePath - - def getPreviewImageUrl(ebkey): - return tileUrlBasePath + '/' + ebkey + '/quickview.jpg' - - def getZeroTileUrl(ebkey): - return tileUrlBasePath + '/' + ebkey + '/1/0/0.jpg' - - headers = {'Referer': 'http://admin.ch'} - url = getPreviewImageUrl(ebkey) - #testing these 2 url could be done more python like - if not h.resource_exists(url, headers): - url = getZeroTileUrl(ebkey) - - return url - def date_to_str(datum): try: return datetime.datetime.strptime(datum.strip(), "%Y%m%d").strftime("%d-%m-%Y") except: return request.translate('None') + request.translate('Datenstand') - -def get_viewer_url(request, params): - f = { - 'width': params[0], - 'height': params[1], - 'title': params[2].encode('utf8'), - 'bildnummer': params[3], - 'datenherr': params[4].encode('utf8'), - 'layer': params[5].encode('utf8'), - 'lang': params[6], - 'rotation': params[7] - } - return route_url('luftbilder', request) + '?' + urlencode(f) - %> <%def name="table_body(c, lang)"> @@ -61,35 +28,7 @@ tt_lubis_ebkey = c['layerBodId'] + '.' + 'id' lang = lang if lang in ('fr','it','en') else 'de' c['stable_id'] = True request = context.get('request') -aerialimages_data_host = request.registry.settings['aerialimages_data_host'] -tileUrlBasePath = aerialimages_data_host + '/tiles' - -preview_url = determinePreviewUrl(tileUrlBasePath, c['featureId']) - - -image_width = c['attributes']['image_width'] if 'image_width' in c['attributes'] else None -image_height = c['attributes']['image_height'] if 'image_height' in c['attributes'] else None -image_rotation = c['attributes']['rotation'] if 'rotation' in c['attributes'] else None - -if image_width is None or image_height is None: - wh = h.imagesize_from_metafile(tileUrlBasePath, c['featureId']) - image_width = wh[0] - image_height = wh[1] - -if image_rotation is None: - image_rotation = 0 - datum = date_to_str(c['attributes']['flugdatum']) -params = ( - image_width, - image_height, - _('ch.swisstopo.lubis-luftbilder-dritte-kantone.ebkey'), - c['featureId'], - c['attributes']['firma'], - c['layerBodId'], - lang, - image_rotation) -viewer_url = get_viewer_url(request, params) %> ${_(tt_lubis_ebkey)} @@ -111,15 +50,7 @@ viewer_url = get_viewer_url(request, params) % endif -% if preview_url != "" and image_width != None: - - ${_('tt_lubis_Quickview')} - - quickview - - - -% elif str(c['attributes'].get('doi_link', '-')).startswith('http'): +% if str(c['attributes'].get('doi_link', '-')).startswith('http'): ${_('tt_lubis_Quickview')} ${c['attributes']['doi_link']} @@ -155,121 +86,3 @@ viewer_url = get_viewer_url(request, params) % endif - - -<%def name="extended_info(c, lang)"> -<% -c['stable_id'] = True -protocol = request.scheme -c['baseUrl'] = h.make_agnostic(''.join((protocol, '://', request.registry.settings['geoadminhost']))) -topic = request.matchdict.get('map') -lang = request.lang -aerialimages_data_host = request.registry.settings['aerialimages_data_host'] -tileUrlBasePath = aerialimages_data_host + '/tiles' - - -preview_url = determinePreviewUrl(tileUrlBasePath, c['featureId']) - -filesize_mb = '-' -filename = c['attributes']['filename'] -if filename: - filesize_mb = c['attributes']['filesize_mb'] -endif -orientierung = '-' -if c['attributes']['orientierung']: - orientierung = 'True' -endif - -datum = date_to_str(c['attributes']['flugdatum']) -image_width = c['attributes']['image_width'] if 'image_width' in c['attributes'] else None -image_height = c['attributes']['image_height'] if 'image_height' in c['attributes'] else None -image_rotation = c['attributes']['rotation'] if 'rotation' in c['attributes'] else None - -if image_width is None or image_height is None: - wh = h.imagesize_from_metafile(tileUrlBasePath, c['featureId']) - image_width = wh[0] - image_height = wh[1] - -if image_rotation is None: - image_rotation = 0 - -params = ( - image_width, - image_height, - _('tt_lubis_ebkey'), - c['featureId'], - c['attributes']['firma'], - c['layerBodId'], - lang, - image_rotation) -viewer_url = get_viewer_url(request, params) -%> -${_('tt_lubis_ebkey')}: ${c['featureId']} - - - - - - - - - - - - -% if 'contact_image_url' in c['attributes'] and c['attributes']['contact_image_url']: - - - - -% endif - - - - - -% if filename and filename.startswith('http'): - -% else: - -% endif - -% if str(c['attributes'].get('doi_link', '')).startswith('http'): - -% endif - - - -% if 'contact_web' in c['attributes']: - - - - -% endif -
${_('tt_lubis_ebkey')} ${c['featureId'] or '-'}
${_('tt_lubis_inventarnummer')} ${c['attributes']['inventarnummer'] or '-'}
${_('tt_lubis_Flugdatum')} ${datum or '-'}
${_('tt_lubis_flughoehe')} ${c['attributes']['flughoehe'] or '-'}
${_('tt_lubis_massstab')} 1:${c['attributes']['massstab'] or '-'}
${_('tt_lubis_y')} ${c['attributes']['x'] or '-'}
${_('tt_lubis_x')} ${c['attributes']['y'] or '-'}
${_('tt_lubis_Filmart')} ${c['attributes']['filmart'] or '-'}
${_('tt_lubis_url_canton')}${c['attributes']['contact_image_url']}
${_('tt_lubis_originalsize')} ${c['attributes']['originalsize'] or '-'}
${_('tt_lubis_filesize_mb')} ${filesize_mb or '-'}
${_('tt_lubis_bildpfad')}${filename or '-'}
${filename or '-'}
DOI Link ${c['attributes']['doi_link']}
${_('tt_lubis_orthophoto')} ${c['attributes']['orthophoto'] or '-'}
${_('tt_lubis_orientierung')} ${orientierung or '-'}
${_('tt_lubis_rotation')} ${c['attributes']['rotation'] or '-'}
${_('tt_lubis_bildorder')}${c['attributes']['contact'] | br }
${c['attributes']['contact_email']}
${c['attributes']['contact_web']}
-
-
- -
-
-% if preview_url != "" and image_width != None: -
-
-
-% endif -
- - - - - - -<%def name="extended_resources(c, lang)"> - - diff --git a/chsdi/templates/htmlpopup/lubis_schraegaufnahmen.mako b/chsdi/templates/htmlpopup/lubis_schraegaufnahmen.mako index c6868af9e7..2ec568ad0c 100644 --- a/chsdi/templates/htmlpopup/lubis_schraegaufnahmen.mako +++ b/chsdi/templates/htmlpopup/lubis_schraegaufnahmen.mako @@ -1,33 +1,7 @@ <%inherit file="base.mako"/> -<%namespace name="lubis_map" file="../luftbilder/lubis_map.mako"/> <%! import datetime -import urllib -from pyramid.url import route_url -import chsdi.lib.helpers as h -import markupsafe - -def br(text): - return text.replace('\n', markupsafe.Markup('
')) - -def determinePreviewUrl(tileUrlBasePath, ebkey): - - tileUrlBasePath = tileUrlBasePath - - def getPreviewImageUrl(ebkey): - return tileUrlBasePath + '/' + ebkey + '/quickview.jpg' - - def getZeroTileUrl(ebkey): - return tileUrlBasePath + '/' + ebkey + '/0/0/0.jpg' - - headers = {'Referer': 'http://admin.ch'} - url = getPreviewImageUrl(ebkey) - #testing these 2 url could be done more python like - if not h.resource_exists(url, headers): - url = getZeroTileUrl(ebkey) - - return url def date_to_str(datum): try: @@ -35,20 +9,6 @@ def date_to_str(datum): except: return request.translate('None') + request.translate('Datenstand') -def get_viewer_url(request, params): - f = { - 'width': params[0], - 'height': params[1], - 'title': params[2].encode('utf8'), - 'bildnummer': params[3], - 'datenherr': params[4].encode('utf8'), - 'layer': params[5].encode('utf8'), - 'lang': params[6], - 'rotation': params[7] - } - - return h.make_agnostic(route_url('luftbilder', request)) + '?' + urllib.parse.urlencode(f) - %> <%def name="table_body(c, lang)"> @@ -57,168 +17,33 @@ def get_viewer_url(request, params): lang = lang if lang in ('fr','it','en') else 'de' c['stable_id'] = True request = context.get('request') -aerialimages_data_host = request.registry.settings['aerialimages_data_host'] -tileUrlBasePath = aerialimages_data_host + '/tiles' datum = date_to_str(c['attributes']['flightdate']) tt_lubis_Quickview='tt_lubis_Quickview' image_width = None -# set true if featureId comes from stac -isStac = c['featureId'].startswith('lubis-luftbilder_schraegaufnahmen') -# new feature ids start with: lubis-luftbilder -# simply create a link to the stac browser -# there is no way to open to activate the orthophoto with the link parameters -if isStac: - dataGeoAdminHost = request.registry.settings['datageoadminhost'] - asset_url=f"{dataGeoAdminHost}/{c['layerBodId']}/{c['featureId']}/{c['featureId']}_2056.tif" - preview_url=f"{dataGeoAdminHost}/{c['layerBodId']}/{c['featureId']}/{c['featureId']}.jpg" - meta_csv_url=f"{dataGeoAdminHost}/{c['layerBodId']}/{c['featureId']}/{c['featureId']}.csv" - viewer_url=asset_url - tt_lubis_Quickview='tt_lubis_Quickview_stac' -# legacy: old ebkeys with fullresviewer in aerialimages bucket -# this part can be removed when the migration of the aerialimages bucket to stac/data.geo.admin.ch is finished -else: - preview_url = determinePreviewUrl(tileUrlBasePath, c['featureId']) - image_rotation = 0 - wh = h.imagesize_from_metafile(tileUrlBasePath, c['featureId']) - image_width = wh[0] - image_height = wh[1] - - params = ( - image_width, - image_height, - _('tt_lubis_ebkey'), - c['featureId'], - 'swisstopo', - c['layerBodId'], - lang, - image_rotation) - viewer_url = get_viewer_url(request, params) +dataGeoAdminHost = request.registry.settings['datageoadminhost'] +asset_url=f"{dataGeoAdminHost}/{c['layerBodId']}/{c['featureId']}/{c['featureId']}_2056.tif" +preview_url=f"{dataGeoAdminHost}/{c['layerBodId']}/{c['featureId']}/{c['featureId']}.jpg" +meta_csv_url=f"{dataGeoAdminHost}/{c['layerBodId']}/{c['featureId']}/{c['featureId']}.csv" +viewer_url=asset_url +tt_lubis_Quickview='tt_lubis_Quickview_stac' %> -% if isStac: # STAC Tooltips - ${_('tt_lubis_ebkey')} ${c['featureId']} - ${_('tt_lubis_Flugdatum')} ${datum} - ${_('tt_lubis_bildpfad')} ${c['attributes']['filename']} - ${_('tt_lubis_schraegaufnahmen_stereo_couple')} ${c['attributes']['stereo_couple']} - ${_('tt_lubis_schraegaufnahmen_x')} ${c['attributes']['x']} - ${_('tt_lubis_schraegaufnahmen_y')} ${c['attributes']['y']} - ${_("zusatzinfo")} - - ${_(f"{c['layerBodId']}.meta_csv_url")} - - - ${_(tt_lubis_Quickview)} - - quickview - - -% else: # OLD Tooltips with GDWH datasource - ${_('tt_lubis_ebkey')} ${c['featureId']} - ${_('tt_lubis_inventarnummer')} ${c['attributes']['inventory_number']} - ${_('tt_lubis_Flugdatum')} ${datum} - -% if preview_url != "" and image_width != None: - - ${_('tt_lubis_Quickview')} - quickview +${_('tt_lubis_ebkey')} ${c['featureId']} +${_('tt_lubis_Flugdatum')} ${datum} +${_('tt_lubis_bildpfad')} ${c['attributes']['filename']} +${_('tt_lubis_schraegaufnahmen_stereo_couple')} ${c['attributes']['stereo_couple']} +${_('tt_lubis_schraegaufnahmen_x')} ${c['attributes']['x']} +${_('tt_lubis_schraegaufnahmen_y')} ${c['attributes']['y']} +${_("zusatzinfo")} + + ${_(f"{c['layerBodId']}.meta_csv_url")} + -% else: - - ${_('tt_lubis_Quickview')} - ${_('tt_lubis_noQuickview')} +${_(tt_lubis_Quickview)} + + quickview + -% endif - -% endif - - - - -<%def name="extended_info(c, lang)"> -<% -# TODO: extended tooltip can be completely removed after the migration to stac -c['stable_id'] = True -protocol = request.scheme -c['baseUrl'] = h.make_agnostic(''.join((protocol, '://', request.registry.settings['geoadminhost']))) -topic = request.matchdict.get('map') -lang = request.lang - -datum = date_to_str(c['attributes']['flightdate']) - -isStac = c['featureId'].startswith('lubis-luftbilder_schraegaufnahmen') -if not isStac: - aerialimages_data_host = request.registry.settings['aerialimages_data_host'] - tileUrlBasePath = aerialimages_data_host + '/tiles' - preview_url = determinePreviewUrl(tileUrlBasePath, c['featureId']) - image_rotation = 0 - wh = h.imagesize_from_metafile(tileUrlBasePath, c['featureId']) - image_width = wh[0] - image_height = wh[1] - params = ( - image_width, - image_height, - _('tt_lubis_ebkey'), - c['featureId'], - 'swisstopo', - c['layerBodId'], - lang, - image_rotation) - viewer_url = get_viewer_url(request, params) -%> - -% if isStac: # STAC Tooltips -${_('tt_lubis_ebkey')}: ${c['featureId']} - - - - - - - - -
${_('tt_lubis_ebkey')} ${c['featureId']}
${_('tt_lubis_Flugdatum')} ${datum}
${_('tt_lubis_bildpfad')} ${c['attributes']['filename']}
${_('tt_lubis_schraegaufnahmen_stereo_couple')} ${c['attributes']['stereo_couple']}
${_('tt_lubis_schraegaufnahmen_x')} ${c['attributes']['x']}
${_('tt_lubis_schraegaufnahmen_y')} ${c['attributes']['y']}
- -% else: # quickview and iframe are only activated for the old images -${_('tt_lubis_ebkey')}: ${c['featureId']} - - - - - - - - - - - - - -
${_('tt_lubis_ebkey')} ${c['featureId']}
${_('tt_lubis_inventarnummer')} ${c['attributes']['inventory_number']}
${_('tt_lubis_Flugdatum')} ${datum}
${_('tt_lubis_originalsize')} ${c['attributes']['medium_format']}
${_('tt_lubis_filesize_mb')} ${c['attributes']['filesize_mb']}
${_('tt_lubis_bildpfad')} ${c['attributes']['filename']}
${_('tt_lubis_schraegaufnahmen_stereo_couple')} ${c['attributes']['stereo_couple']}
${_('tt_lubis_schraegaufnahmen_x')} ${c['attributes']['x']}
${_('tt_lubis_schraegaufnahmen_y')} ${c['attributes']['y']}
${_('tt_lubis_bildorder')} ${c['attributes']['contact'] | br }
${c['attributes']['contact_email']}
-
-
- -
-
-% if preview_url != "" and image_width != None: -
-
-
-% endif - - - -% endif - - - -<%def name="extended_resources(c, lang)"> - diff --git a/chsdi/templates/htmlpopup/lubis_stac.mako b/chsdi/templates/htmlpopup/lubis_stac.mako index 256bb14ece..9584a02598 100644 --- a/chsdi/templates/htmlpopup/lubis_stac.mako +++ b/chsdi/templates/htmlpopup/lubis_stac.mako @@ -1,49 +1,7 @@ <%inherit file="base.mako"/> -<%namespace name="lubis_map" file="../luftbilder/lubis_map.mako"/> <%! import datetime -from pyramid.url import route_url -import chsdi.lib.helpers as h -import markupsafe - -# TODO python2 clean-up -try: - from urllib import urlencode -except ImportError: - from urllib.parse import urlencode - -def br(text): - return text.replace('\n', markupsafe.Markup('
')) - -def determinePreviewUrl(tileUrlBasePath, featureid): - headers = {'Referer': 'http://admin.ch'} - url = f'{tileUrlBasePath}/{featureid}/quickview.jpg' - # check if url is valid - if not h.resource_exists(url, headers): - return False - - return url - -def date_to_str(datum): - try: - return datetime.datetime.strptime(datum.strip(), "%Y%m%d").strftime("%d-%m-%Y") - except: - return request.translate('None') + request.translate('Datenstand') - -def get_viewer_url(request, params): - f = { - 'width': params[0], - 'height': params[1], - 'title': params[2].encode('utf8'), - 'bildnummer': params[3], - 'datenherr': params[4].encode('utf8'), - 'layer': params[5].encode('utf8'), - 'lang': params[6], - 'rotation': params[7] - } - return route_url('luftbilder', request) + '?' + urlencode(f) - %> <%def name="table_body(c, lang)"> @@ -53,58 +11,20 @@ tt_lubis_ebkey = f"{c['layerBodId']}.id" lang = lang if lang in ('fr','it','en') else 'de' c['stable_id'] = True request = context.get('request') -aerialimages_data_host = request.registry.settings['aerialimages_data_host'] -tileUrlBasePath = aerialimages_data_host + '/tiles' -preview_url = determinePreviewUrl(tileUrlBasePath, c['featureId']) tt_lubis_Quickview='tt_lubis_Quickview' -# new feature ids start with: lubis-luftbilder -# simply create a link to the stac browser -# there is no way to open to activate the orthophoto with the link parameters -if c['featureId'].startswith('lubis-luftbilder'): - datum = datetime.datetime.strptime(c['attributes']['acquired'], '%Y-%m-%d').strftime("%d-%m-%Y") - dataGeoAdminHost = request.registry.settings['datageoadminhost'] - aerialimages_url=f"{dataGeoAdminHost}/{c['layerBodId']}/{c['featureId']}/{c['attributes']['filename']}" - meta_csv_url=f"{dataGeoAdminHost}/{c['layerBodId']}/{c['featureId']}/{c['featureId']}.csv" - orthophoto_url=f"{dataGeoAdminHost}/{c['layerBodId']}/{c['featureId']}/{c['attributes']['orthofilename']}" - preview_url=f"{dataGeoAdminHost}/{c['layerBodId']}/{c['featureId']}/{c['featureId']}.jpg" - - viewer_url=aerialimages_url - tt_lubis_Quickview='tt_lubis_Quickview_stac' - -# legacy: old ebkeys with fullresviewer in aerialimages bucket -# this part can be removed when the migration of the aerialimages bucket to stac/data.geo.admin.ch is finished -else: - datum = date_to_str(c['attributes']['flugdatum']) - - image_width = c['attributes']['image_width'] if 'image_width' in c['attributes'] else None - image_height = c['attributes']['image_height'] if 'image_height' in c['attributes'] else None - image_rotation = c['attributes']['rotation'] if 'rotation' in c['attributes'] else None - - if image_width is None or image_height is None: - wh = h.imagesize_from_metafile(tileUrlBasePath, c['featureId']) - image_width = wh[0] - image_height = wh[1] - - if image_rotation is None: - image_rotation = 0 - - params = ( - image_width, - image_height, - _('ch.swisstopo.lubis-luftbilder-dritte-kantone.ebkey'), - c['featureId'], - c['attributes']['firma'], - c['layerBodId'], - lang, - image_rotation) - viewer_url = get_viewer_url(request, params) +datum = datetime.datetime.strptime(c['attributes']['acquired'], '%Y-%m-%d').strftime("%d-%m-%Y") +dataGeoAdminHost = request.registry.settings['datageoadminhost'] +aerialimages_url=f"{dataGeoAdminHost}/{c['layerBodId']}/{c['featureId']}/{c['attributes']['filename']}" +meta_csv_url=f"{dataGeoAdminHost}/{c['layerBodId']}/{c['featureId']}/{c['featureId']}.csv" +orthophoto_url=f"{dataGeoAdminHost}/{c['layerBodId']}/{c['featureId']}/{c['attributes']['orthofilename']}" +preview_url=f"{dataGeoAdminHost}/{c['layerBodId']}/{c['featureId']}/{c['featureId']}.jpg" +viewer_url=aerialimages_url +tt_lubis_Quickview='tt_lubis_Quickview_stac' %> - -% if c['featureId'].startswith('lubis-luftbilder'): # STAC Tooltips ${_(f"{c['layerBodId']}.id")} @@ -148,152 +68,11 @@ else: -% else: # OLD Tooltips with GDWH data delivery - - ${_(tt_lubis_ebkey)} - ${c['featureId'] or '-'} - - - ${_('tt_lubis_Flugdatum')} - ${datum or '-'} - - - ${_('tt_lubis_Filmart')} - ${c['attributes']['filmart'] or '-'} - -% endif - - -% if preview_url: ${_(tt_lubis_Quickview)} quickview -% else: - - ${_(tt_lubis_Quickview)} - ${_('tt_lubis_noQuickview')} - -% endif - - - - -<%def name="extended_info(c, lang)"> -<% -c['stable_id'] = True -protocol = request.scheme -c['baseUrl'] = h.make_agnostic(''.join((protocol, '://', request.registry.settings['geoadminhost']))) -topic = request.matchdict.get('map') -lang = request.lang -aerialimages_data_host = request.registry.settings['aerialimages_data_host'] -tileUrlBasePath = aerialimages_data_host + '/tiles' - - -preview_url = determinePreviewUrl(tileUrlBasePath, c['featureId']) - -filesize_mb = '-' -filename = c['attributes']['filename'] -if filename: - filesize_mb = c['attributes']['filesize_mb'] -endif -orientierung = '-' -if c['attributes']['orientierung']: - orientierung = 'True' -endif - -datum = date_to_str(c['attributes']['flugdatum']) -image_width = c['attributes']['image_width'] if 'image_width' in c['attributes'] else None -image_height = c['attributes']['image_height'] if 'image_height' in c['attributes'] else None -image_rotation = c['attributes']['rotation'] if 'rotation' in c['attributes'] else None - -if image_width is None or image_height is None: - wh = h.imagesize_from_metafile(tileUrlBasePath, c['featureId']) - image_width = wh[0] - image_height = wh[1] - -if image_rotation is None: - image_rotation = 0 - -params = ( - image_width, - image_height, - _('tt_lubis_ebkey'), - c['featureId'], - c['attributes']['firma'], - c['layerBodId'], - lang, - image_rotation) -viewer_url = get_viewer_url(request, params) -%> -${_('tt_lubis_ebkey')}: ${c['featureId']} - - - - - - - - - - - - -% if 'contact_image_url' in c['attributes'] and c['attributes']['contact_image_url']: - - - - -% endif - - - - - -% if filename and filename.startswith('http'): - -% else: - -% endif - -% if str(c['attributes'].get('doi_link', '')).startswith('http'): - -% endif - - - -% if 'contact_web' in c['attributes']: - - - - -% endif -
${_('tt_lubis_ebkey')} ${c['featureId'] or '-'}
${_('tt_lubis_inventarnummer')} ${c['attributes']['inventarnummer'] or '-'}
${_('tt_lubis_Flugdatum')} ${datum or '-'}
${_('tt_lubis_flughoehe')} ${c['attributes']['flughoehe'] or '-'}
${_('tt_lubis_massstab')} 1:${c['attributes']['massstab'] or '-'}
${_('tt_lubis_y')} ${c['attributes']['x'] or '-'}
${_('tt_lubis_x')} ${c['attributes']['y'] or '-'}
${_('tt_lubis_Filmart')} ${c['attributes']['filmart'] or '-'}
${_('tt_lubis_url_canton')}${c['attributes']['contact_image_url']}
${_('tt_lubis_originalsize')} ${c['attributes']['originalsize'] or '-'}
${_('tt_lubis_filesize_mb')} ${filesize_mb or '-'}
${_('tt_lubis_bildpfad')}${filename or '-'}
${filename or '-'}
DOI Link ${c['attributes']['doi_link']}
${_('tt_lubis_orthophoto')} ${c['attributes']['orthophoto'] or '-'}
${_('tt_lubis_orientierung')} ${orientierung or '-'}
${_('tt_lubis_rotation')} ${c['attributes']['rotation'] or '-'}
${_('tt_lubis_bildorder')}${c['attributes']['contact'] | br }
${c['attributes']['contact_email']}
${c['attributes']['contact_web']}
-
-
- -
-
-% if preview_url != "" and image_width != None: -
-
-
-% endif -
- - - - - -<%def name="extended_resources(c, lang)"> - diff --git a/chsdi/templates/htmlpopup/lubis_terra.mako b/chsdi/templates/htmlpopup/lubis_terra.mako index da1b8da7a7..64471426bc 100644 --- a/chsdi/templates/htmlpopup/lubis_terra.mako +++ b/chsdi/templates/htmlpopup/lubis_terra.mako @@ -1,34 +1,12 @@ <%inherit file="base.mako"/> -<%namespace name="lubis_map" file="../luftbilder/lubis_map.mako"/> <%! import datetime -import urllib -from pyramid.url import route_url import chsdi.lib.helpers as h -import markupsafe def br(text): return text.replace('\n', markupsafe.Markup('
')) -def determinePreviewUrl(tileUrlBasePath, ebkey): - - tileUrlBasePath = tileUrlBasePath - - def getPreviewImageUrl(ebkey): - return tileUrlBasePath + '/' + ebkey + '/quickview.jpg' - - def getZeroTileUrl(ebkey): - return tileUrlBasePath + '/' + ebkey + '/1/0/0.jpg' - - headers = {'Referer': 'http://admin.ch'} - url = getPreviewImageUrl(ebkey) - #testing these 2 url could be done more python like - if not h.resource_exists(url, headers): - url = getZeroTileUrl(ebkey) - - return url - def date_to_str(datum): try: return datetime.datetime.strptime(datum.strip(), "%Y%m%d").strftime("%d-%m-%Y") @@ -40,19 +18,6 @@ def date_to_str(datum): except: return datum -def get_viewer_url(request, params): - f = { - 'width': params[0], - 'height': params[1], - 'title': params[2].encode('utf8'), - 'bildnummer': params[3], - 'datenherr': params[4].encode('utf8'), - 'layer': params[5].encode('utf8'), - 'lang': params[6], - 'rotation': params[7] - } - return h.make_agnostic(route_url('luftbilder', request)) + '?' + urllib.parse.urlencode(f) - %> <%def name="table_body(c, lang)"> @@ -63,46 +28,19 @@ lang = lang if lang in ('fr','it','en') else 'de' c['stable_id'] = True request = context.get('request') -aerialimages_data_host = request.registry.settings['aerialimages_data_host'] -tileUrlBasePath = aerialimages_data_host + '/tiles' -preview_url = determinePreviewUrl(tileUrlBasePath, c['featureId']) - - -# set true if featureId comes from stac -isStac = c['featureId'].startswith('lubis-terrestrische_aufnahmen') - datum = date_to_str(c['attributes']['flugdatum']) -if isStac: - dataGeoAdminHost = request.registry.settings['datageoadminhost'] - asset_url=f"{dataGeoAdminHost}/{c['layerBodId']}/{c['featureId']}/{c['featureId']}.tif" - preview_url=f"{dataGeoAdminHost}/{c['layerBodId']}/{c['featureId']}/{c['featureId']}.jpg" - meta_csv_url=f"{dataGeoAdminHost}/{c['layerBodId']}/{c['featureId']}/{c['featureId']}.csv" - viewer_url=asset_url - tt_lubis_Quickview='tt_lubis_Quickview_stac' - url_pdf = dataGeoAdminHost + "/" + c['layerBodId'] + "/pdf/" + c['attributes']['base_uuid'] + '.pdf' - pdf = h.resource_exists(url_pdf) or None - url_smapshot= "https://smapshot.heig-vd.ch/map/?imageId={}".format(c['attributes']['smapshot_id']) +dataGeoAdminHost = request.registry.settings['datageoadminhost'] +asset_url=f"{dataGeoAdminHost}/{c['layerBodId']}/{c['featureId']}/{c['featureId']}.tif" +preview_url=f"{dataGeoAdminHost}/{c['layerBodId']}/{c['featureId']}/{c['featureId']}.jpg" +meta_csv_url=f"{dataGeoAdminHost}/{c['layerBodId']}/{c['featureId']}/{c['featureId']}.csv" +viewer_url=asset_url +tt_lubis_Quickview='tt_lubis_Quickview_stac' +url_pdf = dataGeoAdminHost + "/" + c['layerBodId'] + "/pdf/" + c['attributes']['base_uuid'] + '.pdf' +pdf = h.resource_exists(url_pdf) or None +url_smapshot= "https://smapshot.heig-vd.ch/map/?imageId={}".format(c['attributes']['smapshot_id']) # legacy: old ebkeys with fullresviewer in aerialimages bucket # this part can be removed when the migration of the aerialimages bucket to stac/data.geo.admin.ch is finished -else: - image_rotation = 0 - firma = '-' - wh = h.imagesize_from_metafile(tileUrlBasePath, c['featureId']) - image_width = wh[1] - image_height = wh[0] - params = ( - image_width, - image_height, - _('tt_lubis_ebkey'), - c['featureId'], - firma, - c['layerBodId'], - lang, - image_rotation) - viewer_url = get_viewer_url(request, params) - %> -% if isStac: # STAC Tooltips ${_(tt_lubis_ebkey)} ${c['featureId'] or '-'} ${_('ch.swisstopo.lubis-terrestrische_aufnahmen.tt_lubis_aufnahmedatum')}${datum or '-'} ${_('ch.swisstopo.lubis-terrestrische_aufnahmen.operate_name')} ${c['attributes']['ort'] or '-'} @@ -124,124 +62,4 @@ else: quickview -% else: # OLD Tooltips with GDWH datasource -${_(tt_lubis_ebkey)} ${c['attributes']['image_number'] or '-'} -${_('tt_lubis_inventarnummer')} ${c['attributes']['inventarnummer'] or '-'} -${_('ch.swisstopo.lubis-terrestrische_aufnahmen.tt_lubis_aufnahmedatum')}${datum or '-'} -${_('tt_lubis_Filmart')}${c['attributes']['filmart'] or '-'} - -% if preview_url != "" and image_width != None: - - ${_('tt_lubis_Quickview')} - - quickview - - -% else: - - ${_('tt_lubis_Quickview')} - ${_('tt_lubis_noQuickview')} - -% endif -% endif - - - -<%def name="extended_info(c, lang)"> -<% -# TODO: extended tooltip can be completely removed after the migration to stac -from chsdi.lib.helpers import resource_exists - -c['stable_id'] = True -protocol = request.scheme -c['baseUrl'] = h.make_agnostic(''.join((protocol, '://', request.registry.settings['geoadminhost']))) -topic = request.matchdict.get('map') -lang = request.lang - -aerialimages_data_host = request.registry.settings['aerialimages_data_host'] -tileUrlBasePath = aerialimages_data_host + '/tiles' -preview_url = determinePreviewUrl(tileUrlBasePath, c['featureId']) - -filename = c['attributes']['filename'] or '-' -filesize_mb = c['attributes']['filesize_mb'] or '-' - -datum = date_to_str(c['attributes']['flugdatum']) -image_rotation = 0 -firma = '-' -wh = h.imagesize_from_metafile(tileUrlBasePath, c['featureId']) -image_width = wh[1] -image_height = wh[0] -params = ( - image_width, - image_height, - _('tt_lubis_ebkey'), - c['featureId'], - firma, - c['layerBodId'], - lang, - image_rotation) -viewer_url = get_viewer_url(request, params) - -dataPath = 'ch.swisstopo.lubis-terrestrische_aufnahmen/' -dataGeoAdminHost = request.registry.settings['datageoadminhost'] -pdf = None -url_pdf = dataGeoAdminHost + "/" + dataPath + "pdf/" + c['attributes']['base_uuid'] + '.pdf' -pdf = resource_exists(url_pdf) - -url_smapshot= "https://smapshot.heig-vd.ch/map/?imageId={}".format(c['attributes']['smapshot_id']) - -isStac = c['featureId'].startswith('lubis-terrestrische_aufnahmen') -%> -${_('tt_lubis_ebkey')}: ${c['featureId']} - - - - - - - - - - - - - - - - - - -
${_('tt_lubis_ebkey')} ${c['attributes']['image_number'] or '-'}
${_('tt_lubis_inventarnummer')} ${c['attributes']['inventarnummer'] or '-'}
${_('ch.swisstopo.lubis-terrestrische_aufnahmen.tt_lubis_aufnahmedatum')} ${datum or '-'}
${_('ch.swisstopo.lubis-terrestrische_aufnahmen.operate_name')} ${c['attributes']['ort'] or '-'}
${_('ch.swisstopo.lubis-terrestrische_aufnahmen.station')} ${c['attributes']['station'] or '-'}
${_('tt_lubis_schraegaufnahmen_x')} ${c['attributes']['x'] or '-'}
${_('tt_lubis_schraegaufnahmen_y')} ${c['attributes']['y'] or '-'}
${_('tt_lubis_Filmart')} ${c['attributes']['filmart'] or '-'}
${_('ch.swisstopo.lubis-luftbilder_schraegaufnahmen.tt_lubis_schraegaufnahmen_medium_format')} ${c['attributes']['medium_format'] or '-'}
${_('ch.swisstopo.lubis-terrestrische_aufnahmen.tt_filesize')} ${c['attributes']['filesize_mb'] or '-'}
${_('tt_lubis_bildpfad')} ${filename or '-'}
${_('link')} -% if pdf: - ${_('ch.swisstopo.lubis-terrestrische_aufnahmen.expertenlink')} - pdf -% else: - - -% endif -
${_('link')} smapshot ${_('link')} smapshot
-% if not isStac: -
-
- -
-
-% if preview_url != "" and image_width != None: -
-
-
-% endif -
- -% endif - - - - -<%def name="extended_resources(c, lang)"> - diff --git a/chsdi/templates/index.mako b/chsdi/templates/index.mako index 562e87f962..400891607b 100644 --- a/chsdi/templates/index.mako +++ b/chsdi/templates/index.mako @@ -92,8 +92,6 @@ version = python_version()

CatalogService (non ESRI)

Catalog for topic 'blw' -

Lubis Viewer

- Link to Lubis full screen Viewer

Search

Layers Search (type=layers)

diff --git a/chsdi/templates/luftbilder/lubis_map.mako b/chsdi/templates/luftbilder/lubis_map.mako deleted file mode 100644 index 632a95544b..0000000000 --- a/chsdi/templates/luftbilder/lubis_map.mako +++ /dev/null @@ -1,205 +0,0 @@ -<%def name="init_map(ebkey, width, height, rotation, target, aerialimages_data_host)"> - var TILE_SIZE = 256; - var width = parseInt(${width | u}); - var height = parseInt(${height | u}); - var rotation= parseInt(${rotation if rotation != 'None' and rotation is not None else 0 | u}) * Math.PI / 180; - - var url = '${aerialimages_data_host}/tiles/${ebkey}/'; - var resolutions = [1]; // 1 is the min resolution of the pyramid (for all images) - var curResolution = resolutions[0]; - var maxResolution = Math.max(width, height) / TILE_SIZE; - - var Xn = 0.950470; - var Yn = 1; - var Zn = 1.088830; - var t0 = 4 / 29; - var t1 = 6 / 29; - var t2 = 3 * t1 * t1; - var t3 = t1 * t1 * t1; - var twoPi = 2 * Math.PI; - - - /** - * Convert an RGB pixel into an HCL pixel. - * @param {Array.} pixel A pixel in RGB space. - * @return {Array.} A pixel in HCL space. - */ - function rgb2hcl(pixel) { - var red = rgb2xyz(pixel[0]); - var green = rgb2xyz(pixel[1]); - var blue = rgb2xyz(pixel[2]); - - var x = xyz2lab( - (0.4124564 * red + 0.3575761 * green + 0.1804375 * blue) / Xn); - var y = xyz2lab( - (0.2126729 * red + 0.7151522 * green + 0.0721750 * blue) / Yn); - var z = xyz2lab( - (0.0193339 * red + 0.1191920 * green + 0.9503041 * blue) / Zn); - - var l = 116 * y - 16; - var a = 500 * (x - y); - var b = 200 * (y - z); - - var c = Math.sqrt(a * a + b * b); - var h = Math.atan2(b, a); - if (h < 0) { - h += twoPi; - } - - pixel[0] = h; - pixel[1] = c; - pixel[2] = l; - - return pixel; - } - - - /** - * Convert an HCL pixel into an RGB pixel. - * @param {Array.} pixel A pixel in HCL space. - * @return {Array.} A pixel in RGB space. - */ - function hcl2rgb(pixel) { - var h = pixel[0]; - var c = pixel[1]; - var l = pixel[2]; - - var a = Math.cos(h) * c; - var b = Math.sin(h) * c; - - var y = (l + 16) / 116; - var x = isNaN(a) ? y : y + a / 500; - var z = isNaN(b) ? y : y - b / 200; - - y = Yn * lab2xyz(y); - x = Xn * lab2xyz(x); - z = Zn * lab2xyz(z); - - pixel[0] = xyz2rgb(3.2404542 * x - 1.5371385 * y - 0.4985314 * z); - pixel[1] = xyz2rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z); - pixel[2] = xyz2rgb(0.0556434 * x - 0.2040259 * y + 1.0572252 * z); - - return pixel; - } - - function xyz2lab(t) { - return t > t3 ? Math.pow(t, 1 / 3) : t / t2 + t0; - } - - function lab2xyz(t) { - return t > t1 ? t * t * t : t2 * (t - t0); - } - - function rgb2xyz(x) { - return (x /= 255) <= 0.04045 ? x / 12.92 : Math.pow((x + 0.055) / 1.055, 2.4); - } - - function xyz2rgb(x) { - return 255 * (x <= 0.0031308 ? - 12.92 * x : 1.055 * Math.pow(x, 1 / 2.4) - 0.055); - } - - // in case you want to add a slider, add a degree parameter (value range:0-200) - function getPixelValue(pixel, mean, equalizedValues){ - var hcl = rgb2hcl(pixel); - var l = parseInt(hcl[2]); - var equalizedValue = equalizedValues[l]; - var new_l; - var degree = 150; - - if (degree<100){ - new_l = mean * (1 - (degree / 100)) + l * (degree / 100); - }else{ - new_l = l * (2 - (degree / 100)) + ((degree / 100)-1) * 100 * equalizedValue; - } - - hcl[2] = new_l; - return hcl2rgb(hcl); - } - - - while (curResolution < maxResolution) { - curResolution *= 2; - resolutions.unshift(curResolution); - } - - var tileimage = new ol.source.TileImage({ - crossOrigin: 'anonymous', - tileGrid: new ol.tilegrid.TileGrid({ - origin: [0, 0], - resolutions: resolutions - }), - tileUrlFunction: function(tileCoord, pixelRatio, projection) { - var coords = tileCoord; - if (coords[0] < 0 || coords[1] < 0 || coords[2] < 0) { - return undefined; - } - var factor = this.getTileGrid().getTileSize() * this.getTileGrid().getResolutions()[coords[0]]; - if (coords[1] * factor > width || coords[2] * factor > height) { - return undefined; - } - return url + tileCoord.join('/') + ".jpg"; - } - }); - - var tile = new ol.layer.Tile({ - preload: 0, - source: tileimage, - visible: true - }); - - var raster = new ol.source.Raster({ - sources: [tileimage], - crossOrigin: 'anonymous', - operation: function(pixels, data) { - var pixel = pixels[0]; - if (data.equalizedValues && pixel[3]!=0){ - pixel = getPixelValue(pixel, data.mean, data.equalizedValues); - } - return pixel; - }, - lib:{ - getPixelValue: getPixelValue, - rgb2hcl: rgb2hcl, - hcl2rgb: hcl2rgb, - rgb2xyz: rgb2xyz, - lab2xyz: lab2xyz, - xyz2lab: xyz2lab, - xyz2rgb: xyz2rgb, - Xn: Xn, - Yn: Yn, - Zn: Zn, - t0: t0, - t1: t1, - t2: t2, - t3: t3, - twoPi: twoPi - } - }); - - var contrastLayer = new ol.layer.Image({ - source: raster, - visible: false - }); - - var lubisMap = new ol.Map({ - layers: [ - tile, contrastLayer - ], - controls: ol.control.defaults().extend([new ol.control.FullScreen()]), - renderer: 'canvas', - target: ${target}, - logo: false, - view: new ol.View({ - projection: new ol.proj.Projection({ - code: 'PIXELS', - units: 'pixels', - extent: [0, 0, TILE_SIZE * resolutions[0], TILE_SIZE * resolutions[0]] // max extent of the pyramid at zoom level 0 - }), - maxZoom: resolutions.length + 1 // The min resolution of the pyramid is 1, so we add 2 client zoom equivalent to resolutions 0.5 and 0.25 - }) - }); - lubisMap.getView().fit([0, 0, width, height], lubisMap.getSize()); - lubisMap.getView().setRotation(rotation); - - diff --git a/chsdi/templates/luftbilder/viewer.mako b/chsdi/templates/luftbilder/viewer.mako deleted file mode 100644 index e51c614776..0000000000 --- a/chsdi/templates/luftbilder/viewer.mako +++ /dev/null @@ -1,425 +0,0 @@ -<%namespace name="lubis_map" file="lubis_map.mako"/> - -<% - from pyramid.url import route_url - from urllib.request import urlopen - from json import loads - - c = context - topic = 'luftbilder' - request = c.get('request') - baseUrl = '//' + c.get('baseUrl') - layerBodId = c.get('layer') - featureId = c.get('bildnummer') - contrast = 'true' if c.get('contrast')=='true' else 'false' - displayLink = True - ## This is a HACK to ensure backward compatibility - if not layerBodId.startswith('ch.'): - templateURL = request.registry.settings['search_base_url'] + '/rest/services/' + topic + '/SearchServer?features=ch.swisstopo.lubis-luftbilder_schwarzweiss,ch.swisstopo.lubis-luftbilder_farbe,ch.swisstopo.lubis-luftbilder-dritte-firmen,ch.swisstopo.lubis-luftbilder-dritte-kantone,ch.swisstopo.lubis-luftbilder_infrarot&type=featuresearch&searchText=' + featureId - searchFile = None - try: - searchFile = urlopen(templateURL) - res = loads(searchFile.read()) - layerBodId = res['results'][0]['attrs']['layer'] - except: - displayLink = False - finally: - if searchFile: - searchFile.close() - lang = c.get('lang') if c.get('lang') is not None else 'de' - title = request.translate(layerBodId) if c.get('datenherr') is None else request.translate(layerBodId) + ' (' + c.get('datenherr') + ')' - pageTitle = c.get('title') + ': ' + featureId - title += ': ' + pageTitle - loaderUrl = h.make_agnostic(route_url('ga_api', request)) - - aerialimages_data_host = request.registry.settings['aerialimages_data_host'] -%> - - - - - - - - - ${pageTitle} - - - - - - - - - - - -
${title}
-
-
- -
-
- - - - - diff --git a/chsdi/views/luftbilder.py b/chsdi/views/luftbilder.py deleted file mode 100644 index 574e41f093..0000000000 --- a/chsdi/views/luftbilder.py +++ /dev/null @@ -1,40 +0,0 @@ -# -*- coding: utf-8 -*- - -from pyramid.view import view_config - -from pyramid.renderers import render_to_response -import pyramid.httpexceptions as exc - - -@view_config(route_name='luftbilder') -def luftbilder(request): - width = request.params.get('width') - height = request.params.get('height') - rotation = request.params.get('rotation') - title = request.params.get('title') - bildnummer = request.params.get('bildnummer') - datenherr = request.params.get('datenherr') - layer = request.params.get('layer') - contrast = request.params.get('contrast') - lang = request.params.get('lang') - baseUrl = request.registry.settings.get('geoadminhost') - - if None in (width, height, title, bildnummer, layer): - raise exc.HTTPBadRequest('Missing parameter(s)') - - return render_to_response( - 'chsdi:templates/luftbilder/viewer.mako', - { - 'width': width, - 'height': height, - 'rotation': rotation, - 'title': title, - 'bildnummer': bildnummer, - 'datenherr': datenherr, - 'layer': layer, - 'baseUrl': baseUrl, - 'contrast': contrast, - 'lang': lang - }, - request=request - ) diff --git a/tests/integration/test_features_service.py b/tests/integration/test_features_service.py index cb39694150..182e0615cd 100644 --- a/tests/integration/test_features_service.py +++ b/tests/integration/test_features_service.py @@ -216,7 +216,7 @@ def test_find_boolean_false(self): self.assertEsrijsonFeature(resp.json['results'][0], 21781, hasGeometry=False) def test_find_wrong_boolean(self): - params = {'layer': 'ch.swisstopo.lubis-luftbilder_farbe', + params = {'layer': 'ch.swisstopo.lubis-luftbilder-dritte-firmen', 'searchField': 'orientierung', 'searchText': '3190', 'returnGeometry': 'false', diff --git a/tests/integration/test_luftbilder.py b/tests/integration/test_luftbilder.py deleted file mode 100644 index 2cc075768f..0000000000 --- a/tests/integration/test_luftbilder.py +++ /dev/null @@ -1,22 +0,0 @@ -# -*- coding: utf-8 -*- - -from tests.integration import TestsBase - - -class TestLuftbilder(TestsBase): - - # Old, we ensure backward compatibility here - def test_luftbilder_old(self): - params = {'width': '4641', 'height': '7000', 'title': 'Bildnummer', - 'bildnummer': '19280250012535', 'datenherr': 'swisstopo', 'layer': 'Luftbilder'} - resp = self.testapp.get('/luftbilder/viewer.html', params=params, status=200) - self.assertEqual(resp.content_type, 'text/html') - - def test_lufbilder(self): - params = {'width': '4641', 'height': '7000', 'title': 'Bildnummer', - 'bildnummer': '19280250012535', 'datenherr': 'swisstopo', 'layer': 'ch.swisstopo.lubis-luftbilder_schwarzweiss'} - resp = self.testapp.get('/luftbilder/viewer.html', params=params, status=200) - self.assertEqual(resp.content_type, 'text/html') - - def test_luftbilder_fail(self): - self.testapp.get('/luftbilder/viewer.html', status=400)