Skip to content
This repository has been archived by the owner on Jul 24, 2021. It is now read-only.

osmosis creates incorrect linestring geometry in simple schema #3650

Open
openstreetmap-trac opened this issue Jul 23, 2021 · 1 comment
Open

Comments

@openstreetmap-trac
Copy link

Reporter: bestoujev[at]gmail.com
[Submitted to the original trac issue database at 10.18pm, Tuesday, 5th April 2011]

When a one node way is present in the database and osmosis creates a linestring geometry for it the resulting geometry is something like LINESTRING(139.386972 37.095865)

When we process this linestring with any postgis function it gives us an error - the linestring must contain 0 or > 1 nodes.

When linestring objects are created with internal osmosis functions the number of nodes is checked to be >= 2, but the sql-command does not contain such a check.

I suggest changing the code of WayDao.java from:

private static final String SQL_UPDATE_WAY_LINESTRING =
	"UPDATE ways w SET linestring = ("
	+ " SELECT MakeLine(c.geom) AS way_line FROM ("
	+ " SELECT n.geom AS geom FROM nodes n INNER JOIN way_nodes wn ON n.id = wn.node_id"
	+ " WHERE (wn.way_id = w.id) ORDER BY wn.sequence_id"
	+ " ) c"
	+ " )"
	+ " WHERE w.id  = ?";

to

private static final String SQL_UPDATE_WAY_LINESTRING =
	"UPDATE ways w SET linestring = ("
	+ " SELECT MakeLine(c.geom) AS way_line FROM ("
	+ " SELECT n.geom AS geom FROM nodes n INNER JOIN way_nodes wn ON n.id = wn.node_id"
	+ " WHERE (wn.way_id = w.id) and array_length(nodes, 1) > 1 ORDER BY wn.sequence_id"
	+ " ) c"
	+ " )"
	+ " WHERE w.id  = ?";

the "and array_length(nodes, 1) > 1" code will make sure that there are more than 1 node in this way.

I am not a java programmer, so I am not sure that it is the best solution, but this is surely a workaround for the problem . One node ways do not allow to work with the database properly, so this is a very important issue.

@openstreetmap-trac
Copy link
Author

Author: bestoujev[at]gmail.com
[Added to the original trac issue at 12.06pm, Thursday, 7th April 2011]

The origin of duplicate nodes can be found here: http://trac.openstreetmap.org/ticket/2501

Second problem is also from that poltach bug: ways with two nodes, where both nodes are same. I have not figured yet how to solve it easily...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant