forked from MapComplete/MapComplete
chore: automated housekeeping...
This commit is contained in:
parent
c1a2126b32
commit
4c93f023dd
32 changed files with 1551 additions and 76 deletions
|
@ -10,12 +10,12 @@ import {
|
|||
MultiPolygon,
|
||||
Point,
|
||||
Polygon,
|
||||
Position
|
||||
Position,
|
||||
} from "geojson"
|
||||
import { Tiles } from "../Models/TileRange"
|
||||
import { Utils } from "../Utils"
|
||||
|
||||
("use strict")
|
||||
;("use strict")
|
||||
|
||||
export class GeoOperations {
|
||||
private static readonly _earthRadius = 6378137
|
||||
|
@ -29,7 +29,7 @@ export class GeoOperations {
|
|||
"behind",
|
||||
"sharp_left",
|
||||
"left",
|
||||
"slight_left"
|
||||
"slight_left",
|
||||
] as const
|
||||
private static reverseBearing = {
|
||||
N: 0,
|
||||
|
@ -47,7 +47,7 @@ export class GeoOperations {
|
|||
W: 270,
|
||||
WNW: 292.5,
|
||||
NW: 315,
|
||||
NNW: 337.5
|
||||
NNW: 337.5,
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -309,7 +309,7 @@ export class GeoOperations {
|
|||
bufferSizeInMeter: number
|
||||
): Feature<Polygon | MultiPolygon> | FeatureCollection<Polygon | MultiPolygon> {
|
||||
return turf.buffer(feature, bufferSizeInMeter / 1000, {
|
||||
units: "kilometers"
|
||||
units: "kilometers",
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -325,9 +325,9 @@ export class GeoOperations {
|
|||
[lon0, lat],
|
||||
[lon0, lat0],
|
||||
[lon, lat0],
|
||||
[lon, lat]
|
||||
]
|
||||
}
|
||||
[lon, lat],
|
||||
],
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -373,25 +373,32 @@ export class GeoOperations {
|
|||
type: "Feature",
|
||||
geometry: {
|
||||
type: "LineString",
|
||||
coordinates: linestringCoors
|
||||
coordinates: linestringCoors,
|
||||
},
|
||||
properties: way.properties
|
||||
properties: way.properties,
|
||||
}
|
||||
})
|
||||
}
|
||||
if (way.geometry.type === "MultiPolygon") {
|
||||
const mpoly: Feature<MultiPolygon> = <Feature<MultiPolygon>>way
|
||||
|
||||
return [].concat(...mpoly.geometry.coordinates.map(linestrings =>
|
||||
[].concat(...linestrings.map(linestring =>
|
||||
<Feature<LineString>>{
|
||||
type: "Feature",
|
||||
geometry: {
|
||||
type: "LineString",
|
||||
coordinates: linestring
|
||||
},
|
||||
properties: way.properties
|
||||
}))))
|
||||
return [].concat(
|
||||
...mpoly.geometry.coordinates.map((linestrings) =>
|
||||
[].concat(
|
||||
...linestrings.map(
|
||||
(linestring) =>
|
||||
<Feature<LineString>>{
|
||||
type: "Feature",
|
||||
geometry: {
|
||||
type: "LineString",
|
||||
coordinates: linestring,
|
||||
},
|
||||
properties: way.properties,
|
||||
}
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
if (way.geometry.type === "LineString") {
|
||||
return [<Feature<LineString>>way]
|
||||
|
@ -568,7 +575,7 @@ export class GeoOperations {
|
|||
}
|
||||
const properties = {
|
||||
...f.properties,
|
||||
id
|
||||
id,
|
||||
}
|
||||
intersectionPart.properties = properties
|
||||
newFeatures.push(intersectionPart)
|
||||
|
@ -600,8 +607,8 @@ export class GeoOperations {
|
|||
properties: {},
|
||||
geometry: {
|
||||
type: "Point",
|
||||
coordinates: p
|
||||
}
|
||||
coordinates: p,
|
||||
},
|
||||
}
|
||||
)
|
||||
}
|
||||
|
@ -617,7 +624,7 @@ export class GeoOperations {
|
|||
trackPoints.push(trkpt)
|
||||
}
|
||||
const header =
|
||||
"<gpx version=\"1.1\" creator=\"mapcomplete.org\" xmlns=\"http://www.topografix.com/GPX/1/1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">"
|
||||
'<gpx version="1.1" creator="mapcomplete.org" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">'
|
||||
return (
|
||||
header +
|
||||
"\n<name>" +
|
||||
|
@ -656,7 +663,7 @@ export class GeoOperations {
|
|||
trackPoints.push(trkpt)
|
||||
}
|
||||
const header =
|
||||
"<gpx version=\"1.1\" creator=\"mapcomplete.org\" xmlns=\"http://www.topografix.com/GPX/1/1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd\">"
|
||||
'<gpx version="1.1" creator="mapcomplete.org" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">'
|
||||
return (
|
||||
header +
|
||||
"\n<name>" +
|
||||
|
@ -682,7 +689,7 @@ export class GeoOperations {
|
|||
|
||||
const copy = {
|
||||
...feature,
|
||||
geometry: { ...feature.geometry }
|
||||
geometry: { ...feature.geometry },
|
||||
}
|
||||
let coordinates: [number, number][]
|
||||
if (feature.geometry.type === "LineString") {
|
||||
|
@ -740,8 +747,8 @@ export class GeoOperations {
|
|||
type: "Feature",
|
||||
geometry: {
|
||||
type: "LineString",
|
||||
coordinates: [a, b]
|
||||
}
|
||||
coordinates: [a, b],
|
||||
},
|
||||
},
|
||||
distanceMeter,
|
||||
{ units: "meters" }
|
||||
|
@ -788,8 +795,8 @@ export class GeoOperations {
|
|||
type: "Feature",
|
||||
geometry: {
|
||||
type: "Polygon",
|
||||
coordinates
|
||||
}
|
||||
coordinates,
|
||||
},
|
||||
}
|
||||
)
|
||||
return !polygons.some((polygon) => !booleanWithin(polygon, possiblyEnclosingFeature))
|
||||
|
@ -868,8 +875,8 @@ export class GeoOperations {
|
|||
type: "Feature",
|
||||
properties: { ...toSplit.properties },
|
||||
geometry: boundary.geometry,
|
||||
bbox: boundary.bbox
|
||||
}
|
||||
bbox: boundary.bbox,
|
||||
},
|
||||
]
|
||||
}
|
||||
return []
|
||||
|
@ -967,8 +974,8 @@ export class GeoOperations {
|
|||
properties: p.properties,
|
||||
geometry: {
|
||||
type: "LineString",
|
||||
coordinates: p.geometry.coordinates[0]
|
||||
}
|
||||
coordinates: p.geometry.coordinates[0],
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -996,7 +1003,7 @@ export class GeoOperations {
|
|||
console.debug("Splitting way", feature.properties.id)
|
||||
result.push(<Feature>{
|
||||
...feature,
|
||||
geometry: { ...feature.geometry, coordinates: coors.slice(i + 1) }
|
||||
geometry: { ...feature.geometry, coordinates: coors.slice(i + 1) },
|
||||
})
|
||||
coors = coors.slice(0, i + 1)
|
||||
break
|
||||
|
@ -1005,7 +1012,7 @@ export class GeoOperations {
|
|||
}
|
||||
result.push(<Feature>{
|
||||
...feature,
|
||||
geometry: { ...feature.geometry, coordinates: coors }
|
||||
geometry: { ...feature.geometry, coordinates: coors },
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -1179,8 +1186,8 @@ export class GeoOperations {
|
|||
properties: multiLineStringFeature.properties,
|
||||
geometry: {
|
||||
type: "LineString",
|
||||
coordinates: coors[0]
|
||||
}
|
||||
coordinates: coors[0],
|
||||
},
|
||||
}
|
||||
}
|
||||
return {
|
||||
|
@ -1188,8 +1195,8 @@ export class GeoOperations {
|
|||
properties: multiLineStringFeature.properties,
|
||||
geometry: {
|
||||
type: "MultiLineString",
|
||||
coordinates: coors
|
||||
}
|
||||
coordinates: coors,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1342,7 +1349,7 @@ export class GeoOperations {
|
|||
const intersection = turf.intersect(
|
||||
turf.featureCollection([
|
||||
turf.truncate(feature),
|
||||
turf.truncate(otherFeature)
|
||||
turf.truncate(otherFeature),
|
||||
])
|
||||
)
|
||||
if (intersection == null) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue