[OpenLayers-Users] GeoRSS projection confusion:
DeDuikertjes
DeDuikertjes at xs4all.nl
Thu Sep 3 02:54:06 EDT 2009
Dear List,
thanks to Christpher Schmidt and some research the confusion is solved.
So here I describe some usefull things to know about GeoRSS layers.
1) The GeoRSS format reverses X and Y positions. So the first number in
a GeoRSS part like
<gml:pos>6.36844646999779 51.8855430932258</gml:pos>
should be the Y-coordinate (or latitude) the second number the X-coordinate (or longitude).
2) Although the GeoRSS format should be in EPSG:4326 by definition, in Openlayers it is possible to use other coordinate systems.
E.g. A GML layer in EPSG:28992 lines up perfectly with a GeoRSS layer in EPSG:28992 without any reprojection.
3) It is possible to reproject GeoRSS layers by the familiar openlayers reprojection methods. Don't forget to include the proj4 library and a suitable definition for your coordinate system! Here is a working example:
<script src="http://www.openlayers.org/api/OpenLayers.js"></script>
<script src="js/proj4js/lib/proj4js-compressed.js" type="text/javascript"></script>
<script type="text/javascript">
Proj4js.defs["EPSG:28992"] = "+proj=sterea +lat_0=52.15616055555555 +lon_0=5.38763888888889 +k=0.999908 +x_0=155000 +y_0=463000 +ellps=bessel +towgs84=565.237,50.0087,465.658,-0.406857,0.350733,-1.87035,4.0812 +units=m +no_defs";
Proj4js.defs["EPSG:900913"] = "+proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs";
Proj4js.defs["EPSG:4326"] = "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs";
var map = null;
var plangebiedLayerURL;
var rsslayerURL;
function init(){
map = new OpenLayers.Map('map', {
allOverlays: true,
maxExtent :new OpenLayers.Bounds(222222.273,432970.413,223085.973,433807.112),
units :'m',
projection: new OpenLayers.Projection("EPSG:28992"),
displayProjection: new OpenLayers.Projection("EPSG:28992"),
controls: []
});
plangebiedLayerURL = "wkt/NL.IMRO.0999.BP2008000001-0005.wkt";
plangebiedBaseLayer = new OpenLayers.Layer.GML("Plangebied", plangebiedLayerURL, {
format: OpenLayers.Format.WKT,
units :'m',
projection :new OpenLayers.Projection("EPSG:28992"),
})
plangebiedBaseLayer.setIsBaseLayer(true);
map.addLayers([plangebiedBaseLayer]);
rsslayerURL = "wkt/NL.IMRO.0999.BP2008000001-0005-2r.rss";
rssLayer = new OpenLayers.Layer.GeoRSS("Informatielaag",rsslayerURL, {
projection: new OpenLayers.Projection("EPSG:4326"),
});
map.addLayers([rssLayer]);
map.zoomToMaxExtent();
map.addControl(new OpenLayers.Control.PanZoomBar());
map.addControl(new OpenLayers.Control.LayerSwitcher());
map.addControl(new OpenLayers.Control.MousePosition());
}
</script>
Thanks for all the help, MArco
DeDuikertjes schreef:
> Dear List,
>
> I have a georss file (with should be by definition in EPSG:4326) with
> one point:
> <gml:pos>6.36844646999779 51.8855430932258</gml:pos> it gets reprojected
> without me asking for it.
>
> When I show that as simple as possible in openlayers with:
> (working example on:
> http://80.101.100.35/planhosting/testplannen/openlayers/showmap3c.html)
> var map = null;
> var rsslayerURL;
>
> function init(){
>
> map = new OpenLayers.Map('map', {
> allOverlays: true,
> controls: []
> });
>
> rsslayerURL = "wkt/NL.IMRO.0999.BP2008000001-0005-2b.rss";
> rssLayer = new
> OpenLayers.Layer.GeoRSS("Informatielaag",rsslayerURL, {
>
> });
>
> map.addLayers([rssLayer]);
> map.zoomToMaxExtent();
>
> map.addControl(new OpenLayers.Control.PanZoomBar());
> map.addControl(new OpenLayers.Control.LayerSwitcher());
> map.addControl(new OpenLayers.Control.MousePosition());
>
> The point gets (according to the mouseposition) reprojected to about
> 52.38 11.25. Why is that? I've never asked for that.
>
> If I specify EPSG:4326 as layerprojection, mapprojection and
> displayprojection the same happens.
> (working example:
> http://80.101.100.35/planhosting/testplannen/openlayers/showmap3b.html).
>
> If I try to reproject it together with other data (Working example:
> http://80.101.100.35/planhosting/testplannen/openlayers/showmap3.html),
> the other data gets reprojected as should, but not the georss layer.
>
> What is happening ?
> Please help, I'd like to have the georss layer lined up with my data in
> epsg 28992.
>
> MArco
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
More information about the Users
mailing list