From: Ludovic CHEVALIER Date: Tue, 28 Apr 2015 07:19:24 +0000 (+0200) Subject: [PLUGINS] ~maj gis v4.26.1-->4.26.10 X-Git-Tag: production~10 X-Git-Url: http://git.cyclocoop.org/?p=lhc%2Fweb%2Fclavette_www.git;a=commitdiff_plain;h=ebeac5db7a6b2678204355fcf4837d4986f2b2a3 [PLUGINS] ~maj gis v4.26.1-->4.26.10 --- diff --git a/www/plugins/gis/formulaires/configurer_gis.php b/www/plugins/gis/formulaires/configurer_gis.php index 40bdc3b..23999bd 100644 --- a/www/plugins/gis/formulaires/configurer_gis.php +++ b/www/plugins/gis/formulaires/configurer_gis.php @@ -8,8 +8,12 @@ if (!defined('_ECRIRE_INC_VERSION')) return; */ function formulaires_configurer_gis_verifier_dist(){ $erreurs = array(); - - if ((_request('layer_defaut') == 'bing_aerial') OR in_array('bing_aerial', _request('layers'))){ + $layers = _request('layers'); + if (!is_array($layers)) { + $layers = array(); + } + + if ((_request('layer_defaut') == 'bing_aerial') OR in_array('bing_aerial', $layers)){ $obligatoire = 'api_key_bing'; if (!_request($obligatoire)){ $erreurs[$obligatoire] = _T('info_obligatoire'); @@ -22,8 +26,8 @@ function formulaires_configurer_gis_verifier_dist(){ $layer_defaut = lire_config('gis/layer_defaut'); // Si on change la couche par défaut ou si une couche google est présente dans la conf, le formulaire ne doit pas etre traiter en ajax if ((_request('layer_defaut') != $layer_defaut) - OR (count(array_intersect(array('google_roadmap', 'google_satellite', 'google_terrain'), _request('layers'))) > 0) - OR (in_array('bing_aerial', _request('layers')))) + OR (count(array_intersect(array('google_roadmap', 'google_satellite', 'google_terrain'), $layers)) > 0) + OR (in_array('bing_aerial', $layers))) refuser_traiter_formulaire_ajax(); } diff --git a/www/plugins/gis/gis_autoriser.php b/www/plugins/gis/gis_autoriser.php index 13d4c48..8f67652 100644 --- a/www/plugins/gis/gis_autoriser.php +++ b/www/plugins/gis/gis_autoriser.php @@ -15,7 +15,7 @@ function gis_autoriser(){}; * @param array $opt Des options * @return boolean true/false */ -function autoriser_gis_iconifier_dist($faire,$quoi){ +function autoriser_gis_iconifier_dist($faire,$quoi,$id,$qui,$opts){ return autoriser('modifier','gis',$id,$qui,$opts); } @@ -110,4 +110,4 @@ function autoriser_gis_supprimer_dist($faire,$quoi,$id,$qui,$opts){ } return autoriser('modifier','gis',$id,$qui,$opts); } -?> \ No newline at end of file +?> diff --git a/www/plugins/gis/gis_fonctions.php b/www/plugins/gis/gis_fonctions.php index 1c22da8..ac757ca 100755 --- a/www/plugins/gis/gis_fonctions.php +++ b/www/plugins/gis/gis_fonctions.php @@ -418,8 +418,11 @@ function gis_icon_properties($img=''){ $props .= "\n\"popup_anchor\": ". json_encode(array(1,-$h/1.2)); } - if ($shadow = find_in_path('images/marker_defaut_shadow.png')) + if ($shadow = find_in_path('images/marker_defaut_shadow.png')) { $props .= ",\n\"shadow\": ". json_encode(url_absolue($shadow)); + list($h,$w) = taille_image($shadow); + $props .= ",\n\"shadow_size\": ". json_encode(array($w,$h)); + } return $props; } diff --git a/www/plugins/gis/gis_options.php b/www/plugins/gis/gis_options.php index a02cc19..72616c6 100755 --- a/www/plugins/gis/gis_options.php +++ b/www/plugins/gis/gis_options.php @@ -9,7 +9,7 @@ $GLOBALS['logo_libelles']['id_gis'] = _T('gis:libelle_logo_gis'); $config = @unserialize($GLOBALS['meta']['gis']); -$GLOBALS['gis_layers'] = array ( +$gis_layers = array ( 'openstreetmap_mapnik' => array( 'nom' => 'OpenStreetMap', 'layer' => 'L.tileLayer.provider("OpenStreetMap")' @@ -31,7 +31,7 @@ $GLOBALS['gis_layers'] = array ( 'layer' => 'L.Google("ROADMAP")' ), 'google_satellite' => array( - 'nom' => 'Google Satelitte', + 'nom' => 'Google Satellite', 'layer' => 'L.Google("SATELLITE")' ), 'google_terrain' => array( @@ -58,6 +58,10 @@ $GLOBALS['gis_layers'] = array ( 'nom' => 'Thunderforest Outdoors', 'layer' => 'L.tileLayer.provider("Thunderforest.Outdoors")' ), + 'opentopomap' => array( + 'nom' => 'OpenTopoMap', + 'layer' => 'L.tileLayer.provider("OpenTopoMap")' + ), 'openmapsurfer' => array( 'nom' => 'OpenMapSurfer', 'layer' => 'L.tileLayer.provider("OpenMapSurfer")' @@ -160,4 +164,8 @@ $GLOBALS['gis_layers'] = array ( ) ); -?> \ No newline at end of file +if (isset($GLOBALS['gis_layers']) and is_array($GLOBALS['gis_layers'])) { + $GLOBALS['gis_layers'] = array_merge($gis_layers,$GLOBALS['gis_layers']); +} else { + $GLOBALS['gis_layers'] = $gis_layers; +} diff --git a/www/plugins/gis/javascript/gis_geocoder.js b/www/plugins/gis/javascript/gis_geocoder.js index 822cb7f..d3bf6fc 100644 --- a/www/plugins/gis/javascript/gis_geocoder.js +++ b/www/plugins/gis/javascript/gis_geocoder.js @@ -79,9 +79,9 @@ L.Geocoder = L.Class.extend({ else { place = response; } - + var street_components = []; - + if (place.address.country) { return_location.country = place.address.country; } @@ -99,8 +99,12 @@ L.Geocoder = L.Class.extend({ */ if (place.address.city) { return_location.locality = place.address.city; - }else if(place.address.county){ - street_components.push(place.address.pedestrian); + } else if (place.address.town) { + return_location.locality = place.address.town; + } else if (place.address.village) { + return_location.locality = place.address.village; + } else if (place.address.county) { + street_components.push(place.address.county); } if (place.address.postcode) { return_location.postcode = place.address.postcode; diff --git a/www/plugins/gis/lib/leaflet/plugins/KML.js b/www/plugins/gis/lib/leaflet/plugins/KML.js index 2a7839d..d521a30 100755 --- a/www/plugins/gis/lib/leaflet/plugins/KML.js +++ b/www/plugins/gis/lib/leaflet/plugins/KML.js @@ -69,6 +69,11 @@ L.Util.extend(L.KML, { l = this.parsePlacemark(el[j], xml, style); if (l) { layers.push(l); } } + el = xml.getElementsByTagName('GroundOverlay'); + for (var k = 0; k < el.length; k++) { + l = this.parseGroundOverlay(el[k]); + if (l) { layers.push(l); } + } return layers; }, @@ -87,9 +92,7 @@ L.Util.extend(L.KML, { var style = {}; var sl = xml.getElementsByTagName('Style'); - //for (var i = 0; i < sl.length; i++) { - var attributes = {color: true, width: true, Icon: true, href: true, - hotSpot: true}; + var attributes = { color: true, width: true, Icon: true, href: true, hotSpot: true }; function _parse(xml) { var options = {}; @@ -180,13 +183,28 @@ L.Util.extend(L.KML, { l = this.parsePlacemark(el[j], xml, style); if (l) { layers.push(l); } } + el = xml.getElementsByTagName('GroundOverlay'); + for (var k = 0; k < el.length; k++) { + if (!this._check_folder(el[k], xml)) { continue; } + l = this.parseGroundOverlay(el[k]); + if (l) { layers.push(l); } + } if (!layers.length) { return; } if (layers.length === 1) { return layers[0]; } return new L.FeatureGroup(layers); }, parsePlacemark: function (place, xml, style) { - var i, j, el, options = {}; + var h, i, j, el, options = {}; + + var multi = ['MultiGeometry', 'MultiTrack', 'gx:MultiTrack']; + for (h in multi) { + el = place.getElementsByTagName(multi[h]); + for (i = 0; i < el.length; i++) { + return this.parsePlacemark(el[i], xml, style); + } + } + el = place.getElementsByTagName('styleUrl'); for (i = 0; i < el.length; i++) { var url = el[i].childNodes[0].nodeValue; @@ -196,17 +214,13 @@ L.Util.extend(L.KML, { } var layers = []; - var parse = ['LineString', 'Polygon', 'Point']; + var parse = ['LineString', 'Polygon', 'Point', 'Track', 'gx:Track']; for (j in parse) { - // for jshint - if (true) - { - var tag = parse[j]; - el = place.getElementsByTagName(tag); - for (i = 0; i < el.length; i++) { - var l = this['parse' + tag](el[i], xml, options); - if (l) { layers.push(l); } - } + var tag = parse[j]; + el = place.getElementsByTagName(tag); + for (i = 0; i < el.length; i++) { + var l = this['parse' + tag.replace(/gx:/, '')](el[i], xml, options); + if (l) { layers.push(l); } } } @@ -248,6 +262,17 @@ L.Util.extend(L.KML, { return new L.Polyline(coords, options); }, + parseTrack: function (line, xml, options) { + var el = xml.getElementsByTagName('gx:coord'); + if (el.length === 0) { el = xml.getElementsByTagName('coord'); } + var coords = []; + for (var j = 0; j < el.length; j++) { + coords = coords.concat(this._read_gxcoords(el[j])); + } + if (!coords.length) { return; } + return new L.Polyline(coords, options); + }, + parsePoint: function (line, xml, options) { var el = line.getElementsByTagName('coordinates'); if (!el.length) { @@ -309,6 +334,54 @@ L.Util.extend(L.KML, { coords.push(new L.LatLng(ll[1], ll[0])); } return coords; + }, + + _read_gxcoords: function (el) { + var text = '', coords = []; + text = el.firstChild.nodeValue.split(' '); + coords.push(new L.LatLng(text[1], text[0])); + return coords; + }, + + parseGroundOverlay: function (xml) { + var latlonbox = xml.getElementsByTagName('LatLonBox')[0]; + var bounds = new L.LatLngBounds( + [ + latlonbox.getElementsByTagName('south')[0].childNodes[0].nodeValue, + latlonbox.getElementsByTagName('west')[0].childNodes[0].nodeValue + ], + [ + latlonbox.getElementsByTagName('north')[0].childNodes[0].nodeValue, + latlonbox.getElementsByTagName('east')[0].childNodes[0].nodeValue + ] + ); + var attributes = {Icon: true, href: true, color: true}; + function _parse(xml) { + var options = {}, ioptions = {}; + for (var i = 0; i < xml.childNodes.length; i++) { + var e = xml.childNodes[i]; + var key = e.tagName; + if (!attributes[key]) { continue; } + var value = e.childNodes[0].nodeValue; + if (key === 'Icon') { + ioptions = _parse(e); + if (ioptions.href) { options.href = ioptions.href; } + } else if (key === 'href') { + options.href = value; + } else if (key === 'color') { + options.opacity = parseInt(value.substring(0, 2), 16) / 255.0; + options.color = '#' + value.substring(6, 8) + value.substring(4, 6) + value.substring(2, 4); + } + } + return options; + } + var options = {}; + options = _parse(xml); + if (latlonbox.getElementsByTagName('rotation')[0] !== undefined) { + var rotation = latlonbox.getElementsByTagName('rotation')[0].childNodes[0].nodeValue; + options.rotation = parseFloat(rotation); + } + return new L.RotatedImageOverlay(options.href, bounds, {opacity: options.opacity, angle: options.rotation}); } }); @@ -322,12 +395,14 @@ L.KMLIcon = L.Icon.extend({ this.style.width = i.width + 'px'; this.style.height = i.height + 'px'; - if (this.anchorType.x === 'UNITS_FRACTION' || this.anchorType.x === 'fraction') { + if (this.anchorType.x === 'fraction' && this.anchorType.y === 'fraction') { img.style.marginLeft = (-this.anchor.x * i.width) + 'px'; - } - if (this.anchorType.y === 'UNITS_FRACTION' || this.anchorType.x === 'fraction') { img.style.marginTop = (-(1 - this.anchor.y) * i.height) + 'px'; } + if (this.anchorType.x === 'pixels' && this.anchorType.y === 'pixels') { + img.style.marginLeft = (-this.anchor.x) + 'px'; + img.style.marginTop = (this.anchor.y - i.height + 1) + 'px'; + } this.style.display = ''; }; return img; @@ -348,3 +423,34 @@ L.KMLMarker = L.Marker.extend({ } }); +// Inspired by https://github.com/bbecquet/Leaflet.PolylineDecorator/tree/master/src +L.RotatedImageOverlay = L.ImageOverlay.extend({ + options: { + angle: 0 + }, + _reset: function () { + L.ImageOverlay.prototype._reset.call(this); + this._rotate(); + }, + _animateZoom: function (e) { + L.ImageOverlay.prototype._animateZoom.call(this, e); + this._rotate(); + }, + _rotate: function () { + if (L.DomUtil.TRANSFORM) { + // use the CSS transform rule if available + this._image.style[L.DomUtil.TRANSFORM] += ' rotate(' + this.options.angle + 'deg)'; + } else if(L.Browser.ie) { + // fallback for IE6, IE7, IE8 + var rad = this.options.angle * (Math.PI / 180), + costheta = Math.cos(rad), + sintheta = Math.sin(rad); + this._image.style.filter += ' progid:DXImageTransform.Microsoft.Matrix(sizingMethod=\'auto expand\', M11=' + + costheta + ', M12=' + (-sintheta) + ', M21=' + sintheta + ', M22=' + costheta + ')'; + } + }, + getBounds: function() { + return this._bounds; + } +}); + diff --git a/www/plugins/gis/lib/leaflet/plugins/leaflet-providers.js b/www/plugins/gis/lib/leaflet/plugins/leaflet-providers.js index 62f650a..5f077fc 100644 --- a/www/plugins/gis/lib/leaflet/plugins/leaflet-providers.js +++ b/www/plugins/gis/lib/leaflet/plugins/leaflet-providers.js @@ -41,6 +41,11 @@ provider.url = provider.url(parts.splice(1, parts.length - 1).join('.')); } + var forceHTTP = window.location.protocol === 'file:' || provider.options.forceHTTP; + if (provider.url.indexOf('//') === 0 && forceHTTP) { + provider.url = 'http:' + provider.url; + } + // replace attribution placeholders with their values from toplevel provider attribution, // recursively var attributionReplacer = function (attr) { @@ -66,10 +71,9 @@ * see http://leafletjs.com/reference.html#tilelayer for options in the options map. */ - //jshint maxlen:220 L.TileLayer.Provider.providers = { OpenStreetMap: { - url: 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', + url: '//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', options: { attribution: '© OpenStreetMap' @@ -96,8 +100,15 @@ attribution: 'Map data: © OpenSeaMap contributors' } }, + OpenTopoMap: { + url: '//{s}.tile.opentopomap.org/{z}/{x}/{y}.png', + options: { + maxZoom: 16, + attribution: 'Map data: {attribution.OpenStreetMap}, SRTM | Map style: © OpenTopoMap (CC-BY-SA)' + } + }, Thunderforest: { - url: 'http://{s}.tile.thunderforest.com/{variant}/{z}/{x}/{y}.png', + url: '//{s}.tile.thunderforest.com/{variant}/{z}/{x}/{y}.png', options: { attribution: '© OpenCycleMap, {attribution.OpenStreetMap}', @@ -106,6 +117,7 @@ variants: { OpenCycleMap: 'cycle', Transport: 'transport', + TransportDark: 'transport-dark', Landscape: 'landscape', Outdoors: 'outdoors' } @@ -145,12 +157,18 @@ variants: { Full: 'full', Base: 'base', - RoadsAndLabels: 'roads_and_labels', + RoadsAndLabels: 'roads_and_labels' } }, MapQuestOpen: { - url: 'http://otile{s}.mqcdn.com/tiles/1.0.0/map/{z}/{x}/{y}.jpeg', + /* Mapquest does support https, but with a different subdomain: + * https://otile{s}-s.mqcdn.com/tiles/1.0.0/{type}/{z}/{x}/{y}.{ext} + * which makes implementing protocol relativity impossible. + */ + url: 'http://otile{s}.mqcdn.com/tiles/1.0.0/{type}/{z}/{x}/{y}.{ext}', options: { + type: 'map', + ext: 'jpg', attribution: 'Tiles Courtesy of MapQuest — ' + 'Map data {attribution.OpenStreetMap}', @@ -159,18 +177,25 @@ variants: { OSM: {}, Aerial: { - url: 'http://oatile{s}.mqcdn.com/tiles/1.0.0/sat/{z}/{x}/{y}.jpg', options: { + type: 'sat', attribution: 'Tiles Courtesy of MapQuest — ' + 'Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency' } + }, + HybridOverlay: { + options: { + type: 'hyb', + ext: 'png', + opacity: 0.9 + } } } }, MapBox: { url: function (id) { - return 'http://{s}.tiles.mapbox.com/v3/' + id + '/{z}/{x}/{y}.png'; + return '//{s}.tiles.mapbox.com/v3/' + id + '/{z}/{x}/{y}.png'; }, options: { attribution: @@ -180,7 +205,7 @@ } }, Stamen: { - url: 'http://{s}.tile.stamen.com/{variant}/{z}/{x}/{y}.png', + url: 'http://{s}.tile.stamen.com/{variant}/{z}/{x}/{y}.{ext}', options: { attribution: 'Map tiles by Stamen Design, ' + @@ -189,7 +214,8 @@ subdomains: 'abcd', minZoom: 0, maxZoom: 20, - variant: 'toner' + variant: 'toner', + ext: 'png' }, variants: { Toner: 'toner', @@ -198,31 +224,47 @@ TonerLines: 'toner-lines', TonerLabels: 'toner-labels', TonerLite: 'toner-lite', + Watercolor: { + options: { + variant: 'watercolor', + minZoom: 1, + maxZoom: 16 + } + }, Terrain: { options: { variant: 'terrain', minZoom: 4, - maxZoom: 18 + maxZoom: 18, + bounds: [[22, -132], [70, -56]] } }, TerrainBackground: { options: { variant: 'terrain-background', minZoom: 4, - maxZoom: 18 + maxZoom: 18, + bounds: [[22, -132], [70, -56]] } }, - Watercolor: { + TopOSMRelief: { options: { - variant: 'watercolor', - minZoom: 1, - maxZoom: 16 + variant: 'toposm-color-relief', + ext: 'jpg', + bounds: [[22, -132], [51, -56]] + } + }, + TopOSMFeatures: { + options: { + variant: 'toposm-features', + bounds: [[22, -132], [51, -56]], + opacity: 0.9 } } } }, Esri: { - url: 'http://server.arcgisonline.com/ArcGIS/rest/services/{variant}/MapServer/tile/{z}/{y}/{x}', + url: '//server.arcgisonline.com/ArcGIS/rest/services/{variant}/MapServer/tile/{z}/{y}/{x}', options: { variant: 'World_Street_Map', attribution: 'Tiles © Esri' @@ -336,7 +378,7 @@ * envirionments. */ url: - 'http://{s}.{base}.maps.cit.api.here.com/maptile/2.1/' + + '//{s}.{base}.maps.cit.api.here.com/maptile/2.1/' + 'maptile/{mapID}/{variant}/{z}/{x}/{y}/256/png8?' + 'app_id={app_id}&app_code={app_code}', options: { @@ -451,6 +493,108 @@ DarkMatter: 'dark_all', DarkMatterNoLabels: 'dark_nolabels' } + }, + HikeBike: { + url: 'http://{s}.tiles.wmflabs.org/hikebike/{z}/{x}/{y}.png', + options: { + attribution: '{attribution.OpenStreetMap}' + } + }, + BasemapAT: { + url: '//maps{s}.wien.gv.at/basemap/{variant}/normal/google3857/{z}/{y}/{x}.{format}', + options: { + attribution: 'Datenquelle: basemap.at', + subdomains: ['', '1', '2', '3', '4'], + bounds: [[46.358770, 8.782379], [49.037872, 17.189532]] + }, + variants: { + basemap: { + options: { + variant: 'geolandbasemap', + format: 'jpeg' + } + }, + highdpi: { + options: { + variant: 'bmaphidpi', + format: 'jpeg' + } + }, + grau: { + options: { + variant: 'bmapgrau', + format: 'png' + } + }, + overlay: { + options: { + variant: 'bmapoverlay', + format: 'png' + } + }, + orthofoto: { + options: { + variant: 'bmaporthofoto30cm', + format: 'jpeg' + } + } + } + }, + NASAGIBS: { + url: '//map1.vis.earthdata.nasa.gov/wmts-webmerc/{variant}/default/{time}/{tilematrixset}{maxZoom}/{z}/{y}/{x}.{format}', + options: { + attribution: + 'Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System ' + + '(ESDIS) with funding provided by NASA/HQ.', + bounds: [[-85.0511287776, -179.999999975], [85.0511287776, 179.999999975]], + minZoom: 1, + maxZoom: 9, + format: 'jpg', + time: '', + tilematrixset: 'GoogleMapsCompatible_Level' + }, + variants: { + ModisTerraTrueColorCR: 'MODIS_Terra_CorrectedReflectance_TrueColor', + ModisTerraBands367CR: 'MODIS_Terra_CorrectedReflectance_Bands367', + ViirsEarthAtNight2012: { + options: { + variant: 'VIIRS_CityLights_2012', + maxZoom: 8 + } + }, + ModisTerraLSTDay: { + options: { + variant: 'MODIS_Terra_Land_Surface_Temp_Day', + format: 'png', + maxZoom: 7, + opacity: 0.75 + } + }, + ModisTerraSnowCover: { + options: { + variant: 'MODIS_Terra_Snow_Cover', + format: 'png', + maxZoom: 8, + opacity: 0.75 + } + }, + ModisTerraAOD: { + options: { + variant: 'MODIS_Terra_Aerosol', + format: 'png', + maxZoom: 6, + opacity: 0.75 + } + }, + ModisTerraChlorophyll: { + options: { + variant: 'MODIS_Terra_Chlorophyll_A', + format: 'png', + maxZoom: 7, + opacity: 0.75 + } + } + } } }; diff --git a/www/plugins/gis/modeles/carte_gis_preview.html b/www/plugins/gis/modeles/carte_gis_preview.html index 2e9ca57..a6b38f8 100755 --- a/www/plugins/gis/modeles/carte_gis_preview.html +++ b/www/plugins/gis/modeles/carte_gis_preview.html @@ -1,6 +1,6 @@
- +#SET{autocenter,''}