Skip to content

Introduce new node types

Thuy edited this page Dec 5, 2016 · 6 revisions

This is a guide to understand the process of introducing new node types to the wheelmap project, for this we need:

  • node_types categories & tags
  • translations
  • icons

0. Get infos from Sozialhelden

  • Product manager (Sozialhelden) will provide a list of:

    • openstreetmap categories
    • openstreetmap tags
    • mapicons

    that need to be introduced into the wheelmap project.

Useful resources

I. Add icons

  • Add the new icons to the folder app/assets/images/icons # a sprite will be generated automatically by compass which will then be precompiled during the deployment process

2. Generate icons zip

  • Generate icons zip with the rake task: bundle exec rake assets:create_zip _# this will create the file in the public/ folder that is referenced by all other devices, e.g. mobile clients

Find more infos here

3. Add keys & values

  • Add the new keys & values to the resource file categories.yml(EN) # this file is needed to start the transifex translation process
  • Add the new keys and values to fixtures/node_types.yml for tests

Note: Please consider to translate the german files before hand, if possible and if there aren't many words to translate in german, this way you could prevent displaying messages that are shown to the user similar to:

translation missing: de.community_support_form.new.form.submit_button

4. Pull & export translations

  • After OK from product manager fetch the new translations from transifex with: tx pull
  • Generate i18n js files with bundle exec rake i18n:js:export after importing the new translations

5. Update seed file (for development)

  • Add new node types categories to the seed.rb file.

Attention: Make sure to empty your local database to prevent duplicates before seeding data from db/seed.rb file into the database.

6. Check into Github

  • push to github to check in node_types, translations and icons

7. Get new node types into the database

If your database is not empty, don't seed from the seed.rb file, add the new categories manually to the database instead by running following example in the rails console:

public_transfer = Category.find_by_identifier('public_transfer')
NodeType.create([
  {category: public_transfer, identifier: :bicycle_rental,  osm_key: 'amenity',   osm_value: 'bicycle_rental', icon: 'cycling.png'},
  {category: public_transfer, identifier: :parking,         osm_key: 'amenity',   osm_value: 'parking',        icon: 'parking.png'}
])

Example to check via sql queries in the database if the new node types have been created, limit and order them:

SELECT osm_id, created_at FROM pois WHERE node_type_id IN (SELECT id FROM node_types WHERE DATE(created_at) = '2016-11-29') ORDER BY created_at DESC LIMIT 100;

8. Manual import of edits from osm to wheelmap database

Currently the planet importer (worker) syncs only the latest changes that have been made on osm after the new node types have been introduced to wheelmap (maybe also a few changes before the introduction). This means you have to import the osm node edits manually to the wheelmap database.

Following are the steps to consider:

  • Download the planet files from:

  • Filter the node types from the planet file and write to a separate file (example):

    $ osmosis --read-pbf-fast file=planet.pbf workers=<no_of_cpu> \
    
    --tag-filter reject-relations \
    
    --tag-filter  reject-ways \
    
    --tag-filter accept-nodes sport=arena,swim amenity=* leisure=* \
    
    --write-xml file=filtered.osm.xml.bz2
    
  • Log into the server, go to current release and get the new file (filtered.osm.xml.bz2) onto the server with scp

  • Import the file with a rake task (example):

    $ bzcat filtered.osm.xml.bz2 | RAILS_ENV=staging bundle exec rake osm:import