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
10●7●7●12
accept rate:
0%
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.
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
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