[OpenLayers-Dev] SVG Format patch q's
tschaub at opengeo.org
Tue Nov 4 15:44:28 EST 2008
Jonathan Lister wrote:
>> The format doesn't yet support internalProjection/externalProjection parameters: I'd recommend doing so.
>> (if this is too difficult, I can help make it happen.)
> I have a couple of questions about this, which expose my lack of
> understanding of projections! In short, I really don't know how
> setting projection parameters controls the appearance of a map or a
> layer, nor how one should support this when reading in data. What is a
> projection? How do you convert between them?
For our purposes, a "projection" defines the relationship between a
location on the earth (or a spheroid approximating the earth) and a
corresponding location on a flat plane (map space). There is a second
projection that takes coordinates in map space and transforms them into
coordinates appropriate for your monitor (in pixels), but that is the
So, the coordinates in your data are in some projection - or spatial
reference system. If your data has coordinates that range from -180 to
180 in one axis and -90 to 90 in another, then your data is likely in a
geographic projection - probably Geographic/WGS84. Note that while some
people may tell you that this data is "unprojected", this is misleading.
A circle on the earth will not be a circle on your map. A map in
Geographic/WGS 84 is what you typically see hanging on the wall in 6th
grade - northern & southern latitudes all stretched out east/west,
equatorial latitudes not so distorted.
Looking at Google Maps, you'll notice that it looks a bit different than
a map in a geographic projection. The tiles that Google serves up for
its maps (and Microsoft VE, and Yahoo Maps) are in a Mercator
projection. We call it Spherical Mercator.
This is a nice display of how the two projections distort things in
So, there are tons of different spatial references systems for
geospatial data. A lot of them can be represented by an identifying
code. OpenLayers uses the "EPSG:X" shorthand to identify spatial
reference systems. You will get in trouble if you claim this in certain
circles, but for our purposes, if the coordinates in your geometry are
in Geographic/WGS84 you can represent the spatial reference system with
the code "EPSG:4326". For data in spherical mercator, we use "EPSG:900913".
When using a format to parse your data (translate SVG or whatever into
OpenLayers.Feature.Vector objects), you can provide the ability to
transform geometry coordinates as they are parsed.
The externalProjection property of a format represents the spatial
reference system of your source data - i.e. the remote or native spatial
The internalProjection property of a format represents the map's spatial
reference system - i.e. the local spatial reference system used for
So, if you want to read in data in Geographic/WGS84 and display it over
Google's tiles, you set the following:
externalProjection: new OpenLayers.Projection("EPSG:4326"),
internalProjection: new OpenLayers.Projection("EPSG:900913")
Then, the format applies a transform after parsing geometries.
// transform from remote to local projection
You can look at one of the other formats for inspiration.
OpenGeo - http://opengeo.org
Expert service straight from the developers.
More information about the Dev