mirror of
https://github.com/umap-project/umap.git
synced 2025-04-29 03:42:37 +02:00
wip: simpler syntax for dynamic import in formatters
This commit is contained in:
parent
891f04656f
commit
741fc70a17
2 changed files with 8 additions and 17 deletions
|
@ -3,19 +3,12 @@ import { translate } from './i18n.js'
|
||||||
|
|
||||||
export default class Formatter {
|
export default class Formatter {
|
||||||
async fromGPX(str) {
|
async fromGPX(str) {
|
||||||
let togeojson
|
const togeojson = await import('../../vendors/togeojson/togeojson.es.js')
|
||||||
await import('../../vendors/togeojson/togeojson.es.js').then((module) => {
|
|
||||||
togeojson = module
|
|
||||||
})
|
|
||||||
return togeojson.gpx(this.toDom(str))
|
return togeojson.gpx(this.toDom(str))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fromKML(str) {
|
async fromKML(str) {
|
||||||
console.log(str)
|
const togeojson = await import('../../vendors/togeojson/togeojson.es.js')
|
||||||
let togeojson
|
|
||||||
await import('../../vendors/togeojson/togeojson.es.js').then((module) => {
|
|
||||||
togeojson = module
|
|
||||||
})
|
|
||||||
return togeojson.kml(this.toDom(str), {
|
return togeojson.kml(this.toDom(str), {
|
||||||
skipNullGeometry: true,
|
skipNullGeometry: true,
|
||||||
})
|
})
|
||||||
|
@ -111,10 +104,7 @@ export default class Formatter {
|
||||||
}
|
}
|
||||||
|
|
||||||
async toGPX(geojson) {
|
async toGPX(geojson) {
|
||||||
let togpx
|
const togpx = await import('../../vendors/geojson-to-gpx/index.js')
|
||||||
await import('../../vendors/geojson-to-gpx/index.js').then((module) => {
|
|
||||||
togpx = module
|
|
||||||
})
|
|
||||||
for (const feature of geojson.features) {
|
for (const feature of geojson.features) {
|
||||||
feature.properties.desc = feature.properties.description
|
feature.properties.desc = feature.properties.description
|
||||||
}
|
}
|
||||||
|
@ -123,10 +113,7 @@ export default class Formatter {
|
||||||
}
|
}
|
||||||
|
|
||||||
async toKML(geojson) {
|
async toKML(geojson) {
|
||||||
let tokml
|
const tokml = await import('../../vendors/tokml/tokml.es.js')
|
||||||
await import('../../vendors/tokml/tokml.es.js').then((module) => {
|
|
||||||
tokml = module
|
|
||||||
})
|
|
||||||
return tokml.toKML(geojson)
|
return tokml.toKML(geojson)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,6 +35,10 @@ class UmapManifestStaticFilesStorage(ManifestStaticFilesStorage):
|
||||||
r"""(?P<matched>import\(["'](?P<url>.*?)["']\))\.then""",
|
r"""(?P<matched>import\(["'](?P<url>.*?)["']\))\.then""",
|
||||||
"""import("%(url)s")""",
|
"""import("%(url)s")""",
|
||||||
),
|
),
|
||||||
|
(
|
||||||
|
r"""(?P<matched>await import\(["'](?P<url>.*?)["']\))""",
|
||||||
|
"""import("%(url)s")""",
|
||||||
|
),
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue