forked from MapComplete/MapComplete
GeoOperations.distanceBetween now uses meters, fix GPS tracking
This commit is contained in:
parent
79012c42ab
commit
680e56397d
10 changed files with 40 additions and 40 deletions
|
@ -111,12 +111,12 @@ export default class CreateNewNodeAction extends OsmChangeAction {
|
|||
// We check that it isn't close to an already existing point
|
||||
let reusedPointId = undefined;
|
||||
const prev = <[number, number]>geojson.geometry.coordinates[index]
|
||||
if (GeoOperations.distanceBetween(prev, <[number, number]>projected.geometry.coordinates) * 1000 < this._reusePointDistance) {
|
||||
if (GeoOperations.distanceBetween(prev, <[number, number]>projected.geometry.coordinates) < this._reusePointDistance) {
|
||||
// We reuse this point instead!
|
||||
reusedPointId = this._snapOnto.nodes[index]
|
||||
}
|
||||
const next = <[number, number]>geojson.geometry.coordinates[index + 1]
|
||||
if (GeoOperations.distanceBetween(next, <[number, number]>projected.geometry.coordinates) * 1000 < this._reusePointDistance) {
|
||||
if (GeoOperations.distanceBetween(next, <[number, number]>projected.geometry.coordinates) < this._reusePointDistance) {
|
||||
// We reuse this point instead!
|
||||
reusedPointId = this._snapOnto.nodes[index + 1]
|
||||
}
|
||||
|
|
|
@ -225,7 +225,7 @@ export default class CreateWayWithPointReuseAction extends OsmChangeAction {
|
|||
const coor = coordinates[i]
|
||||
// Check closeby (and probably identical) point further in the coordinate list, mark them as duplicate
|
||||
for (let j = i + 1; j < coordinates.length; j++) {
|
||||
if (1000 * GeoOperations.distanceBetween(coor, coordinates[j]) < 0.1) {
|
||||
if (GeoOperations.distanceBetween(coor, coordinates[j]) < 0.1) {
|
||||
coordinateInfo[j] = {
|
||||
lngLat: coor,
|
||||
identicalTo: i
|
||||
|
@ -244,7 +244,7 @@ export default class CreateWayWithPointReuseAction extends OsmChangeAction {
|
|||
}[] = []
|
||||
for (const node of allNodes) {
|
||||
const center = node.geometry.coordinates
|
||||
const d = 1000 * GeoOperations.distanceBetween(coor, center)
|
||||
const d = GeoOperations.distanceBetween(coor, center)
|
||||
if (d > maxDistance) {
|
||||
continue
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ export default class ReplaceGeometryAction extends OsmChangeAction {
|
|||
continue
|
||||
}
|
||||
for (let j = i + 1; j < coordinates.length; j++) {
|
||||
const d = 1000 * GeoOperations.distanceBetween(coordinates[i], coordinates[j])
|
||||
const d = GeoOperations.distanceBetween(coordinates[i], coordinates[j])
|
||||
if (d < 0.1) {
|
||||
console.log("Identical coordinates detected: ", i, " and ", j, ": ", coordinates[i], coordinates[j], "distance is", d)
|
||||
this.identicalTo[j] = i
|
||||
|
|
|
@ -172,7 +172,7 @@ export class Changes {
|
|||
return Math.min(...changedObjectCoordinates.map(coor =>
|
||||
Math.min(...recentLocationPoints.map(gpsPoint => {
|
||||
const otherCoor = GeoOperations.centerpointCoordinates(gpsPoint)
|
||||
return GeoOperations.distanceBetween(coor, otherCoor) * 1000
|
||||
return GeoOperations.distanceBetween(coor, otherCoor)
|
||||
}))
|
||||
))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue