better handling of unpacked kmz files

This commit is contained in:
Dave Conway-Jones 2021-09-28 17:58:10 +01:00
parent 3d337c75a6
commit 64db718fea
No known key found for this signature in database
GPG Key ID: 88BA2B8A411BE9FF
4 changed files with 12 additions and 3 deletions

View File

@ -1,5 +1,6 @@
### Change Log for Node-RED Worldmap ### Change Log for Node-RED Worldmap
- v2.16.2 - better handling of unpacked gpz objects.
- v2.16.0 - Allow specifying custom base map server. - v2.16.0 - Allow specifying custom base map server.
- v2.15.8 - Adjust ui check timing for UI worldmap. - v2.15.8 - Adjust ui check timing for UI worldmap.
- v2.15.7 - Tidy up geoJson handling a bit more. - v2.15.7 - Tidy up geoJson handling a bit more.

View File

@ -11,6 +11,7 @@ map web page for plotting "things" on.
### Updates ### Updates
- v2.16.2 - better handling of unpacked gpz objects.
- v2.16.0 - Allow specifying custom base map server. - v2.16.0 - Allow specifying custom base map server.
- v2.15.8 - Adjust ui check timing for UI worldmap. - v2.15.8 - Adjust ui check timing for UI worldmap.
- v2.15.7 - Tidy up geoJson handling a bit more. - v2.15.7 - Tidy up geoJson handling a bit more.

View File

@ -1,6 +1,6 @@
{ {
"name": "node-red-contrib-web-worldmap", "name": "node-red-contrib-web-worldmap",
"version": "2.16.1", "version": "2.16.2",
"description": "A Node-RED node to provide a web page of a world map for plotting things on.", "description": "A Node-RED node to provide a web page of a world map for plotting things on.",
"dependencies": { "dependencies": {
"cgi": "0.3.1", "cgi": "0.3.1",

View File

@ -111,6 +111,10 @@ var handleData = function(data) {
setMarker(data[prop]); setMarker(data[prop]);
// bnds.extend(markers[data[prop].name].getLatLng()); // bnds.extend(markers[data[prop].name].getLatLng());
} }
else if (data[prop].hasOwnProperty("filename") && data[prop].filename === "doc.kml") {
data = {command:{map:{overlay:"KML", kml:data[prop].payload}}};
doCommand(data.command); return;
}
else { console.log("SKIP A",data[prop]); } else { console.log("SKIP A",data[prop]); }
} }
// map.fitBounds(bnds.pad(0.25)); // map.fitBounds(bnds.pad(0.25));
@ -124,7 +128,6 @@ var handleData = function(data) {
data = {command:{map:{overlay:"KML", kml:data}}}; data = {command:{map:{overlay:"KML", kml:data}}};
} }
else if (data.indexOf("<gpx") != -1) { else if (data.indexOf("<gpx") != -1) {
console.log("GPX")
data = {command:{map:{overlay:"GPX", gpx:data}}}; data = {command:{map:{overlay:"GPX", gpx:data}}};
} }
} }
@ -203,11 +206,12 @@ var readFile = function(file) {
if (file.type && if (file.type &&
file.type.indexOf('text') === -1 && file.type.indexOf('text') === -1 &&
file.type.indexOf('kml') === -1 && file.type.indexOf('kml') === -1 &&
file.type.indexOf('kmz') === -1 &&
file.type.indexOf('json') === -1 && file.type.indexOf('json') === -1 &&
file.type.indexOf('image/jpeg') === -1 && file.type.indexOf('image/jpeg') === -1 &&
file.type.indexOf('image/png') === -1 && file.type.indexOf('image/png') === -1 &&
file.type.indexOf('image/tiff') === -1) { file.type.indexOf('image/tiff') === -1) {
console.log('File is not text, kml, jpeg, png, or json', file.type, file); console.log('File is not text, kml, kmz, jpeg, png, or json', file.type, file);
return; return;
} }
@ -229,6 +233,9 @@ var readFile = function(file) {
doCommand({map:{overlay:file.name, nvg:data}}); doCommand({map:{overlay:file.name, nvg:data}});
} }
} }
else if (data.indexOf('PK') === 0) {
console.log("ZIP FILE");
}
else { else {
try { try {
data = JSON.parse(data); data = JSON.parse(data);