Skip to content
This repository has been archived by the owner on May 7, 2020. It is now read-only.

Commit

Permalink
Filter administrative boundaries in parallel.
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinnot committed Jun 4, 2017
1 parent 6994f08 commit 62ad143
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 37 deletions.
37 changes: 3 additions & 34 deletions Dockerfile
Expand Up @@ -111,41 +111,10 @@ RUN mkdir ${USERHOME}/Nominatim/build && \
USER nominatim
RUN curl -L ${PBF_URL} --create-dirs -o /srv/nominatim/src/data.osm.pbf

# Filter country boundaries
# Filter administrative boundaries
USER nominatim
RUN if ${IMPORT_ADMINISTRATIVE}; then \
osmosis -v \
--read-pbf-fast workers=${IMPORT_THREADS} /srv/nominatim/src/data.osm.pbf \
--tf accept-nodes "boundary=administrative" \
--tf reject-relations \
--tf reject-ways \
--write-pbf file=/srv/nominatim/src/nodes.osm.pbf \
fi
RUN if ${IMPORT_ADMINISTRATIVE}; then \
osmosis -v \
--read-pbf-fast workers=${IMPORT_THREADS} /srv/nominatim/src/data.osm.pbf \
--tf accept-ways "boundary=administrative" \
--tf reject-relations \
--used-node \
--write-pbf file=/srv/nominatim/src/ways.osm.pbf \
fi
RUN if ${IMPORT_ADMINISTRATIVE}; then \
osmosis -v \
--read-pbf-fast workers=${IMPORT_THREADS} /srv/nominatim/src/data.osm.pbf \
--tf accept-relations "boundary=administrative" \
--used-node \
--used-way \
--write-pbf file=/srv/nominatim/src/relations.osm.pbf \
fi
RUN if ${IMPORT_ADMINISTRATIVE}; then \
osmosis -v \
--rb /srv/nominatim/src/nodes.osm.pbf outPipe.0=N \
--rb /srv/nominatim/src/ways.osm.pbf outPipe.0=W \
--rb /srv/nominatim/src/relations.osm.pbf outPipe.0=R \
--merge inPipe.0=N inPipe.1=W outPipe.0=NW \
--merge inPipe.0=NW inPipe.1=R outPipe.0=NWR \
--wb inPipe.0=NWR file=/srv/nominatim/src/data.osm.pbf \
fi
COPY scripts /srv/nominatim/scripts/
RUN /srv/nominatim/scripts/filter_administrative.sh

# Add postgresql users
USER root
Expand Down
2 changes: 1 addition & 1 deletion LICENSE.md
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
10 changes: 8 additions & 2 deletions README.md
@@ -1,8 +1,14 @@
# Nominatim Docker container
Nominatim Docker container
==========================

Fully-featured container for geocoding, reverse geocoding and address lookup based on [Nominatim](https://github.com/openstreetmap/Nominatim) and [Open Street Map](http://www.openstreetmap.org) data.

## (#Build)
## Table of content
- [Build](#build)
- [Run](#run)
- [Develop](#develop)

## Build
The build process is fairly straightforward, but requires lots of computer resources and can take days to complete.

To build, install [Docker](https://get.docker.com) and run following command:
Expand Down
46 changes: 46 additions & 0 deletions scripts/filter_administrative.sh
@@ -0,0 +1,46 @@
#!/bin/bash

if ${IMPORT_ADMINISTRATIVE}; then
FAIL=0
osmosis -v \
--read-pbf-fast workers=${IMPORT_THREADS} /srv/nominatim/src/data.osm.pbf \
--tf accept-nodes "boundary=administrative" \
--tf reject-relations \
--tf reject-ways \
--write-pbf file=/srv/nominatim/src/nodes.osm.pbf &
osmosis -v \
--read-pbf-fast workers=${IMPORT_THREADS} /srv/nominatim/src/data.osm.pbf \
--tf accept-ways "boundary=administrative" \
--tf reject-relations \
--used-node \
--write-pbf file=/srv/nominatim/src/ways.osm.pbf &
osmosis -v \
--read-pbf-fast workers=${IMPORT_THREADS} /srv/nominatim/src/data.osm.pbf \
--tf accept-relations "boundary=administrative" \
--used-node \
--used-way \
--write-pbf file=/srv/nominatim/src/relations.osm.pbf &

echo "Filtering administrative boundaries started."

for job in `jobs -p` do
echo ${job}
wait ${job} || let "FAIL+=1"
done

echo "${FAIL} jobs failed."

if [ "$FAIL" == "0" ]; then
echo "Filtering nodes, ways and relations completed."
echo "Starting merge process."
exec osmosis -v \
--rb /srv/nominatim/src/nodes.osm.pbf outPipe.0=N \
--rb /srv/nominatim/src/ways.osm.pbf outPipe.0=W \
--rb /srv/nominatim/src/relations.osm.pbf outPipe.0=R \
--merge inPipe.0=N inPipe.1=W outPipe.0=NW \
--merge inPipe.0=NW inPipe.1=R outPipe.0=NWR \
--wb inPipe.0=NWR file=/srv/nominatim/src/data.osm.pbf
else
exit 1;
fi
fi
1 change: 1 addition & 0 deletions start.sh
@@ -1,3 +1,4 @@
#!/bin/bash

service postgresql start
/usr/sbin/apache2ctl -D FOREGROUND

0 comments on commit 62ad143

Please sign in to comment.