diff --git a/package.json b/package.json index 6b1e0522..c5c4c835 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "colorbrewer": "^1.5.6", "csv2geojson": "5.1.2", "dompurify": "^3.0.11", - "georsstogeojson": "^0.1.0", + "georsstogeojson": "^0.2.0", "jsdom": "^24.0.0", "leaflet": "1.9.4", "leaflet-contextmenu": "^1.4.0", diff --git a/umap/static/umap/js/modules/formatter.js b/umap/static/umap/js/modules/formatter.js index 99677e0f..4f1059ed 100644 --- a/umap/static/umap/js/modules/formatter.js +++ b/umap/static/umap/js/modules/formatter.js @@ -1,4 +1,4 @@ -/* Uses globals for: csv2geojson, osmtogeojson, GeoRSSToGeoJSON (not available as ESM) */ +/* Uses globals for: csv2geojson, osmtogeojson (not available as ESM) */ import { translate } from './i18n.js' export const EXPORT_FORMATS = { @@ -115,7 +115,8 @@ export class Formatter { } async fromGeoRSS(str) { - return GeoRSSToGeoJSON(this.toDom(str)) + const GeoRSSToGeoJSON = await import('../../vendors/georsstogeojson/GeoRSSToGeoJSON.js') + return GeoRSSToGeoJSON.parse(this.toDom(str)) } toDom(x) { diff --git a/umap/static/umap/vendors/georsstogeojson/GeoRSSToGeoJSON.js b/umap/static/umap/vendors/georsstogeojson/GeoRSSToGeoJSON.js index 560f0bb5..4fa2e1bc 100644 --- a/umap/static/umap/vendors/georsstogeojson/GeoRSSToGeoJSON.js +++ b/umap/static/umap/vendors/georsstogeojson/GeoRSSToGeoJSON.js @@ -1,89 +1,120 @@ -var GeoRSSToGeoJSON = function (dom, options) { +export function parse(dom, options) { + const g = { + type: 'FeatureCollection', + features: [], + } - function get(x, y) { return x.getElementsByTagName(y); } - function get1(x, y) { var n = get(x, y); return n.length ? n[0] : null; } - function norm(el) { if (el.normalize) { el.normalize(); } return el; } - function nodeVal(x) { if (x) {norm(x);} return x && x.firstChild && x.firstChild.nodeValue; } - function attr(x, y) { return x.getAttribute(y); } - - var g = { - type: 'FeatureCollection', - features: [] - }; - - function geom (node) { - - function p(c) {return parseFloat(c);} - function r(c) {return c.reverse().map(p);} // we have latlon we want lonlat - function e(f) {var _=[]; for (var i=0; i -