Osmer

Osmer is a tool to manage local OSM database: import data, transform it to convenient scheme and update it.

Features

  • Importing and updating data in osm2pgsql schema (osm2pgsql required)

  • Custom derived schemas for analysis or rendering convenience

  • BBox restriction of imported data

  • Data reprojection between schemas

  • planned

    Rails-like config/database.yml support for seamless integration with webapps

  • planned

    Importing and updating data in pgsnapshot schema (osmosis required)

Configuration

Database schemas definition goes to Osmfile which contains basic flags and schema definitions:

prefix 'osmer' # Prefix for all tables

schema :source, :type => :osm2pgsql do # Osm2pgsql schema named 'source'

  bbox 35.859375, 54.367759, 36.562495, 54.775345 # It has bounding box restriction as minlon, minlat, maxlon, maxlat

  updates :daily do # It may be updated on daily basis
    dump 'http://data.gis-lab.info/osm_dump/dump/RU-KLU/RU-KLU-{today}.osm.pbf' # Where initial dump should be downloaded from here
    diff 'http://data.gis-lab.info/osm_dump/diff/RU/RU-{yesterday}-{today}.osc.gz' # And diff should be downloaded from here
  end

end

schema :rendering, :projection => 900913 do # Rendering schema containing only necessary data

  multipolygons :places do # Table of place boundaries
    map :place => [:city, :town, :village, :hamlet] # It contains features which have place tag with one of values: city, town, village, hamlet

    with :area # And also polygon area
  end

  lines :roads do # Table of roads
    map :highway # It contains features with highway tag

    with :length, :ref => :string # And also road length and ref tag to additional table column
  end

end

Usage

Osmer may be used as command-line executable with following commands:

  • osmer schema create [SCHEMA] # Create given osm schema in database (create all if none specified)

  • osmer schema drop [SCHEMA] # Drop given osm schema in database (drop all if none specified)

  • osmer schema recreate [SCHEMA] # Recreate given osm schema in database (recreate all if none specified)

  • osmer data import [SCHEMA] [FILE] # Import data to given schema from file

  • osmer data update [SCHEMA] [FILE] # Update data in schema from given change file

Details

Schema

Schema is a set of tables representing osm data in a common way. Examples of schemas may be:

  • Osm2Pgsql schema

  • PgSnapshot schema populated with Osmosis

  • Custom set of tables, representing data in convenient way

All tables in schema share common projection. In database schemas are represented with table prefixes (native schemas will be supported later)

In code, schema is representd by an object, which have following methods:

  • create! - to create schema in database

  • drop! - to drop schema in database

  • attach_listener! - (optional) - to add listener to schema data, which may be used to have autoupdate functionality

listener with name <name> is a stored procedure set:

<name>_insert(id,*args)
<name>_update(id,*args)
<name>_delete(id)

Contributors

See github.com/alno/osmer/graphs/contributors

Copyright © 2012 Alexey Noskov, released under the MIT license