Skip to content

Commit e4ed401

Browse files
committed
Update to use adiff file
1 parent 25b568c commit e4ed401

File tree

4 files changed

+33
-10
lines changed

4 files changed

+33
-10
lines changed

pipeline/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ Note:
1010
```sh
1111

1212
docker build -t osm-gradient .
13-
docker run -it -v ./data:/tmp osm-gradient sh -c "./cli.js process-hour 2024-05-18 02"
14-
docker run -it -v ./data:/tmp osm-gradient sh -c "ogr2ogr -f FlatGeobuf /tmp/2024-05-18T02/2024-05-18T02:00.fgb /tmp/2024-05-18T02/2024-05-18T02:00.geojson -skipfailures"
15-
```
13+
docker run -it -v ./data:/tmp osm-gradient sh -c "./cli.js process-hour 2025-05-18 02"
14+
docker run -it -v ./data:/tmp osm-gradient sh -c "ogr2ogr -f FlatGeobuf /tmp/2025-05-18T02/2025-05-18T02:00.fgb /tmp/2025-05-18T02/2025-05-18T02:00.geojson -skipfailures"
15+
```

pipeline/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"author": "",
99
"license": "ISC",
1010
"dependencies": {
11+
"@osmcha/osm-adiff-parser": "^3.1.0",
1112
"axios": "^1.5.0",
1213
"commander": "12.0.0",
1314
"real-changesets-parser": "https://github.com/developmentseed/real-changesets-parser.git",

pipeline/src/process.js

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const axios = require('axios');
2-
const changesetParser = require("real-changesets-parser");
2+
const adiffParser = require("@osmcha/osm-adiff-parser");
3+
const changesetParser = require("real-changesets-parser");
34
const fs = require('fs');
45
const readline = require('readline');
56

@@ -44,15 +45,24 @@ async function processChangesets(changesets, date, hour) {
4445
* @returns {Promise<string>} A promise that resolves to the file path of the processed changeset.
4546
*/
4647
async function processChangeset(changeset, dataPath) {
47-
// Process the changeset asynchronously and return the result
48-
const url = `https://real-changesets.s3.amazonaws.com/${changeset}.json`;
48+
const url = `https://adiffs.osmcha.org/changesets/${changeset}.adiff`;
4949
// console.log(`Processing changeset ${changeset}`);
5050
try {
51-
const response = await axios.get(url);
51+
const response = await axios.get(url, { responseType: "text" });
5252
const data = response.data;
53-
const geojson = changesetParser(data);
54-
// console.log(`geojson: ${JSON.stringify(geojson)}`);
55-
const features = geojson.features;
53+
const diffData = await adiffParser(data);
54+
55+
// Convert adiff changesets to the shape of real changesets to minimize the code change
56+
const features = diffData.actions
57+
.map((a) => {
58+
return {
59+
...a.new,
60+
...(a.old && { old: a.old }),
61+
action: a.type,
62+
};
63+
})
64+
.map(changesetParser.elementParser)
65+
.flat();
5666

5767
if (features.length === 0) {
5868
console.log(`No features found in changeset ${changeset}`);

pipeline/yarn.lock

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
# yarn lockfile v1
33

44

5+
"@osmcha/osm-adiff-parser@^3.1.0":
6+
version "3.1.0"
7+
resolved "https://registry.npmjs.org/@osmcha/osm-adiff-parser/-/osm-adiff-parser-3.1.0.tgz#bbd6a4a4052145ba19fe04a1039a28a164cfe1e6"
8+
integrity sha512-TX+cCDkBE3bDMqn4ice5R7UzQY+cX+4h16DGRTvZfzq5QwRxluPcnD7PlQdc2JoJ7L2ViACLMkc7VxRqnf2noA==
9+
dependencies:
10+
sax "^1.4.1"
11+
512
"@turf/bbox-polygon@^6.0.1":
613
version "6.5.0"
714
resolved "https://registry.yarnpkg.com/@turf/bbox-polygon/-/bbox-polygon-6.5.0.tgz#f18128b012eedfa860a521d8f2b3779cc0801032"
@@ -120,3 +127,8 @@ sax@^1.3.0:
120127
version "1.3.0"
121128
resolved "https://registry.yarnpkg.com/sax/-/sax-1.3.0.tgz#a5dbe77db3be05c9d1ee7785dbd3ea9de51593d0"
122129
integrity sha512-0s+oAmw9zLl1V1cS9BtZN7JAd0cW5e0QH4W3LWEK6a4LaLEA2OTpGYWDY+6XasBLtz6wkm3u1xRw95mRuJ59WA==
130+
131+
sax@^1.4.1:
132+
version "1.4.1"
133+
resolved "https://registry.npmjs.org/sax/-/sax-1.4.1.tgz#44cc8988377f126304d3b3fc1010c733b929ef0f"
134+
integrity sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg==

0 commit comments

Comments
 (0)