From 7da988d8ab31ea66c546b68700bfd9ecdfd9d432 Mon Sep 17 00:00:00 2001 From: Yannick Vaucher Date: Fri, 21 Aug 2020 12:06:10 +0200 Subject: [PATCH 1/3] Travis: exclude new branch from build --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index 4ba2ffc3ce..da98e0e6dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -47,3 +47,7 @@ script: after_success: - if [ -z "$DOCS" ] ; then travis_after_tests_success; fi - if [ -n "$DOCS" ] ; then ./.travis_push_doc; fi + +branches: + except: + - /^merge-branch-.*$/ From b4f509a0d5f2eeedc807ee8ef5e2c887a17acf67 Mon Sep 17 00:00:00 2001 From: Yannick Payot Date: Thu, 26 Jan 2023 18:09:20 +0100 Subject: [PATCH 2/3] WIP projection swisstopo --- .../geo_view/geo_raster_layer.py | 37 +++++++++++++++++-- .../geo_view/geo_raster_layer_view.xml | 3 ++ .../static/src/js/geoengine_swisstopo.js | 14 ++----- 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/geoengine_swisstopo/geo_view/geo_raster_layer.py b/geoengine_swisstopo/geo_view/geo_raster_layer.py index 94d6da30b6..f38394e3b1 100644 --- a/geoengine_swisstopo/geo_view/geo_raster_layer.py +++ b/geoengine_swisstopo/geo_view/geo_raster_layer.py @@ -1,12 +1,43 @@ # Copyright 2019 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl). -from odoo import fields, models +from odoo import api, fields, models + + +BASE_URL = ( + "https://wmts{{0-9}}.geo.admin.ch/1.0.0/{layername}/default/" + "{time}/{matrix_set}/{{TileSetId}}/{{TileRow}}/{{TileCol}}.{ext}" +) class GeoRasterLayer(models.Model): _inherit = 'geoengine.raster.layer' raster_type = fields.Selection(selection_add=[('swisstopo', 'Swisstopo')]) - layername = fields.Char('Layer Machine Name') - time = fields.Char('Time Dimension') + projection = fields.Char('Projection', default="EPSG:21781") + layername = fields.Char("Layer Machine Name", default="ch.swisstopo.pixelkarte-farbe") + matrix_set = fields.Selection( + [ + ("2056", "LV95/CH1903+ (EPSG:2056)"), + ("21781", "LV03/CH1903 (EPSG:21781)"), + ("4326", "LV95/CH1903+ (EPSG:4326)"), + ("3857", "LV95/CH1903+ (EPSG:3857, as used in OSM, Bing, Google Map)"), + ], + default="21781", + string='TileMatrixSet', + ) + time = fields.Char('Time Dimension', default="current") + wmts_url = fields.Char(compute="_compute_wmts_url", readonly=True, store=True) + + @api.depends("raster_type", "layername", "time", "matrix_set", "format_suffix") + def _compute_wmts_url(self): + for record in self: + if record.raster_type == "swisstopo": + record.wmts_url = BASE_URL.format( + layername=record.layername or "ch.swisstopo.pixelkarte-farbe", + time=record.time or "current", + matrix_set=record.matrix_set or "21781", + ext=record.format_suffix or "jpeg", + ) + else: + record.wmts_url = False diff --git a/geoengine_swisstopo/geo_view/geo_raster_layer_view.xml b/geoengine_swisstopo/geo_view/geo_raster_layer_view.xml index 73ac646635..195af38441 100644 --- a/geoengine_swisstopo/geo_view/geo_raster_layer_view.xml +++ b/geoengine_swisstopo/geo_view/geo_raster_layer_view.xml @@ -18,6 +18,9 @@ + + + diff --git a/geoengine_swisstopo/static/src/js/geoengine_swisstopo.js b/geoengine_swisstopo/static/src/js/geoengine_swisstopo.js index 60062ac93f..c51d87e7a2 100644 --- a/geoengine_swisstopo/static/src/js/geoengine_swisstopo.js +++ b/geoengine_swisstopo/static/src/js/geoengine_swisstopo.js @@ -9,8 +9,6 @@ var RESOLUTIONS = [ 0.25, 0.1 ]; -var BASE_URL = 'https://wmts{0-9}.geo.admin.ch/1.0.0/{Layer}/default/{Time}/21781/{TileMatrix}/{TileRow}/{TileCol}.{format}'; - var ATTRIBUTIONS = 'swisstopo'; /** @@ -89,25 +87,19 @@ odoo.define('geoengine_swisstopo.BackgroundLayers', function (require) { var out = this._super.apply(this, arguments); if (l.raster_type == 'swisstopo') { var format = l.format_suffix || 'jpeg'; - var layer = l.layername || 'ch.swisstopo.pixelkarte-farbe'; - var url = BASE_URL.replace('{format}', format); - var projection = ol.proj.get(PROJECTION_CODE); + var projection = ol.proj.get(l.projection || 'EPSG:21781'); var source = new ol.source.WMTS({ attributions: [ new ol.Attribution({ html: ATTRIBUTIONS, }) ], - url: url, - dimensions: { - 'Time': l.time || 'current', - }, + url: l.wmts_url, projection: projection, requestEncoding: 'REST', - layer: layer, + version: '1.0.0', style: 'default', - matrixSet: '21781', format: 'image/' + format, tileGrid: this.createTileGrid(), crossOrigin: 'anonymous', From 7f53ff4c28d802fbd3af36dbccdeac7bff8b8c49 Mon Sep 17 00:00:00 2001 From: cyrilmanuel Date: Thu, 24 Aug 2023 13:39:13 +0200 Subject: [PATCH 3/3] push working branch --- base_geoengine/geo_view/geo_raster_layer.py | 2 +- .../geo_view/geo_raster_layer.py | 3 +-- .../static/src/js/geoengine_swisstopo.js | 22 ++++++++++++------- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/base_geoengine/geo_view/geo_raster_layer.py b/base_geoengine/geo_view/geo_raster_layer.py index 4180dc8aef..d4b25ef8f9 100644 --- a/base_geoengine/geo_view/geo_raster_layer.py +++ b/base_geoengine/geo_view/geo_raster_layer.py @@ -75,7 +75,7 @@ class GeoRasterLayer(models.Model): @api.depends('raster_type', 'is_wmts') def _compute_has_type(self): for rec in self: - rec.has_type = rec.raster_type == 'is_wmts' + rec.has_type = rec.raster_type @api.multi @api.depends('raster_type') diff --git a/geoengine_swisstopo/geo_view/geo_raster_layer.py b/geoengine_swisstopo/geo_view/geo_raster_layer.py index f38394e3b1..6589a948fb 100644 --- a/geoengine_swisstopo/geo_view/geo_raster_layer.py +++ b/geoengine_swisstopo/geo_view/geo_raster_layer.py @@ -6,10 +6,9 @@ BASE_URL = ( "https://wmts{{0-9}}.geo.admin.ch/1.0.0/{layername}/default/" - "{time}/{matrix_set}/{{TileSetId}}/{{TileRow}}/{{TileCol}}.{ext}" + "{time}/{matrix_set}/{{TileMatrix}}/{{TileRow}}/{{TileCol}}.{ext}" ) - class GeoRasterLayer(models.Model): _inherit = 'geoengine.raster.layer' diff --git a/geoengine_swisstopo/static/src/js/geoengine_swisstopo.js b/geoengine_swisstopo/static/src/js/geoengine_swisstopo.js index c51d87e7a2..510776fb81 100644 --- a/geoengine_swisstopo/static/src/js/geoengine_swisstopo.js +++ b/geoengine_swisstopo/static/src/js/geoengine_swisstopo.js @@ -16,22 +16,28 @@ var ATTRIBUTIONS = 'swi */ var EXTENT = [420000, 30000, 900000, 350000]; -var PROJECTION_CODE = "EPSG:21781"; +var PROJECTION_CODE_1 = "EPSG:21781"; +var PROJECTION_CODE_2 = "EPSG:2056"; +var PROJECTION_CODE_3 = "EPSG:4326"; -var init_EPSG_21781 = function (self) { +var init_EPSG_PROJ = function (self) { // Adding proj4 self.jsLibs.push( '/geoengine_swisstopo/static/lib/proj4.js' ); }; -var define_EPSG_21781 = function () { +var define_EPSG_SUISSE = function () { // add swiss projection to allow conversions - if (!ol.proj.get(PROJECTION_CODE)) { + if (!ol.proj.get(PROJECTION_CODE_1)) { proj4.defs('EPSG:21781', '+proj=somerc +lat_0=46.95240555555556 ' + '+lon_0=7.439583333333333 +k_0=1 +x_0=600000 +y_0=200000 +ellps=bessel ' + '+towgs84=674.4,15.1,405.3,0,0,0,0 +units=m +no_defs'); } + if (!ol.proj.get(PROJECTION_CODE_2)) { + proj4.defs("EPSG:2056","+proj=somerc +lat_0=46.9524055555556 +lon_0=7.43958333333333 +k_0=1 +x_0=2600000 +y_0=1200000 +ellps=bessel +towgs84=674.374,15.056,405.346,0,0,0,0 +units=m +no_defs +type=crs"); + } + proj4.defs("EPSG:4326","+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees"); }; @@ -44,10 +50,10 @@ odoo.define('geoengine_swisstopo.projection_EPSG_21781', function (require) { GeoengineWidgets.FieldGeoEngineEditMap.include({ init: function (parent) { this._super.apply(this, arguments); - init_EPSG_21781(this); + init_EPSG_PROJ(this); }, _render: function (parent) { - define_EPSG_21781(); + define_EPSG_SUISSE(); this._super.apply(this, arguments); }, @@ -55,10 +61,10 @@ odoo.define('geoengine_swisstopo.projection_EPSG_21781', function (require) { GeoengineView.include({ init: function (parent) { this._super.apply(this, arguments); - init_EPSG_21781(this); + init_EPSG_PROJ(this); }, _render: function (parent) { - define_EPSG_21781(); + define_EPSG_SUISSE(); this._super.apply(this, arguments); },