Coder Social home page Coder Social logo

cyclestreets / osm-snapshot-server Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gravitystorm/snapshot-server

0.0 4.0 0.0 556 KB

Serving OSM map requests from an osmosis pgsnapshot schema

Ruby 79.64% JavaScript 5.00% CSS 6.83% HTML 8.54%

osm-snapshot-server's Introduction

Snapshot server

A small rails application for taking .osm files and serving OpenStreetMap map-calls.

The data is loaded into the system using osmosis snapshot schema (--write-pgsql), although the latest version of the software can handle multiple projects (i.e. multiple .osm files) and so the database schema is slightly modified.

Installation

This is a rails application, so lots of things will seem familar if you're familiar with rails projects.

Prerequisites

For an Ubuntu 12.04 LTS server, you need the following packages installed:

sudo apt-get install git postgresql-9.1 postgresql-server-dev-9.1 postgresql-9.1-postgis postgresql-contrib-9.1 \
                         ruby1.9.1 ruby1.9.1-dev libxml2-dev libxslt-dev

You'll need to install bundler using the gem1.9 binary. Don't install the ruby-bundler package, since that uses ruby 1.8

sudo /usr/bin/gem1.9.1 install bundler

Of course, if you want to mess around with rvm or rbenv or anything like that, feel free!

You also need to create a database role (i.e. user), with superuser priviledges (for installing postgis functions). It's easiest if you create one with the same username as you are logged in with, e.g. andy.

andy$ sudo su postgres
postgres$ createuser -s andy
postgres$ exit
andy$

If you want to use a different setup for your postgres database, like needing passwords or connecting to a different server, just make a note of your connection details. Don't create any databases at this stage.

First steps

First, grab the code, using git

git clone https://github.com/gravitystorm/snapshot-server.git

Then install the gem dependencies. This will install rails and all the components of the rails app that you need.

cd snapshot-server
bundle install

Databases

Then sort out the database. Cleverly, the next steps will create the required databases, add the postgis and hstore extensions, and create all the table and indexes automatically.

cp config/database.yml.example config/database.yml
nano config/database.yml # Only required if you need to change the connection settings, e.g. for postgresql username and passwords
rake db:create
rake db:migrate

If you have problems with the PostGIS functions and tables not being installed into the database, check the script_dir paths in config/database.yml. If you are using PostgreSQL 9.2, or PostGIS 2.0, you'll need to change the paths.

Now, Launch a webserver.

rails server

Navigate to e.g. http://localhost:3000 and you'll see a getting started page. Follow the instructions to set up an account on the site.

Loading data

At present, loading data is in two stages. First we use osmosis to load the data into the staging tables.

osmosis --read-xml --write-pgsql

After the data is loaded, you need to create a new project (via the web interface), and transfer the data from the staging tables into that project.

rails console
project = Project.last
project.transfer

This can take a minute or two, depending on the size of your dataset. You can clear out the staging tables with project.truncate_staging_tables.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.