forked from MapComplete/MapComplete
Fix reviews for way objects, fix #1296
This commit is contained in:
parent
fa44f8deb7
commit
f8f30f8d7a
2 changed files with 12 additions and 10 deletions
|
@ -10,7 +10,7 @@ import {
|
||||||
MultiPolygon,
|
MultiPolygon,
|
||||||
Polygon,
|
Polygon,
|
||||||
} from "@turf/turf"
|
} from "@turf/turf"
|
||||||
import { GeoJSON, LineString, Point } from "geojson"
|
import { GeoJSON, LineString, Point, Position } from "geojson"
|
||||||
import togpx from "togpx"
|
import togpx from "togpx"
|
||||||
import Constants from "../Models/Constants"
|
import Constants from "../Models/Constants"
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ export class GeoOperations {
|
||||||
* @param lonlat0
|
* @param lonlat0
|
||||||
* @param lonlat1
|
* @param lonlat1
|
||||||
*/
|
*/
|
||||||
static distanceBetween(lonlat0: [number, number], lonlat1: [number, number]) {
|
static distanceBetween(lonlat0: [number, number], lonlat1: [number, number] | Position) {
|
||||||
return turf.distance(lonlat0, lonlat1, { units: "meters" })
|
return turf.distance(lonlat0, lonlat1, { units: "meters" })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -87,21 +87,23 @@ export default class FeatureReviews {
|
||||||
if (feature.geometry.type === "Point") {
|
if (feature.geometry.type === "Point") {
|
||||||
this._uncertainty = options?.uncertaintyRadius ?? 10
|
this._uncertainty = options?.uncertaintyRadius ?? 10
|
||||||
} else {
|
} else {
|
||||||
let coords: Position[][]
|
let coordss: Position[][]
|
||||||
if (feature.geometry.type === "LineString") {
|
if (feature.geometry.type === "LineString") {
|
||||||
coords = [feature.geometry.coordinates]
|
coordss = [feature.geometry.coordinates]
|
||||||
} else if (
|
} else if (
|
||||||
feature.geometry.type === "MultiLineString" ||
|
feature.geometry.type === "MultiLineString" ||
|
||||||
feature.geometry.type === "Polygon"
|
feature.geometry.type === "Polygon"
|
||||||
) {
|
) {
|
||||||
coords = feature.geometry.coordinates
|
coordss = feature.geometry.coordinates
|
||||||
}
|
}
|
||||||
let maxDistance = 0
|
let maxDistance = 0
|
||||||
for (const coord of coords) {
|
for (const coords of coordss) {
|
||||||
maxDistance = Math.max(
|
for (const coord of coords) {
|
||||||
maxDistance,
|
maxDistance = Math.max(
|
||||||
GeoOperations.distanceBetween(centerLonLat, <any>coord)
|
maxDistance,
|
||||||
)
|
GeoOperations.distanceBetween(centerLonLat, coord)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this._uncertainty = options?.uncertaintyRadius ?? maxDistance
|
this._uncertainty = options?.uncertaintyRadius ?? maxDistance
|
||||||
|
|
Loading…
Reference in a new issue