pelias-openstreetmap 5.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/.dockerignore ADDED
@@ -0,0 +1,2 @@
1
+ .git
2
+ node_modules
package/.editorconfig ADDED
@@ -0,0 +1,9 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ insert_final_newline = true
6
+
7
+ [*.{js,yml,json}]
8
+ indent_style = space
9
+ indent_size = 2
@@ -0,0 +1,55 @@
1
+ name: Continuous Integration
2
+ on: push
3
+ jobs:
4
+ unit-tests:
5
+ runs-on: '${{ matrix.os }}'
6
+ strategy:
7
+ matrix:
8
+ os:
9
+ - ubuntu-20.04
10
+ node-version:
11
+ - 12.x
12
+ - 14.x
13
+ - 16.x
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+ - name: 'Install node.js ${{ matrix.node-version }}'
17
+ uses: actions/setup-node@v2-beta
18
+ with:
19
+ node-version: '${{ matrix.node-version }}'
20
+ - name: Run unit tests
21
+ run: |
22
+ npm install
23
+ npm run ci
24
+ npm-publish:
25
+ needs: unit-tests
26
+ if: github.ref == 'refs/heads/master' && github.event_name == 'push'
27
+ runs-on: ubuntu-20.04
28
+ steps:
29
+ - uses: actions/checkout@v2
30
+ - name: Install Node.js
31
+ uses: actions/setup-node@v2-beta
32
+ with:
33
+ node-version: 16.x
34
+ - name: Run semantic-release
35
+ env:
36
+ GH_TOKEN: ${{ secrets.GH_SEMANTIC_RELEASE_TOKEN }}
37
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
38
+ run: >
39
+ if [[ -n "$GH_TOKEN" && -n "$NPM_TOKEN" ]]; then
40
+ curl "https://raw.githubusercontent.com/pelias/ci-tools/master/semantic-release.sh" | bash -
41
+ fi
42
+ build-docker-images:
43
+ # run this job if the unit tests passed and the npm-publish job was a success or was skipped
44
+ # note: github actions won't run a job if you don't call one of the status check functions, so `always()` is called since it evalutes to `true`
45
+ if: ${{ always() && needs.unit-tests.result == 'success' && (needs.npm-publish.result == 'success' || needs.npm-publish.result == 'skipped') }}
46
+ needs: [unit-tests, npm-publish]
47
+ runs-on: ubuntu-20.04
48
+ steps:
49
+ - uses: actions/checkout@v2
50
+ - name: Build Docker images
51
+ env:
52
+ DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
53
+ DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
54
+ run: |
55
+ curl "https://raw.githubusercontent.com/pelias/ci-tools/master/build-docker-images.sh" | bash -
package/.jshintignore ADDED
@@ -0,0 +1,6 @@
1
+ /node_modules/
2
+ esclient.log
3
+ *.log
4
+ nohup.out
5
+ test/*.pbf
6
+ coverage
package/.jshintrc ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "esversion": 6,
3
+ "node": true,
4
+ "curly": true,
5
+ "eqeqeq": true,
6
+ "freeze": true,
7
+ "immed": true,
8
+ "indent": 2,
9
+ "latedef": false,
10
+ "newcap": true,
11
+ "noarg": true,
12
+ "noempty": true,
13
+ "nonbsp": true,
14
+ "nonew": true,
15
+ "plusplus": false,
16
+ "quotmark": "single",
17
+ "undef": true,
18
+ "unused": false,
19
+ "maxparams": 4,
20
+ "maxdepth": 5,
21
+ "maxlen": 140
22
+ }
package/Dockerfile ADDED
@@ -0,0 +1,23 @@
1
+ # base image
2
+ FROM pelias/baseimage
3
+
4
+ # downloader apt dependencies
5
+ # note: this is done in one command in order to keep down the size of intermediate containers
6
+ RUN apt-get update && apt-get install -y bzip2 unzip && rm -rf /var/lib/apt/lists/*
7
+
8
+ # change working dir
9
+ ENV WORKDIR /code/pelias/openstreetmap
10
+ WORKDIR ${WORKDIR}
11
+
12
+ # copy package.json first to prevent npm install being rerun when only code changes
13
+ COPY ./package.json ${WORKDIR}
14
+ RUN npm install
15
+
16
+ # add local code
17
+ ADD . ${WORKDIR}
18
+
19
+ # run tests, clean up LevelDB lockfile
20
+ RUN npm test && rm -rf /tmp/*
21
+
22
+ # run as the pelias user
23
+ USER pelias
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2014 Mapzen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,184 @@
1
+ <p align="center">
2
+ <img height="100" src="https://raw.githubusercontent.com/pelias/design/master/logo/pelias_github/Github_markdown_hero.png">
3
+ </p>
4
+ <h3 align="center">A modular, open-source search engine for our world.</h3>
5
+ <p align="center">Pelias is a geocoder powered completely by open data, available freely to everyone.</p>
6
+ <p align="center">
7
+ <a href="https://en.wikipedia.org/wiki/MIT_License"><img src="https://img.shields.io/github/license/pelias/api?style=flat&color=orange" /></a>
8
+ <a href="https://hub.docker.com/u/pelias"><img src="https://img.shields.io/docker/pulls/pelias/api?style=flat&color=informational" /></a>
9
+ <a href="https://gitter.im/pelias/pelias"><img src="https://img.shields.io/gitter/room/pelias/pelias?style=flat&color=yellow" /></a>
10
+ </p>
11
+ <p align="center">
12
+ <a href="https://github.com/pelias/docker">Local Installation</a> ·
13
+ <a href="https://geocode.earth">Cloud Webservice</a> ·
14
+ <a href="https://github.com/pelias/documentation">Documentation</a> ·
15
+ <a href="https://gitter.im/pelias/pelias">Community Chat</a>
16
+ </p>
17
+ <details open>
18
+ <summary>What is Pelias?</summary>
19
+ <br />
20
+ Pelias is a search engine for places worldwide, powered by open data. It turns addresses and place names into geographic coordinates, and turns geographic coordinates into places and addresses. With Pelias, you’re able to turn your users’ place searches into actionable geodata and transform your geodata into real places.
21
+ <br /><br />
22
+ We think open data, open source, and open strategy win over proprietary solutions at any part of the stack and we want to ensure the services we offer are in line with that vision. We believe that an open geocoder improves over the long-term only if the community can incorporate truly representative local knowledge.
23
+ </details>
24
+
25
+ # Pelias OpenStreetMap importer
26
+
27
+ ## Overview
28
+
29
+ The OpenStreetMap importer handles importing data from [OpenStreetMap](https://www.openstreetmap.org/) into Elasticsearch for use by Pelias.
30
+
31
+ It includes logic for filtering to select only data relevant for geocoding, transforming it to match the Pelias data model, and augmenting the data as required.
32
+
33
+ ## Prerequisites
34
+
35
+ See [Pelias software requirements](https://github.com/pelias/documentation/blob/master/requirements.md)
36
+
37
+ ## Clone and Install dependencies
38
+
39
+ > For instructions on setting up Pelias as a whole, see our [getting started guide](https://github.com/pelias/documentation/blob/master/getting_started_install.md). Further instructions here pertain to the OSM importer only
40
+
41
+ ```bash
42
+ $ git clone https://github.com/pelias/openstreetmap.git && cd openstreetmap;
43
+ $ npm install
44
+ ```
45
+
46
+ ## Download data
47
+
48
+ The importer will accept any valid `pbf` extract you have, such as a full planet file (50GB+) from [planet.openstreetmap.org](https://planet.openstreetmap.org) or [download.geofabrik.de](https://download.geofabrik.de)
49
+ You can use the included download script to obtain the desired `pbf` files as follows. In the configuration file you can
50
+ specify which files are to be downloaded. They will all be downloaded to the `imports.openstreetmap.datapath` directory.
51
+
52
+ If no download sources are specified in the configuration, the entire planet file will be downloaded. Keep in mind this file is quite large.
53
+
54
+ ```bash
55
+ $ PELIAS_CONFIG=<path-to-config> npm run download
56
+ ```
57
+
58
+ ## Configuration
59
+
60
+ In order to tell the importer the location of your downloads, temp space and environmental settings you will first need to create a `~/pelias.json` file.
61
+
62
+ See [the config](https://github.com/pelias/config) documentation for details on the structure of this file. Your relevant config info for the openstreetmap module might look something like this:
63
+
64
+ ```javascript
65
+ {
66
+ "imports": {
67
+ "openstreetmap": {
68
+ "download": [{
69
+ "sourceURL": "https://s3.amazonaws.com/metro-extracts.nextzen.org/portland_oregon.osm.pbf"
70
+ }],
71
+ "datapath": "/mnt/pelias/openstreetmap",
72
+ "leveldbpath": "/tmp",
73
+ "import": [{
74
+ "filename": "portland_oregon.osm.pbf"
75
+ }]
76
+ }
77
+ }
78
+ }
79
+ ```
80
+
81
+ ### Configuration Settings
82
+
83
+ #### `imports.openstreetmap.datapath`
84
+
85
+ This is the directory where the OSM importer will look for files to import. If configured it will also download files to this location.
86
+
87
+ #### `imports.openstreetmap.download[0].sourceURL`
88
+
89
+ A URL to download when the download script (in `./bin/download`) is run. Will be downloaded to the `datapath` directory.
90
+
91
+ #### `imports.openstreetmap.import[0].filename`
92
+
93
+ The OSM importer will look for a file with a name matching this value in the configured `datapath` directory when importing data.
94
+
95
+ If downloading from a remote URL, the filename must match the value in `sourceURL`.
96
+
97
+ #### `imports.openstreetmap.leveldbpath`
98
+
99
+ This is the directory where temporary files will be stored in order to
100
+ denormalize OSM ways and relations. In the case of a planet import it is best
101
+ to have at least 100GB free.
102
+
103
+ Defaults to `tmp`.
104
+
105
+ #### `imports.openstreetmap.importVenues`
106
+
107
+ By default, the OSM importer imports both venue records and addresses. If set to false, only address records will be imported.
108
+
109
+ #### `imports.openstreetmap.removeDisusedVenues`
110
+
111
+ If set to boolean `true`, `venue`s with popularity below `0` (as determined by OSM tags) will be
112
+ discarded. In practice, this affects records with tags such as
113
+ [`disused`](https://wiki.openstreetmap.org/wiki/Key:disused#disused:_namespace),
114
+ [`amenity:disused`](https://wiki.openstreetmap.org/wiki/Tag:amenity%3Ddisused) and
115
+ [`abandoned`](https://wiki.openstreetmap.org/wiki/Key:abandoned:)
116
+
117
+ By default, or if set to any other value besides `true`, these records will be imported.
118
+
119
+ ### Administrative Hierarchy Lookup
120
+
121
+ OSM records often do not contain information about which city, state (or
122
+ other region like province), or country that they belong to. Pelias has the
123
+ ability to compute these values from [Who's on First](http://www.whosonfirst.org/) data.
124
+ For more info on how admin lookup works, see the documentation for
125
+ [pelias/wof-admin-lookup](https://github.com/pelias/wof-admin-lookup). By default,
126
+ adminLookup is enabled. To disable, set `imports.adminLookup.enabled` to `false` in Pelias config.
127
+
128
+ **Note:** Admin lookup requires loading around 5GB of data into memory.
129
+
130
+ ## Running an import
131
+
132
+ This will start the import process. It may take a few minutes to load administrative data and begin processing the OSM PBF file, then you should see regular progress updates in the terminal.
133
+
134
+ ```bash
135
+ $ npm start
136
+ ```
137
+
138
+ ## How long does it take?
139
+
140
+ If all goes well, you should see between 6000-7000 records imported per second on a modern machine. A full planet install will import about 80 million records, whereas most city extracts will import at most a few thousand.
141
+
142
+ These counts are of records containing valid location names to search on, data which is not directly searchable by the end user, such as fire hydrants, lamp posts, etc is not imported.
143
+
144
+ If you are looking to run a planet-wide cluster like the one we provide for [geocode.earth](https://geocode.earth) please see our documentation on [full planet builds](https://github.com/pelias/documentation/blob/master/full_planet_considerations.md#importer-machine).
145
+
146
+ ## Issues
147
+
148
+ If you have any issues getting set up or the documentation is missing something, please open an issue here: https://github.com/pelias/openstreetmap/issues
149
+
150
+ ## Contributing
151
+
152
+ Please fork and pull request against upstream master on a feature branch.
153
+
154
+ Pretty please; provide unit tests and script fixtures in the `test` directory.
155
+
156
+ ## Code Linting
157
+
158
+ A `.jshintrc` file is provided which contains a linting config, usually your text editor will understand this config and give you inline hints on code style and readability.
159
+
160
+ These settings are strictly enforced when you do a `git commit`, you can execute `git commit` at any time to run the linter against your code.
161
+
162
+ ### Running Unit Tests
163
+
164
+ ```bash
165
+ $ npm test
166
+ ```
167
+
168
+ ### Running End-to-End Tests
169
+
170
+ These tests run the entire pipeline against a small PBF extract to assert that the individual units work as expected when wired together.
171
+
172
+ ```bash
173
+ $ npm run end-to-end
174
+ ```
175
+
176
+ ## Code Coverage
177
+
178
+ ```bash
179
+ $ npm run coverage
180
+ ```
181
+
182
+ ### Continuous Integration
183
+
184
+ CI tests every change against all supported Node.js versions.
package/bin/download ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ exec node util/download_data.js
package/bin/start ADDED
@@ -0,0 +1,3 @@
1
+ #!/bin/bash
2
+
3
+ exec node --max_old_space_size=8000 index.js
package/bin/test ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+
3
+ # run tests with pipefail to avoid false passes
4
+ # see https://github.com/pelias/pelias/issues/744
5
+ set -o pipefail
6
+
7
+ NODE_ENV=test node test/run.js | npx tap-spec