forked from MapComplete/MapComplete
Fix typing in scripts
This commit is contained in:
parent
6ca5c31e3a
commit
3c345f43a3
2 changed files with 8 additions and 7 deletions
|
@ -442,29 +442,30 @@ class LayerOverviewUtils {
|
||||||
|
|
||||||
if (themeFile.icon.endsWith(".svg")) {
|
if (themeFile.icon.endsWith(".svg")) {
|
||||||
try {
|
try {
|
||||||
ScriptUtils.ReadSvgSync(json.icon, (svg) => {
|
ScriptUtils.ReadSvgSync(themeFile.icon, (svg) => {
|
||||||
const width: string = svg.$.width
|
const width: string = svg.$.width
|
||||||
const height: string = svg.$.height
|
const height: string = svg.$.height
|
||||||
|
const err = themeFile.hideFromOverview ? console.warn : console.error
|
||||||
if (width !== height) {
|
if (width !== height) {
|
||||||
const e =
|
const e =
|
||||||
`the icon for theme ${json.id} is not square. Please square the icon at ${json.icon}` +
|
`the icon for theme ${themeFile.id} is not square. Please square the icon at ${themeFile.icon}` +
|
||||||
` Width = ${width} height = ${height}`
|
` Width = ${width} height = ${height}`
|
||||||
;(json.hideFromOverview ? warnings : errors).push(e)
|
err(e)
|
||||||
}
|
}
|
||||||
|
|
||||||
const w = parseInt(width)
|
const w = parseInt(width)
|
||||||
const h = parseInt(height)
|
const h = parseInt(height)
|
||||||
if (w < 370 || h < 370) {
|
if (w < 370 || h < 370) {
|
||||||
const e: string = [
|
const e: string = [
|
||||||
`the icon for theme ${json.id} is too small. Please rescale the icon at ${json.icon}`,
|
`the icon for theme ${themeFile.id} is too small. Please rescale the icon at ${themeFile.icon}`,
|
||||||
`Even though an SVG is 'infinitely scaleable', the icon should be dimensioned bigger. One of the build steps of the theme does convert the image to a PNG (to serve as PWA-icon) and having a small dimension will cause blurry images.`,
|
`Even though an SVG is 'infinitely scaleable', the icon should be dimensioned bigger. One of the build steps of the theme does convert the image to a PNG (to serve as PWA-icon) and having a small dimension will cause blurry images.`,
|
||||||
` Width = ${width} height = ${height}; we recommend a size of at least 500px * 500px and to use a square aspect ratio.`,
|
` Width = ${width} height = ${height}; we recommend a size of at least 500px * 500px and to use a square aspect ratio.`,
|
||||||
].join("\n")
|
].join("\n")
|
||||||
;(json.hideFromOverview ? warnings : errors).push(e)
|
err(e)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Could not read " + json.icon + " due to " + e)
|
console.error("Could not read " + themeFile.icon + " due to " + e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ async function readGeojsonLineByLine(inputFile: string): Promise<any[]> {
|
||||||
|
|
||||||
async function readFeaturesFromGeoJson(inputFile: string): Promise<any[]> {
|
async function readFeaturesFromGeoJson(inputFile: string): Promise<any[]> {
|
||||||
try {
|
try {
|
||||||
return JSON.parse(fs.readFileSync(inputFile, "UTF-8")).features
|
return JSON.parse(fs.readFileSync(inputFile, { encoding: "utf-8" })).features
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// We retry, but with a line-by-line approach
|
// We retry, but with a line-by-line approach
|
||||||
return await readGeojsonLineByLine(inputFile)
|
return await readGeojsonLineByLine(inputFile)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue