forked from MapComplete/MapComplete
Scripts(community_index): create script to update community index files, create weekly data maintenance script
This commit is contained in:
parent
36a9b49c66
commit
7bddaa7d4c
11 changed files with 412 additions and 141 deletions
|
@ -6,7 +6,7 @@ import { describe, expect, it } from "vitest"
|
|||
describe("GeoOperations", () => {
|
||||
describe("calculateOverlap", () => {
|
||||
it("should not give too much overlap (regression test)", () => {
|
||||
const polyGrb = {
|
||||
const polyGrb: Feature<Polygon> = <any>{
|
||||
type: "Feature",
|
||||
properties: {
|
||||
osm_id: "25189153",
|
||||
|
@ -37,7 +37,7 @@ describe("GeoOperations", () => {
|
|||
"_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",
|
||||
"_loaded:datetime": "2021-12-05 21:51:40"
|
||||
},
|
||||
geometry: {
|
||||
type: "Polygon",
|
||||
|
@ -50,21 +50,21 @@ describe("GeoOperations", () => {
|
|||
[3.24329779999996, 50.837435399999855],
|
||||
[3.2431881000000504, 50.83740090000025],
|
||||
[3.243152699999997, 50.83738980000017],
|
||||
[3.2431059999999974, 50.83730270000021],
|
||||
],
|
||||
],
|
||||
[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,
|
||||
minLat: 50.83728850000007,
|
||||
minLon: 3.2431059999999974,
|
||||
},
|
||||
minLon: 3.2431059999999974
|
||||
}
|
||||
}
|
||||
const polyHouse = {
|
||||
const polyHouse: Feature<Polygon> = <any>{
|
||||
type: "Feature",
|
||||
id: "way/594963177",
|
||||
properties: {
|
||||
|
@ -95,7 +95,7 @@ describe("GeoOperations", () => {
|
|||
"_loaded:date": "2021-12-05",
|
||||
"_loaded:datetime": "2021-12-05 21:51:39",
|
||||
_surface: "93.32785810484549",
|
||||
"_surface:ha": "0",
|
||||
"_surface:ha": "0"
|
||||
},
|
||||
geometry: {
|
||||
type: "Polygon",
|
||||
|
@ -108,9 +108,9 @@ describe("GeoOperations", () => {
|
|||
[3.2431691, 50.8374252],
|
||||
[3.2430936, 50.837401],
|
||||
[3.243046, 50.8374112],
|
||||
[3.2429993, 50.8373243],
|
||||
],
|
||||
],
|
||||
[3.2429993, 50.8373243]
|
||||
]
|
||||
]
|
||||
},
|
||||
_lon: 3.2430937,
|
||||
_lat: 50.83736395,
|
||||
|
@ -118,8 +118,8 @@ describe("GeoOperations", () => {
|
|||
maxLat: 50.8374252,
|
||||
maxLon: 3.2431881,
|
||||
minLat: 50.8373027,
|
||||
minLon: 3.2429993,
|
||||
},
|
||||
minLon: 3.2429993
|
||||
}
|
||||
}
|
||||
|
||||
const p0 = turf.polygon(polyGrb.geometry.coordinates)
|
||||
|
@ -145,11 +145,11 @@ describe("GeoOperations", () => {
|
|||
[3.218560377159008, 51.21499687768525],
|
||||
[3.2207456783268356, 51.21499687768525],
|
||||
[3.2207456783268356, 51.21600586532159],
|
||||
[3.218560377159008, 51.21600586532159],
|
||||
],
|
||||
[3.218560377159008, 51.21600586532159]
|
||||
]
|
||||
],
|
||||
type: "Polygon",
|
||||
},
|
||||
type: "Polygon"
|
||||
}
|
||||
}
|
||||
const line: Feature<LineString> = {
|
||||
type: "Feature",
|
||||
|
@ -157,10 +157,10 @@ describe("GeoOperations", () => {
|
|||
geometry: {
|
||||
coordinates: [
|
||||
[3.218405371672816, 51.21499091846559],
|
||||
[3.2208408127450525, 51.21560173433727],
|
||||
[3.2208408127450525, 51.21560173433727]
|
||||
],
|
||||
type: "LineString",
|
||||
},
|
||||
type: "LineString"
|
||||
}
|
||||
}
|
||||
const result = GeoOperations.clipWith(line, bbox)
|
||||
expect(result.length).to.equal(1)
|
||||
|
@ -168,10 +168,83 @@ describe("GeoOperations", () => {
|
|||
const clippedLine = (<Feature<LineString>>result[0]).geometry.coordinates
|
||||
const expCoordinates = [
|
||||
[3.2185604, 51.215029800031594],
|
||||
[3.2207457, 51.21557787977764],
|
||||
[3.2207457, 51.21557787977764]
|
||||
]
|
||||
|
||||
expect(clippedLine).to.deep.equal(expCoordinates)
|
||||
})
|
||||
it("clipWith should contain the full feature if it is fully contained", () => {
|
||||
const bbox: Feature<Polygon> = {
|
||||
type: "Feature",
|
||||
properties: {},
|
||||
geometry: {
|
||||
coordinates: [
|
||||
[
|
||||
[
|
||||
2.1541744759711037,
|
||||
51.73994420687188
|
||||
],
|
||||
[
|
||||
2.1541744759711037,
|
||||
50.31129074222787
|
||||
],
|
||||
[
|
||||
4.53247037641421,
|
||||
50.31129074222787
|
||||
],
|
||||
[
|
||||
4.53247037641421,
|
||||
51.73994420687188
|
||||
],
|
||||
[
|
||||
2.1541744759711037,
|
||||
51.73994420687188
|
||||
]
|
||||
]
|
||||
],
|
||||
type: "Polygon"
|
||||
}
|
||||
}
|
||||
const content: Feature<Polygon> = {
|
||||
"type": "Feature",
|
||||
"properties": {},
|
||||
"geometry": {
|
||||
"coordinates": [
|
||||
[
|
||||
[
|
||||
2.8900597545854225,
|
||||
50.9035099487991
|
||||
],
|
||||
[
|
||||
3.4872999807053873,
|
||||
50.74856284865993
|
||||
],
|
||||
[
|
||||
3.9512276563531543,
|
||||
50.947206170675486
|
||||
],
|
||||
[
|
||||
3.897902636163167,
|
||||
51.25526892606362
|
||||
],
|
||||
[
|
||||
3.188679867646016,
|
||||
51.24525576870511
|
||||
], [
|
||||
2.8900597545854225,
|
||||
50.9035099487991
|
||||
]
|
||||
]
|
||||
],
|
||||
"type": "Polygon"
|
||||
}
|
||||
}
|
||||
const clipped = GeoOperations.clipWith(content, bbox)
|
||||
expect(clipped.length).to.equal(1)
|
||||
|
||||
const clippedReverse = GeoOperations.clipWith(bbox, content)
|
||||
expect(clippedReverse.length).to.equal(1)
|
||||
}
|
||||
)
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue