Re: Geographical Coordinate Systems and textPath

Hey Andreas,

Thanks for your suggestion.  

I think for the task of geographical documentation, unmodified
geographic coordinates in the SVG document are probably the most
transparent (easy to understand) for users/contributors.  So I did some
more testing and am now able to use scaled textPaths with unmodified
geographical coordinates.  The technique I'm using is

* order geographic coordinates in (latitude,longitude) as opposed to
(longitude,latitude),
* translate the viewBox midpoint to the origin
* rotate by -90 degrees to get North pointing up
* scale longitude by cos(latitude of viewBox midpoint) to get an
equidistant projection
* translate back to the viewBox midpoint

In case you're interested, here is an example:

- - -

<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<svg viewBox="20 -40 5 10"
    preserveAspectRatio="xMidYMid"
    xmlns="http://www.w3.org/2000/svg"
    xmlns:xlink="http://www.w3.org/1999/xlink">

    <title>test19.svg</title>
    <desc>
         - use lat,lng order for coordinates as opposed to lng,lat
         - translate viewbox midpoint to origin
         - rotate by -90 degrees to get North pointing up
         - scale longitude by cos(latitude of viewbox midpoint) to get
equidistant projection
         - translate back to viewbox midpoint
    </desc>

    <defs>
        <style type="text/css">
            <![CDATA[
            .TestFont { font-size:0.75; font-family:Verdana;
stroke:blue; stroke-width:0.05; fill:none; }
            .TestLine { fill:none; stroke:black; stroke-width:2;
stroke-linecap:round; }
            ]]>
        </style>

        <path id="diagUL_LR" d="M  25 -40 L  20 -30"/>
        <path id="diagLL_UR" d="M  20 -40 L  25 -30"/>
    </defs>

    <g transform="translate(22.5,-35) rotate(-90) scale(1,0.5)
translate(-22.5,35)" >

        <g fill="none" stroke="red" stroke-width="3" >
            <line x1="20.0"  y1="-40" x2="20.0" y2="-30" />
            <line x1="20.0"  y1="-30" x2="25.0" y2="-30" />
            <line x1="25.0"  y1="-30" x2="25.0" y2="-40" />
            <line x1="25.0"  y1="-40" x2="20.0" y2="-40" />
        </g>

        <use xlink:href="#diagUL_LR" class="TestLine" title="UL to LR"
/>
        <text class="TestFont">
            <textPath xlink:href="#diagUL_LR">UL to LR</textPath>
        </text>

        <use xlink:href="#diagLL_UR" class="TestLine" title="LL to UR"
/>
        <text class="TestFont">
            <textPath xlink:href="#diagLL_UR">LL to UR</textPath>
        </text>
    </g>
</svg>

- - -

This doesn't address the skewing of the textPath.  But knowing that is a
more difficult problem, I think I'll just try to develop a liking for
the skewed text ... or move closer to the equator.  :*)

Greg


Andreas Neumann wrote:
> 
> Hi Greg!
> 
> My attempt to the problem is:
> 
> * project the GIS data prior to translating it to SVG
> * use a negative y-axis during the conversion process.
> * adjust your viewBox to the negative y-axis.
> 
> Due to all the problems with text, all the scaling approaches don't work well,
> as you experienced yourself.
> 
> Usually I also use nested SVGs. A screen-oriented coordinate system for the
> Userinterface, title and legend of the map. Nested within I use a map coordinate
> system with a separate svg-element.
> 
> Andreas
>

Received on Thursday, 29 January 2004 01:23:55 UTC