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

Hi im getting this error when i try to insert my osm data into my postgres database.

SEVERE: Thread for task 1-read-xml failed
org.openstreetmap.osmosis.core.OsmosisRuntimeException: Unable to load current ways.

and

ERROR: duplicate key value violates unique constraint "current_ways_pkey"
  Detail: Key (id)=(197) already exists.

The command im using is:

osmosis --read-xml file="/home/ubuntu/osmosis/bin/mergedeuroad.osm" --write-apidb host="localhost" database="openstreetmap" user="xxx" password="xxx" validateSchemaVersion="no"

any solutions to solve this?

ERROR LOG:

INFO: Pipeline executing, waiting for completion.
Nov 14, 2020 7:46:41 PM org.openstreetmap.osmosis.core.pipeline.common.ActiveTaskManager waitForCompletion
SEVERE: Thread for task 1-read-xml failed
org.openstreetmap.osmosis.core.OsmosisRuntimeException: Unable to load current ways.
        at org.openstreetmap.osmosis.apidb.v0_6.ApidbWriter.populateCurrentWays(ApidbWriter.java:1035)
        at org.openstreetmap.osmosis.apidb.v0_6.ApidbWriter.populateCurrentTables(ApidbWriter.java:1108)
        at org.openstreetmap.osmosis.apidb.v0_6.ApidbWriter.complete(ApidbWriter.java:1141)
        at org.openstreetmap.osmosis.xml.v0_6.XmlReader.run(XmlReader.java:92)
        at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "current_ways_pkey"
  Detail: Key (id)=(197) already exists.
        at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2510)
        at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2245)
        at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:311)
        at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:447)
        at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:368)
        at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:159)
        at org.postgresql.jdbc.PgPreparedStatement.execute(PgPreparedStatement.java:148)
        at org.openstreetmap.osmosis.apidb.v0_6.ApidbWriter.populateCurrentWays(ApidbWriter.java:1032)
        ... 4 more

Nov 14, 2020 7:46:41 PM org.openstreetmap.osmosis.core.Osmosis main
SEVERE: Execution aborted.
org.openstreetmap.osmosis.core.OsmosisRuntimeException: One or more tasks failed.
        at org.openstreetmap.osmosis.core.pipeline.common.Pipeline.waitForCompletion(Pipeline.java:146)
        at org.openstreetmap.osmosis.core.Osmosis.run(Osmosis.java:92)
        at org.openstreetmap.osmosis.core.Osmosis.main(Osmosis.java:37)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:321)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:234)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
        at org.codehaus.classworlds.Launcher.main(Launcher.java:47)

asked 14 Nov '20, 20:09

shafi-as's gravatar image

shafi-as
107712
accept rate: 0%

edited 16 Nov '20, 10:48

scai's gravatar image

scai ♦
33.3k21309459

  1. Please explain how the file "mergedeuroad.osm" has been created, or upload it to a place where we can see.
  2. Are you really, really sure that you want to create a database in the API DB format? Because if you just want to be able to run queries on the road network, osm2pgsql would be a much better choice for importing than osmosis.
(14 Nov '20, 21:37) Frederik Ramm ♦

1) the merged osm was created, using osmfilter, it was originally a geofabrik Europe file. i filtered it to only to have highways, once filtered it was merged with a file containing rails and seaways for certain countries in Europe created on josm.

2) i chose APIDB as it was on the guide i was following to create a private osm server. im trying to view that road rail and seaway data on josm. will osm2pgql work the same for intupting data into josm? also im more familiar with the osmosis commands.

(14 Nov '20, 22:54) shafi-as
1

If you want to set up your own OSM server then APIDB is indeed what you need. If you have created new objects with OSM then these will likely have negative IDs and therefore cannot be loaded into an APIDB. If you have created the objects with JOSM by downloading data from OSM, you have likely created duplicates accidentally. Note that a way can have a highway and a railway tag at the same time: https://www.openstreetmap.org/way/281583600

(15 Nov '20, 01:39) Frederik Ramm ♦

ive loaded both files in separately before the merge in to the database successfully. but when they are emerged its when the duplicate key error im getting. so i think i can rule out the negative IDs being an issue. is there any osmosis command to filter out or view duplicates. or any ways to go around the duplicate error

(15 Nov '20, 15:38) shafi-as

As fredrerik mentioned it may be that two tags such as railway and highway have the same ID, as one one my osm was custom made this was the case for me. To over come this, i opened the file on notepad++ and searched for the the duplicate id and gave it and unrealistic number that wouldn't be used again. this will work for ways. if it is a duplicate node node problem, once you change the node you then make sure you search for the references of that duplicate node and change them aswell. this is a wacky fix but it worked for me.

permanent link

answered 16 Nov '20, 10:37

shafi-as's gravatar image

shafi-as
107712
accept rate: 0%

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:

×252
×165

question asked: 14 Nov '20, 20:09

question was seen: 1,481 times

last updated: 16 Nov '20, 10:48

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