Cleanup of last tests

This commit is contained in:
pietervdvn 2022-03-24 03:30:05 +01:00
parent 712806c682
commit 51fe206736
10 changed files with 412 additions and 756 deletions

View file

@ -549,7 +549,10 @@ export class GeoOperations {
/**
* Removes points that do not contribute to the geometry from linestrings and the outer ring of polygons.
* Returs a new copy of the feature
* @param feature
*
* const feature = {"geometry": {"type": "Polygon","coordinates": [[[4.477944199999975,51.02783550000022],[4.477987899999996,51.027818800000034],[4.478004500000021,51.02783399999988],[4.478025499999962,51.02782489999994],[4.478079099999993,51.027873899999896],[4.47801040000006,51.027903799999955],[4.477964799999972,51.02785709999982],[4.477964699999964,51.02785690000006],[4.477944199999975,51.02783550000022]]]}}
* const copy = GeoOperations.removeOvernoding(feature)
* expect(copy.geometry.coordinates[0]).deep.equal([[4.477944199999975,51.02783550000022],[4.477987899999996,51.027818800000034],[4.478004500000021,51.02783399999988],[4.478025499999962,51.02782489999994],[4.478079099999993,51.027873899999896],[4.47801040000006,51.027903799999955],[4.477944199999975,51.02783550000022]])
*/
static removeOvernoding(feature: any) {
if (feature.geometry.type !== "LineString" && feature.geometry.type !== "Polygon") {

File diff suppressed because one or more lines are too long

View file

@ -1,273 +0,0 @@
import * as Assert from "assert";
import T from "./TestHelper";
import {GeoOperations} from "../Logic/GeoOperations";
import * as turf from "@turf/turf"
import {expect} from "chai";
export default class GeoOperationsSpec extends T {
constructor() {
super([
["Regression test: intersection/overlap", () => {
const polyGrb = {
"type": "Feature",
"properties": {
"osm_id": "25189153",
"size_grb_building": "217.14",
"addr:housenumber": "173",
"addr:street": "Kortrijksestraat",
"building": "house",
"source:geometry:entity": "Gbg",
"source:geometry:date": "2015/02/27",
"source:geometry:oidn": "1729460",
"source:geometry:uidn": "8713648",
"H_DTM_MIN": "17.28",
"H_DTM_GEM": "17.59",
"H_DSM_MAX": "29.04",
"H_DSM_P99": "28.63",
"HN_MAX": "11.45",
"HN_P99": "11.04",
"detection_method": "from existing OSM building source: house ,hits (3)",
"auto_building": "house",
"size_shared": "210.68",
"size_source_building": "212.63",
"id": "https://betadata.grbosm.site/grb?bbox=360935.6475626023,6592540.815539878,361088.52161917265,6592693.689596449/37",
"_lat": "50.83736194999996",
"_lon": "3.2432137000000116",
"_layer": "GRB",
"_length": "48.51529464293261",
"_length:km": "0.0",
"_now:date": "2021-12-05",
"_now:datetime": "2021-12-05 21:51:40",
"_loaded:date": "2021-12-05",
"_loaded:datetime": "2021-12-05 21:51:40"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
3.2431059999999974,
50.83730270000021
],
[
3.243174299999987,
50.83728850000007
],
[
3.2432116000000173,
50.83736910000003
],
[
3.2433214000000254,
50.83740350000011
],
[
3.24329779999996,
50.837435399999855
],
[
3.2431881000000504,
50.83740090000025
],
[
3.243152699999997,
50.83738980000017
],
[
3.2431059999999974,
50.83730270000021
]
]
]
},
"id": "https://betadata.grbosm.site/grb?bbox=360935.6475626023,6592540.815539878,361088.52161917265,6592693.689596449/37",
"_lon": 3.2432137000000116,
"_lat": 50.83736194999996,
"bbox": {
"maxLat": 50.837435399999855,
"maxLon": 3.2433214000000254,
"minLat": 50.83728850000007,
"minLon": 3.2431059999999974
}
}
const polyHouse = {
"type": "Feature",
"id": "way/594963177",
"properties": {
"timestamp": "2021-12-05T04:04:55Z",
"version": 3,
"changeset": 114571409,
"user": "Pieter Vander Vennet",
"uid": 3818858,
"addr:housenumber": "171",
"addr:street": "Kortrijksestraat",
"building": "house",
"source:geometry:date": "2018-10-22",
"source:geometry:ref": "Gbg/5096537",
"_last_edit:contributor": "Pieter Vander Vennet",
"_last_edit:contributor:uid": 3818858,
"_last_edit:changeset": 114571409,
"_last_edit:timestamp": "2021-12-05T04:04:55Z",
"_version_number": 3,
"id": "way/594963177",
"_backend": "https://www.openstreetmap.org",
"_lat": "50.83736395",
"_lon": "3.2430937",
"_layer": "OSM-buildings",
"_length": "43.561938680928506",
"_length:km": "0.0",
"_now:date": "2021-12-05",
"_now:datetime": "2021-12-05 21:51:40",
"_loaded:date": "2021-12-05",
"_loaded:datetime": "2021-12-05 21:51:39",
"_surface": "93.32785810484549",
"_surface:ha": "0"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
3.2429993,
50.8373243
],
[
3.243106,
50.8373027
],
[
3.2431527,
50.8373898
],
[
3.2431881,
50.8374009
],
[
3.2431691,
50.8374252
],
[
3.2430936,
50.837401
],
[
3.243046,
50.8374112
],
[
3.2429993,
50.8373243
]
]
]
},
"_lon": 3.2430937,
"_lat": 50.83736395,
"bbox": {
"maxLat": 50.8374252,
"maxLon": 3.2431881,
"minLat": 50.8373027,
"minLon": 3.2429993
}
}
const p0 = turf.polygon(polyGrb.geometry.coordinates)
Assert.notEqual(p0, null)
const p1 = turf.polygon(polyHouse.geometry.coordinates)
Assert.notEqual(p1, null)
const overlaps = GeoOperations.calculateOverlap(polyGrb, [polyHouse])
Assert.equal(overlaps.length, 0)
const overlapsRev = GeoOperations.calculateOverlap(polyHouse, [polyGrb])
Assert.equal(overlapsRev.length, 0)
}],
["Overnode removal test", () => {
const feature = {
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
4.477944199999975,
51.02783550000022
],
[
4.477987899999996,
51.027818800000034
],
[
4.478004500000021,
51.02783399999988
],
[
4.478025499999962,
51.02782489999994
],
[
4.478079099999993,
51.027873899999896
],
[
4.47801040000006,
51.027903799999955
],
[
4.477964799999972,
51.02785709999982
],
[
4.477964699999964,
51.02785690000006
],
[
4.477944199999975,
51.02783550000022
]
]
]
}
}
const copy = GeoOperations.removeOvernoding(feature)
Assert.equal(copy.geometry.coordinates[0].length, 7)
expect(copy.geometry.coordinates[0]).deep.equal([
[
4.477944199999975,
51.02783550000022
],
[
4.477987899999996,
51.027818800000034
],
[
4.478004500000021,
51.02783399999988
],
[
4.478025499999962,
51.02782489999994
],
[
4.478079099999993,
51.027873899999896
],
[
4.47801040000006,
51.027903799999955
],
[
4.477944199999975,
51.02783550000022
]
])
}]
]
)
}
}

View file

@ -1,297 +0,0 @@
import T from "./TestHelper";
import {FixLegacyTheme} from "../Models/ThemeConfig/Conversion/LegacyJsonConvert";
import LayoutConfig from "../Models/ThemeConfig/LayoutConfig";
import {TagRenderingConfigJson} from "../Models/ThemeConfig/Json/TagRenderingConfigJson";
import {ExtractImages} from "../Models/ThemeConfig/Conversion/FixImages";
import {PrepareLayer} from "../Models/ThemeConfig/Conversion/PrepareLayer";
import {LayerConfigJson} from "../Models/ThemeConfig/Json/LayerConfigJson";
import LineRenderingConfigJson from "../Models/ThemeConfig/Json/LineRenderingConfigJson";
import {expect} from "chai";
export default class LegacyThemeLoaderSpec extends T {
private static readonly walking_node_theme = {
"id": "walkingnodenetworks",
"title": {
"en": "Walking node networks"
},
"maintainer": "L'imaginaire",
"icon": "https://upload.wikimedia.org/wikipedia/commons/3/30/Man_walking_icon_1410105361.svg",
"description": {
"en": "This map shows walking node networks"
},
"language": [
"en"
],
socialImage: "img.jpg",
"version": "2021-10-02",
"startLat": 51.1599,
"startLon": 3.34750,
"startZoom": 12,
"clustering": {
"maxZoom": 12
},
"layers": [
{
"id": "node2node",
"name": {
"en": "node to node links"
},
"source": {
"osmTags": {
"and": [
"network=rwn",
"network:type=node_network"
]
}
},
"minzoom": 12,
"title": {
"render": {
"en": "node to node link"
},
"mappings": [
{
"if": "ref~*",
"then": {
"en": "node to node link <strong>{ref}</strong>"
}
}
]
},
"width": {
"render": "4"
},
"color": {
"render": "#8b1e20"
},
"tagRenderings": [
{
"question": {
"en": "When was this node to node link last surveyed?"
},
"render": {
"en": "This node to node link was last surveyed on {survey:date}"
},
"freeform": {
"key": "survey:date",
"type": "date"
},
"mappings": [
{
"if": "survey:date:={_now:date}",
"then": "Surveyed today!"
}
]
}
]
},
{
"id": "node",
"name": {
"en": "nodes"
},
"source": {
"osmTags": "rwn_ref~*"
},
"minzoom": 12,
"title": {
"render": {
"en": "walking node <strong>{rwn_ref}</strong>"
}
},
"label": {
"mappings": [
{
"if": "rwn_ref~*",
"then": "<div style='position: absolute; top: 10px; right: 10px; color: white; background-color: #8b1e20; width: 20px; height: 20px; border-radius: 100%'>{rwn_ref}</div>"
}
]
},
"tagRenderings": [
{
"question": {
"en": "When was this walking node last surveyed?"
},
"render": {
"en": "This walking node was last surveyed on {survey:date}"
},
"freeform": {
"key": "survey:date",
"type": "date"
},
"mappings": [
{
"if": "survey:date:={_now:date}",
"then": "Surveyed today!"
}
]
},
{
"question": {
"en": "How many other walking nodes does this node link to?"
},
"render": {
"en": "This node links to {expected_rwn_route_relations} other walking nodes."
},
"freeform": {
"key": "expected_rwn_route_relations",
"type": "int"
}
},
"images"
]
}
]
}
constructor() {
super([
["should load the Walking_node_theme", () => {
const config = LegacyThemeLoaderSpec.walking_node_theme
const fixed = new FixLegacyTheme().convert(
// @ts-ignore
config,
"While testing")
expect(fixed.errors.length === 0, "Could not fix the legacy theme").true
const theme = new LayoutConfig(fixed.result)
}],
["Images in 'thens' are detected in QuestionableTagRenderings", () => {
const r = new ExtractImages(true, new Map<string, any>()).convert(<any>{
"layers": [
{
tagRenderings: [
{
"mappings": [
{
"if": "bicycle_parking=stands",
"then": {
"en": "Staple racks",
},
"icon": {
path: "./assets/layers/bike_parking/staple.svg",
class: "small"
}
},
{
"if": "bicycle_parking=stands",
"then": {
"en": "Bollard",
},
"icon": "./assets/layers/bike_parking/bollard.svg",
}
]
}
]
}
]
}, "test");
const images = r.result
images.length // => 2
expect(images.findIndex(img => img == "./assets/layers/bike_parking/staple.svg") >= 0, "staple.svg not mentioned").true
expect(images.findIndex(img => img == "./assets/layers/bike_parking/bollard.svg") >= 0, "bollard.svg not mentioned").true
}],
["Rotation and colours is not detected as image", () => {
const r = new ExtractImages(true, new Map<string, any>()).convert(<any>{
"layers": [
{
mapRendering: [
{
"location": ["point", "centroid"],
"icon": "pin:black",
rotation: 180,
iconSize: "40,40,center"
}
]
}
]
}, "test");
const images = r.result
expect(images.length > 0, "No images found").true
expect(images.length < 2, "To much images found: " + images.join(", ")).true
expect(images[0] === "pin", "pin not mentioned").true
}],
["Test expansion in map renderings", () => {
const exampleLayer: LayerConfigJson = {
id: "testlayer",
source: {
osmTags: "key=value"
},
mapRendering: [
{
"rewrite": {
sourceString: ["left|right", "lr_offset"],
into: [
["left", "right"],
[-6, +6]
]
},
renderings: <LineRenderingConfigJson>{
"color": {
"render": "#888",
"mappings": [
{
"if": "parking:condition:left|right=free",
"then": "#299921"
},
{
"if": "parking:condition:left|right=disc",
"then": "#219991"
}
]
},
"offset": "lr_offset"
}
}
]
}
const prep = new PrepareLayer({
tagRenderings: new Map<string, TagRenderingConfigJson>(),
sharedLayers: new Map<string, LayerConfigJson>()
})
const result = prep.convertStrict(exampleLayer, "test")
const expected = {
"id": "testlayer",
"source": {"osmTags": "key=value"},
"mapRendering": [{
"color": {
"render": "#888",
"mappings": [{
"if": "parking:condition:left=free",
"then": "#299921"
},
{"if": "parking:condition:left=disc",
"then": "#219991"}]
},
"offset": -6
}, {
"color": {
"render": "#888",
"mappings": [{
"if": "parking:condition:right=free",
"then": "#299921"
},
{"if": "parking:condition:right=disc",
"then": "#219991"}]
},
"offset": 6
}],
"titleIcons": [{"render": "defaults", "id": "defaults"}]
}
expect(result).deep.eq(expected)
}
],
]
);
}
}

View file

@ -1,59 +0,0 @@
import GeoOperationsSpec from "./GeoOperations.spec";
import LegacyThemeLoaderSpec from "./LegacyThemeLoader.spec";
import T from "./TestHelper";
import CreateCacheSpec from "./CreateCache.spec";
import ImportMultiPolygonSpec from "./ImportMultiPolygon.spec";
async function main() {
const allTests: T[] = [
new GeoOperationsSpec(),
new LegacyThemeLoaderSpec(),
new CreateCacheSpec(),
new ImportMultiPolygonSpec(),
]
let args = [...process.argv]
args.splice(0, 2)
args = args.map(a => a.toLowerCase().replace(/"/g, ""))
const allFailures: { testsuite: string, name: string, msg: string } [] = []
let testsToRun = allTests
if (args.length > 0) {
args = args.map(a => a.toLowerCase()).map(a => {
if (!a.endsWith("spec")) {
return a + "spec"
} else {
return a;
}
})
testsToRun = allTests.filter(t => args.indexOf(t.name.toLowerCase()) >= 0)
console.log("Only running test "+testsToRun.join(", "))
}
if (testsToRun.length == 0) {
const available = allTests.map(t => t.name)
available.sort()
throw "No tests found. Try one of " + available.join(", ")
}
for (let i = 0; i < testsToRun.length; i++) {
const test = testsToRun[i];
console.log(" Running test", i, "/", testsToRun.length, test.name)
allFailures.push(...(await test.Run() ?? []))
console.log("OK!")
}
if (allFailures.length > 0) {
for (const failure of allFailures) {
console.error(" !! " + failure.testsuite + "." + failure.name + " failed due to: " + failure.msg)
}
throw "Some test failed"
}
console.log("All tests successful: ", testsToRun.map(t => t.name).join(", "))
}
main()

View file

@ -1,42 +0,0 @@
import {expect} from "chai"
export default class T {
public readonly name: string;
private readonly _tests: [string, (() => (void | Promise<void>))][];
constructor(tests: [string, () => (Promise<void> | void)][]) {
this.name = this.constructor.name;
this._tests = tests;
}
/**
* RUns the test, returns the error messages.
* Returns an empty list if successful
* @constructor
*/
public async Run(): Promise<{ testsuite: string, name: string, msg: string } []> {
const failures: { testsuite: string, name: string, msg: string } [] = []
for (const [name, test] of this._tests) {
try {
const r = test()
if (r instanceof Promise) {
try {
await r
} catch (e) {
console.log("ASYNC ERROR: ", e, e.stack)
failures.push({testsuite: this.name, name: name, msg: "" + e});
}
}
} catch (e) {
console.log("ERROR: ", e, e.stack)
failures.push({testsuite: this.name, name: name, msg: "" + e});
}
}
if (failures.length == 0) {
return undefined
} else {
return failures
}
}
}

View file

@ -1,14 +1,13 @@
import T from "./TestHelper";
import CreateMultiPolygonWithPointReuseAction from "../Logic/Osm/Actions/CreateMultiPolygonWithPointReuseAction";
import {Tag} from "../Logic/Tags/Tag";
import {Changes} from "../Logic/Osm/Changes";
import {expect} from "chai";
import {describe} from 'mocha'
import {expect} from 'chai'
import CreateMultiPolygonWithPointReuseAction from "../../../Logic/Osm/Actions/CreateMultiPolygonWithPointReuseAction";
import {Tag} from "../../../Logic/Tags/Tag";
import {Changes} from "../../../Logic/Osm/Changes";
export default class ImportMultiPolygonSpec extends T {
describe("CreateMultiPolygonWithPointReuseAction", () => {
it("should produce a correct changeset", () => {
constructor() {
super([
["Correct changeset",
async () => {
const feature = {
@ -190,28 +189,21 @@ export default class ImportMultiPolygonSpec extends T {
)
const descriptions = await action.Perform(new Changes())
function getCoor(id: number): {lat: number, lon:number} {
return <any> descriptions.find(d => d.type === "node" && d.id === id).changes
}
const ways= descriptions.filter(d => d.type === "way")
expect(ways[0].id == -18, "unexpected id").true
expect(ways[1].id == -27, "unexpected id").true
const outer = ways[0].changes["coordinates"]
const outerExpected = [[5.262684300000043,50.84624409999995],[5.262777500000024,50.84620759999988],[5.262798899999998,50.84621390000019],[5.262999799999994,50.84619519999999],[5.263107500000007,50.84618920000014],[5.263115,50.84620990000026],[5.26310279999998,50.84623050000014],[5.263117999999977,50.846247400000166],[5.263174599999989,50.84631019999971],[5.263166999999989,50.84631459999995],[5.263243999999979,50.84640239999989],[5.2631607000000065,50.84643459999996],[5.26313309999997,50.84640089999985],[5.262907499999996,50.84647790000018],[5.2628939999999576,50.846463699999774],[5.262872100000033,50.846440700000294],[5.262784699999991,50.846348899999924],[5.262684300000043,50.84624409999995]]
expect(outer).deep.equal(feature.geometry.coordinates[0])
const inner = ways[1].changes["coordinates"]
expect(inner).deep.equal(feature.geometry.coordinates[1])
const members = <{type: string, role: string, ref: number}[]> descriptions.find(d => d.type === "relation").changes["members"]
expect(members[0].role == "outer", "incorrect role").true
expect(members[1].role == "inner", "incorrect role").true
expect(members[0].type == "way", "incorrect type").true
expect(members[1].type == "way", "incorrect type").true
expect(members[0].ref == -18, "incorrect id").true
expect(members[1].ref == -27, "incorrect id").true
}]
]);
}
expect(members[0].role, "incorrect role").eq("outer")
expect(members[1].role, "incorrect role").eq("inner")
expect(members[0].type , "incorrect type").eq("way")
expect(members[1].type , "incorrect type").eq("way")
expect(members[0].ref, "incorrect id").eq(-18)
expect(members[1].ref , "incorrect id").eq(-27)
}
}
})
})

View file

@ -0,0 +1,186 @@
import {describe} from 'mocha'
import {expect} from 'chai'
import * as turf from "@turf/turf";
import {GeoOperations} from "../../Logic/GeoOperations";
describe("GeoOperations", () => {
describe("calculateOverlap", () => {
it("should not give too much overlap (regression test)", () => {
const polyGrb = {
"type": "Feature",
"properties": {
"osm_id": "25189153",
"size_grb_building": "217.14",
"addr:housenumber": "173",
"addr:street": "Kortrijksestraat",
"building": "house",
"source:geometry:entity": "Gbg",
"source:geometry:date": "2015/02/27",
"source:geometry:oidn": "1729460",
"source:geometry:uidn": "8713648",
"H_DTM_MIN": "17.28",
"H_DTM_GEM": "17.59",
"H_DSM_MAX": "29.04",
"H_DSM_P99": "28.63",
"HN_MAX": "11.45",
"HN_P99": "11.04",
"detection_method": "from existing OSM building source: house ,hits (3)",
"auto_building": "house",
"size_shared": "210.68",
"size_source_building": "212.63",
"id": "https://betadata.grbosm.site/grb?bbox=360935.6475626023,6592540.815539878,361088.52161917265,6592693.689596449/37",
"_lat": "50.83736194999996",
"_lon": "3.2432137000000116",
"_layer": "GRB",
"_length": "48.51529464293261",
"_length:km": "0.0",
"_now:date": "2021-12-05",
"_now:datetime": "2021-12-05 21:51:40",
"_loaded:date": "2021-12-05",
"_loaded:datetime": "2021-12-05 21:51:40"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
3.2431059999999974,
50.83730270000021
],
[
3.243174299999987,
50.83728850000007
],
[
3.2432116000000173,
50.83736910000003
],
[
3.2433214000000254,
50.83740350000011
],
[
3.24329779999996,
50.837435399999855
],
[
3.2431881000000504,
50.83740090000025
],
[
3.243152699999997,
50.83738980000017
],
[
3.2431059999999974,
50.83730270000021
]
]
]
},
"id": "https://betadata.grbosm.site/grb?bbox=360935.6475626023,6592540.815539878,361088.52161917265,6592693.689596449/37",
"_lon": 3.2432137000000116,
"_lat": 50.83736194999996,
"bbox": {
"maxLat": 50.837435399999855,
"maxLon": 3.2433214000000254,
"minLat": 50.83728850000007,
"minLon": 3.2431059999999974
}
}
const polyHouse = {
"type": "Feature",
"id": "way/594963177",
"properties": {
"timestamp": "2021-12-05T04:04:55Z",
"version": 3,
"changeset": 114571409,
"user": "Pieter Vander Vennet",
"uid": 3818858,
"addr:housenumber": "171",
"addr:street": "Kortrijksestraat",
"building": "house",
"source:geometry:date": "2018-10-22",
"source:geometry:ref": "Gbg/5096537",
"_last_edit:contributor": "Pieter Vander Vennet",
"_last_edit:contributor:uid": 3818858,
"_last_edit:changeset": 114571409,
"_last_edit:timestamp": "2021-12-05T04:04:55Z",
"_version_number": 3,
"id": "way/594963177",
"_backend": "https://www.openstreetmap.org",
"_lat": "50.83736395",
"_lon": "3.2430937",
"_layer": "OSM-buildings",
"_length": "43.561938680928506",
"_length:km": "0.0",
"_now:date": "2021-12-05",
"_now:datetime": "2021-12-05 21:51:40",
"_loaded:date": "2021-12-05",
"_loaded:datetime": "2021-12-05 21:51:39",
"_surface": "93.32785810484549",
"_surface:ha": "0"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
3.2429993,
50.8373243
],
[
3.243106,
50.8373027
],
[
3.2431527,
50.8373898
],
[
3.2431881,
50.8374009
],
[
3.2431691,
50.8374252
],
[
3.2430936,
50.837401
],
[
3.243046,
50.8374112
],
[
3.2429993,
50.8373243
]
]
]
},
"_lon": 3.2430937,
"_lat": 50.83736395,
"bbox": {
"maxLat": 50.8374252,
"maxLon": 3.2431881,
"minLat": 50.8373027,
"minLon": 3.2429993
}
}
const p0 = turf.polygon(polyGrb.geometry.coordinates)
expect(p0).not.null
const p1 = turf.polygon(polyHouse.geometry.coordinates)
expect(p1).not.null
const overlaps = GeoOperations.calculateOverlap(polyGrb, [polyHouse])
expect(overlaps).empty
const overlapsRev = GeoOperations.calculateOverlap(polyHouse, [polyGrb])
expect(overlapsRev).empty
})
})
})

View file

@ -0,0 +1,153 @@
import {describe} from 'mocha'
import {expect} from 'chai'
import LayoutConfig from "../../../../Models/ThemeConfig/LayoutConfig";
import {FixLegacyTheme} from "../../../../Models/ThemeConfig/Conversion/LegacyJsonConvert";
describe("FixLegacyTheme", () => {
it("should create a working theme config", () => {
const walking_node_theme = {
"id": "walkingnodenetworks",
"title": {
"en": "Walking node networks"
},
"maintainer": "L'imaginaire",
"icon": "https://upload.wikimedia.org/wikipedia/commons/3/30/Man_walking_icon_1410105361.svg",
"description": {
"en": "This map shows walking node networks"
},
"language": [
"en"
],
socialImage: "img.jpg",
"version": "2021-10-02",
"startLat": 51.1599,
"startLon": 3.34750,
"startZoom": 12,
"clustering": {
"maxZoom": 12
},
"layers": [
{
"id": "node2node",
"name": {
"en": "node to node links"
},
"source": {
"osmTags": {
"and": [
"network=rwn",
"network:type=node_network"
]
}
},
"minzoom": 12,
"title": {
"render": {
"en": "node to node link"
},
"mappings": [
{
"if": "ref~*",
"then": {
"en": "node to node link <strong>{ref}</strong>"
}
}
]
},
"width": {
"render": "4"
},
"color": {
"render": "#8b1e20"
},
"tagRenderings": [
{
"question": {
"en": "When was this node to node link last surveyed?"
},
"render": {
"en": "This node to node link was last surveyed on {survey:date}"
},
"freeform": {
"key": "survey:date",
"type": "date"
},
"mappings": [
{
"if": "survey:date:={_now:date}",
"then": "Surveyed today!"
}
]
}
]
},
{
"id": "node",
"name": {
"en": "nodes"
},
"source": {
"osmTags": "rwn_ref~*"
},
"minzoom": 12,
"title": {
"render": {
"en": "walking node <strong>{rwn_ref}</strong>"
}
},
"label": {
"mappings": [
{
"if": "rwn_ref~*",
"then": "<div style='position: absolute; top: 10px; right: 10px; color: white; background-color: #8b1e20; width: 20px; height: 20px; border-radius: 100%'>{rwn_ref}</div>"
}
]
},
"tagRenderings": [
{
"question": {
"en": "When was this walking node last surveyed?"
},
"render": {
"en": "This walking node was last surveyed on {survey:date}"
},
"freeform": {
"key": "survey:date",
"type": "date"
},
"mappings": [
{
"if": "survey:date:={_now:date}",
"then": "Surveyed today!"
}
]
},
{
"question": {
"en": "How many other walking nodes does this node link to?"
},
"render": {
"en": "This node links to {expected_rwn_route_relations} other walking nodes."
},
"freeform": {
"key": "expected_rwn_route_relations",
"type": "int"
}
},
"images"
]
}
]
}
const fixed = new FixLegacyTheme().convert(
<any> walking_node_theme,
"While testing")
expect(fixed.errors, "Could not fix the legacy theme").empty
const theme = new LayoutConfig(fixed.result, false,"test")
expect(theme).not.undefined
})
})

File diff suppressed because one or more lines are too long