forked from MapComplete/MapComplete
Fix: revert some dependencies to a lower number to fix the build, update turf to 7.2.0
This commit is contained in:
parent
191391e1a7
commit
c83b7c1d95
7 changed files with 14928 additions and 3722 deletions
18405
package-lock.json
generated
18405
package-lock.json
generated
File diff suppressed because it is too large
Load diff
29
package.json
29
package.json
|
@ -150,7 +150,6 @@
|
||||||
"create:database": "vite-node scripts/osm2pgsql/createNewDatabase.ts",
|
"create:database": "vite-node scripts/osm2pgsql/createNewDatabase.ts",
|
||||||
"delete:database:old": "vite-node scripts/osm2pgsql/deleteOldDbs.ts",
|
"delete:database:old": "vite-node scripts/osm2pgsql/deleteOldDbs.ts",
|
||||||
"upload:panoramax": "vite-node scripts/ImgurToPanoramax.ts # && josm imgur_to_panoramax.osc",
|
"upload:panoramax": "vite-node scripts/ImgurToPanoramax.ts # && josm imgur_to_panoramax.osc",
|
||||||
|
|
||||||
"#": "Android development",
|
"#": "Android development",
|
||||||
"android:prepare": "./scripts/prepareAndroid.sh",
|
"android:prepare": "./scripts/prepareAndroid.sh",
|
||||||
"android:build": "./scripts/buildAndroid.sh",
|
"android:build": "./scripts/buildAndroid.sh",
|
||||||
|
@ -180,13 +179,13 @@
|
||||||
"@rgossiaux/svelte-headlessui": "^1.0.2",
|
"@rgossiaux/svelte-headlessui": "^1.0.2",
|
||||||
"@rgossiaux/svelte-heroicons": "^0.1.2",
|
"@rgossiaux/svelte-heroicons": "^0.1.2",
|
||||||
"@rollup/plugin-typescript": "^11.0.0",
|
"@rollup/plugin-typescript": "^11.0.0",
|
||||||
"@turf/boolean-intersects": "^6.5.0",
|
"@turf/boolean-intersects": "^7.2.0",
|
||||||
"@turf/buffer": "^6.5.0",
|
"@turf/buffer": "^7.2.0",
|
||||||
"@turf/collect": "^6.5.0",
|
"@turf/collect": "^7.2.0",
|
||||||
"@turf/difference": "^6.5.0",
|
"@turf/difference": "^7.2.0",
|
||||||
"@turf/distance": "^6.5.0",
|
"@turf/distance": "^7.2.0",
|
||||||
"@turf/length": "^6.5.0",
|
"@turf/length": "^7.2.0",
|
||||||
"@turf/turf": "^6.5.0",
|
"@turf/turf": "^7.2.0",
|
||||||
"@types/dompurify": "^3.0.2",
|
"@types/dompurify": "^3.0.2",
|
||||||
"@types/follow-redirects": "^1.14.4",
|
"@types/follow-redirects": "^1.14.4",
|
||||||
"@types/pg": "^8.10.9",
|
"@types/pg": "^8.10.9",
|
||||||
|
@ -225,6 +224,7 @@
|
||||||
"monaco-editor": "^0.46.0",
|
"monaco-editor": "^0.46.0",
|
||||||
"mvt-to-geojson": "^0.0.6",
|
"mvt-to-geojson": "^0.0.6",
|
||||||
"name-suggestion-index": "^6.0.20250119",
|
"name-suggestion-index": "^6.0.20250119",
|
||||||
|
"npm": "^11.1.0",
|
||||||
"opening_hours": "^3.6.0",
|
"opening_hours": "^3.6.0",
|
||||||
"osm-auth": "^2.6.0",
|
"osm-auth": "^2.6.0",
|
||||||
"osmtogeojson": "^3.0.0-beta.5",
|
"osmtogeojson": "^3.0.0-beta.5",
|
||||||
|
@ -238,17 +238,17 @@
|
||||||
"prompt-sync": "^4.2.0",
|
"prompt-sync": "^4.2.0",
|
||||||
"qrcode-generator": "^1.4.4",
|
"qrcode-generator": "^1.4.4",
|
||||||
"showdown": "^2.1.0",
|
"showdown": "^2.1.0",
|
||||||
|
"svelte": "^3.59.2",
|
||||||
"svg-path-parser": "^1.1.0",
|
"svg-path-parser": "^1.1.0",
|
||||||
"tailwind-merge": "^1.14.0",
|
"tailwind-merge": "^1.14.0",
|
||||||
"tailwindcss": "^3.4.17",
|
"tailwindcss": "^3.4.17",
|
||||||
|
"ts-node": "^10.9.2",
|
||||||
"turndown": "^7.2.0",
|
"turndown": "^7.2.0",
|
||||||
"wikibase-sdk": "^10.2.1",
|
"wikibase-sdk": "^10.2.1",
|
||||||
"xml2js": "^0.5.0"
|
"xml2js": "^0.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babeard/svelte-heroicons": "^2.0.0-rc.0",
|
"@babeard/svelte-heroicons": "^2.0.0-rc.0",
|
||||||
"vite-node": "^3.0.5",
|
|
||||||
"vitest": "^3.0.5",
|
|
||||||
"@babel/polyfill": "^7.10.4",
|
"@babel/polyfill": "^7.10.4",
|
||||||
"@babel/preset-env": "7.13.8",
|
"@babel/preset-env": "7.13.8",
|
||||||
"@capacitor/cli": "^6.1.2",
|
"@capacitor/cli": "^6.1.2",
|
||||||
|
@ -262,7 +262,7 @@
|
||||||
"@types/jsonld": "^1.5.13",
|
"@types/jsonld": "^1.5.13",
|
||||||
"@types/lz-string": "^1.3.34",
|
"@types/lz-string": "^1.3.34",
|
||||||
"@types/mocha": "^10.0.1",
|
"@types/mocha": "^10.0.1",
|
||||||
"@types/node": "^18.11.18",
|
"@types/node": "^18.19.75",
|
||||||
"@types/papaparse": "^5.3.1",
|
"@types/papaparse": "^5.3.1",
|
||||||
"@types/prompt-sync": "^4.1.0",
|
"@types/prompt-sync": "^4.1.0",
|
||||||
"@types/wikidata-sdk": "^6.1.0",
|
"@types/wikidata-sdk": "^6.1.0",
|
||||||
|
@ -284,12 +284,13 @@
|
||||||
"sass": "^1.58.0",
|
"sass": "^1.58.0",
|
||||||
"sharp": "^0.32.6",
|
"sharp": "^0.32.6",
|
||||||
"standard-version": "^9.5.0",
|
"standard-version": "^9.5.0",
|
||||||
"svelte": "^3.59.2",
|
|
||||||
"svelte-check": "^3.0.2",
|
"svelte-check": "^3.0.2",
|
||||||
"svelte-preprocess": "^5.0.1",
|
"svelte-preprocess": "^5.0.1",
|
||||||
"ts2json-schema": "^1.4.0",
|
"ts2json-schema": "^1.4.0",
|
||||||
"tslib": "^2.5.0",
|
"tslib": "^2.5.0",
|
||||||
"typescript": "~5.0.0",
|
"typescript": "^4.7.4",
|
||||||
"vite": "^4.5.9"
|
"vite": "^4.5.9",
|
||||||
|
"vite-node": "^0.28.3",
|
||||||
|
"vitest": "^0.28.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import * as turf from "@turf/turf"
|
import { bbox } from "@turf/bbox"
|
||||||
|
import { AllGeoJSON } from "@turf/turf"
|
||||||
import { TileRange, Tiles } from "../Models/TileRange"
|
import { TileRange, Tiles } from "../Models/TileRange"
|
||||||
import { GeoOperations } from "./GeoOperations"
|
import { GeoOperations } from "./GeoOperations"
|
||||||
import { Feature, Polygon } from "geojson"
|
import { Feature, Polygon } from "geojson"
|
||||||
|
@ -61,7 +62,7 @@ export class BBox {
|
||||||
* Gets the bbox from a feature and caches it (by monkeypatching) the relevant feature
|
* Gets the bbox from a feature and caches it (by monkeypatching) the relevant feature
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* const f = {type:"Feature",properties: {}, geometry: {type: "Point", coordinates: [-100,45]}}
|
* const f = <Feature> {type:"Feature",properties: {}, geometry: {type: "Point", coordinates: [-100,45]}}
|
||||||
* const bb = BBox.get(f)
|
* const bb = BBox.get(f)
|
||||||
* bb.minLat // => 45
|
* bb.minLat // => 45
|
||||||
* bb.minLon // => -100
|
* bb.minLon // => -100
|
||||||
|
@ -70,12 +71,22 @@ export class BBox {
|
||||||
static get(feature: Feature): BBox {
|
static get(feature: Feature): BBox {
|
||||||
const f = <any>feature
|
const f = <any>feature
|
||||||
if (f.bbox?.overlapsWith === undefined) {
|
if (f.bbox?.overlapsWith === undefined) {
|
||||||
const [minX, minY, maxX, maxY]: number[] = turf.bbox(feature)
|
const bb = bbox(<AllGeoJSON>feature)
|
||||||
// Note: x is longitude
|
console.log(">>> ", bb)
|
||||||
f["bbox"] = new BBox([
|
if (Array.isArray(bb)) {
|
||||||
[minX, minY],
|
const [minX, minY, maxX, maxY]: number[] = bb
|
||||||
[maxX, maxY],
|
f["bbox"] = new BBox([
|
||||||
])
|
[minX, minY],
|
||||||
|
[maxX, maxY]
|
||||||
|
])
|
||||||
|
} else {
|
||||||
|
const { minLon, minLat, maxLon, maxLat } = bb
|
||||||
|
// Note: x is longitude
|
||||||
|
f["bbox"] = new BBox([
|
||||||
|
[minLon, minLat],
|
||||||
|
[maxLon, maxLat]
|
||||||
|
])
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return f["bbox"]
|
return f["bbox"]
|
||||||
}
|
}
|
||||||
|
@ -260,7 +271,7 @@ export class BBox {
|
||||||
return this["geojsonCache"]
|
return this["geojsonCache"]
|
||||||
}
|
}
|
||||||
|
|
||||||
public asGeoJson<T = {}>(properties?: T): Feature<Polygon, T> {
|
public asGeoJson<T = Record<string, string>>(properties?: T): Feature<Polygon, T> {
|
||||||
return {
|
return {
|
||||||
type: "Feature",
|
type: "Feature",
|
||||||
properties: properties,
|
properties: properties,
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { BBox } from "./BBox"
|
import { BBox } from "./BBox"
|
||||||
import * as turf from "@turf/turf"
|
import * as turf from "@turf/turf"
|
||||||
import { AllGeoJSON, booleanWithin, Coord, Polygon } from "@turf/turf"
|
import { AllGeoJSON, booleanWithin, Coord } from "@turf/turf"
|
||||||
import {
|
import {
|
||||||
Feature,
|
Feature,
|
||||||
FeatureCollection,
|
FeatureCollection,
|
||||||
|
@ -9,11 +9,11 @@ import {
|
||||||
MultiLineString,
|
MultiLineString,
|
||||||
MultiPolygon,
|
MultiPolygon,
|
||||||
Point,
|
Point,
|
||||||
|
Polygon,
|
||||||
Position
|
Position
|
||||||
} from "geojson"
|
} from "geojson"
|
||||||
import { Tiles } from "../Models/TileRange"
|
import { Tiles } from "../Models/TileRange"
|
||||||
import { Utils } from "../Utils"
|
import { Utils } from "../Utils"
|
||||||
import { NearestPointOnLine } from "@turf/nearest-point-on-line"
|
|
||||||
|
|
||||||
("use strict")
|
("use strict")
|
||||||
|
|
||||||
|
@ -57,14 +57,14 @@ export class GeoOperations {
|
||||||
f0: Feature<Polygon | MultiPolygon>,
|
f0: Feature<Polygon | MultiPolygon>,
|
||||||
f1: Feature<Polygon | MultiPolygon>
|
f1: Feature<Polygon | MultiPolygon>
|
||||||
): Feature<Polygon | MultiPolygon> | null {
|
): Feature<Polygon | MultiPolygon> | null {
|
||||||
return turf.union(f0, f1)
|
return turf.union(turf.featureCollection([f0, f1]))
|
||||||
}
|
}
|
||||||
|
|
||||||
public static intersect(
|
public static intersect(
|
||||||
f0: Readonly<Feature<Polygon | MultiPolygon>>,
|
f0: Readonly<Feature<Polygon | MultiPolygon>>,
|
||||||
f1: Readonly<Feature<Polygon | MultiPolygon>>
|
f1: Readonly<Feature<Polygon | MultiPolygon>>
|
||||||
): Feature<Polygon | MultiPolygon> | null {
|
): Feature<Polygon | MultiPolygon> | null {
|
||||||
return turf.intersect(f0, f1)
|
return turf.intersect(turf.featureCollection([f0, f1]))
|
||||||
}
|
}
|
||||||
|
|
||||||
static surfaceAreaInSqMeters(feature: Feature<Polygon | MultiPolygon>): number {
|
static surfaceAreaInSqMeters(feature: Feature<Polygon | MultiPolygon>): number {
|
||||||
|
@ -145,7 +145,7 @@ export class GeoOperations {
|
||||||
* const line = {"type": "Feature","properties": {},"geometry": {"type": "LineString","coordinates": [[3.779296875,48.777912755501845],[1.23046875,47.60616304386874]]}};
|
* const line = {"type": "Feature","properties": {},"geometry": {"type": "LineString","coordinates": [[3.779296875,48.777912755501845],[1.23046875,47.60616304386874]]}};
|
||||||
* const lineOverlap = GeoOperations.calculateOverlap(line, [polygon]);
|
* const lineOverlap = GeoOperations.calculateOverlap(line, [polygon]);
|
||||||
* lineOverlap.length // => 1
|
* lineOverlap.length // => 1
|
||||||
* lineOverlap[0].overlap // => 156745.3293320278
|
* lineOverlap[0].overlap // => 158835.70531134616
|
||||||
* lineOverlap[0].feat == polygon // => true
|
* lineOverlap[0].feat == polygon // => true
|
||||||
* const line0 = {"type": "Feature","properties": {},"geometry": {"type": "LineString","coordinates": [[0.0439453125,47.31648293428332],[0.6591796875,46.77749276376827]]}};
|
* const line0 = {"type": "Feature","properties": {},"geometry": {"type": "LineString","coordinates": [[0.0439453125,47.31648293428332],[0.6591796875,46.77749276376827]]}};
|
||||||
* const overlap0 = GeoOperations.calculateOverlap(line0, [polygon]);
|
* const overlap0 = GeoOperations.calculateOverlap(line0, [polygon]);
|
||||||
|
@ -158,7 +158,7 @@ export class GeoOperations {
|
||||||
const featureBBox = BBox.get(feature)
|
const featureBBox = BBox.get(feature)
|
||||||
const result: { feat: Feature; overlap: number }[] = []
|
const result: { feat: Feature; overlap: number }[] = []
|
||||||
if (feature.geometry.type === "Point") {
|
if (feature.geometry.type === "Point") {
|
||||||
const coor = <[number, number]>feature.geometry.coordinates
|
const coor = <[number, number]>(<Feature<Point>>feature).geometry.coordinates
|
||||||
for (const otherFeature of otherFeatures) {
|
for (const otherFeature of otherFeatures) {
|
||||||
if (
|
if (
|
||||||
feature.properties.id !== undefined &&
|
feature.properties.id !== undefined &&
|
||||||
|
@ -278,7 +278,7 @@ export class GeoOperations {
|
||||||
|
|
||||||
if (feature.geometry.type === "MultiPolygon") {
|
if (feature.geometry.type === "MultiPolygon") {
|
||||||
const coordinatess: [number, number][][][] = <[number, number][][][]>(
|
const coordinatess: [number, number][][][] = <[number, number][][][]>(
|
||||||
feature.geometry.coordinates
|
(<Feature<MultiPolygon>>feature).geometry.coordinates
|
||||||
)
|
)
|
||||||
for (const coordinates of coordinatess) {
|
for (const coordinates of coordinatess) {
|
||||||
const inThisPolygon = GeoOperations.pointInPolygonCoordinates(x, y, coordinates)
|
const inThisPolygon = GeoOperations.pointInPolygonCoordinates(x, y, coordinates)
|
||||||
|
@ -293,7 +293,7 @@ export class GeoOperations {
|
||||||
return GeoOperations.pointInPolygonCoordinates(
|
return GeoOperations.pointInPolygonCoordinates(
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
<[number, number][][]>feature.geometry.coordinates
|
<[number, number][][]>(<Feature<Polygon>>feature).geometry.coordinates
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +313,7 @@ export class GeoOperations {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
static bbox(feature: Feature | FeatureCollection): Feature<LineString> {
|
static bbox(feature: AllGeoJSON): Feature<LineString> {
|
||||||
const [lon, lat, lon0, lat0] = turf.bbox(feature)
|
const [lon, lat, lon0, lat0] = turf.bbox(feature)
|
||||||
return {
|
return {
|
||||||
type: "Feature",
|
type: "Feature",
|
||||||
|
@ -345,7 +345,7 @@ export class GeoOperations {
|
||||||
public static nearestPoint(
|
public static nearestPoint(
|
||||||
way: Feature<LineString>,
|
way: Feature<LineString>,
|
||||||
point: [number, number]
|
point: [number, number]
|
||||||
): NearestPointOnLine {
|
): Feature<Point, { dist: number; index: number; multiFeatureIndex: number; location: number }> {
|
||||||
return turf.nearestPointOnLine(<Feature<LineString>>way, point, { units: "kilometers" })
|
return turf.nearestPointOnLine(<Feature<LineString>>way, point, { units: "kilometers" })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -576,7 +576,7 @@ export class GeoOperations {
|
||||||
}
|
}
|
||||||
title = Utils.EncodeXmlValue(title)
|
title = Utils.EncodeXmlValue(title)
|
||||||
const trackPoints: string[] = []
|
const trackPoints: string[] = []
|
||||||
let locationsWithMeta: Feature<Point, { date?: string; altitude?: number | string }>[]
|
let locationsWithMeta: Feature<Point>[]
|
||||||
if (Array.isArray(locations)) {
|
if (Array.isArray(locations)) {
|
||||||
locationsWithMeta = locations
|
locationsWithMeta = locations
|
||||||
} else {
|
} else {
|
||||||
|
@ -826,7 +826,7 @@ export class GeoOperations {
|
||||||
}
|
}
|
||||||
if (toSplit.geometry.type === "Polygon" || toSplit.geometry.type == "MultiPolygon") {
|
if (toSplit.geometry.type === "Polygon" || toSplit.geometry.type == "MultiPolygon") {
|
||||||
|
|
||||||
const splitup = turf.intersect(<Feature<Polygon>>toSplit, boundary)
|
const splitup = turf.intersect(turf.featureCollection([<Feature<Polygon | MultiPolygon>>toSplit, boundary]))
|
||||||
if (splitup === null) {
|
if (splitup === null) {
|
||||||
// No intersection found.
|
// No intersection found.
|
||||||
// Either: the boundary is contained fully in 'toSplit', 'toSplit' is contained fully in 'boundary' or they are unrelated at all
|
// Either: the boundary is contained fully in 'toSplit', 'toSplit' is contained fully in 'boundary' or they are unrelated at all
|
||||||
|
@ -859,7 +859,7 @@ export class GeoOperations {
|
||||||
* f("start", g({type:"Point", coordinates:[1,2]})) // => undefined
|
* f("start", g({type:"Point", coordinates:[1,2]})) // => undefined
|
||||||
* f("centroid", g({type:"LineString", coordinates:[[1,2], [3,4]]})) // => [2,3]
|
* f("centroid", g({type:"LineString", coordinates:[[1,2], [3,4]]})) // => [2,3]
|
||||||
* f("centroid", g({type:"Polygon", coordinates:[[[1,2], [3,4], [1,2]]]})) // => [2,3]
|
* f("centroid", g({type:"Polygon", coordinates:[[[1,2], [3,4], [1,2]]]})) // => [2,3]
|
||||||
* f("projected_centerpoint", g({type:"LineString", coordinates:[[1,2], [3,4]]})) // => [1.9993137596003214,2.999313759600321]
|
* f("projected_centerpoint", g({type:"LineString", coordinates:[[1,2], [3,4]]})) // => [ 1.9993134785863844, 3.000684536363483]
|
||||||
* f("start", g({type:"LineString", coordinates:[[1,2], [3,4]]})) // => [1,2]
|
* f("start", g({type:"LineString", coordinates:[[1,2], [3,4]]})) // => [1,2]
|
||||||
* f("end", g({type:"LineString", coordinates:[[1,2], [3,4]]})) // => [3,4]
|
* f("end", g({type:"LineString", coordinates:[[1,2], [3,4]]})) // => [3,4]
|
||||||
*
|
*
|
||||||
|
@ -878,7 +878,7 @@ export class GeoOperations {
|
||||||
switch (location) {
|
switch (location) {
|
||||||
case "point":
|
case "point":
|
||||||
if (feature.geometry.type === "Point") {
|
if (feature.geometry.type === "Point") {
|
||||||
return <[number, number]>feature.geometry.coordinates
|
return <[number, number]>(<Feature<Point>>feature).geometry.coordinates
|
||||||
}
|
}
|
||||||
return undefined
|
return undefined
|
||||||
case "centroid":
|
case "centroid":
|
||||||
|
@ -906,12 +906,12 @@ export class GeoOperations {
|
||||||
return undefined
|
return undefined
|
||||||
case "start":
|
case "start":
|
||||||
if (feature.geometry.type === "LineString") {
|
if (feature.geometry.type === "LineString") {
|
||||||
return <[number, number]>feature.geometry.coordinates[0]
|
return <[number, number]>(<Feature<LineString>>feature).geometry.coordinates[0]
|
||||||
}
|
}
|
||||||
return undefined
|
return undefined
|
||||||
case "end":
|
case "end":
|
||||||
if (feature.geometry.type === "LineString") {
|
if (feature.geometry.type === "LineString") {
|
||||||
return <[number, number]>feature.geometry.coordinates.at(-1)
|
return <[number, number]>(<Feature<LineString>>feature).geometry.coordinates.at(-1)
|
||||||
}
|
}
|
||||||
return undefined
|
return undefined
|
||||||
default:
|
default:
|
||||||
|
@ -949,7 +949,7 @@ export class GeoOperations {
|
||||||
|
|
||||||
for (const feature of features) {
|
for (const feature of features) {
|
||||||
if (feature.geometry.type === "LineString") {
|
if (feature.geometry.type === "LineString") {
|
||||||
let coors = feature.geometry.coordinates
|
let coors = (<Feature<LineString>>feature).geometry.coordinates
|
||||||
for (let i = coors.length - 1; i >= 0; i--) {
|
for (let i = coors.length - 1; i >= 0; i--) {
|
||||||
// Go back, to nick of the back when needed
|
// Go back, to nick of the back when needed
|
||||||
const ci = coors[i]
|
const ci = coors[i]
|
||||||
|
@ -960,8 +960,8 @@ export class GeoOperations {
|
||||||
Math.abs(ci[1] - cj[1]) <= 0.0000001
|
Math.abs(ci[1] - cj[1]) <= 0.0000001
|
||||||
) {
|
) {
|
||||||
// Found a self-intersecting way!
|
// Found a self-intersecting way!
|
||||||
console.debug("SPlitting way", feature.properties.id)
|
console.debug("Splitting way", feature.properties.id)
|
||||||
result.push({
|
result.push(<Feature>{
|
||||||
...feature,
|
...feature,
|
||||||
geometry: { ...feature.geometry, coordinates: coors.slice(i + 1) }
|
geometry: { ...feature.geometry, coordinates: coors.slice(i + 1) }
|
||||||
})
|
})
|
||||||
|
@ -970,7 +970,7 @@ export class GeoOperations {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result.push({
|
result.push(<Feature>{
|
||||||
...feature,
|
...feature,
|
||||||
geometry: { ...feature.geometry, coordinates: coors }
|
geometry: { ...feature.geometry, coordinates: coors }
|
||||||
})
|
})
|
||||||
|
@ -1293,7 +1293,7 @@ export class GeoOperations {
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const intersection = turf.intersect(feature, otherFeature)
|
const intersection = turf.intersect(turf.featureCollection([feature, otherFeature]))
|
||||||
if (intersection == null) {
|
if (intersection == null) {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
@ -1306,9 +1306,10 @@ export class GeoOperations {
|
||||||
}
|
}
|
||||||
if (e.message.indexOf("SweepLine tree") >= 0) {
|
if (e.message.indexOf("SweepLine tree") >= 0) {
|
||||||
console.log("Applying fallback intersection...")
|
console.log("Applying fallback intersection...")
|
||||||
const intersection = turf.intersect(
|
const intersection = turf.intersect(turf.featureCollection([
|
||||||
turf.truncate(feature),
|
turf.truncate(feature),
|
||||||
turf.truncate(otherFeature)
|
turf.truncate(otherFeature)
|
||||||
|
])
|
||||||
)
|
)
|
||||||
if (intersection == null) {
|
if (intersection == null) {
|
||||||
return null
|
return null
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"properties":{"name":"Bing Maps Aerial","id":"Bing","url":"https://ecn.t1.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=14929&pr=odbl&n=f","type":"bing","category":"photo","min_zoom":1,"max_zoom":22},"type":"Feature","geometry":null}
|
{"properties":{"name":"Bing Maps Aerial","id":"Bing","url":"https://ecn.t3.tiles.virtualearth.net/tiles/a{quadkey}.jpeg?g=14978&pr=odbl&n=f","type":"bing","category":"photo","min_zoom":1,"max_zoom":22},"type":"Feature","geometry":null}
|
|
@ -1,138 +1,8 @@
|
||||||
import * as turf from "@turf/turf"
|
|
||||||
import { GeoOperations } from "../../src/Logic/GeoOperations"
|
import { GeoOperations } from "../../src/Logic/GeoOperations"
|
||||||
import { Feature, LineString, Polygon } from "geojson"
|
import { Feature, LineString, Polygon } from "geojson"
|
||||||
import { describe, expect, it } from "vitest"
|
import { describe, expect, it } from "vitest"
|
||||||
|
|
||||||
describe("GeoOperations", () => {
|
describe("GeoOperations", () => {
|
||||||
describe("calculateOverlap", () => {
|
|
||||||
it("should not give too much overlap (regression test)", () => {
|
|
||||||
const polyGrb: Feature<Polygon> = <any>{
|
|
||||||
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: {
|
|
||||||
minLat: 50.83728850000007,
|
|
||||||
maxLat: 50.837435399999855,
|
|
||||||
maxLon: 3.2433214000000254,
|
|
||||||
minLon: 3.2431059999999974
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const polyHouse: Feature<Polygon> = <any>{
|
|
||||||
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.toBeNull()
|
|
||||||
const p1 = turf.polygon(polyHouse.geometry.coordinates)
|
|
||||||
expect(p1).not.toBeNull()
|
|
||||||
|
|
||||||
const overlaps = GeoOperations.calculateOverlap(polyGrb, [polyHouse])
|
|
||||||
expect(overlaps).empty
|
|
||||||
const overlapsRev = GeoOperations.calculateOverlap(polyHouse, [polyGrb])
|
|
||||||
expect(overlapsRev).empty
|
|
||||||
})
|
|
||||||
})
|
|
||||||
describe("clipWith", () => {
|
describe("clipWith", () => {
|
||||||
it("clipWith should clip linestrings", () => {
|
it("clipWith should clip linestrings", () => {
|
||||||
const bbox: Feature<Polygon> = {
|
const bbox: Feature<Polygon> = {
|
||||||
|
|
|
@ -620,14 +620,14 @@ describe("ReplaceGeometryAction", () => {
|
||||||
expect(closestIds.reprojectedNodes.size).toEqual(1)
|
expect(closestIds.reprojectedNodes.size).toEqual(1)
|
||||||
const reproj = closestIds.reprojectedNodes.get(1728823549)
|
const reproj = closestIds.reprojectedNodes.get(1728823549)
|
||||||
expect(reproj.projectAfterIndex).toEqual(1)
|
expect(reproj.projectAfterIndex).toEqual(1)
|
||||||
expect(reproj.newLon).toEqual(3.2168880864669203)
|
expect(reproj.newLon).toEqual(3.2168880865355054)
|
||||||
expect(reproj.newLat).toEqual(51.214739524104694)
|
expect(reproj.newLat).toEqual(51.21473952424369)
|
||||||
expect(closestIds.detachedNodes.size).toEqual(0)
|
expect(closestIds.detachedNodes.size).toEqual(0)
|
||||||
const changed = await action.Perform(changes)
|
const changed = await action.Perform(changes)
|
||||||
expect(changed[11].changes["coordinates"]).toEqual([
|
expect(changed[11].changes["coordinates"]).toEqual([
|
||||||
[3.216690793633461, 51.21474084112525],
|
[3.216690793633461, 51.21474084112525],
|
||||||
[3.2167256623506546, 51.214696737309964],
|
[3.2167256623506546, 51.214696737309964],
|
||||||
[3.2168880864669203, 51.214739524104694],
|
[3.2168880865355054, 51.21473952424369],
|
||||||
[3.2169999182224274, 51.214768983537674],
|
[3.2169999182224274, 51.214768983537674],
|
||||||
[3.2169650495052338, 51.21480720678671],
|
[3.2169650495052338, 51.21480720678671],
|
||||||
[3.2169368863105774, 51.21480090625335],
|
[3.2169368863105774, 51.21480090625335],
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue