[tarent-useful-scripts SCM] {mirkarte} branch master updated. 8720b010fead667914b39733403653fb06c9206a

mirabilos at evolvis.org mirabilos at evolvis.org
Fri Jun 13 16:24:14 CEST 2014


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Supplemental git repository mirkarte for Evolvis project useful-scripts".

The branch, master has been updated
       via  8720b010fead667914b39733403653fb06c9206a (commit)
       via  f0e254bbffb92a752bff3df42e6f1cd900beabc1 (commit)
       via  e275b7e2e5856476cc069e2e84b281b06e2edd4a (commit)
       via  6c5e8d79d7235abaa2062050142ad747462b7a75 (commit)
       via  08b8f3e5dfc750676b38b67ea8124993d4364092 (commit)
       via  9c1b63b981c42bdf27099e6c7574824231e0de01 (commit)
       via  23e52825ed6719a1cf2308fe0b46afa9a314f7cc (commit)
       via  e5e7c323b55b4d10309b224448a3f2dfea956e77 (commit)
       via  5d1f26e2016a5a3e932731cdae3b2efeb5276bea (commit)
      from  d8abf72bf3066f949dcf2203e964365c2af09530 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 8720b010fead667914b39733403653fb06c9206a
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Fri Jun 13 16:24:09 2014 +0200

    final tweaks

commit f0e254bbffb92a752bff3df42e6f1cd900beabc1
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Fri Jun 13 15:30:07 2014 +0200

    proper attributions for TC waypoints

commit e275b7e2e5856476cc069e2e84b281b06e2edd4a
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Fri Jun 13 15:29:28 2014 +0200

    globalose the attributions array

commit 6c5e8d79d7235abaa2062050142ad747462b7a75
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Fri Jun 13 15:12:29 2014 +0200

    working waypoint import, except attributions
    
    (also, GPX-to-GeoJSON does not properly handle TC GPX files…)
    (but we do our best)

commit 08b8f3e5dfc750676b38b67ea8124993d4364092
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Fri Jun 13 14:39:51 2014 +0200

    track the filename

commit 9c1b63b981c42bdf27099e6c7574824231e0de01
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Fri Jun 13 14:32:05 2014 +0200

    initialise the Zoom control after the Layers control, for it contains the Menu

commit 23e52825ed6719a1cf2308fe0b46afa9a314f7cc
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Fri Jun 13 14:31:28 2014 +0200

    globalise the Layers control

commit e5e7c323b55b4d10309b224448a3f2dfea956e77
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Fri Jun 13 14:26:53 2014 +0200

    decide on quotes: double quotes for strings (like BASIC) except if they contain HTML or are copied from offsite

commit 5d1f26e2016a5a3e932731cdae3b2efeb5276bea
Author: Thorsten Glaser <tg at mirbsd.org>
Date:   Fri Jun 13 14:25:24 2014 +0200

    branding

-----------------------------------------------------------------------

Summary of changes:
 mirkarte.js |  192 +++++++++++++++++++++++++++++++++++++----------------------
 1 file changed, 120 insertions(+), 72 deletions(-)

diff --git a/mirkarte.js b/mirkarte.js
index f6580f8..6d2cd05 100644
--- a/mirkarte.js
+++ b/mirkarte.js
@@ -21,12 +21,30 @@
 var isNum = /^-?[0-9]*(\.[0-9]*)?$/;
 var isTwoNum = /^-?[0-9]*(\.[0-9]*)?,-?[0-9]*(\.[0-9]*)?$/;
 var map_initialised = false, myzoomcontrol_text;
-var map, marker = false, params, params_saved = '';
+var map, maplayers, marker = false, params, params_saved = "";
+
+var attributions = {
+	"OSM": '© <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
+	"OCM": '© <a href="http://www.opencyclemap.org">OpenCycleMap</a>, <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
+	"MapQuestOpen": 'Tiles Courtesy of <a href="http://www.mapquest.com/">MapQuest</a> — Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
+	"MapQuestAerial": 'Tiles Courtesy of <a href="http://www.mapquest.com/">MapQuest</a> — Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency',
+	"MapBox": 'Imagery from <a href="http://mapbox.com/about/maps/">MapBox</a> — Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
+	"Stamen": 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> — Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
+	"Esri": "Tiles © Esri",
+	"EsriDeLorme": "Tiles © Esri — Copyright: ©2012 DeLorme",
+	"EsriWorldTopoMap": "Tiles © Esri — Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community",
+	"EsriWorldImagery": "Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community",
+	"EsriOceanBasemap": "Tiles © Esri — Sources: GEBCO, NOAA, CHS, OSU, UNH, CSUMB, National Geographic, DeLorme, NAVTEQ, and Esri",
+	"EsriNatGeoWorldMap": "Tiles © Esri — National Geographic, Esri, DeLorme, NAVTEQ, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, iPC",
+	"Google": 'Map data © <a href="http://googlemaps.com">Google</a>',
+	"Geocommons": 'Tiles by Geocommons © <a href="http://geocommons.com/overlays/acetate">Esri & Stamen</a>. © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
+	"TC": '© <a href="http://www.terracaching.com/">Terra Interactive, LLC</a>'
+    };
 
 function zeropad(n, len) {
-	n = '' + n;
+	n = "" + n;
 	while (n.length < len)
-		n = '0' + n;
+		n = "0" + n;
 	return (n);
 }
 
@@ -57,7 +75,7 @@ function llformat(lat, lon) {
 
 function marker_popup(marker, text) {
 	marker.bindPopup(text);
-	marker.on('popupopen', function () {
+	marker.on("popupopen", function () {
 		var xtext, f, pos = marker.getLatLng();
 
 		f = llformat(pos.lat, pos.lng);
@@ -76,9 +94,20 @@ function nuke_marker() {
 	update_hash();
 }
 
+var MarkerWithAttribution = L.Marker.extend({
+	options: {
+		"attribution": ""
+	},
+
+	getAttribution: function () {
+		return (this.options.attribution);
+	}
+});
+
 var show_menu_marker = (function () {
 	var hasfile = false;
 	var filestr = "Your browser does not support the File API";
+	var current_filename = "";
 
 	if (window.File && window.FileList && window.FileReader && window.Blob) {
 		hasfile = true;
@@ -90,25 +119,58 @@ var show_menu_marker = (function () {
 	}
 
 	var handleGpxFileLoaded = function (e) {
-		$("gpxupload").update("GPX loaded.");
+		$("gpxupload").update("GPX " + current_filename + " loaded.");
 		if (!/<gpx/.test(e.target.result))
-			$("gpxupload").update("Not a valid GPX file.");
+			$("gpxupload").update(current_filename +
+			    " is not a valid GPX file.");
 		var dom = (new DOMParser()).parseFromString(e.target.result,
 		    "text/xml");
 		var gjsn = toGeoJSON.gpx(dom);
-		alert(JSON.stringify(gjsn));
+		maplayers.addOverlay(L.geoJson(gjsn, {
+			pointToLayer: function (feature, latlng) {
+				var o = {}, res;
+
+				if (feature.properties["sym"] == "TerraCache") {
+					o["icon"] = tc_icon;
+					o["attribution"] = attributions["TC"];
+				}
+				feature["_isWP"] = latlng;
+				return (new MarkerWithAttribution(latlng, o));
+			},
+			onEachFeature: function (feature, layer) {
+				if (!feature["_isWP"])
+					return;
+				var s, f, x, pos = feature["_isWP"];
+
+				f = llformat(pos.lat, pos.lng);
+				x = feature.properties["name"];
+				s = (x ? (x + " ") : "") + f[0] + " " + f[1];
+
+				x = feature.properties["desc"];
+				if (/TC/.test(feature.properties["name"]) &&
+				    feature.properties["sym"] == "TerraCache")
+					x = '<a href="http://www.terracaching.com/viewcache.cgi?ID=' +
+					    feature.properties.name + '">' +
+					    (x ? x : "(no description)") +
+					    '</a>';
+				if (x)
+					s = s + "<br />" + x;
+				layer.bindPopup(s);
+			}
+		    }).addTo(map), current_filename);
 	};
 
 	var handleZipExtraction = function (entry) {
-		$("gpxupload").update("Extracting");
+		current_filename = entry.filename;
+		$("gpxupload").update("Extracting " + current_filename);
 		entry.getData(new zip.BlobWriter(), function (asblob) {
-			$("gpxupload").update("Extracted");
+			$("gpxupload").update("Extracted " + current_filename);
 			var reader = new FileReader();
 			reader.onload = handleGpxFileLoaded;
 			reader.readAsText(asblob);
 		    }, function (current, total) {
-			$("gpxupload").update("Extracting... " +
-			    current + "/" + total);
+			$("gpxupload").update("Extracting " +
+			    current_filename + "… " + current + "/" + total);
 		    }, true);
 	};
 
@@ -125,19 +187,24 @@ var show_menu_marker = (function () {
 			ents.appendChild(new Element("li").update(a));
 		    });
 		if (ents.empty())
-			ents = "Empty ZIP file.";
-		$("gpxupload").update(ents);
+			$("gpxupload").update("Empty ZIP file: " +
+			    current_filename);
+		else
+			$("gpxupload").update("Directory of " +
+			    current_filename + ":").appendChild(ents);
 	};
 
 	var handleFileSelect = function (e, filetype, cb) {
 		var reader, f = e.target.files[0];
 
 		if (!f) {
+			current_filename = "";
 			$("gpxupload").update("No file found.");
 			return;
 		}
-		$("gpxupload").update("Loading…");
-		if (filetype == 'zip') {
+		current_filename = f.name;
+		$("gpxupload").update("Loading " + current_filename + "…");
+		if (filetype == "zip") {
 			zip.createReader(new zip.BlobReader(f),
 			    function (zipReader) {
 				zipReader.getEntries(cb);
@@ -148,7 +215,7 @@ var show_menu_marker = (function () {
 		} else {
 			reader = new FileReader();
 			reader.onload = cb;
-			if (filetype == 'text')
+			if (filetype == "text")
 				reader.readAsText(f);
 			else
 				reader.readAsBinaryString(f);
@@ -156,11 +223,11 @@ var show_menu_marker = (function () {
 	};
 
 	var handleGpxFileSelect = function (e) {
-		handleFileSelect(e, 'text', handleGpxFileLoaded);
+		handleFileSelect(e, "text", handleGpxFileLoaded);
 	};
 
 	var handleZipFileSelect = function (e) {
-		handleFileSelect(e, 'zip', handleZipFileLoaded);
+		handleFileSelect(e, "zip", handleZipFileLoaded);
 	};
 
 	var res = function () {
@@ -190,7 +257,7 @@ if (typeof(window.onhashchange) !== "undefined" &&
 				prevhash = newhash;
 				/*
 				 * Event.fire(document, "hashchange");
-				 * doesn't work here
+				 * doesn’t work here
 				 */
 				fn_hashchange(this);
 			}
@@ -215,7 +282,7 @@ var tc_icon = L.icon({
 	"shadowUrl": "tc/markerShadow.png",
 	"iconSize": [20, 34],
 	"iconAnchor": [10, 34],
-	"infoWindowAnchor": [10, 15],
+	"popupAnchor": [0, -30],
 	"shadowSize": [37, 34]
 });
 var fn_mousemove = function (e) {
@@ -237,13 +304,13 @@ var fn_hashchange = function (event) {
 		params = {};
 		$H(newhash.parseQuery()).each(function (pair) {
 			switch (pair.key) {
-			case 'center_lat':
-			case 'center_lon':
-			case 'll':
-			case 'zoom':
-			case 'mlat':
-			case 'mlon':
-			case 'm':
+			case "center_lat":
+			case "center_lon":
+			case "ll":
+			case "zoom":
+			case "mlat":
+			case "mlon":
+			case "m":
 				params[pair.key] = pair.value;
 				break;
 			}
@@ -329,7 +396,7 @@ var fn_hashchange = function (event) {
 				marker = L.marker([mlat, mlon], {
 					"icon": marker_icon,
 					"draggable": true
-				    }).addTo(map).on('dragend', function(e) {
+				    }).addTo(map).on("dragend", function(e) {
 					var newloc = marker.getLatLng();
 
 					params["m"] = newloc.lat + "," + newloc.lng;
@@ -371,46 +438,14 @@ $(document).observe("dom:loaded", function () {
 		"attributionControl": false,
 		"zoomControl": false
 	    });
-	L.control.attribution({"prefix": "MirKarte (Beta) | " +
+	L.control.attribution({"prefix": '<a href="https://evolvis.org/plugins/scmgit/cgi-bin/gitweb.cgi?p=useful-scripts/mirkarte.git">MirKarte</a> (Beta) | ' +
 	    L.Control.Attribution.prototype.options.prefix}).addTo(map);
-	var myzoomclass = L.Control.Zoom.extend({
-		onAdd: function (map) {
-			var container = L.Control.Zoom.prototype.onAdd.apply(this, [map]);
-
-			myzoomcontrol_text = this._createButton("-",
-			    "Menu", "myzoomcontrol-text", false,
-			    show_menu_marker, false);
-			container.insertBefore(myzoomcontrol_text,
-			    this._zoomOutButton);
-
-			return (container);
-		}
-	    });
-	var myzoomcontrol = new myzoomclass();
-	map.addControl(myzoomcontrol);
-	var attributions = {
-		"OSM": '© <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
-		"OCM": '© <a href="http://www.opencyclemap.org">OpenCycleMap</a>, <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
-		"MapQuestOpen": 'Tiles Courtesy of <a href="http://www.mapquest.com/">MapQuest</a> — Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
-		"MapQuestAerial": 'Tiles Courtesy of <a href="http://www.mapquest.com/">MapQuest</a> — Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency',
-		"MapBox": 'Imagery from <a href="http://mapbox.com/about/maps/">MapBox</a> — Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
-		"Stamen": 'Map tiles by <a href="http://stamen.com">Stamen Design</a>, <a href="http://creativecommons.org/licenses/by/3.0">CC BY 3.0</a> — Map data © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
-		"Esri": "Tiles © Esri",
-		"EsriDeLorme": "Tiles © Esri — Copyright: ©2012 DeLorme",
-		"EsriWorldTopoMap": "Tiles © Esri — Esri, DeLorme, NAVTEQ, TomTom, Intermap, iPC, USGS, FAO, NPS, NRCAN, GeoBase, Kadaster NL, Ordnance Survey, Esri Japan, METI, Esri China (Hong Kong), and the GIS User Community",
-		"EsriWorldImagery": "Tiles © Esri — Source: Esri, i-cubed, USDA, USGS, AEX, GeoEye, Getmapping, Aerogrid, IGN, IGP, UPR-EGP, and the GIS User Community",
-		"EsriOceanBasemap": "Tiles © Esri — Sources: GEBCO, NOAA, CHS, OSU, UNH, CSUMB, National Geographic, DeLorme, NAVTEQ, and Esri",
-		"EsriNatGeoWorldMap": "Tiles © Esri — National Geographic, Esri, DeLorme, NAVTEQ, UNEP-WCMC, USGS, NASA, ESA, METI, NRCAN, GEBCO, NOAA, iPC",
-		"Google": 'Map data © <a href="http://googlemaps.com">Google</a>',
-		"Geocommons": 'Tiles by Geocommons © <a href="http://geocommons.com/overlays/acetate">Esri & Stamen</a>. © <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>',
-		"TC": "© 2004-2014, Terra Interactive, LLC — http://www.terracaching.com/"
-	    };
-	var baseMaps = function (map, layers) {
+	maplayers = function (map, layers) {
 		var baseMaps = {};
 		var n = layers.length;
 
 		for (var i = 0; i < n; ++i) {
-			var data = layers[i]; //Object.clone(layers[i]);
+			var data = layers[i];
 			var name = data["_name"];
 			var url = data["_url"];
 			var layer;
@@ -426,9 +461,7 @@ $(document).observe("dom:loaded", function () {
 				layer.addTo(map);
 			baseMaps[name] = layer;
 		}
-		L.control.layers(baseMaps).addTo(map);
-
-		return (baseMaps);
+		return (L.control.layers(baseMaps).addTo(map));
 	    } (map, [
 		{
 			"_name": "OpenStreetMap (0..18)",
@@ -617,20 +650,35 @@ too much */
 			"attribution": attributions["OCM"]
 		}
 	    ]);
+	var myzoomclass = L.Control.Zoom.extend({
+		onAdd: function (map) {
+			var container = L.Control.Zoom.prototype.onAdd.apply(this, [map]);
+
+			myzoomcontrol_text = this._createButton("-",
+			    "Menu", "myzoomcontrol-text", false,
+			    show_menu_marker, false);
+			container.insertBefore(myzoomcontrol_text,
+			    this._zoomOutButton);
+
+			return (container);
+		}
+	    });
+	var myzoomcontrol = new myzoomclass();
+	map.addControl(myzoomcontrol);
 	L.control.scale().addTo(map);
 	map_initialised = true;
-	map.on('moveend', function () {
+	map.on("moveend", function () {
 		var newloc = map.getCenter();
 
 		params["ll"] = newloc.lat + "," + newloc.lng;
 		update_hash();
 	    });
-	map.on('zoomend', function () {
+	map.on("zoomend", function () {
 		myzoomcontrol_text.innerHTML = map.getZoom();
 		params["zoom"] = map.getZoom();
 		update_hash();
 	    });
-	map.on('contextmenu', function (e) {
+	map.on("contextmenu", function (e) {
 		var f = llformat(e.latlng.lat, e.latlng.lng);
 
 		if (marker === false)
@@ -640,9 +688,9 @@ too much */
 		    e.latlng.lat + "," + e.latlng.lng + "<br />dm: " +
 		    f[0] + " " + f[1]).openOn(map);
 	    });
-	map.on('mousemove', fn_mousemove);
-	map.on('dragstart', function () { map.off('mousemove', fn_mousemove); });
-	map.on('dragend', function () { map.on('mousemove', fn_mousemove); });
+	map.on("mousemove", fn_mousemove);
+	map.on("dragstart", function () { map.off("mousemove", fn_mousemove); });
+	map.on("dragend", function () { map.on("mousemove", fn_mousemove); });
 	fn_hashchange(false);
 	$("map").focus();
 });


hooks/post-receive
-- 
Supplemental git repository mirkarte for Evolvis project useful-scripts
(Evolvis project useful-scripts repository mirkarte)


More information about the useful-scripts-commits mailing list