Skip to content

Commit

Permalink
Use @osmcha/osm-adiff-parser instead of osm-adiff-parser-saxjs (#268)
Browse files Browse the repository at this point in the history
  • Loading branch information
jake-low authored Sep 10, 2024
1 parent db7fd0c commit a84d08d
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 44 deletions.
48 changes: 22 additions & 26 deletions lib/getChangeset.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import adiffParser from 'osm-adiff-parser-saxjs';
import adiffParser from '@osmcha/osm-adiff-parser';
import jsonParser from 'real-changesets-parser';
import { query } from './query';
import { config } from './config';
Expand Down Expand Up @@ -43,32 +43,28 @@ function fetchFromOverPass(changesetID, changeset, overpassBase) {
'Response-Type': 'application/osm3s+xml'
})
.then(r => r.text())
.then(response => {
return new Promise((res, rej) => {
adiffParser(response, null, (err, json) => {
if (err) {
return rej({
msg: 'Failed to parser adiff xml.',
error: err
});
}
var elements = Object.keys(json).reduce(
(result, item) => result.concat(json[item]),
[]
);
var geojson = jsonParser({
elements: elements
});
var featureMap = getFeatureMap(geojson);

var ret = {
geojson: geojson,
featureMap: featureMap,
changeset: changeset
};
return res(ret);
});
.then(xml => adiffParser(xml))
.catch(err =>
Promise.reject({
msg: 'Failed to parser adiff xml.',
error: err
})
)
.then(json => {
var elements = Object.keys(json).reduce(
(result, item) => result.concat(json[item]),
[]
);
var geojson = jsonParser({
elements: elements
});
var featureMap = getFeatureMap(geojson);

return {
geojson: geojson,
featureMap: featureMap,
changeset: changeset
};
})
.catch(err =>
Promise.reject({
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
"react-dom": "^15.5.4"
},
"dependencies": {
"@osmcha/osm-adiff-parser": "^2.0.0",
"@turf/bbox": "^6.4.0",
"@turf/bbox-polygon": "^6.4.0",
"@turf/helpers": "^6.4.0",
"date-fns": "^2.22.1",
"mapbox-gl": "^1.13.1",
"osm-adiff-parser-saxjs": "^1.0.0",
"platform-detect": "^3.0.1",
"react-click-outside": "^3.0.1",
"real-changesets-parser": "^1.3.0"
Expand Down
28 changes: 11 additions & 17 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,13 @@
resolved "https://registry.yarnpkg.com/@mapbox/whoots-js/-/whoots-js-3.1.0.tgz#497c67a1cef50d1a2459ba60f315e448d2ad87fe"
integrity sha512-Es6WcD0nO5l+2BOQS4uLfNPYQaNDfbot3X1XUoloz+x0mPDS3eeORZJl06HXjwBG1fOGwCRnzK88LMdxKRrd6Q==

"@osmcha/osm-adiff-parser@^2.0.0":
version "2.0.0"
resolved "https://registry.yarnpkg.com/@osmcha/osm-adiff-parser/-/osm-adiff-parser-2.0.0.tgz#8d199d51613f8fb9229ada87652d447bb0cfa9fc"
integrity sha512-KXpEHYaYQiDaUijYXDAIxsTv9XJ3sxzB/LbyLe8elXTcgcSdyg+RlbTT27Uh4MhBejWSk9ozVBNSpdSkuHW4NA==
dependencies:
sax "^1.4.1"

"@rollup/plugin-babel@^5.2.0":
version "5.2.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-babel/-/plugin-babel-5.2.0.tgz#b87556d61ed108b4eaf9d18b5323965adf8d9bee"
Expand Down Expand Up @@ -3398,14 +3405,6 @@ os-locale@^1.4.0:
dependencies:
lcid "^1.0.0"

osm-adiff-parser-saxjs@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/osm-adiff-parser-saxjs/-/osm-adiff-parser-saxjs-1.0.0.tgz#fd5adff9d16c32bf8720d5faf8bac9fe31c54401"
integrity sha1-/Vrf+dFsMr+HINX6+LrJ/jHFRAE=
dependencies:
ramda "^0.23.0"
sax "^1.2.2"

p-finally@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae"
Expand Down Expand Up @@ -3725,11 +3724,6 @@ quickselect@^2.0.0:
resolved "https://registry.yarnpkg.com/quickselect/-/quickselect-2.0.0.tgz#f19680a486a5eefb581303e023e98faaf25dd018"
integrity sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw==

ramda@^0.23.0:
version "0.23.0"
resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.23.0.tgz#ccd13fff73497a93974e3e86327bfd87bd6e8e2b"
integrity sha1-zNE//3NJepOXTj6GMnv9h71ujis=

ramda@^0.27.1:
version "0.27.1"
resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.27.1.tgz#66fc2df3ef873874ffc2da6aa8984658abacf5c9"
Expand Down Expand Up @@ -4124,10 +4118,10 @@ safe-regex@^1.1.0:
resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==

sax@^1.2.2:
version "1.2.4"
resolved "https://registry.yarnpkg.com/sax/-/sax-1.2.4.tgz#2816234e2378bddc4e5354fab5caa895df7100d9"
integrity sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw==
sax@^1.4.1:
version "1.4.1"
resolved "https://registry.yarnpkg.com/sax/-/sax-1.4.1.tgz#44cc8988377f126304d3b3fc1010c733b929ef0f"
integrity sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg==

[email protected]:
version "3.0.1"
Expand Down

0 comments on commit a84d08d

Please sign in to comment.