Fix: fix tests with some refactoring
This commit is contained in:
parent
f132963485
commit
0b992e75a4
7 changed files with 64 additions and 401 deletions
|
@ -1,5 +1,4 @@
|
|||
import { Utils } from "../../../../src/Utils"
|
||||
import LayoutConfig from "../../../../src/Models/ThemeConfig/LayoutConfig"
|
||||
import { BBox } from "../../../../src/Logic/BBox"
|
||||
import ReplaceGeometryAction from "../../../../src/Logic/Osm/Actions/ReplaceGeometryAction"
|
||||
import { describe, expect, it } from "vitest"
|
||||
|
@ -9,305 +8,6 @@ import { Changes } from "../../../../src/Logic/Osm/Changes"
|
|||
import FullNodeDatabaseSource from "../../../../src/Logic/FeatureSource/TiledFeatureSource/FullNodeDatabaseSource"
|
||||
|
||||
describe("ReplaceGeometryAction", () => {
|
||||
const grbStripped = {
|
||||
id: "grb",
|
||||
title: {
|
||||
nl: "GRB import helper",
|
||||
},
|
||||
description: "Smaller version of the GRB theme",
|
||||
language: ["nl", "en"],
|
||||
socialImage: "img.jpg",
|
||||
version: "0",
|
||||
startLat: 51.0249,
|
||||
startLon: 4.026489,
|
||||
startZoom: 9,
|
||||
clustering: false,
|
||||
overrideAll: {
|
||||
minzoom: 19,
|
||||
},
|
||||
layers: [
|
||||
{
|
||||
id: "type_node",
|
||||
source: {
|
||||
osmTags: "type=node",
|
||||
},
|
||||
pointRendering: null,
|
||||
lineRendering: [{}],
|
||||
override: {
|
||||
calculatedTags: [
|
||||
"_is_part_of_building=feat.get('parent_ways')?.some(p => p.building !== undefined && p.building !== '') ?? false",
|
||||
"_is_part_of_grb_building=feat.get('parent_ways')?.some(p => p['source:geometry:ref'] !== undefined) ?? false",
|
||||
"_is_part_of_building_passage=feat.get('parent_ways')?.some(p => p.tunnel === 'building_passage') ?? false",
|
||||
"_is_part_of_highway=!feat.get('is_part_of_building_passage') && (feat.get('parent_ways')?.some(p => p.highway !== undefined && p.highway !== '') ?? false)",
|
||||
"_is_part_of_landuse=feat.get('parent_ways')?.some(p => (p.landuse !== undefined && p.landuse !== '') || (p.natural !== undefined && p.natural !== '')) ?? false",
|
||||
"_moveable=feat.get('_is_part_of_building') && !feat.get('_is_part_of_grb_building')",
|
||||
],
|
||||
pointRendering: [
|
||||
{
|
||||
marker: [
|
||||
{
|
||||
icon: "square",
|
||||
color: "#cc0",
|
||||
},
|
||||
],
|
||||
iconSize: "5,5",
|
||||
location: ["point"],
|
||||
},
|
||||
],
|
||||
passAllFeatures: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "osm-buildings",
|
||||
name: "All OSM-buildings",
|
||||
source: {
|
||||
osmTags: "building~*",
|
||||
},
|
||||
calculatedTags: ["_surface:strict:=feat.get('_surface')"],
|
||||
lineRendering: [
|
||||
{
|
||||
width: {
|
||||
render: "2",
|
||||
mappings: [
|
||||
{
|
||||
if: "fixme~*",
|
||||
then: "5",
|
||||
},
|
||||
],
|
||||
},
|
||||
color: {
|
||||
render: "#00c",
|
||||
mappings: [
|
||||
{
|
||||
if: "fixme~*",
|
||||
then: "#ff00ff",
|
||||
},
|
||||
{
|
||||
if: "building=house",
|
||||
then: "#a00",
|
||||
},
|
||||
{
|
||||
if: "building=shed",
|
||||
then: "#563e02",
|
||||
},
|
||||
{
|
||||
if: {
|
||||
or: ["building=garage", "building=garages"],
|
||||
},
|
||||
then: "#f9bfbb",
|
||||
},
|
||||
{
|
||||
if: "building=yes",
|
||||
then: "#0774f2",
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
title: "OSM-gebouw",
|
||||
tagRenderings: [
|
||||
{
|
||||
id: "building type",
|
||||
freeform: {
|
||||
key: "building",
|
||||
},
|
||||
render: "The building type is <b>{building}</b>",
|
||||
question: {
|
||||
en: "What kind of building is this?",
|
||||
},
|
||||
mappings: [
|
||||
{
|
||||
if: "building=house",
|
||||
then: "A normal house",
|
||||
},
|
||||
{
|
||||
if: "building=detached",
|
||||
then: "A house detached from other building",
|
||||
},
|
||||
{
|
||||
if: "building=semidetached_house",
|
||||
then: "A house sharing only one wall with another house",
|
||||
},
|
||||
{
|
||||
if: "building=apartments",
|
||||
then: "An apartment building - highrise for living",
|
||||
},
|
||||
{
|
||||
if: "building=office",
|
||||
then: "An office building - highrise for work",
|
||||
},
|
||||
{
|
||||
if: "building=apartments",
|
||||
then: "An apartment building",
|
||||
},
|
||||
{
|
||||
if: "building=shed",
|
||||
then: "A small shed, e.g. in a garden",
|
||||
},
|
||||
{
|
||||
if: "building=garage",
|
||||
then: "A single garage to park a car",
|
||||
},
|
||||
{
|
||||
if: "building=garages",
|
||||
then: "A building containing only garages; typically they are all identical",
|
||||
},
|
||||
{
|
||||
if: "building=yes",
|
||||
then: "A building - no specification",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "grb-housenumber",
|
||||
render: {
|
||||
nl: "Het huisnummer is <b>{addr:housenumber}</b>",
|
||||
},
|
||||
question: {
|
||||
nl: "Wat is het huisnummer?",
|
||||
},
|
||||
freeform: {
|
||||
key: "addr:housenumber",
|
||||
},
|
||||
mappings: [
|
||||
{
|
||||
if: {
|
||||
and: ["not:addr:housenumber=yes", "addr:housenumber="],
|
||||
},
|
||||
then: {
|
||||
nl: "Geen huisnummer",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "grb-unit",
|
||||
question: "Wat is de wooneenheid-aanduiding?",
|
||||
render: {
|
||||
nl: "De wooneenheid-aanduiding is <b>{addr:unit}</b> ",
|
||||
},
|
||||
freeform: {
|
||||
key: "addr:unit",
|
||||
},
|
||||
mappings: [
|
||||
{
|
||||
if: "addr:unit=",
|
||||
then: "Geen wooneenheid-nummer",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "grb-street",
|
||||
render: {
|
||||
nl: "De straat is <b>{addr:street}</b>",
|
||||
},
|
||||
freeform: {
|
||||
key: "addr:street",
|
||||
},
|
||||
question: {
|
||||
nl: "Wat is de straat?",
|
||||
},
|
||||
},
|
||||
{
|
||||
id: "grb-fixme",
|
||||
render: {
|
||||
nl: "De fixme is <b>{fixme}</b>",
|
||||
},
|
||||
question: {
|
||||
nl: "Wat zegt de fixme?",
|
||||
},
|
||||
freeform: {
|
||||
key: "fixme",
|
||||
},
|
||||
mappings: [
|
||||
{
|
||||
if: {
|
||||
and: ["fixme="],
|
||||
},
|
||||
then: {
|
||||
nl: "Geen fixme",
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "grb-min-level",
|
||||
render: {
|
||||
nl: "Dit gebouw begint maar op de {building:min_level} verdieping",
|
||||
},
|
||||
question: {
|
||||
nl: "Hoeveel verdiepingen ontbreken?",
|
||||
},
|
||||
freeform: {
|
||||
key: "building:min_level",
|
||||
type: "pnat",
|
||||
},
|
||||
},
|
||||
"all_tags",
|
||||
],
|
||||
filter: [
|
||||
{
|
||||
id: "has-fixme",
|
||||
options: [
|
||||
{
|
||||
osmTags: "fixme~*",
|
||||
question: "Heeft een FIXME",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "grb",
|
||||
description: "Geometry which comes from GRB with tools to import them",
|
||||
source: {
|
||||
osmTags: {
|
||||
and: ["HUISNR~*", "man_made!=mast"],
|
||||
},
|
||||
geoJson:
|
||||
"https://betadata.grbosm.site/grb?bbox={x_min},{y_min},{x_max},{y_max}",
|
||||
geoJsonZoomLevel: 18,
|
||||
mercatorCrs: true,
|
||||
},
|
||||
name: "GRB geometries",
|
||||
title: "GRB outline",
|
||||
calculatedTags: [
|
||||
"_overlaps_with_buildings=feat.overlapWith('osm-buildings').filter(f => f.feat.properties.id.indexOf('-') < 0)",
|
||||
"_overlaps_with=feat.get('_overlaps_with_buildings').filter(f => f.overlap > 1 /* square meter */ )[0] ?? ''",
|
||||
"_osm_obj:source:ref=feat.get('_overlaps_with')?.feat?.properties['source:geometry:ref']",
|
||||
"_osm_obj:id=feat.get('_overlaps_with')?.feat?.properties?.id",
|
||||
"_osm_obj:source:date=feat.get('_overlaps_with')?.feat?.properties['source:geometry:date'].replace(/\\//g, '-')",
|
||||
"_osm_obj:building=feat.get('_overlaps_with')?.feat?.properties?.building",
|
||||
"_osm_obj:addr:street=(feat.get('_overlaps_with')?.feat?.properties ?? {})['addr:street']",
|
||||
"_osm_obj:addr:housenumber=(feat.get('_overlaps_with')?.feat?.properties ?? {})['addr:housenumber']",
|
||||
"_osm_obj:surface=(feat.get('_overlaps_with')?.feat?.properties ?? {})['_surface:strict']",
|
||||
|
||||
"_overlap_absolute=feat.get('_overlaps_with')?.overlap",
|
||||
"_reverse_overlap_percentage=Math.round(100 * feat.get('_overlap_absolute') / feat.get('_surface'))",
|
||||
"_overlap_percentage=Math.round(100 * feat.get('_overlap_absolute') / feat.get('_osm_obj:surface'))",
|
||||
"_grb_ref=feat.properties['source:geometry:entity'] + '/' + feat.properties['source:geometry:oidn']",
|
||||
"_imported_osm_object_found= feat.properties['_osm_obj:source:ref'] == feat.properties._grb_ref",
|
||||
"_grb_date=feat.properties['source:geometry:date'].replace(/\\//g,'-')",
|
||||
"_imported_osm_still_fresh= feat.properties['_osm_obj:source:date'] == feat.properties._grb_date",
|
||||
"_target_building_type=feat.properties['_osm_obj:building'] === 'yes' ? feat.properties.building : (feat.properties['_osm_obj:building'] ?? feat.properties.building)",
|
||||
"_building:min_level= feat.properties['fixme']?.startsWith('verdieping, correct the building tag, add building:level and building:min_level before upload in JOSM!') ? '1' : ''",
|
||||
"_intersects_with_other_features=feat.intersectionsWith('generic_osm_object').map(f => \"<a href='https://osm.org/\"+f.feat.properties.id+\"' target='_blank'>\" + f.feat.properties.id + \"</a>\").join(', ')",
|
||||
],
|
||||
tagRenderings: [],
|
||||
pointRendering: [
|
||||
{
|
||||
marker: [
|
||||
{
|
||||
icon: "./assets/themes/grb/housenumber_blank.svg",
|
||||
},
|
||||
],
|
||||
iconSize: "50,50",
|
||||
location: ["point", "centroid"],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}
|
||||
|
||||
const coordinates = <[number, number][]>[
|
||||
[3.216690793633461, 51.21474084112525],
|
||||
|
@ -890,10 +590,7 @@ describe("ReplaceGeometryAction", () => {
|
|||
const data = await Utils.downloadJson(url)
|
||||
const fullNodeDatabase = new FullNodeDatabaseSource()
|
||||
fullNodeDatabase.handleOsmJson(data, 0, 0, 0)
|
||||
const changes = new Changes({
|
||||
dryRun: new ImmutableStore(true),
|
||||
osmConnection: new OsmConnection(),
|
||||
})
|
||||
const changes = Changes.createTestObject()
|
||||
const osmConnection = new OsmConnection({
|
||||
dryRun: new ImmutableStore(true),
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue