Full code cleanup
This commit is contained in:
parent
8e6ee8c87f
commit
bd21212eba
246 changed files with 19418 additions and 11729 deletions
|
@ -1,10 +1,8 @@
|
|||
import T from "./TestHelper";
|
||||
import State from "../State";
|
||||
import {AllKnownLayouts} from "../Customizations/AllKnownLayouts";
|
||||
import SelectedElementTagsUpdater from "../Logic/Actors/SelectedElementTagsUpdater";
|
||||
import UserRelatedState from "../Logic/State/UserRelatedState";
|
||||
import {Utils} from "../Utils";
|
||||
import ScriptUtils from "../scripts/ScriptUtils";
|
||||
import SelectedFeatureHandler from "../Logic/Actors/SelectedFeatureHandler";
|
||||
import {UIEventSource} from "../Logic/UIEventSource";
|
||||
import {ElementStorage} from "../Logic/ElementStorage";
|
||||
|
@ -113,14 +111,14 @@ export default class ActorsSpec extends T {
|
|||
lon: 0,
|
||||
zoom: 0
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
loc.addCallback(_ => {
|
||||
T.equals("node/5568693115", selected.data.properties.id)
|
||||
T.equals(14, loc.data.zoom)
|
||||
T.equals( 51.2179199, loc.data.lat)
|
||||
T.equals(51.2179199, loc.data.lat)
|
||||
})
|
||||
|
||||
|
||||
new SelectedFeatureHandler(hash, {
|
||||
selectedElement: selected,
|
||||
allElements: new ElementStorage(),
|
||||
|
@ -128,9 +126,7 @@ export default class ActorsSpec extends T {
|
|||
locationControl: loc,
|
||||
layoutToUse: undefined
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}]
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import {Utils} from "../Utils";
|
||||
import * as Assert from "assert";
|
||||
import {equal} from "assert";
|
||||
import T from "./TestHelper";
|
||||
import {GeoOperations} from "../Logic/GeoOperations";
|
||||
import {equal} from "assert";
|
||||
import {BBox} from "../Logic/BBox";
|
||||
|
||||
Utils.runningFromConsole = true;
|
||||
|
|
|
@ -4,23 +4,24 @@ import {UIEventSource} from "../Logic/UIEventSource";
|
|||
import {Utils} from "../Utils";
|
||||
|
||||
export default class ImageProviderSpec extends T {
|
||||
|
||||
|
||||
constructor() {
|
||||
super("ImageProvider", [
|
||||
["Search images", () => {
|
||||
|
||||
|
||||
let i = 0
|
||||
|
||||
function expects(url, tags, providerName = undefined) {
|
||||
tags.id = "test/"+i
|
||||
tags.id = "test/" + i
|
||||
i++
|
||||
AllImageProviders.LoadImagesFor(new UIEventSource(tags)).addCallbackD(images => {
|
||||
console.log("ImageProvider test", tags.id, "for", tags)
|
||||
const img = images[0]
|
||||
if(img === undefined){
|
||||
if (img === undefined) {
|
||||
throw "No image found"
|
||||
}
|
||||
T.equals(url, img.url, tags.id)
|
||||
if(providerName){
|
||||
if (providerName) {
|
||||
T.equals(img.provider.constructor.name, providerName)
|
||||
}
|
||||
console.log("OK")
|
||||
|
@ -30,51 +31,53 @@ export default class ImageProviderSpec extends T {
|
|||
const muntpoort_expected = "https://commons.wikimedia.org/wiki/Special:FilePath/File%3ABr%C3%BCgge-Muntpoort_6-29510-58192.jpg?width=500&height=400"
|
||||
expects(
|
||||
muntpoort_expected,
|
||||
{ "wikimedia_commons":"File:Brügge-Muntpoort_6-29510-58192.jpg"
|
||||
} , "WikimediaImageProvider")
|
||||
|
||||
{
|
||||
"wikimedia_commons": "File:Brügge-Muntpoort_6-29510-58192.jpg"
|
||||
}, "WikimediaImageProvider")
|
||||
|
||||
|
||||
expects(muntpoort_expected,
|
||||
{ "wikimedia_commons":"https://upload.wikimedia.org/wikipedia/commons/c/cd/Br%C3%BCgge-Muntpoort_6-29510-58192.jpg"
|
||||
} , "WikimediaImageProvider")
|
||||
|
||||
expects(muntpoort_expected , {
|
||||
"image":"https://upload.wikimedia.org/wikipedia/commons/c/cd/Br%C3%BCgge-Muntpoort_6-29510-58192.jpg"
|
||||
} , "WikimediaImageProvider")
|
||||
{
|
||||
"wikimedia_commons": "https://upload.wikimedia.org/wikipedia/commons/c/cd/Br%C3%BCgge-Muntpoort_6-29510-58192.jpg"
|
||||
}, "WikimediaImageProvider")
|
||||
|
||||
|
||||
expects("https://commons.wikimedia.org/wiki/Special:FilePath/File%3ABelgium-5955_-_Simon_Stevin_(13746657193).jpg?width=500&height=400" , {
|
||||
"image":"File:Belgium-5955_-_Simon_Stevin_(13746657193).jpg"
|
||||
} , "WikimediaImageProvider")
|
||||
|
||||
expects("https://commons.wikimedia.org/wiki/Special:FilePath/File%3ABelgium-5955_-_Simon_Stevin_(13746657193).jpg?width=500&height=400" , {
|
||||
"wikimedia_commons":"File:Belgium-5955_-_Simon_Stevin_(13746657193).jpg"
|
||||
} , "WikimediaImageProvider")
|
||||
|
||||
|
||||
|
||||
|
||||
expects("https://commons.wikimedia.org/wiki/Special:FilePath/File%3ABrugge_Leeuwstraat_zonder_nummer_Leeuwbrug_-_119334_-_onroerenderfgoed.jpg?width=500&height=400",{
|
||||
image:"File:Brugge_Leeuwstraat_zonder_nummer_Leeuwbrug_-_119334_-_onroerenderfgoed.jpg"
|
||||
expects(muntpoort_expected, {
|
||||
"image": "https://upload.wikimedia.org/wikipedia/commons/c/cd/Br%C3%BCgge-Muntpoort_6-29510-58192.jpg"
|
||||
}, "WikimediaImageProvider")
|
||||
|
||||
expects("https://commons.wikimedia.org/wiki/Special:FilePath/File%3APapageno_Jef_Claerhout.jpg?width=500&height=400",{
|
||||
"wikimedia_commons": "File:Papageno_Jef_Claerhout.jpg"
|
||||
|
||||
expects("https://commons.wikimedia.org/wiki/Special:FilePath/File%3ABelgium-5955_-_Simon_Stevin_(13746657193).jpg?width=500&height=400", {
|
||||
"image": "File:Belgium-5955_-_Simon_Stevin_(13746657193).jpg"
|
||||
}, "WikimediaImageProvider")
|
||||
|
||||
expects("https://commons.wikimedia.org/wiki/Special:FilePath/File%3ABelgium-5955_-_Simon_Stevin_(13746657193).jpg?width=500&height=400", {
|
||||
"wikimedia_commons": "File:Belgium-5955_-_Simon_Stevin_(13746657193).jpg"
|
||||
}, "WikimediaImageProvider")
|
||||
|
||||
|
||||
expects("https://commons.wikimedia.org/wiki/Special:FilePath/File%3ABrugge_Leeuwstraat_zonder_nummer_Leeuwbrug_-_119334_-_onroerenderfgoed.jpg?width=500&height=400", {
|
||||
image: "File:Brugge_Leeuwstraat_zonder_nummer_Leeuwbrug_-_119334_-_onroerenderfgoed.jpg"
|
||||
}, "WikimediaImageProvider")
|
||||
|
||||
expects("https://commons.wikimedia.org/wiki/Special:FilePath/File%3APapageno_Jef_Claerhout.jpg?width=500&height=400", {
|
||||
"wikimedia_commons": "File:Papageno_Jef_Claerhout.jpg"
|
||||
}, "WikimediaImageProvider")
|
||||
|
||||
Utils.injectJsonDownloadForTests(
|
||||
"https://graph.mapillary.com/196804715753265?fields=thumb_1024_url&&access_token=MLY|4441509239301885|b40ad2d3ea105435bd40c7e76993ae85" ,
|
||||
{"thumb_1024_url":"https://scontent-bru2-1.xx.fbcdn.net/m1/v/t6/An8HQ3DrfU76tWMC602spvM_e_rqOHyiUcYUTetXM7K52DDBEY5J4FWg4WKQqVUlMsWJn4nLXk0pxlBLx31146FqZ2Kg65z7lJUfR6wpW6WPSR5_y7RKdv4YEuzPjwIN0lagBnQONV3UjmXnEGpMouU?stp=s1024x768&ccb=10-5&oh=d460b401c505714ee1cb8bd6baf8ae5d&oe=61731FC3&_nc_sid=122ab1","id":"196804715753265"}
|
||||
"https://graph.mapillary.com/196804715753265?fields=thumb_1024_url&&access_token=MLY|4441509239301885|b40ad2d3ea105435bd40c7e76993ae85",
|
||||
{
|
||||
"thumb_1024_url": "https://scontent-bru2-1.xx.fbcdn.net/m1/v/t6/An8HQ3DrfU76tWMC602spvM_e_rqOHyiUcYUTetXM7K52DDBEY5J4FWg4WKQqVUlMsWJn4nLXk0pxlBLx31146FqZ2Kg65z7lJUfR6wpW6WPSR5_y7RKdv4YEuzPjwIN0lagBnQONV3UjmXnEGpMouU?stp=s1024x768&ccb=10-5&oh=d460b401c505714ee1cb8bd6baf8ae5d&oe=61731FC3&_nc_sid=122ab1",
|
||||
"id": "196804715753265"
|
||||
}
|
||||
)
|
||||
|
||||
expects("https://scontent-bru2-1.xx.fbcdn.net/m1/v/t6/An8HQ3DrfU76tWMC602spvM_e_rqOHyiUcYUTetXM7K52DDBEY5J4FWg4WKQqVUlMsWJn4nLXk0pxlBLx31146FqZ2Kg65z7lJUfR6wpW6WPSR5_y7RKdv4YEuzPjwIN0lagBnQONV3UjmXnEGpMouU?stp=s1024x768&ccb=10-5&oh=d460b401c505714ee1cb8bd6baf8ae5d&oe=61731FC3&_nc_sid=122ab1", {
|
||||
"mapillary":"https://www.mapillary.com/app/?pKey=196804715753265"
|
||||
"mapillary": "https://www.mapillary.com/app/?pKey=196804715753265"
|
||||
})
|
||||
|
||||
|
||||
|
||||
|
||||
}]
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -2,7 +2,6 @@ import T from "./TestHelper";
|
|||
import UserDetails, {OsmConnection} from "../Logic/Osm/OsmConnection";
|
||||
import {UIEventSource} from "../Logic/UIEventSource";
|
||||
import ScriptUtils from "../scripts/ScriptUtils";
|
||||
import {AllKnownLayouts} from "../Customizations/AllKnownLayouts";
|
||||
import {ElementStorage} from "../Logic/ElementStorage";
|
||||
import {Changes} from "../Logic/Osm/Changes";
|
||||
|
||||
|
|
|
@ -1,26 +1,13 @@
|
|||
import T from "./TestHelper";
|
||||
import {OsmObject} from "../Logic/Osm/OsmObject";
|
||||
import ScriptUtils from "../scripts/ScriptUtils";
|
||||
import {UIEventSource} from "../Logic/UIEventSource";
|
||||
|
||||
export default class OsmObjectSpec extends T {
|
||||
private static async runTest(){
|
||||
const ways = await OsmObject.DownloadReferencingWays("node/1124134958")
|
||||
if(ways === undefined){
|
||||
throw "Did not get the ways"
|
||||
}
|
||||
if (ways.length !== 4) {
|
||||
throw "Expected 4 ways but got "+ways.length
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
constructor() {
|
||||
super("osmobject", [
|
||||
[
|
||||
"Download referencing ways",
|
||||
() => {
|
||||
OsmObjectSpec.runTest().then(_ => console.log("Referencing ways test is done (async)"))
|
||||
OsmObjectSpec.runTest().then(_ => console.log("Referencing ways test is done (async)"))
|
||||
}
|
||||
|
||||
]
|
||||
|
@ -28,4 +15,14 @@ export default class OsmObjectSpec extends T {
|
|||
|
||||
]);
|
||||
}
|
||||
|
||||
private static async runTest() {
|
||||
const ways = await OsmObject.DownloadReferencingWays("node/1124134958")
|
||||
if (ways === undefined) {
|
||||
throw "Did not get the ways"
|
||||
}
|
||||
if (ways.length !== 4) {
|
||||
throw "Expected 4 ways but got " + ways.length
|
||||
}
|
||||
}
|
||||
}
|
|
@ -266,13 +266,285 @@ export default class RelationSplitHandlerSpec extends T {
|
|||
}
|
||||
)
|
||||
Utils.injectJsonDownloadForTests(
|
||||
"https://www.openstreetmap.org/api/0.6/relation/4374576" ,
|
||||
{"version":"0.6","generator":"CGImap 0.8.5 (1266692 spike-06.openstreetmap.org)","copyright":"OpenStreetMap and contributors","attribution":"http://www.openstreetmap.org/copyright","license":"http://opendatacommons.org/licenses/odbl/1-0/","elements":[{"type":"relation","id":4374576,"timestamp":"2014-12-23T21:42:27Z","version":2,"changeset":27660623,"user":"escada","uid":436365,"members":[{"type":"way","ref":318616190,"role":"from"},{"type":"node","ref":1407529979,"role":"via"},{"type":"way","ref":143298912,"role":"to"}],"tags":{"restriction":"no_right_turn","type":"restriction"}}]}
|
||||
"https://www.openstreetmap.org/api/0.6/relation/4374576",
|
||||
{
|
||||
"version": "0.6",
|
||||
"generator": "CGImap 0.8.5 (1266692 spike-06.openstreetmap.org)",
|
||||
"copyright": "OpenStreetMap and contributors",
|
||||
"attribution": "http://www.openstreetmap.org/copyright",
|
||||
"license": "http://opendatacommons.org/licenses/odbl/1-0/",
|
||||
"elements": [{
|
||||
"type": "relation",
|
||||
"id": 4374576,
|
||||
"timestamp": "2014-12-23T21:42:27Z",
|
||||
"version": 2,
|
||||
"changeset": 27660623,
|
||||
"user": "escada",
|
||||
"uid": 436365,
|
||||
"members": [{"type": "way", "ref": 318616190, "role": "from"}, {
|
||||
"type": "node",
|
||||
"ref": 1407529979,
|
||||
"role": "via"
|
||||
}, {"type": "way", "ref": 143298912, "role": "to"}],
|
||||
"tags": {"restriction": "no_right_turn", "type": "restriction"}
|
||||
}]
|
||||
}
|
||||
)
|
||||
|
||||
Utils.injectJsonDownloadForTests(
|
||||
"https://www.openstreetmap.org/api/0.6/way/143298912/full" ,
|
||||
{"version":"0.6","generator":"CGImap 0.8.5 (4046166 spike-07.openstreetmap.org)","copyright":"OpenStreetMap and contributors","attribution":"http://www.openstreetmap.org/copyright","license":"http://opendatacommons.org/licenses/odbl/1-0/","elements":[{"type":"node","id":26343912,"lat":51.2146847,"lon":3.2397007,"timestamp":"2015-04-11T10:40:56Z","version":5,"changeset":30139621,"user":"M!dgard","uid":763799},{"type":"node","id":26343913,"lat":51.2161912,"lon":3.2386907,"timestamp":"2015-04-11T10:40:56Z","version":6,"changeset":30139621,"user":"M!dgard","uid":763799},{"type":"node","id":26343914,"lat":51.2193456,"lon":3.2360696,"timestamp":"2015-04-11T10:40:56Z","version":5,"changeset":30139621,"user":"M!dgard","uid":763799},{"type":"node","id":26343915,"lat":51.2202816,"lon":3.2352429,"timestamp":"2015-04-11T10:40:56Z","version":5,"changeset":30139621,"user":"M!dgard","uid":763799},{"type":"node","id":875668688,"lat":51.2131868,"lon":3.2406009,"timestamp":"2015-04-11T10:40:56Z","version":4,"changeset":30139621,"user":"M!dgard","uid":763799},{"type":"node","id":1109632153,"lat":51.2207068,"lon":3.234882,"timestamp":"2015-04-11T10:40:55Z","version":3,"changeset":30139621,"user":"M!dgard","uid":763799},{"type":"node","id":1109632154,"lat":51.220784,"lon":3.2348394,"timestamp":"2021-05-30T08:01:17Z","version":4,"changeset":105557550,"user":"albertino","uid":499281},{"type":"node","id":1109632177,"lat":51.2205082,"lon":3.2350441,"timestamp":"2015-04-11T10:40:55Z","version":3,"changeset":30139621,"user":"M!dgard","uid":763799},{"type":"node","id":1407529961,"lat":51.2168476,"lon":3.2381772,"timestamp":"2015-04-11T10:40:55Z","version":2,"changeset":30139621,"user":"M!dgard","uid":763799},{"type":"node","id":1407529969,"lat":51.2155155,"lon":3.23917,"timestamp":"2011-08-21T20:08:27Z","version":1,"changeset":9088257,"user":"toeklk","uid":219908},{"type":"node","id":1407529979,"lat":51.212694,"lon":3.2409595,"timestamp":"2015-04-11T10:40:55Z","version":6,"changeset":30139621,"user":"M!dgard","uid":763799,"tags":{"highway":"traffic_signals"}},{"type":"node","id":1634435395,"lat":51.2129189,"lon":3.2408257,"timestamp":"2012-02-15T19:37:51Z","version":1,"changeset":10695640,"user":"Eimai","uid":6072},{"type":"node","id":1634435396,"lat":51.2132508,"lon":3.2405417,"timestamp":"2012-02-15T19:37:51Z","version":1,"changeset":10695640,"user":"Eimai","uid":6072},{"type":"node","id":1634435397,"lat":51.2133918,"lon":3.2404416,"timestamp":"2015-04-11T10:40:55Z","version":2,"changeset":30139621,"user":"M!dgard","uid":763799},{"type":"node","id":1974988033,"lat":51.2127459,"lon":3.240928,"timestamp":"2012-10-20T12:24:13Z","version":1,"changeset":13566903,"user":"skyman81","uid":955688},{"type":"node","id":3250129361,"lat":51.2127906,"lon":3.2409016,"timestamp":"2018-12-19T00:00:33Z","version":2,"changeset":65596519,"user":"beardhatcode","uid":5439560,"tags":{"crossing":"traffic_signals","highway":"crossing"}},{"type":"node","id":3250129363,"lat":51.2149189,"lon":3.2395571,"timestamp":"2015-04-11T10:40:56Z","version":2,"changeset":30139621,"user":"M!dgard","uid":763799},{"type":"node","id":3450326133,"lat":51.2139571,"lon":3.2401205,"timestamp":"2015-04-11T10:40:26Z","version":1,"changeset":30139621,"user":"M!dgard","uid":763799},{"type":"node","id":3450326135,"lat":51.2181385,"lon":3.2370893,"timestamp":"2015-04-11T10:40:26Z","version":1,"changeset":30139621,"user":"M!dgard","uid":763799},{"type":"node","id":4794847239,"lat":51.2191224,"lon":3.2362584,"timestamp":"2019-08-27T23:07:05Z","version":2,"changeset":73816461,"user":"Pieter Vander Vennet","uid":3818858},{"type":"node","id":8493044168,"lat":51.2130348,"lon":3.2407284,"timestamp":"2021-03-06T21:52:51Z","version":1,"changeset":100555232,"user":"kaart_fietser","uid":11022240,"tags":{"highway":"traffic_signals","traffic_signals":"traffic_lights"}},{"type":"node","id":8792687918,"lat":51.2207505,"lon":3.2348579,"timestamp":"2021-06-02T18:27:15Z","version":1,"changeset":105735092,"user":"albertino","uid":499281},{"type":"way","id":143298912,"timestamp":"2021-06-02T18:27:15Z","version":15,"changeset":105735092,"user":"albertino","uid":499281,"nodes":[1407529979,1974988033,3250129361,1634435395,8493044168,875668688,1634435396,1634435397,3450326133,26343912,3250129363,1407529969,26343913,1407529961,3450326135,4794847239,26343914,26343915,1109632177,1109632153,8792687918,1109632154],"tags":{"cycleway:right":"track","highway":"primary","lanes":"2","lit":"yes","maxspeed":"70","name":"Buiten Kruisvest","oneway":"yes","ref":"R30","surface":"asphalt","wikipedia":"nl:Buiten Kruisvest"}}]}
|
||||
"https://www.openstreetmap.org/api/0.6/way/143298912/full",
|
||||
{
|
||||
"version": "0.6",
|
||||
"generator": "CGImap 0.8.5 (4046166 spike-07.openstreetmap.org)",
|
||||
"copyright": "OpenStreetMap and contributors",
|
||||
"attribution": "http://www.openstreetmap.org/copyright",
|
||||
"license": "http://opendatacommons.org/licenses/odbl/1-0/",
|
||||
"elements": [{
|
||||
"type": "node",
|
||||
"id": 26343912,
|
||||
"lat": 51.2146847,
|
||||
"lon": 3.2397007,
|
||||
"timestamp": "2015-04-11T10:40:56Z",
|
||||
"version": 5,
|
||||
"changeset": 30139621,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 26343913,
|
||||
"lat": 51.2161912,
|
||||
"lon": 3.2386907,
|
||||
"timestamp": "2015-04-11T10:40:56Z",
|
||||
"version": 6,
|
||||
"changeset": 30139621,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 26343914,
|
||||
"lat": 51.2193456,
|
||||
"lon": 3.2360696,
|
||||
"timestamp": "2015-04-11T10:40:56Z",
|
||||
"version": 5,
|
||||
"changeset": 30139621,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 26343915,
|
||||
"lat": 51.2202816,
|
||||
"lon": 3.2352429,
|
||||
"timestamp": "2015-04-11T10:40:56Z",
|
||||
"version": 5,
|
||||
"changeset": 30139621,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 875668688,
|
||||
"lat": 51.2131868,
|
||||
"lon": 3.2406009,
|
||||
"timestamp": "2015-04-11T10:40:56Z",
|
||||
"version": 4,
|
||||
"changeset": 30139621,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 1109632153,
|
||||
"lat": 51.2207068,
|
||||
"lon": 3.234882,
|
||||
"timestamp": "2015-04-11T10:40:55Z",
|
||||
"version": 3,
|
||||
"changeset": 30139621,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 1109632154,
|
||||
"lat": 51.220784,
|
||||
"lon": 3.2348394,
|
||||
"timestamp": "2021-05-30T08:01:17Z",
|
||||
"version": 4,
|
||||
"changeset": 105557550,
|
||||
"user": "albertino",
|
||||
"uid": 499281
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 1109632177,
|
||||
"lat": 51.2205082,
|
||||
"lon": 3.2350441,
|
||||
"timestamp": "2015-04-11T10:40:55Z",
|
||||
"version": 3,
|
||||
"changeset": 30139621,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 1407529961,
|
||||
"lat": 51.2168476,
|
||||
"lon": 3.2381772,
|
||||
"timestamp": "2015-04-11T10:40:55Z",
|
||||
"version": 2,
|
||||
"changeset": 30139621,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 1407529969,
|
||||
"lat": 51.2155155,
|
||||
"lon": 3.23917,
|
||||
"timestamp": "2011-08-21T20:08:27Z",
|
||||
"version": 1,
|
||||
"changeset": 9088257,
|
||||
"user": "toeklk",
|
||||
"uid": 219908
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 1407529979,
|
||||
"lat": 51.212694,
|
||||
"lon": 3.2409595,
|
||||
"timestamp": "2015-04-11T10:40:55Z",
|
||||
"version": 6,
|
||||
"changeset": 30139621,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"highway": "traffic_signals"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 1634435395,
|
||||
"lat": 51.2129189,
|
||||
"lon": 3.2408257,
|
||||
"timestamp": "2012-02-15T19:37:51Z",
|
||||
"version": 1,
|
||||
"changeset": 10695640,
|
||||
"user": "Eimai",
|
||||
"uid": 6072
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 1634435396,
|
||||
"lat": 51.2132508,
|
||||
"lon": 3.2405417,
|
||||
"timestamp": "2012-02-15T19:37:51Z",
|
||||
"version": 1,
|
||||
"changeset": 10695640,
|
||||
"user": "Eimai",
|
||||
"uid": 6072
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 1634435397,
|
||||
"lat": 51.2133918,
|
||||
"lon": 3.2404416,
|
||||
"timestamp": "2015-04-11T10:40:55Z",
|
||||
"version": 2,
|
||||
"changeset": 30139621,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 1974988033,
|
||||
"lat": 51.2127459,
|
||||
"lon": 3.240928,
|
||||
"timestamp": "2012-10-20T12:24:13Z",
|
||||
"version": 1,
|
||||
"changeset": 13566903,
|
||||
"user": "skyman81",
|
||||
"uid": 955688
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 3250129361,
|
||||
"lat": 51.2127906,
|
||||
"lon": 3.2409016,
|
||||
"timestamp": "2018-12-19T00:00:33Z",
|
||||
"version": 2,
|
||||
"changeset": 65596519,
|
||||
"user": "beardhatcode",
|
||||
"uid": 5439560,
|
||||
"tags": {"crossing": "traffic_signals", "highway": "crossing"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 3250129363,
|
||||
"lat": 51.2149189,
|
||||
"lon": 3.2395571,
|
||||
"timestamp": "2015-04-11T10:40:56Z",
|
||||
"version": 2,
|
||||
"changeset": 30139621,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 3450326133,
|
||||
"lat": 51.2139571,
|
||||
"lon": 3.2401205,
|
||||
"timestamp": "2015-04-11T10:40:26Z",
|
||||
"version": 1,
|
||||
"changeset": 30139621,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 3450326135,
|
||||
"lat": 51.2181385,
|
||||
"lon": 3.2370893,
|
||||
"timestamp": "2015-04-11T10:40:26Z",
|
||||
"version": 1,
|
||||
"changeset": 30139621,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 4794847239,
|
||||
"lat": 51.2191224,
|
||||
"lon": 3.2362584,
|
||||
"timestamp": "2019-08-27T23:07:05Z",
|
||||
"version": 2,
|
||||
"changeset": 73816461,
|
||||
"user": "Pieter Vander Vennet",
|
||||
"uid": 3818858
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8493044168,
|
||||
"lat": 51.2130348,
|
||||
"lon": 3.2407284,
|
||||
"timestamp": "2021-03-06T21:52:51Z",
|
||||
"version": 1,
|
||||
"changeset": 100555232,
|
||||
"user": "kaart_fietser",
|
||||
"uid": 11022240,
|
||||
"tags": {"highway": "traffic_signals", "traffic_signals": "traffic_lights"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8792687918,
|
||||
"lat": 51.2207505,
|
||||
"lon": 3.2348579,
|
||||
"timestamp": "2021-06-02T18:27:15Z",
|
||||
"version": 1,
|
||||
"changeset": 105735092,
|
||||
"user": "albertino",
|
||||
"uid": 499281
|
||||
}, {
|
||||
"type": "way",
|
||||
"id": 143298912,
|
||||
"timestamp": "2021-06-02T18:27:15Z",
|
||||
"version": 15,
|
||||
"changeset": 105735092,
|
||||
"user": "albertino",
|
||||
"uid": 499281,
|
||||
"nodes": [1407529979, 1974988033, 3250129361, 1634435395, 8493044168, 875668688, 1634435396, 1634435397, 3450326133, 26343912, 3250129363, 1407529969, 26343913, 1407529961, 3450326135, 4794847239, 26343914, 26343915, 1109632177, 1109632153, 8792687918, 1109632154],
|
||||
"tags": {
|
||||
"cycleway:right": "track",
|
||||
"highway": "primary",
|
||||
"lanes": "2",
|
||||
"lit": "yes",
|
||||
"maxspeed": "70",
|
||||
"name": "Buiten Kruisvest",
|
||||
"oneway": "yes",
|
||||
"ref": "R30",
|
||||
"surface": "asphalt",
|
||||
"wikipedia": "nl:Buiten Kruisvest"
|
||||
}
|
||||
}]
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
|
@ -394,7 +666,7 @@ export default class RelationSplitHandlerSpec extends T {
|
|||
allWaysNodesInOrder: withSplit
|
||||
}, "no-theme")
|
||||
const changeDescription = await splitter.CreateChangeDescriptions(new Changes())
|
||||
const allIds = changeDescription[0].changes["members"].map(m => m.type+"/"+ m.ref+"-->"+m.role).join(",")
|
||||
const allIds = changeDescription[0].changes["members"].map(m => m.type + "/" + m.ref + "-->" + m.role).join(",")
|
||||
const expected = "way/318616190-->from,node/1407529979-->via,way/-1-->to"
|
||||
T.equals(expected, allIds)
|
||||
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import T from "./TestHelper";
|
||||
import FullNodeDatabaseSource from "../Logic/FeatureSource/TiledFeatureSource/FullNodeDatabaseSource";
|
||||
import {Utils} from "../Utils";
|
||||
|
||||
export default class ReplaceGeometrySpec extends T {
|
||||
|
@ -177,8 +176,6 @@ export default class ReplaceGeometrySpec extends T {
|
|||
const rawData = await Utils.downloadJsonCached(url, 1000)
|
||||
|
||||
|
||||
|
||||
|
||||
}]
|
||||
]);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,290 @@ import {Utils} from "../Utils";
|
|||
export default class SplitActionSpec extends T {
|
||||
|
||||
|
||||
constructor() {
|
||||
super("splitaction", [
|
||||
["split 295132739",
|
||||
() => SplitActionSpec.split().then(_ => console.log("OK"))],
|
||||
["split 295132739 on already existing node",
|
||||
() => SplitActionSpec.splitWithPointReuse().then(_ => console.log("OK"))],
|
||||
["split 61435323 on already existing node",
|
||||
() => SplitActionSpec.SplitHoutkaai().then(_ => console.log("OK"))],
|
||||
["Split test line",
|
||||
async () => {
|
||||
|
||||
Utils.injectJsonDownloadForTests(
|
||||
"https://www.openstreetmap.org/api/0.6/way/941079939/full",
|
||||
{
|
||||
"version": "0.6",
|
||||
"generator": "CGImap 0.8.5 (957273 spike-08.openstreetmap.org)",
|
||||
"copyright": "OpenStreetMap and contributors",
|
||||
"attribution": "http://www.openstreetmap.org/copyright",
|
||||
"license": "http://opendatacommons.org/licenses/odbl/1-0/",
|
||||
"elements": [{
|
||||
"type": "node",
|
||||
"id": 6490126559,
|
||||
"lat": 51.2332219,
|
||||
"lon": 3.1429387,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 2,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"highway": "street_lamp", "power": "pole", "support": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440363,
|
||||
"lat": 51.2324011,
|
||||
"lon": 3.1367377,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"fixme": "continue"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440364,
|
||||
"lat": 51.232455,
|
||||
"lon": 3.1368759,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"power": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440365,
|
||||
"lat": 51.2325883,
|
||||
"lon": 3.1373986,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"power": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440366,
|
||||
"lat": 51.232688,
|
||||
"lon": 3.1379837,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"power": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440367,
|
||||
"lat": 51.2327354,
|
||||
"lon": 3.1385649,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"power": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440368,
|
||||
"lat": 51.2327042,
|
||||
"lon": 3.1392187,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"highway": "street_lamp", "power": "pole", "support": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440369,
|
||||
"lat": 51.2323902,
|
||||
"lon": 3.139353,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"power": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440370,
|
||||
"lat": 51.2321027,
|
||||
"lon": 3.139601,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"highway": "street_lamp", "power": "pole", "ref": "242", "support": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440371,
|
||||
"lat": 51.2322614,
|
||||
"lon": 3.1401564,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"power": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440372,
|
||||
"lat": 51.232378,
|
||||
"lon": 3.1407909,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"power": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440373,
|
||||
"lat": 51.2325532,
|
||||
"lon": 3.1413659,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"power": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440374,
|
||||
"lat": 51.2327611,
|
||||
"lon": 3.1418877,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"power": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440375,
|
||||
"lat": 51.2330037,
|
||||
"lon": 3.142418,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"power": "pole"}
|
||||
}, {
|
||||
"type": "way",
|
||||
"id": 941079939,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"nodes": [6490126559, 8715440375, 8715440374, 8715440373, 8715440372, 8715440371, 8715440370, 8715440369, 8715440368, 8715440367, 8715440366, 8715440365, 8715440364, 8715440363],
|
||||
"tags": {"power": "minor_line"}
|
||||
}]
|
||||
}
|
||||
)
|
||||
|
||||
Utils.injectJsonDownloadForTests(
|
||||
"https://www.openstreetmap.org/api/0.6/way/941079939/relations",
|
||||
{
|
||||
"version": "0.6",
|
||||
"generator": "CGImap 0.8.5 (2419440 spike-07.openstreetmap.org)",
|
||||
"copyright": "OpenStreetMap and contributors",
|
||||
"attribution": "http://www.openstreetmap.org/copyright",
|
||||
"license": "http://opendatacommons.org/licenses/odbl/1-0/",
|
||||
"elements": []
|
||||
}
|
||||
)
|
||||
|
||||
// Split points are lon,lat
|
||||
const splitPointAroundP3: [number, number] = [3.1392198801040645, 51.232701022376745]
|
||||
const splitAction = new SplitAction("way/941079939", [splitPointAroundP3], {theme: "test"})
|
||||
const changes = await splitAction.Perform(new Changes())
|
||||
console.log(changes)
|
||||
// 8715440368 is the expected point of the split
|
||||
|
||||
/* Nodes are
|
||||
6490126559 (part of ways 941079941 and 941079940)
|
||||
8715440375
|
||||
8715440374
|
||||
8715440373
|
||||
8715440372
|
||||
8715440371
|
||||
8715440370
|
||||
8715440369
|
||||
8715440368 <--- split here
|
||||
8715440367
|
||||
8715440366
|
||||
8715440365
|
||||
8715440364
|
||||
8715440363
|
||||
*/
|
||||
|
||||
const nodeList0 = [6490126559,
|
||||
8715440375,
|
||||
8715440374,
|
||||
8715440373,
|
||||
8715440372,
|
||||
8715440371,
|
||||
8715440370,
|
||||
8715440369,
|
||||
8715440368]
|
||||
|
||||
const nodeList1 = [
|
||||
8715440368,
|
||||
8715440367,
|
||||
8715440366,
|
||||
8715440365,
|
||||
8715440364,
|
||||
8715440363
|
||||
]
|
||||
|
||||
T.listIdentical(nodeList0, changes[0].changes["nodes"])
|
||||
T.listIdentical(nodeList1, changes[1].changes["nodes"])
|
||||
}
|
||||
],
|
||||
["Split minor powerline halfway", async () => {
|
||||
|
||||
|
||||
const splitPointHalfway: [number, number] = [3.1392842531204224, 51.23255322710106]
|
||||
const splitAction = new SplitAction("way/941079939", [splitPointHalfway], {theme: "test"}, 1)
|
||||
const changes = await splitAction.Perform(new Changes())
|
||||
|
||||
const nodeList0 = [6490126559,
|
||||
8715440375,
|
||||
8715440374,
|
||||
8715440373,
|
||||
8715440372,
|
||||
8715440371,
|
||||
8715440370,
|
||||
8715440369,
|
||||
-1]
|
||||
|
||||
const nodeList1 = [
|
||||
-1,
|
||||
8715440368,
|
||||
8715440367,
|
||||
8715440366,
|
||||
8715440365,
|
||||
8715440364,
|
||||
8715440363
|
||||
]
|
||||
// THe first change is the creation of the new node
|
||||
T.equals("node", changes[0].type)
|
||||
T.equals(-1, changes[0].id)
|
||||
|
||||
T.listIdentical(nodeList0, changes[1].changes["nodes"])
|
||||
T.listIdentical(nodeList1, changes[2].changes["nodes"])
|
||||
|
||||
}
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
private static async split(): Promise<void> {
|
||||
|
||||
Utils.injectJsonDownloadForTests(
|
||||
|
@ -214,7 +498,6 @@ export default class SplitActionSpec extends T {
|
|||
equal(changeDescription[2].changes["coordinates"][0][1], splitPoint[1])
|
||||
}
|
||||
|
||||
|
||||
private static async SplitHoutkaai(): Promise<void> {
|
||||
|
||||
Utils.injectJsonDownloadForTests(
|
||||
|
@ -1824,288 +2107,4 @@ export default class SplitActionSpec extends T {
|
|||
equal(nodes0[nodes0.length - 1], nodes1[0])
|
||||
equal(1507524610, nodes1[0])
|
||||
}
|
||||
|
||||
constructor() {
|
||||
super("splitaction", [
|
||||
["split 295132739",
|
||||
() => SplitActionSpec.split().then(_ => console.log("OK"))],
|
||||
["split 295132739 on already existing node",
|
||||
() => SplitActionSpec.splitWithPointReuse().then(_ => console.log("OK"))],
|
||||
["split 61435323 on already existing node",
|
||||
() => SplitActionSpec.SplitHoutkaai().then(_ => console.log("OK"))],
|
||||
["Split test line",
|
||||
async () => {
|
||||
|
||||
Utils.injectJsonDownloadForTests(
|
||||
"https://www.openstreetmap.org/api/0.6/way/941079939/full",
|
||||
{
|
||||
"version": "0.6",
|
||||
"generator": "CGImap 0.8.5 (957273 spike-08.openstreetmap.org)",
|
||||
"copyright": "OpenStreetMap and contributors",
|
||||
"attribution": "http://www.openstreetmap.org/copyright",
|
||||
"license": "http://opendatacommons.org/licenses/odbl/1-0/",
|
||||
"elements": [{
|
||||
"type": "node",
|
||||
"id": 6490126559,
|
||||
"lat": 51.2332219,
|
||||
"lon": 3.1429387,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 2,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"highway": "street_lamp", "power": "pole", "support": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440363,
|
||||
"lat": 51.2324011,
|
||||
"lon": 3.1367377,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"fixme": "continue"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440364,
|
||||
"lat": 51.232455,
|
||||
"lon": 3.1368759,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"power": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440365,
|
||||
"lat": 51.2325883,
|
||||
"lon": 3.1373986,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"power": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440366,
|
||||
"lat": 51.232688,
|
||||
"lon": 3.1379837,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"power": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440367,
|
||||
"lat": 51.2327354,
|
||||
"lon": 3.1385649,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"power": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440368,
|
||||
"lat": 51.2327042,
|
||||
"lon": 3.1392187,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"highway": "street_lamp", "power": "pole", "support": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440369,
|
||||
"lat": 51.2323902,
|
||||
"lon": 3.139353,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"power": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440370,
|
||||
"lat": 51.2321027,
|
||||
"lon": 3.139601,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"highway": "street_lamp", "power": "pole", "ref": "242", "support": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440371,
|
||||
"lat": 51.2322614,
|
||||
"lon": 3.1401564,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"power": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440372,
|
||||
"lat": 51.232378,
|
||||
"lon": 3.1407909,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"power": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440373,
|
||||
"lat": 51.2325532,
|
||||
"lon": 3.1413659,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"power": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440374,
|
||||
"lat": 51.2327611,
|
||||
"lon": 3.1418877,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"power": "pole"}
|
||||
}, {
|
||||
"type": "node",
|
||||
"id": 8715440375,
|
||||
"lat": 51.2330037,
|
||||
"lon": 3.142418,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"tags": {"power": "pole"}
|
||||
}, {
|
||||
"type": "way",
|
||||
"id": 941079939,
|
||||
"timestamp": "2021-05-09T19:04:53Z",
|
||||
"version": 1,
|
||||
"changeset": 104407928,
|
||||
"user": "M!dgard",
|
||||
"uid": 763799,
|
||||
"nodes": [6490126559, 8715440375, 8715440374, 8715440373, 8715440372, 8715440371, 8715440370, 8715440369, 8715440368, 8715440367, 8715440366, 8715440365, 8715440364, 8715440363],
|
||||
"tags": {"power": "minor_line"}
|
||||
}]
|
||||
}
|
||||
)
|
||||
|
||||
Utils.injectJsonDownloadForTests(
|
||||
"https://www.openstreetmap.org/api/0.6/way/941079939/relations",
|
||||
{
|
||||
"version": "0.6",
|
||||
"generator": "CGImap 0.8.5 (2419440 spike-07.openstreetmap.org)",
|
||||
"copyright": "OpenStreetMap and contributors",
|
||||
"attribution": "http://www.openstreetmap.org/copyright",
|
||||
"license": "http://opendatacommons.org/licenses/odbl/1-0/",
|
||||
"elements": []
|
||||
}
|
||||
)
|
||||
|
||||
// Split points are lon,lat
|
||||
const splitPointAroundP3: [number, number] = [3.1392198801040645, 51.232701022376745]
|
||||
const splitAction = new SplitAction("way/941079939", [splitPointAroundP3], {theme: "test"})
|
||||
const changes = await splitAction.Perform(new Changes())
|
||||
console.log(changes)
|
||||
// 8715440368 is the expected point of the split
|
||||
|
||||
/* Nodes are
|
||||
6490126559 (part of ways 941079941 and 941079940)
|
||||
8715440375
|
||||
8715440374
|
||||
8715440373
|
||||
8715440372
|
||||
8715440371
|
||||
8715440370
|
||||
8715440369
|
||||
8715440368 <--- split here
|
||||
8715440367
|
||||
8715440366
|
||||
8715440365
|
||||
8715440364
|
||||
8715440363
|
||||
*/
|
||||
|
||||
const nodeList0 = [6490126559,
|
||||
8715440375,
|
||||
8715440374,
|
||||
8715440373,
|
||||
8715440372,
|
||||
8715440371,
|
||||
8715440370,
|
||||
8715440369,
|
||||
8715440368]
|
||||
|
||||
const nodeList1 = [
|
||||
8715440368,
|
||||
8715440367,
|
||||
8715440366,
|
||||
8715440365,
|
||||
8715440364,
|
||||
8715440363
|
||||
]
|
||||
|
||||
T.listIdentical(nodeList0, changes[0].changes["nodes"])
|
||||
T.listIdentical(nodeList1, changes[1].changes["nodes"])
|
||||
}
|
||||
],
|
||||
["Split minor powerline halfway", async () => {
|
||||
|
||||
|
||||
const splitPointHalfway: [number, number] = [3.1392842531204224, 51.23255322710106]
|
||||
const splitAction = new SplitAction("way/941079939", [splitPointHalfway], {theme: "test"}, 1)
|
||||
const changes = await splitAction.Perform(new Changes())
|
||||
|
||||
const nodeList0 = [6490126559,
|
||||
8715440375,
|
||||
8715440374,
|
||||
8715440373,
|
||||
8715440372,
|
||||
8715440371,
|
||||
8715440370,
|
||||
8715440369,
|
||||
-1]
|
||||
|
||||
const nodeList1 = [
|
||||
-1,
|
||||
8715440368,
|
||||
8715440367,
|
||||
8715440366,
|
||||
8715440365,
|
||||
8715440364,
|
||||
8715440363
|
||||
]
|
||||
// THe first change is the creation of the new node
|
||||
T.equals("node", changes[0].type)
|
||||
T.equals(-1, changes[0].id)
|
||||
|
||||
T.listIdentical(nodeList0, changes[1].changes["nodes"])
|
||||
T.listIdentical(nodeList1, changes[2].changes["nodes"])
|
||||
|
||||
}
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
|
@ -9,7 +9,6 @@ import {Tag} from "../Logic/Tags/Tag";
|
|||
import {And} from "../Logic/Tags/And";
|
||||
import {TagUtils} from "../Logic/Tags/TagUtils";
|
||||
import TagRenderingConfig from "../Models/ThemeConfig/TagRenderingConfig";
|
||||
import {RegexTag} from "../Logic/Tags/RegexTag";
|
||||
|
||||
|
||||
Utils.runningFromConsole = true;
|
||||
|
|
|
@ -38,7 +38,7 @@ Utils.externalDownloadFunction = async (url) => {
|
|||
console.error("Fetching ", url, "blocked in tests, use Utils.injectJsonDownloadForTests")
|
||||
const data = await ScriptUtils.DownloadJSON(url)
|
||||
console.log("\n\n ----------- \nBLOCKED DATA\n Utils.injectJsonDownloadForTests(\n" +
|
||||
" ", JSON.stringify(url),", \n",
|
||||
" ", JSON.stringify(url), ", \n",
|
||||
" ", JSON.stringify(data), "\n )\n------------------\n\n")
|
||||
throw "Detected internet access for URL " + url + ", please inject it with Utils.injectJsonDownloadForTests"
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ if (args.length > 0) {
|
|||
}
|
||||
|
||||
if (testsToRun.length == 0) {
|
||||
throw "No tests found. Try one of "+allTests.map(t => t.name).join(", ")
|
||||
throw "No tests found. Try one of " + allTests.map(t => t.name).join(", ")
|
||||
}
|
||||
|
||||
for (let i = 0; i < testsToRun.length; i++) {
|
||||
|
|
|
@ -8,28 +8,6 @@ export default class T {
|
|||
this._tests = tests;
|
||||
}
|
||||
|
||||
/**
|
||||
* RUns the test, returns the error messages.
|
||||
* Returns an empty list if successful
|
||||
* @constructor
|
||||
*/
|
||||
public Run(): ({ testsuite: string, name: string, msg: string } []) {
|
||||
const failures: { testsuite: string, name: string, msg: string } [] = []
|
||||
for (const [name, test] of this._tests) {
|
||||
try {
|
||||
test();
|
||||
} 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
|
||||
}
|
||||
}
|
||||
|
||||
static assertContains(needle: string, actual: string) {
|
||||
if (actual.indexOf(needle) < 0) {
|
||||
throw `The substring ${needle} was not found`
|
||||
|
@ -57,10 +35,10 @@ export default class T {
|
|||
}
|
||||
|
||||
static listIdentical<T>(expected: T[], actual: T[]): void {
|
||||
if(expected === undefined){
|
||||
if (expected === undefined) {
|
||||
throw "ListIdentical failed: expected list is undefined"
|
||||
}
|
||||
if(actual === undefined){
|
||||
if (actual === undefined) {
|
||||
throw "ListIdentical failed: actual list is undefined"
|
||||
}
|
||||
if (expected.length !== actual.length) {
|
||||
|
@ -68,8 +46,30 @@ export default class T {
|
|||
}
|
||||
for (let i = 0; i < expected.length; i++) {
|
||||
if (expected[i] !== actual[i]) {
|
||||
throw `ListIdentical failed at index ${i}: expected ${expected[i]} but got ${actual[i]}`
|
||||
throw `ListIdentical failed at index ${i}: expected ${expected[i]} but got ${actual[i]}`
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* RUns the test, returns the error messages.
|
||||
* Returns an empty list if successful
|
||||
* @constructor
|
||||
*/
|
||||
public Run(): ({ testsuite: string, name: string, msg: string } []) {
|
||||
const failures: { testsuite: string, name: string, msg: string } [] = []
|
||||
for (const [name, test] of this._tests) {
|
||||
try {
|
||||
test();
|
||||
} 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,9 @@ export default class TileFreshnessCalculatorSpec extends T {
|
|||
equal(42, calc.freshnessFor(20, 266406 * 2, 175534 * 2 + 1).getTime())
|
||||
equal(undefined, calc.freshnessFor(19, 266406, 175535))
|
||||
equal(undefined, calc.freshnessFor(18, 266406 / 2, 175534 / 2))
|
||||
calc.addTileLoad(Tiles.tile_index(19, 266406, 175534+1), date)
|
||||
calc.addTileLoad(Tiles.tile_index(19, 266406+1, 175534), date)
|
||||
calc.addTileLoad(Tiles.tile_index(19, 266406+1, 175534+1), date)
|
||||
calc.addTileLoad(Tiles.tile_index(19, 266406, 175534 + 1), date)
|
||||
calc.addTileLoad(Tiles.tile_index(19, 266406 + 1, 175534), date)
|
||||
calc.addTileLoad(Tiles.tile_index(19, 266406 + 1, 175534 + 1), date)
|
||||
equal(42, calc.freshnessFor(18, 266406 / 2, 175534 / 2).getTime())
|
||||
}
|
||||
]
|
||||
|
|
|
@ -43,7 +43,7 @@ export default class UtilsSpec extends T {
|
|||
["Sort object keys", () => {
|
||||
const o = {
|
||||
x: 'x',
|
||||
abc: {'x':'x','a':'a'},
|
||||
abc: {'x': 'x', 'a': 'a'},
|
||||
def: 'def'
|
||||
}
|
||||
equal('{"x":"x","abc":{"x":"x","a":"a"},"def":"def"}', JSON.stringify(o))
|
||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue