// ==UserScript== // @name Open WME in EST // @description Opens the current Waze Map Editor view in Estonian Land Board Geoportal // @version 0.4 // @include /^https:\/\/(www|beta)\.waze\.com\/*\/(?!user\/)(.{2,6}\/)?editor.*$/ // @include https://xgis.maaamet.ee/maps/* // @include https://xgis.maaamet.ee/xgis2/page/app/* // @require https://greasyfork.org/scripts/13097-proj4js/code/Proj4js.js // @author script is based from orignal google maps script, modified by rain101 // @namespace https://greasyfork.org/users/207621 // @downloadURL none // ==/UserScript== console.log("WME_EE BEGINNING"); const icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAMCAYAAABiDJ37AAAArUlEQVQokbXMPQ6CMBxA8X80EMpgcdBRowaMB2NquKKLxEQ08WOCiR4BptLpeYjqS37rk5OpyU1Dbm7BjuaK5ObGzrzYmWegF7lpkKK6s68+7Kt3oA9F9UAO5ZlNWbMtL4FqDuUZUYs1syRjrpZBZklGslghcRwjIj8RRdEfhlprlFKkaRpEKYXWGmnbFmstfd8HsdbSdR3inONXOef+MByGAe890zQF8d4zjiNfdeREmfFbjlgAAAAASUVORK5CYII='; function gen_url() { Proj4js.defs["EPSG:3301"] = "+proj=lcc +lat_1=59.33333333333334 +lat_2=58 +lat_0=57.51755393055556 +lon_0=24 +x_0=500000 +y_0=6375000 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs"; let center_lonlat = (new OL.LonLat(W.map.getCenter().lon, W.map.getCenter().lat)); const point = new Proj4js.Point(center_lonlat.lon, center_lonlat.lat); // waze zoom leveles 0-10 const zoom = Waze.map.zoom; var array = [10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]; // If Waze zoom is 0, then we'll take first array element and the result is: // Pow(2, 10]) * 175 = 179200 // the result is opened map at level 1:179200 (landportal has 178985) var result = Math.pow(2, array[zoom]) * 175; //const moot = const src = new Proj4js.Proj("EPSG:900913"); const dst = new Proj4js.Proj("EPSG:3301"); Proj4js.transform(src, dst, point); // Normal Flash Estonian Landboard page // return 'http://xgis.maaamet.ee/xGIS/XGis?app_id=UU82&user_id=at&punkt=' + point.x + ',' + point.y + '&moot=4000'; // HTML5 Estonian Landboard page //return 'http://xgis.maaamet.ee/maps/XGis?app_id=UU82A&user_id=at&zlevel=' + zoom + ',' + point.x + ',' + point.y; //https://xgis.maaamet.ee/xgis2/page/app/maainfo?punkt=542228.98,6588663.63&moot=2000 return 'https://xgis.maaamet.ee/xgis2/page/app/maainfo?punkt=' + point.x + ',' + point.y + '&moot=' + result; } function init() { try { const element = $('.WazeControlPermalink'); if ($(element).length) { $('.WazeControlPermalink').prepend('EE'); $('#WMEtoEE').click(function() { window.open(gen_url(), '_blank'); }); console.log("WME_EE done"); } else { setTimeout(init, 1000); } } catch (err) { console.log("WME_EE - " + err); setTimeout(init, 1000); } } init();