[OSM-talk] Another point in support of ways as ordered lists
Robert Hart
Robert.Hart at BuroHappold.com
Tue Sep 26 22:06:22 BST 2006
Yes, I don't have a problem with the names. Anyway, it was just a
suggestion. The problem I have is finding the location. For a node the
location is attributes of the node, but for a way, you have to dereference
the segments then nodes, and find a mid point.
My current code just does ways (see below), but I'd like to include nodes as
way:
<xsl:template name='keyDraw'>
<xsl:for-each select="$data/osm/way/tag[@k='name']">
<xsl:sort select="@v"/>
<xsl:variable name="col" select="floor(position() div (($height -
40) div 6))" />
<xsl:variable name="row" select="position() - $col * floor(($height
- 40) div 6)" />
<text font-family='Verdana' font-size='6px' fill='black'>
<xsl:attribute name='x'><xsl:value-of select='10 + $width +
$col*80'/></xsl:attribute>
<xsl:attribute name='y'><xsl:value-of select='20 + 6 *
$row'/></xsl:attribute>
<xsl:value-of select="@v"/>
</text>
<text font-family='Verdana' font-size='6px' fill='black'>
<xsl:attribute name='x'><xsl:value-of select='80 + $width +
$col*80'/></xsl:attribute>
<xsl:attribute name='y'><xsl:value-of select='20 + 6 *
$row'/></xsl:attribute>
<xsl:variable name='startseg' select='../seg[1]' />
<xsl:variable name='endseg' select='../seg[position()=last()]' />
<xsl:variable name='start'
select='key("segmentById",$startseg/@id)' />
<xsl:variable name='end' select='key("segmentById",$endseg/@id)'
/>
<xsl:variable name='startNode'
select='key("nodeById",$start/@from)'/>
<xsl:variable name='endNode' select='key("nodeById",$end/@from)'/>
<xsl:variable name='lat' select='($startNode/@lat + $endNode/@lat)
div 2' />
<xsl:variable name='lon' select='($startNode/@lon + $endNode/@lon)
div 2' />
<xsl:value-of select="floor(($lon - $bllon) div 0.0089928)"/>
<xsl:value-of
select="substring('ABCDEFGHIJKLMNOPQRSTUVWXYZ',floor((($lat - $bllat) div
0.0089928) * $projection),1)"/>
<!--<xsl:value-of select="$start" />,
<xsl:value-of select="$lat" />,
<xsl:value-of select="$lon" />-->
</text>
</xsl:for-each>
</xsl:template>
-----Original Message-----
From: Etienne
To: Robert Hart
Cc: Nick Whitelegg; talk-bounces at openstreetmap.org ; talk at openstreetmap.org
Sent: 9/26/2006 9:29 PM
Subject: Re: [OSM-talk] Another point in support of ways as ordered lists
Rob
An xpath expression like $elements[tag[@k="name"]] will select all nodes
and ways with a name tag. You don't need to do anything special to
combine nodes and ways, because the $elements variable is already a set
of nodes and ways that match the rule (assuming the rule is <rule
e="node|way">).
If you want all the names in alphabetical order try something like:
<xsl:for-each select='$elements[[tag[@k="name"]]/@name''>
<xsl:sort order="ascending">
...
Etienne
On 9/26/06, Robert Hart < Robert.Hart at burohappold.com
<mailto:Robert.Hart at burohappold.com> > wrote:
I just had a brain wave. If ways are ordered lists of nodes, then POIs
can
be ways containing only one node. This may sound odd, but I think it has
real advantages (well at least one advantage anyway...)
I've been playing around with creating map indices in osmarender. To do
this
I need to know the name and approximate location of everything that
should
be included in the index. This means I have to handle nodes and
ways/areas
seperately, which is going to be painful if I want the whole index in
alphabetical order (as opposed to having separate indices for ways and
nodes). If POIs were single-node ways, everything would just work with
one
code path.
Rob
This message has been scanned for viruses by MailControl -
www.mailcontrol.com <http://www.mailcontrol.com>
_______________________________________________
talk mailing list
<mailto:talk at openstreetmap.org> talk at openstreetmap.org
http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/talk
<http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/talk>
More information about the talk
mailing list