[OSM-newbies] XSLT question (solved!)
Renaud MICHEL
r.h.michel+osm at gmail.com
Sat Sep 19 06:55:39 BST 2009
Le samedi 19 septembre 2009 à 06:31, Andrew Errington a écrit :
> It works! I can now programmatically produce a list of lat/lon pairs for
> amenities regardless of whether they are nodes or areas. If they are
> areas then I use Renaud's code to calculate an average lat and average
> lon, which produces an adequate centroid. Actually, if someone can
> suggest how to sum (and count) all but the first or last lat/lon pair it
> would make the result better, since the first and last pair are identical
> (to close the area) they weight the average.
You can filter your node ref list first, so your
<xsl:variable name="nodes" select="../node[@id=current()/nd/@ref]"/>
will become
<xsl:variable name="noderefs" select="nd[not(@ref=preceding-
sibling::nd/@ref)]"/>
<xsl:variable name="nodes" select="../node[@id=$noderefs/@ref]"/>
(the first variable is not required, you can do it in a single xpath if you
like)
this way you select an nd element only if it does not have a preceding
sibling with the same @ref, so you have each only once.
--
Renaud Michel
More information about the newbies
mailing list