Skip to content

Commit

Permalink
Add center-of-mass and change filnames (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienKN committed Jan 11, 2024
1 parent 4b791c2 commit c10624a
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 6 deletions.
12 changes: 6 additions & 6 deletions jobfile-osm-boundaries.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import _ from 'lodash'
import path from 'path'
import { fileURLToPath } from 'url'
import centroid from '@turf/centroid'
import centerOfMass from '@turf/center-of-mass'
import { hooks } from '@kalisio/krawler'

const __dirname = path.dirname(fileURLToPath(import.meta.url))
const storePath = process.env.STORE_PATH || 'data/OSM'
const dbUrl = process.env.DB_URL || 'mongodb://localhost:27017/atlas'

const baseUrl = 'https://download.geofabrik.de'
const regions = process.env.REGIONS || 'europe/france;europe/albania'
const regions = process.env.REGIONS || 'europe/france'
const fabrikSuffix = '-latest.osm.pbf'
const minLevel = process.env.MIN_LEVEL || 2
const maxLevel = process.env.MAX_LEVEL || 8
const maxLevel = process.env.MAX_LEVEL || 6
const collection = 'osm-boundaries'

let generateTasks = (options) => {
Expand Down Expand Up @@ -77,17 +77,17 @@ export default {
},
extract: {
hook: 'runCommand',
command: `osmium export -f json <%= key %>-name.pbf --geometry-types=polygon --overwrite -o <%= key %>.geojson`
command: `osmium export -f json <%= key %>-name.pbf --geometry-types=polygon --overwrite -o <%= key %>-boundaries.geojson`
},
readJson: {
key: `<%= key %>.geojson`
key: `<%= key %>-boundaries.geojson`
},
generateToponyms: {
hook: 'apply',
function: (item) => {
let toponyms = []
_.forEach(item.data.features, feature => {
const toponym = centroid(feature.geometry)
const toponym = centerOfMass(feature.geometry)
toponym.properties = feature.properties
toponyms.push(toponym)
})
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
},
"dependencies": {
"@turf/centroid": "^6.5.0",
"@turf/center-of-mass": "^6.5.0",
"glob": "^10.3.10",
"lodash": "^4.17.15"
},
Expand Down
64 changes: 64 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,17 @@
resolved "https://registry.yarnpkg.com/@pkgjs/parseargs/-/parseargs-0.11.0.tgz#a77ea742fab25775145434eb1d2328cf5013ac33"
integrity sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==

"@turf/center-of-mass@^6.5.0":
version "6.5.0"
resolved "https://registry.yarnpkg.com/@turf/center-of-mass/-/center-of-mass-6.5.0.tgz#f9e6988bc296b7f763a0137ad6095f54843cf06a"
integrity sha512-EWrriU6LraOfPN7m1jZi+1NLTKNkuIsGLZc2+Y8zbGruvUW+QV7K0nhf7iZWutlxHXTBqEXHbKue/o79IumAsQ==
dependencies:
"@turf/centroid" "^6.5.0"
"@turf/convex" "^6.5.0"
"@turf/helpers" "^6.5.0"
"@turf/invariant" "^6.5.0"
"@turf/meta" "^6.5.0"

"@turf/centroid@^6.5.0":
version "6.5.0"
resolved "https://registry.yarnpkg.com/@turf/centroid/-/centroid-6.5.0.tgz#ecaa365412e5a4d595bb448e7dcdacfb49eb0009"
Expand All @@ -27,11 +38,27 @@
"@turf/helpers" "^6.5.0"
"@turf/meta" "^6.5.0"

"@turf/convex@^6.5.0":
version "6.5.0"
resolved "https://registry.yarnpkg.com/@turf/convex/-/convex-6.5.0.tgz#a7613e0d3795e2f5b9ce79a39271e86f54a3d354"
integrity sha512-x7ZwC5z7PJB0SBwNh7JCeCNx7Iu+QSrH7fYgK0RhhNop13TqUlvHMirMLRgf2db1DqUetrAO2qHJeIuasquUWg==
dependencies:
"@turf/helpers" "^6.5.0"
"@turf/meta" "^6.5.0"
concaveman "*"

"@turf/helpers@^6.5.0":
version "6.5.0"
resolved "https://registry.yarnpkg.com/@turf/helpers/-/helpers-6.5.0.tgz#f79af094bd6b8ce7ed2bd3e089a8493ee6cae82e"
integrity sha512-VbI1dV5bLFzohYYdgqwikdMVpe7pJ9X3E+dlr425wa2/sMJqYDhTO++ec38/pcPvPE6oD9WEEeU3Xu3gza+VPw==

"@turf/invariant@^6.5.0":
version "6.5.0"
resolved "https://registry.yarnpkg.com/@turf/invariant/-/invariant-6.5.0.tgz#970afc988023e39c7ccab2341bd06979ddc7463f"
integrity sha512-Wv8PRNCtPD31UVbdJE/KVAWKe7l6US+lJItRR/HOEW3eh+U/JwRCSUl/KZ7bmjM/C+zLNoreM2TU6OoLACs4eg==
dependencies:
"@turf/helpers" "^6.5.0"

"@turf/meta@^6.5.0":
version "6.5.0"
resolved "https://registry.yarnpkg.com/@turf/meta/-/meta-6.5.0.tgz#b725c3653c9f432133eaa04d3421f7e51e0418ca"
Expand Down Expand Up @@ -85,6 +112,16 @@ color-name@~1.1.4:
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==

concaveman@*:
version "1.2.1"
resolved "https://registry.yarnpkg.com/concaveman/-/concaveman-1.2.1.tgz#47d20b4521125c15fabf453653c2696d9ee41e0b"
integrity sha512-PwZYKaM/ckQSa8peP5JpVr7IMJ4Nn/MHIaWUjP4be+KoZ7Botgs8seAZGpmaOM+UZXawcdYRao/px9ycrCihHw==
dependencies:
point-in-polygon "^1.1.0"
rbush "^3.0.1"
robust-predicates "^2.0.4"
tinyqueue "^2.0.3"

cross-spawn@^7.0.0:
version "7.0.3"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
Expand Down Expand Up @@ -182,6 +219,28 @@ path-scurry@^1.10.1:
lru-cache "^9.1.1 || ^10.0.0"
minipass "^5.0.0 || ^6.0.2 || ^7.0.0"

point-in-polygon@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/point-in-polygon/-/point-in-polygon-1.1.0.tgz#b0af2616c01bdee341cbf2894df643387ca03357"
integrity sha512-3ojrFwjnnw8Q9242TzgXuTD+eKiutbzyslcq1ydfu82Db2y+Ogbmyrkpv0Hgj31qwT3lbS9+QAAO/pIQM35XRw==

quickselect@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/quickselect/-/quickselect-2.0.0.tgz#f19680a486a5eefb581303e023e98faaf25dd018"
integrity sha512-RKJ22hX8mHe3Y6wH/N3wCM6BWtjaxIyyUIkpHOvfFnxdI4yD4tBXEBKSbriGujF6jnSVkJrffuo6vxACiSSxIw==

rbush@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/rbush/-/rbush-3.0.1.tgz#5fafa8a79b3b9afdfe5008403a720cc1de882ecf"
integrity sha512-XRaVO0YecOpEuIvbhbpTrZgoiI6xBlz6hnlr6EHhd+0x9ase6EmeN+hdwwUaJvLcsFFQ8iWVF1GAK1yB0BWi0w==
dependencies:
quickselect "^2.0.0"

robust-predicates@^2.0.4:
version "2.0.4"
resolved "https://registry.yarnpkg.com/robust-predicates/-/robust-predicates-2.0.4.tgz#0a2367a93abd99676d075981707f29cfb402248b"
integrity sha512-l4NwboJM74Ilm4VKfbAtFeGq7aEjWL+5kVFcmgFA2MrdnQWx9iE/tUGvxY5HyMI7o/WpSIUFLbC5fbeaHgSCYg==

shebang-command@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-2.0.0.tgz#ccd0af4f8835fbdc265b82461aaf0c36663f34ea"
Expand Down Expand Up @@ -233,6 +292,11 @@ strip-ansi@^7.0.1:
dependencies:
ansi-regex "^6.0.1"

tinyqueue@^2.0.3:
version "2.0.3"
resolved "https://registry.yarnpkg.com/tinyqueue/-/tinyqueue-2.0.3.tgz#64d8492ebf39e7801d7bd34062e29b45b2035f08"
integrity sha512-ppJZNDuKGgxzkHihX8v9v9G5f+18gzaTfrukGrq6ueg0lmH4nqVnA2IPG0AEH3jKEk2GRJCUhDoqpoiw3PHLBA==

which@^2.0.1:
version "2.0.2"
resolved "https://registry.yarnpkg.com/which/-/which-2.0.2.tgz#7c6a8dd0a636a0327e10b59c9286eee93f3f51b1"
Expand Down

0 comments on commit c10624a

Please sign in to comment.