diff --git a/Logic/GeoOperations.ts b/Logic/GeoOperations.ts index 6406b379a..800f011b5 100644 --- a/Logic/GeoOperations.ts +++ b/Logic/GeoOperations.ts @@ -209,11 +209,15 @@ export class GeoOperations { * GeoOperations.inside([1.42822265625, 48.61838518688487], multiPolygon) // => false * GeoOperations.inside([4.02099609375, 47.81315451752768], multiPolygon) // => false */ - public static inside(pointCoordinate: [number, number] | Feature, feature): boolean { + public static inside( + pointCoordinate: [number, number] | Feature, + feature: Feature + ): boolean { // ray-casting algorithm based on // http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html if (feature.geometry.type === "Point") { + // The feature that should 'contain' pointCoordinate is a point itself, so it cannot contain anything return false } @@ -227,6 +231,7 @@ export class GeoOperations { if (feature.geometry.type === "MultiPolygon") { const coordinatess = feature.geometry.coordinates for (const coordinates of coordinatess) { + // @ts-ignore const inThisPolygon = GeoOperations.pointInPolygonCoordinates(x, y, coordinates) if (inThisPolygon) { return true @@ -236,6 +241,7 @@ export class GeoOperations { } if (feature.geometry.type === "Polygon") { + // @ts-ignore return GeoOperations.pointInPolygonCoordinates(x, y, feature.geometry.coordinates) } diff --git a/Logic/UIEventSource.ts b/Logic/UIEventSource.ts index 21498d047..7bc714954 100644 --- a/Logic/UIEventSource.ts +++ b/Logic/UIEventSource.ts @@ -114,7 +114,7 @@ export abstract class Store implements Readable { abstract map(f: (t: T) => J): Store abstract map(f: (t: T) => J, extraStoresToWatch: Store[]): Store - public mapD(f: (t: T) => J, extraStoresToWatch: Store[]): Store { + public mapD(f: (t: T) => J, extraStoresToWatch?: Store[]): Store { return this.map((t) => { if (t === undefined) { return undefined diff --git a/UI/BigComponents/BackgroundMapSwitch.ts b/UI/BigComponents/BackgroundMapSwitch.ts index 8048f4664..47ff1f0ee 100644 --- a/UI/BigComponents/BackgroundMapSwitch.ts +++ b/UI/BigComponents/BackgroundMapSwitch.ts @@ -108,7 +108,10 @@ class SingleLayerSelectionButton extends Toggle { // Is the previous layer still valid? If so, we don't bother to switch if ( previousLayer.data.feature === null || - GeoOperations.inside(locationControl.data, previousLayer.data.feature) + GeoOperations.inside( + [locationControl.data.lon, locationControl.data.lat], + previousLayer.data.feature + ) ) { return } diff --git a/UI/BigComponents/ContactLink.svelte b/UI/BigComponents/ContactLink.svelte index 88b81308b..3dd7301e7 100644 --- a/UI/BigComponents/ContactLink.svelte +++ b/UI/BigComponents/ContactLink.svelte @@ -1,11 +1,14 @@ -
diff --git a/package-lock.json b/package-lock.json index 47dcea3c6..4d30ff2c9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "0.25.1", "license": "GPL-3.0-or-later", "dependencies": { + "@rollup/plugin-typescript": "^11.0.0", "@turf/boolean-intersects": "^6.5.0", "@turf/buffer": "^6.5.0", "@turf/collect": "^6.5.0", @@ -79,9 +80,10 @@ "sharp": "^0.30.5", "svelte": "^3.55.1", "svelte-check": "^3.0.2", + "svelte-preprocess": "^5.0.1", "ts-node": "^10.9.1", "ts2json-schema": "^1.4.0", - "tslib": "^2.4.1", + "tslib": "^2.5.0", "tslint": "^6.1.3", "tslint-no-circular-imports": "^0.7.0", "typescript": "^4.7.4", @@ -1784,11 +1786,35 @@ } } }, + "node_modules/@rollup/plugin-typescript": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-11.0.0.tgz", + "integrity": "sha512-goPyCWBiimk1iJgSTgsehFD5OOFHiAknrRJjqFCudcW8JtWiBlK284Xnn4flqMqg6YAjVG/EE+3aVzrL5qNSzQ==", + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.14.0||^3.0.0", + "tslib": "*", + "typescript": ">=3.7.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + }, + "tslib": { + "optional": true + } + } + }, "node_modules/@rollup/pluginutils": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.0.2.tgz", "integrity": "sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==", - "dev": true, "dependencies": { "@types/estree": "^1.0.0", "estree-walker": "^2.0.2", @@ -3429,8 +3455,7 @@ "node_modules/@types/estree": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.0.tgz", - "integrity": "sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==", - "dev": true + "integrity": "sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==" }, "node_modules/@types/geojson": { "version": "7946.0.10", @@ -5158,8 +5183,7 @@ "node_modules/estree-walker": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", - "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", - "dev": true + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==" }, "node_modules/esutils": { "version": "2.0.3", @@ -8023,7 +8047,7 @@ "version": "3.10.0", "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.10.0.tgz", "integrity": "sha512-JmRYz44NjC1MjVF2VKxc0M1a97vn+cDxeqWmnwyAF4FvpjK8YFdHpaqvQB+3IxCvX05vJxKZkoMDU8TShhmJVA==", - "dev": true, + "devOptional": true, "bin": { "rollup": "dist/bin/rollup" }, @@ -9358,10 +9382,10 @@ } }, "node_modules/tslib": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz", - "integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==", - "dev": true + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", + "devOptional": true }, "node_modules/tslint": { "version": "6.1.3", @@ -11903,11 +11927,19 @@ "@rollup/pluginutils": "^5.0.1" } }, + "@rollup/plugin-typescript": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-typescript/-/plugin-typescript-11.0.0.tgz", + "integrity": "sha512-goPyCWBiimk1iJgSTgsehFD5OOFHiAknrRJjqFCudcW8JtWiBlK284Xnn4flqMqg6YAjVG/EE+3aVzrL5qNSzQ==", + "requires": { + "@rollup/pluginutils": "^5.0.1", + "resolve": "^1.22.1" + } + }, "@rollup/pluginutils": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.0.2.tgz", "integrity": "sha512-pTd9rIsP92h+B6wWwFbW8RkZv4hiR/xKsqre4SIuAOaOEQRxi0lqLke9k2/7WegC85GgUs9pjmOjCUi3In4vwA==", - "dev": true, "requires": { "@types/estree": "^1.0.0", "estree-walker": "^2.0.2", @@ -13209,8 +13241,7 @@ "@types/estree": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.0.tgz", - "integrity": "sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==", - "dev": true + "integrity": "sha512-WulqXMDUTYAXCjZnk6JtIHPigp55cVtDgDrO2gHRwhyJto21+1zbVCtOYB2L1F9w4qCQ0rOGWBnBe0FNTiEJIQ==" }, "@types/geojson": { "version": "7946.0.10", @@ -14549,8 +14580,7 @@ "estree-walker": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", - "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", - "dev": true + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==" }, "esutils": { "version": "2.0.3", @@ -16722,7 +16752,7 @@ "version": "3.10.0", "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.10.0.tgz", "integrity": "sha512-JmRYz44NjC1MjVF2VKxc0M1a97vn+cDxeqWmnwyAF4FvpjK8YFdHpaqvQB+3IxCvX05vJxKZkoMDU8TShhmJVA==", - "dev": true, + "devOptional": true, "requires": { "fsevents": "~2.3.2" } @@ -17660,10 +17690,10 @@ } }, "tslib": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.1.tgz", - "integrity": "sha512-tGyy4dAjRIEwI7BzsB0lynWgOpfqjUdq91XXAlIWD2OwKBH7oCl/GZG/HT4BOHrTlPMOASlMQ7veyTqpmRcrNA==", - "dev": true + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.5.0.tgz", + "integrity": "sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==", + "devOptional": true }, "tslint": { "version": "6.1.3", diff --git a/package.json b/package.json index f52ef5bb4..9993f56eb 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "description": "A small website to edit OSM easily", "bugs": "https://github.com/pietervdvn/MapComplete/issues", "homepage": "https://mapcomplete.osm.be", - "main": "index.js", + "main": "index.ts", "type": "module", "scripts": { "start": "npm run generate:layeroverview && npm run strt", @@ -64,6 +64,7 @@ "not op_mini all" ], "dependencies": { + "@rollup/plugin-typescript": "^11.0.0", "@turf/boolean-intersects": "^6.5.0", "@turf/buffer": "^6.5.0", "@turf/collect": "^6.5.0", @@ -134,9 +135,10 @@ "sharp": "^0.30.5", "svelte": "^3.55.1", "svelte-check": "^3.0.2", + "svelte-preprocess": "^5.0.1", "ts-node": "^10.9.1", "ts2json-schema": "^1.4.0", - "tslib": "^2.4.1", + "tslib": "^2.5.0", "tslint": "^6.1.3", "tslint-no-circular-imports": "^0.7.0", "typescript": "^4.7.4",