NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

I have setup a local OSM stack by following the instructions on INSTALL.md and CONFIGURE.md . I was able to do this without facing any major issues and loaded the database with a small portion of the map just to play around with it.

Whenever I make an edit on the map, the changes are not applied to the local database - I found this by querying via the website and also by exporting the data in the database to an .osm file using osmosis and searching for my edits in that. I wasn't able to find them

However, the changeset is created because when I go to my profile, I am able to see the changeset there. The only work around I was able to find for this is to download the changeset and manually apply the changeset to the database using osmosis . I came across this answer which suggests that whenever we save the changeset, it is immediately applied to the main database, and rendering could potentially take some time. I understand this, and I am not worried about the rendering part. I only want the changesets to get persisted to the database auotomatically.

Is there something different that I should be doing, or is this the expected behaviour?

Edit: - To add more details I also tried to hit http://localhost:3000/api/0.6/node/1 and http://localhost:3000/api/0.6/way/1/full -- which contains all the data that I edited.

The command that I am using to read data from DB and convert it to .osm is:

osmosis --read-apidb host="localhost" database="openstreetmap" user=< username > validateSchemaVersion="no"   --log-progress interval=60  --write-xml file=db.osm

asked 29 Jun '17, 22:10

nikhileshg92's gravatar image

nikhileshg92
26113
accept rate: 0%

edited 30 Jun '17, 01:15

In my experience editing both with iD directly on a local site, or via other editors with the API configuration pointing to a local server works without issues. Which editor are you using for testing?

(29 Jun '17, 23:27) SimonPoole ♦

I am using iD. I just noticed something interesting in your comment. "with the API configuration pointing to a local server" - The Rails setup instructions don't say anything about this. Do I have to update a separate configuration?

(29 Jun '17, 23:33) nikhileshg92

iD should be set up correctly if you followed the instructions, the only thing it needs is the OAuth configuration (I regularly use iD on my local instance to add test data).

(30 Jun '17, 23:42) SimonPoole ♦

Found the solution myself with some help from Frederik who directed me to think about how I was using osmosis

The data was getting saved into the DB which means my question is sort of void at this point. The problem was with the way I was using osmosis to export it. the "--read-apidb" command reads from a different set of tables. I should be using "--read-apidb-current" which reads from the tables that contain the changes. I found this out by looking at the server logs when I query for my changes on the localhost and I found out that the API queries for data from the "current_nodes" table instead of "nodes".

For example when I hit http://localhost:3000/api/0.6/node/1 this is the log that I got:

Started GET "/api/0.6/node/1" for ::1 at 2017-07-06 14:43:36 -0700 Processing by NodeController#read as HTML Parameters: {"id"=>"1"} Node Load (1.3ms) SELECT "current_nodes".* FROM "current_nodes" WHERE "current_nodes"."id" = $1 LIMIT 1 [["id", 1]] Changeset Load (0.5ms) SELECT "changesets".* FROM "changesets" WHERE "changesets"."id" = $1 LIMIT 1 [["id", 1]] User Load (12.9ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 1]] NodeTag Load (0.9ms) SELECT "current_node_tags".* FROM "current_node_tags" WHERE "current_node_tags"."node_id" = $1 [["node_id", 1]] Rendered text template (0.1ms) Completed 200 OK in 72ms (Views: 7.5ms | ActiveRecord: 15.6ms)

This clearly shows that the API interacts with the current_ tables and hence using the other osmosis* command helped me to resolve the issue

permanent link

answered 06 Jul '17, 22:45

nikhileshg92's gravatar image

nikhileshg92
26113
accept rate: 0%

With regard to your addendum - it sounds that the data is indeed correctly added to your database, otherwise the localhost:3000 URLs would not work. Which means that when you write "the changes are not applied to the local database", you are mistaken. I don't know how you have determined that "the changes are not applied to the local database", but there must be an error in that reasoning.

You write that you're not interested in rendering for now, but are you sure that you are not perhaps looking at a local osm2pgsql-generated database (containing a copy of the data that is in your API database) and are you perhaps somehow expecting that database to get updated automatically? Because that won't happen unless you set up a process that dumps changes to the API database into .osc files (using Osmosis) that are then consumed by osm2pgsql.

permanent link

answered 30 Jun '17, 06:52

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
82.5k927201273
accept rate: 23%

I assumed the same thing, that everything works because the API requests work. So, as I mentioned in the question, the way I am trying to verify this is by exporting the database into a .osm file using osmosis. I have also pasted the corresponding command that I am using for that.

No where in my process I am using osm2pgsql. I use osmosis to load the data and osmosis to read from database and write to a file.

(30 Jun '17, 18:34) nikhileshg92

You say that "you downloaded the changeset manually" and then "applied it to the database with osmosis", and that this worked. However, if you "download the changeset manually" then it clearly is already in the database (where else would you download it from?). Also the fact that you can get /node/1 etc. demonstrates that the data is in fact in the database. -- Is it possible that you have several databases, for example one "production" and one "development" and that your Rails API runs on the development database but your osmosis export runs on production (or vice versa)?

(30 Jun '17, 19:38) Frederik Ramm ♦

I finally realized what was happening. The data was getting saved into the DB like you said. The problem was with the way I was using osmosis to export it. the "--read-apidb" command reads from a different set of tables. I should be using "-read-apidb-current" which reads from the tables that contain the changes. I found this out by looking at the server logs when I query for my changes on the localhost and I found out that the API queries for data from the "current_nodes" table instead of "nodes".

Thanks for all the help!

(06 Jul '17, 22:35) nikhileshg92
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×352
×127
×118
×18
×8

question asked: 29 Jun '17, 22:10

question was seen: 2,843 times

last updated: 06 Jul '17, 22:45

NOTICE: help.openstreetmap.org is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum