[OSM-talk] SVG output

Etienne 80n80n at gmail.com
Fri May 26 16:41:05 BST 2006


On 5/26/06, Steve Chilton <S.L.Chilton at mdx.ac.uk> wrote:
> Thanks for warning. I haven't noticed any anomolies yet.
> I will keep this note and check when I get slightly further to east.
> Currently mapping/editing in long -0.08 area and no probs evident.
> At some point in Enfield there is a Meridian Way and will check when I
> get there!
> Just one point though - I am working in Windows (msxml). Presume my
> command line for your converter will be similar to that which I have
> been using?
> Something like: msxsl -in myFile.osm -xsl normaliseNumbers.xsl -out
> data.osm -xml

Yes, something like that.  The input is the .osm file that you have
downloaded using the API, the template is normaliseNumbers.xsl and the
output is the new .osm file.  With xalan there's an -xml argument that
says create the output with an XML prolog.  I don't know the exact
equivalents in msxml but it will be similar.

Etienne
>
> Cheers
> STEVE
>
> Steve Chilton, Learning Support Fellow
> Learning and Technical Support Unit Manager
> School of Health and Social Sciences
> Middlesex University
> phone/fax: 020 8411 5355
> email: steve8 at mdx.ac.uk
>
> Big Shave for Wateraid - after PICTURE at:
> http://www.mdx.ac.uk/www/gem/bigshave.htm
>
> -----Original Message-----
> From: Etienne [mailto:80n80n at gmail.com]
> Sent: Friday, May 26, 2006 3:12 PM
> To: Steve Chilton; talk at openstreetmap.org
> Subject: Re: [OSM-talk] SVG output
>
>
> Oh, I just remembered something!  The current version of Osmarender has
> a problem with points that are very close to the Greewich Meridien.
>
> The API serves very small numbers up with unnecessary precision as using
> exponential format.  For example:
>
>   <node id='646217' lat='51.4337983632484' lon='9.48436500038951E-4' />
>
> Osmarender chokes on this (since XSL 1.0 can't recognize exponential
> numbers) and produces x='NaN'.  The Adobe treats this as zero and
> everything comes out looking fine.  I haven't checked but I expect that
> if you zoomed in on some points on the meridien you might just see some
> slight distortion in Osmarender's output.
>
> Other SVG viewers, especially the Open Source ones that try to be
> strictly compliant with the standards will throw out x='NaN' as an
> invalid coordinate.  Since Enfield is pretty close to the meridien you
> may well be suffering from this issue.
>
> I have an XSL template that will convert exponential numbers to decimals
> in an .osm file.  You might find that pre-processing your .osm files
> with this template before running osmarender will enable it to be opened
> in other SVG viewers.
>
> Here's the XSL file, save it as normaliseNumbers.xsl and then run it as
> follows:
>
> c:\>java -cp xalan.jar org.apache.xalan.xslt.Process -in yourFile.osm
> -xsl normaliseNumbers.xsl -out data.osm -xml
>
> Then run osmarender on data.osm.
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet
>  version="1.0"  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
>
>         <xsl:template match='/'>
>                 <xsl:apply-templates/>
>         </xsl:template>
>
>         <xsl:template match='node/@lat'>
>                 <xsl:attribute name='lat'>
>                         <xsl:call-template name='normaliseNumber'>
>                                 <xsl:with-param name='number' select='.'
> />
>                         </xsl:call-template>
>                 </xsl:attribute>
>         </xsl:template>
>
>         <xsl:template match='node/@lon'>
>                 <xsl:attribute name='lon'>
>                         <xsl:call-template name='normaliseNumber'>
>                                 <xsl:with-param name='number' select='.'
> />
>                         </xsl:call-template>
>                 </xsl:attribute>
>         </xsl:template>
>
>
>         <!-- Identity transformation -->
>         <xsl:template match="node()|@*">
>                 <xsl:copy>
>                 <xsl:apply-templates select="@*"/>
>                 <xsl:apply-templates/>
>                 </xsl:copy>
>         </xsl:template>
>
>         <!-- Convert a number from scientific to normal notation -->
>         <xsl:template name="normaliseNumber">
>                 <xsl:param name='number'/>
>                 <xsl:choose>
>                         <xsl:when test='contains($number,"E")'>
>                                 <xsl:call-template
> name="scientificToNumeric">
>                                         <xsl:with-param name="m"
> select="substring-before($number,'E')"/>
>                                         <xsl:with-param name="e"
> select="substring-after($number,'E')"/>
>                                 </xsl:call-template>
>                         </xsl:when>
>                         <xsl:otherwise>
>                                 <xsl:value-of select='$number'/>
>                         </xsl:otherwise>
>                 </xsl:choose>
>         </xsl:template>
>
>         <xsl:template name="scientificToNumeric">
>                 <xsl:param name="m"/>
>                 <xsl:param name="e"/>
>
>                 <xsl:choose>
>                         <xsl:when test="$e = 0 or not(boolean($e))">
>                                 <xsl:value-of select="$m"/>
>                         </xsl:when>
>                         <xsl:when test="$e > 0">
>                                 <xsl:call-template
> name="scientificToNumeric">
>                                         <xsl:with-param name="m"
> select="$m * 10"/>
>                                         <xsl:with-param name="e"
> select="$e - 1"/>
>                                 </xsl:call-template>
>                         </xsl:when>
>                         <xsl:when test="$e < 0">
>                                 <xsl:call-template
> name="scientificToNumeric">
>                                         <xsl:with-param name="m"
> select="$m div 10"/>
>                                         <xsl:with-param name="e"
> select="$e + 1"/>
>                                 </xsl:call-template>
>                         </xsl:when>
>                 </xsl:choose>
>         </xsl:template>
>
> </xsl:stylesheet>
>
>
>
>
>
> On 5/26/06, Steve Chilton <S.L.Chilton at mdx.ac.uk> wrote:
> > Ta for responses.
> > Used workaround of a screen dump into ImageForge and out as PNG.
> > Shortcuts suggested certainly help use Adobe viewer, and they are not
> > obvious. File upload was fine (should have seen that in nav bar!) so
> > that is done.
> > Will investigate Christian's suggestion of Inkscape when I have time,
> > looks promising.
> >
> > Cheers
> > STEVE
> >
> > Steve Chilton, Learning Support Fellow
> > Learning and Technical Support Unit Manager
> > School of Health and Social Sciences
> > Middlesex University
> > phone/fax: 020 8411 5355
> > email: steve8 at mdx.ac.uk
> >
> > Big Shave for Wateraid - after PICTURE at:
> > http://www.mdx.ac.uk/www/gem/bigshave.htm
> >
> > -----Original Message-----
> > From: Etienne [mailto:80n80n at gmail.com]
> > Sent: Friday, May 26, 2006 12:59 PM
> > To: Steve Chilton; talk at openstreetmap.org
> > Subject: Re: [OSM-talk] SVG output
> >
> >
> > Steve
> > Well done on pulling together all the bits to make osmarender work.  I
>
> > agree it all needs to be automated so that can be done on the fly....
> >
> > To make a PNG I usually use The GIMP (Windows version) which can read
> > SVG files.  However I find that its just as easy to take a screen shot
> > (Alt+PrtSc) from Adobe in IE and paste that into the GIMP and then
> > Save As .png.
> >
> > A couple of clues might help with using the Adobe viewer in IE.  First
> > Alt+Click allows you to pan the image, Second  Ctrl+Click will zoom
> > in, and thirdly Shift+Ctrl+Click will zoom out.  None of these are
> > very obvious and you don't get much mileage from the viewer until you
> > figure these out.
> >
> > To upload an image to the wiki you need to use Upload File option in
> > the toolbox which is below the navigation panel on the left hand side
> > of every page.
> >
> > Etienne
> >
> >
> >
> > On 5/26/06, Steve Chilton <S.L.Chilton at mdx.ac.uk> wrote:
> > > I have just got osmarender working (msxml version) and figured out
> > > have to download data from OSM to JOSM to osmarender and produce
> > > output. Couple of questions: Can anyone point me to a better SVG
> > > viewer than Adode through IE, which is really inflexible? Can anyone
>
> > > suggest a SVG to PNG route? I have tried all applications I have to
> > > open and save as.. PNG but none work - Ghost Script Viewer, Image
> > > Forge, Corel Photopaint, Fireworks. Can anyone tell me how I would
> > > upload resulting PNG file to wiki page
> > on
> > > London in Community Portal? I can see how to edit the page but not
> > > to get the file in place. I want to put an SVG/PNG file there to
> > > show progress in Barnet and Enfield areas (much to do mind!) of
> > > North
> > London.
> > > Finally I would endorse the view that SVG rendering on the fly
> > > should
> > be
> > > a priority for someone to develop.
> > >
> > > Cheers
> > > STEVE
> > >
> > > Steve Chilton, Learning Support Fellow
> > > Learning and Technical Support Unit Manager
> > > School of Health and Social Sciences
> > > Middlesex University
> > > phone/fax: 020 8411 5355
> > > email: steve8 at mdx.ac.uk
> > >
> > > Big Shave for Wateraid - after PICTURE at:
> > > http://www.mdx.ac.uk/www/gem/bigshave.htm
> > >
> > > _______________________________________________
> > > talk mailing list
> > > talk at openstreetmap.org
> > > http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/talk
> > >
> >
>
>
> --
> Etienne
>
> _______________________________________________
> talk mailing list
> talk at openstreetmap.org
> http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/talk
>




More information about the talk mailing list