For those looking for a quick and dirty fix to the problem, I have hacked an XSL file that will convert a OSM.xml file to another OSM.xml file where ways with non-contiguous segments are broken up into a way per segment. <br>
<br>It can be used to pre-process an OSM xml file to remove jumbled ways without affecting processing steps that come after as the xml structure does not change and all attributes are retained.<br><br>I have used the windows sabcmd XSLT processor for it,
e.g.<br><br>sabcmd.exe fixosm.xsl inputosm.xml outputosm.xml<br><br>Other XSLT processors should work similarly.<br><br>I agree that the issue should be fixed in the db itself, but setting up another db will create huge maintenance problems in the future: what happens if people start committing changes to the both dbs, old and fixed? How will you sync the data? A cleaner way would be to set up a 'view' that would only show contiguous segments.
<br><br>Ludwig<br><br><br><br>The file fixosm.xsl <br><br><?xml version="1.0" encoding="iso-8859-1"?><br><xsl:stylesheet version="1.0" xmlns:xsl="<a href="http://www.w3.org/1999/XSL/Transform">
http://www.w3.org/1999/XSL/Transform</a>"><br><xsl:output method="xml" indent="no" omit-xml-declaration="yes"/><br><br><xsl:template match="text()"/><br><br><xsl:template match="osm"><osm><xsl:apply-templates select="way|segment|node"/></osm></xsl:template>
<br><br><xsl:key name="node" match="/osm/node" use="@id"/><br><xsl:key name="segment" match="/osm/segment" use="@id"/><br><br><xsl:template match="segment|node">
<br><xsl:copy-of select="."/><br></xsl:template><br><br><xsl:template name="splitway"><br><xsl:param name="way"/><br><xsl:for-each select="seg"><br><way id="{../@id}">
<br><seg id="{@id}"/><br><xsl:for-each select="../tag"><br><xsl:copy-of select="."/><br></xsl:for-each><br></way><br></xsl:for-each><br></xsl:template>
<br><br><xsl:template match="way"><br><xsl:variable name="splitifnotempty"><br><xsl:for-each select="seg"><br><xsl:if test="position() != last()"><br><xsl:variable name="thissegment" select="key('segment',@id)"/>
<br><xsl:variable name="next" select="position()+1"/><br><xsl:variable name="nextsegment" select="key('segment',../seg[$next]/@id)"/><br><xsl:variable name="tolon" select="key('node',$thissegment/@to)/@lon"/>
<br><xsl:variable name="tolat" select="key('node',$thissegment/@to)/@lat"/><br><xsl:variable name="fromlon" select="key('node',$nextsegment/@from)/@lon"/>
<br><xsl:variable name="fromlat" select="key('node',$nextsegment/@from)/@lat"/><br><!-- breaking ways with more than 28 segments for cgpsmapper routing --><br><xsl:if test="$tolon != $fromlon or $tolat != $fromlat or $next > 28 ">
<br><!--xsl:if test="$tolon != $fromlon or $tolat != $fromlat"--><br><xsl:value-of select="../@id"/>fail<br></xsl:if><br></xsl:if><br></xsl:for-each><br></xsl:variable>
<br><xsl:choose> <br><xsl:when test="$splitifnotempty=''"><br><xsl:copy-of select="."/><br></xsl:when><br><xsl:otherwise><br><xsl:call-template name="splitway">
<br><xsl:with-param name="way" select="."/><br></xsl:call-template><br></xsl:otherwise><br></xsl:choose><br></xsl:template><br></xsl:stylesheet><br><br><br><br><br>