[OpenLayers-Users] Just another trasformation problem ;)

Giuseppe Naponiello beppenapo at gmail.com
Thu Apr 8 07:43:18 EDT 2010


Thanks for suggestion but doesn't works yet!!!
I found a solution using qgis plugin "ogr2layer", maybe the problem was in
the parameters used in transformation code:

# isoline = OpenLayers.Projection.transform(isoline, epsg2498,
map.projection);

new code is:

# map.addLayer(new OpenLayers.Layer.GML("isoipse_2498
GML","../aramus_data/vector/reproj/isoipse_2498.gml"));

# var extent = new
OpenLayers.Bounds(4970294.552162,4901870.266154,4971024.689123,4902439.542244).transform(new
#OpenLayers.Projection("EPSG:2498"), new
OpenLayers.Projection("EPSG:900913"));

and now works!!!

Anyway, I would like understand how to write correctly a gml layer!

Another question for you:
the second step is to be able to modify the gml, is it possible with
strategy save?

-beppe-

2010/4/7 Arnd Wippermann <arnd.wippermann at web.de>

>  Perhaps you do two times a transformation. I would think, that in your
> Vector layer the transformation takes place, so the second part isn't
> needed.
>
>     var isoline = new OpenLayers.Layer.Vector("isoline", {
>            strategies: [new OpenLayers.Strategy.Fixed()],
>            protocol: new OpenLayers.Protocol.HTTP({
>                url: "../aramus_data/vector/gml/isoipse_2498.gml",
> //1.
>                projection: epsg2498,
>                format: new OpenLayers.Format.GML()
>            })
>        });
> //2.
>    isoline = OpenLayers.Projection.transform(isoline, epsg2498,
> map.projection);
>
> Arnd
>
>  ------------------------------
>  *Von:* users-bounces at openlayers.org [mailto:users-bounces at openlayers.org]
> *Im Auftrag von *Giuseppe Naponiello
> *Gesendet:* Mittwoch, 7. April 2010 12:02
> *An:* users at openlayers.org
> *Betreff:* [OpenLayers-Users] Just another trasformation problem ;)
>
> Hi all,
> I ought to display a map with osm layer as base and a gml file of a little
> part of Armenia.
> First step was convert my shapefile, with projection epsg:2498, in a gml
> format (ogr2ogr -f GML ...).
>
> Second step was set up my map.
> Within tag <head> of my html page, I' ve insert a link to these libraries:
>
> - OpenLayers-2.8/OpenLayers.js
> - http://www.openstreetmap.org/openlayers/OpenStreetMap.js
> - proj4js.js
> - proj4s/lib/defs/EPSG2498.js
>
> And this is a snippet of my map code [1].
>
> The problem is that my gml is in the north of Africa instead of Armenia.
> I've tried with qgis and the layer is correctly positioned, so I suppose
> that the problem is in the code, but I' m not able to detect the bug!!!
>
> thanks
>
> -beppe -
>
> [1] function init() {
>     var epsg2498= new OpenLayers.Projection("EPSG:2498");
>     var epsg900913= new OpenLayers.Projection("EPSG:900913");
>     var epsg4326= new OpenLayers.Projection("EPSG:4326");
>
>    var bounds = new OpenLayers.Bounds(44.532, 40.144, 45.038,
> 40.423).transform(epsg4326, epsg900913);
>
>    map = new OpenLayers.Map ("map", {
>        controls:[
>            new OpenLayers.Control.Navigation(),
>            new OpenLayers.Control.LayerSwitcher({activeColor:"#729aa1"}),
>            new
> OpenLayers.Control.MousePosition({div:document.getElementById("coord")}),
>            new OpenLayers.Control.Attribution()],
>
>        maxExtent: bounds,
>        maxResolution: 156543.0399,
>        numZoomLevels: 5,
>        minZoomLevel: 3,
>        maxZoomLevel: 8,
>        units: 'm',
>        projection: epsg900913,
>        displayProjection: epsg2498
>    } );
>
>
>    var layerCycleMap = new OpenLayers.Layer.OSM.CycleMap("CycleMap");
>     map.addLayer(layerCycleMap);
>
>    var layerTilesAtHome = new
> OpenLayers.Layer.OSM.Osmarender("Osmarender");
>    map.addLayer(layerTilesAtHome);
>
>    var layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
>    map.addLayer(layerMapnik);
>
>     var isoline = new OpenLayers.Layer.Vector("isoline", {
>            strategies: [new OpenLayers.Strategy.Fixed()],
>            protocol: new OpenLayers.Protocol.HTTP({
>                url: "../aramus_data/vector/gml/isoipse_2498.gml",
>                projection: epsg2498,
>                format: new OpenLayers.Format.GML()
>            })
>        });
>    isoline = OpenLayers.Projection.transform(isoline, epsg2498,
> map.projection);
>     map.addLayer(isoline);
> ....
> ....
> ....
> --
> -beppe-
>



-- 
-beppe-
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100408/004b4c70/attachment.html


More information about the Users mailing list