[OpenLayers-Users] Alignment Issue

Nicholas Efremov-Kendall n.e.kendall at gmail.com
Thu Jun 11 22:43:35 EDT 2009


Hi all,

I've been posting in regards to an alignment issue I've been having with a
GML layer showing up in the wrong place when overlain on a Mapnik or
Openstreet map baselayer. The points were originally collected with a
hand-held gps unit in the late 90's. I've since converted from Shp to GML
with GDAL using ogr2ogr. There's been some debate as to whether Tunisia is
in Zone 32N or 32S (Epsg 32632 or 32732). I have since assigned both the SRS
(both) using the ogr2ogr -f "gml" -a_srs "epgs:XXXXXX" out.gml in.shp. This
for some reason removes the bounding box, preventing cool tricks like (if (!
map.getCenter) thanks Jan). The GDAL users list helpfully suggested
specifying both the source and target projections, which I did and works
nicely. The GML file aligns exactly over the island of Jerba near tunisia in
ArcGIS anf QGIS in UTM Zone 32N but does not display in the right place in
OL. Both gml files (i.e. same coordinates plus one with a projection
specified) is offset both vertically and horizontally (somewhere in
Algeria), but the points maintain their spatial relationships to one
another. The reassinged gml file also lines up on top of an unreferenced
(i.e. no epsg code attachted). I've tried the reprojection (but on the whole
layer, I don't know if that will work) and all I get is a firebug error
"sites.transform is not a function." Also, note that when I set the if (!
map.getCenter) to the prsites layer it doesn't work.

   1. why does the projectionless GML file in OL show up in the wrong place,
   regardless of the EPSG code that I specify (i.e. why doesn't it move when I
   specify a different srs?)
   2. why does the projected GML file show up in exactly the sample place?
   3. How do I fix this?

        var map;
        var proj = new OpenLayers.Projection("EPSG:900913");
        function init() {
            map = new OpenLayers.Map ("map", {
                controls:[
                    new OpenLayers.Control.Navigation(),
                    new OpenLayers.Control.PanZoomBar(),
                    new OpenLayers.Control.LayerSwitcher(),
                    new OpenLayers.Control.Attribution()],
                sphericalMercator: true,
                maxExtent: new
OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
                maxResolution: 156543.0399,
                numZoomLevels: 19,
                units: 'm',
                        projection: new
OpenLayers.Projection("EPSG:900913"),
                displayProjection: new OpenLayers.Projection("EPSG:32632"),
            } );
            layerMapnik = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
            map.addLayer(layerMapnik);

       sites = new OpenLayers.Layer.GML (
                               "sites.gml",
                               "sites.gml",

{
                    projection: new OpenLayers.Projection("EPSG:32632"),
                    format: OpenLayers.Format.GML,
                               }
                    );
    map.addLayer(sites);
     sites.transform (proj, map.getProjectionObject());
     prsites = new OpenLayers.Layer.GML (
                               "pjsites",
                               "prjtest.gml",

{
                    projection: new OpenLayers.Projection("EPSG:32632"),
                    format: OpenLayers.Format.GML,
                               }
                    );
    map.addLayer(prsites);
                if( ! map.getCenter() ){
            sites.events.register('loadend', sites,
function(){map.zoomToExtent(sites.getDataExtent())});
            map.setCenter(null, null);
            };

        };

Snippet from the Projected gmlfile

  <gml:boundedBy>
    <gml:Box>

<gml:coord><gml:X>658618.0000002235</gml:X><gml:Y>3722534.999999772</gml:Y></gml:coord>

<gml:coord><gml:X>690975.2797925605</gml:X><gml:Y>3752225.999999834</gml:Y></gml:coord>
    </gml:Box>
  </gml:boundedBy>
  <gml:featureMember>
    <ogr:site2000 fid="F0">
      <ogr:geometryProperty><gml:Point
srsName="EPSG:32632"><gml:coordinates>683247.00000048568,3736338.9999997145</gml:coordinates></gml:Point></ogr:geometryProperty>
      <ogr:NEWSITE_>14811205</ogr:NEWSITE_>
      <ogr:UTM_E>683247</ogr:UTM_E>
      <ogr:UTM_N>3736339</ogr:UTM_N>
    </ogr:site2000>

Snipper from the unprojected GML file.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20090611/628bfd5f/attachment.html


More information about the Users mailing list