[OSM-dev] Various OSM troubles

Ludwig Max Brinckmann ludwigbrinckmann at gmail.com
Sun Jan 7 10:59:29 GMT 2007


Reposted with attachment removed


> >
> > I took a smaller area and converted it successfully for my garmin
> > device. Unfortunately some weird red lines are crossing the map. I
> > guessed those are caused by ways which haven't been downloaded
> > completely, due to the bounding box specified.
>
>
>
> The reason for this might also be that segments in a way are not
> neccessarily ordered. As cgpsmapper draws lines from points to points, these
> ways appear as roads pointing back to themselves. This inconsistency in the
> OSM DB is most likely for longer ways and motorways are most visible. There
> have been various discussions on this in this forum on how to solve it.
>
> I had been working indepenently of Jochen on a OSM to Garmin GPS converter
> and I solved this problem of unordered streets by writing a preprocessing
> XSLT file, which simply breaks up all ways that are not ordered into
> individual ways  of one segment each. It is not very elegant but it works.
> As the result is again an OSM XML file, you can simply process the XML file
> as downloaded from OSM with it, then do all the steps you did with Jochen's
> scripts.
>
> I used it with the sabcmd xslt processor (sabcmd.exe fix.xsl input.xml
> output.xml), other XSLT processors should work similarly, but I have not
> tried. Jochen tried this script and it worked for him.
>
> (I had mailed Jochen the script for inclusion in his toolboox, as I just
> checked he has not done this, so I include it again at the end of this
> mail).
>
> I incidentally made a karlsruhe map with my processor as a test
> application, let me know if it is any good for you.
>
> HTH
>
> Ludwig
>
> Attachment (copy it into a file fix.xsl)
>
>
> <?xml version=" 1.0" encoding="iso-8859-1"?>
> <!-- (c) 2007 Ludwig M Brinckmann, ludwigbrinckmann (at) gmail.com
> This is free software; you can redistribute it and/or modify
> it under the terms of the GNU General Public License as published by
> the Free Software Foundation; either version 2 of the License, or
> (at your option) any later version.
>
> These scripts are distributed in the hope that it will be useful,
> but WITHOUT ANY WARRANTY; without even the implied warranty of
> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> GNU General Public License for more details.
>
> You should have received a copy of the GNU General Public License
> along with these files; if not, write to the Free Software
> Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> -->
> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform
> ">
> <xsl:output method="xml" indent="no" omit-xml-declaration="yes"/>
>
> <xsl:template match="text()"/>
>
> <xsl:template match="osm"><osm><xsl:apply-templates
> select="way|segment|node"/></osm></xsl:template>
>
> <xsl:key name="node" match="/osm/node" use="@id"/>
> <xsl:key name="segment" match="/osm/segment" use="@id"/>
>
> <xsl:template match="segment|node">
> <xsl:copy-of select="."/>
> </xsl:template>
>
> <xsl:template name="splitway">
> <xsl:param name="way"/>
> <xsl:for-each select="seg">
> <way id="{../@id}">
> <seg id="{@id}"/>
> <xsl:for-each select="../tag">
> <xsl:copy-of select="."/>
> </xsl:for-each>
> </way>
> </xsl:for-each>
> </xsl:template>
>
> <xsl:template match="way">
> <xsl:variable name="splitifnotempty">
> <xsl:for-each select="seg">
> <xsl:if test="position() != last()">
> <xsl:variable name="thissegment" select="key('segment', at id)"/>
> <xsl:variable name="next" select="position()+1"/>
> <xsl:variable name="nextsegment"
> select="key('segment',../seg[$next]/@id)"/>
> <xsl:variable name="tolon" select="key('node',$thissegment/@to)/@lon"/>
> <xsl:variable name="tolat" select="key('node',$thissegment/@to)/@lat"/>
> <xsl:variable name="fromlon"
> select="key('node',$nextsegment/@from)/@lon"/>
> <xsl:variable name="fromlat"
> select="key('node',$nextsegment/@from)/@lat"/>
> <!-- breaking ways with more than 28 segments for cgpsmapper routing -->
> <xsl:if test="$tolon != $fromlon or $tolat != $fromlat or $next > 28 ">
>
> <!--xsl:if test="$tolon != $fromlon or $tolat != $fromlat"-->
> <xsl:value-of select="../@id"/>fail
> </xsl:if>
> </xsl:if>
> </xsl:for-each>
> </xsl:variable>
> <xsl:choose>
> <xsl:when test="$splitifnotempty=''">
> <xsl:copy-of select="."/>
> </xsl:when>
> <xsl:otherwise>
> <xsl:call-template name="splitway">
> <xsl:with-param name="way" select="."/>
> </xsl:call-template>
> </xsl:otherwise>
> </xsl:choose>
> </xsl:template>
> </xsl:stylesheet>
>
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/dev/attachments/20070107/c19a406c/attachment.html>


More information about the dev mailing list