New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a rake task for populating the database #282
Comments
Well populating the database should very much be relegated to an "optional extras" section of the documentation - most people just looking to install the rails code in order to develop it should never need to to do any sort of import. So I don't object to this idea, but really the easiest solution for most people is not to bother, which also means you don't have to explain how to install osmosis, making things even simpler! |
Oh indeed - I'm just aiming to reduce the length of the 'optional extras' section too! |
Once the schema is set up it is "just" one osmosis command to load in data. Perhaps just redirect to the osmosis install instructions and give the command? |
The original instructions have lots of resetting of sequences - does osmosis now handle all of these? |
That's for loading data then editing it locally, which is more specialized. If all you need to do is load some data to have something to view, it's pretty easy. Perhaps have a rake task to set sequences to MAX(id) or whatever is appropriate, and run the task after loading data? |
Just to note that I'm currently hoping to try some tweaks to the /browse/ pages, which do require a data import, or else there are no items to browse. (Especially since, by default, the search box's results come from remote.) At present there is no documentation (since the doc has gone from wiki into the CONFIG.md, which tells me literally nothing except this issue number), and no script. We are stuck! Please, something... (even if it's just a link to deprecated wiki instructions...) |
@danstowell I usually just jump into the editor and draw something when I want to test something like that - that way I can be sure it will have the tags I need for whatever I'm testing. But sure, I'm not going to refuse a patch that provides (sensible) instructions on how to load some data. I believe it is a non-trivial thing to do however, so they will need to be well written. |
Are you wanting to import data, or import then edit data? The first is relatively easy - create the database then use the osmosis If the latter, then you need to muck about with sequences so when you add a node it gets a suitable ID. Having set up an apidb database a few times for testing, I can say that it was never properly documented anywhere. |
I only need to import data. (I need fairly rich data, so drawing a few ways myself isn't quite enough for me.) Just for the record (for anyone drafting a rake task!), here's what I've done which seems to have given me a usable read copy of the apidb:
This does not reset the sequences, as mentioned above in this thread. However it doesn't seem to need any weird privileges in the postgres user accounts. But then, since I don't know the database internals I don't know if the sequences issue is the only quirk of the (development) database I've landed myself with. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
@danstowell Error occurred. Any help?
|
@hanchao this is the root cause: drolbr/Overpass-API#257 (even if it didn't come from Overpass). Here's a shell script that will remap user IDs after the extract has been converted to XML: https://github.com/AmericanRedCross/posm-replay-tool/blob/c25d8e1f62af44e0664190723eba51eef7b93adc/remap-userid.sh My notes in https://github.com/AmericanRedCross/posm-replay-tool/blob/28deac4193859b71af34d845f013194a37871870/LOCAL.md#initialization explain what's going on and steps to fix it (locally). |
@mojodna Thanks. This helped greatly。 3642735 1708958 have the same name (Nodes&Roads)
https://www.openstreetmap.org/api/0.6/node/1582851239
The name in china-latest.osm.pbf is not updated |
@maxdeepfield Your comment has nothing to do with this thread and in any case is not appropriate here - please ask on the dev or rails-dev mailing lists, or on #osm-dev on IRC if you need help using the code. |
reading "about 90 lines explaining how to populate the database" is not very hard task if these lines exists and will work. any progress on this? |
Anyway, osmosis --write-apidb works fine with geofabrik extracts, after import I can see and edit data, then get the result via osmosis --read-apidb-current, what with --write-pbf gives new dataset. Also it works with xml/osm files exported directly from openstreetmap website via bounding box, so it is super easy to test on "real" data. If processes done without errors - do I need to care about something? |
Managed to import my region extract from geofabrik after resolving various data issues, which can be resolved with some database knowledge and background understanding (e.g. data extracts need to satisfy some integrity conditions) of these issues #1988, #2449, #2543 Anyway, I feel the real issue now may be that users don't realize "populating the database from an OSM extract" requires the data to be imported to meet certain conditions, for the step to "just work" (and possibly for the proposed rake task to run without getting tripped). Would it help to have another section covering the kind of data preparation which may be required? |
Well I think this script will be never written. |
Currently the installation notes spend about 90 lines explaining how to populate the database from an extract. A substantial portion of this concerns osmosis options and resetting sequences.
This could be simplified by creating a rake task that calls osmosis with the configured database parameters and takes care of the sequences.
The text was updated successfully, but these errors were encountered: