[OpenLayers-Users] Impossible reproject wfs layer

Andreas Hocevar ahocevar at opengeo.org
Mon Jun 29 15:15:43 EDT 2009


Hi,

On Mon, Jun 29, 2009 at 8:36 PM, Micho Gar<michogar at gmail.com> wrote:
> I was searching in the list something about my problem. I can not reproject
> my wfs layer over my OpenStreetMaps layer with spherical mercator. I use
> this code:
>
> function initMap(){
>
>     format = 'image/png';
>
>     if (initBounds == null) initBounds = new
> OpenLayers.Bounds(-18785164.068, -11740727.3725,
>             18785164.068, 11740727.7125);
>
>     var bounds = new OpenLayers.Bounds(-20037508, -20037508,
>             20037508, 20037508.34);
>
>     var proj4326 = new OpenLayers.Projection("EPSG:4326");
>     var proj900913 = new OpenLayers.Projection("EPSG:900913");
>     //initBounds.transform(proj4326, proj900913);
>
>     var options = {
>             controls: [],
>             maxExtent: bounds,
>             maxResolution: 39135.758475,
>             numZoomLevels: 19,
>             projection: proj900913,
>             displayProjection: proj4326,
>             units: 'm'
>     };
>
>     map = new OpenLayers.Map('map',options);
>
>     //carga las capas de Google en caso de que se vayan a utilizar
>     /*var gmap = new OpenLayers.Layer.Google(
>             "Google Streets", {'sphericalMercator': true}
>     );
>
>     var gsat = new OpenLayers.Layer.Google(
>             "Google Satellite",
>             {type: G_SATELLITE_MAP, 'sphericalMercator': true,
> numZoomLevels: 18}
>     );*/
>
>     //carga la capa base de OSM
>     var OSMLayer = new OpenLayers.Layer.OSM.Osmarender("Osmarender");
>
>     var MapnikLayer = new OpenLayers.Layer.OSM.Mapnik("Mapnik");
>
>     // carga capas wms
>     var Instancias  = new OpenLayers.Layer.WMS(
>             "Instancias", "http://localhost:8080/geoserver/wms",
>             {
>                 layers: 'osmius:usuarios_instancias',
>                 srs: 'EPSG:4326',
>                 format: format,
>                 transparent : 'true'//,
>             },
>             {singleTile: true, ratio: 1}
>     );
>     var Servicios = new OpenLayers.Layer.WMS(
>             "Servicios", "http://localhost:8080/geoserver/wms",
>             {
>                 layers: 'osmius:usuarios_servicios',
>                 srs: 'EPSG:4326',
>                 format: format,
>                 transparent : 'true'//,
>             },
>             {singleTile: true, ratio: 1}
>     );
>
>     var WFSlayer = new OpenLayers.Layer.WFS( "Instancias WFS",
>             "http://localhost:8080/geoserver/wfs",
>             { typename: 'osmius:usuarios_instancias'},
>             {
>                 typename: 'usuarios_instancias',
>                 projection: map.displayProjection


Change this to
                 projection: proj4326

The projection provided here is the projection of your data, not the
one you want the layer to be displayed in.

Regards,
Andreas.

>             }
>             );
>
>
> You can see that I use the projection parameter in the wfs layer, but the
> features are not reprojected, I don't understand because.
>
> This is my capabilities:
>
> <FeatureType>
> <Name>osmius:usuarios_instancias</Name>
> <Title>osm_vw_instance_pnt_Type</Title>
> <Abstract>Generated from osmius</Abstract>
> -
> <ows:Keywords>
> <ows:Keyword>osm_vw_instance_pnt</ows:Keyword>
> <ows:Keyword>osmius</ows:Keyword>
> </ows:Keywords>
> <DefaultSRS>urn:x-ogc:def:crs:EPSG:4326</DefaultSRS>
> -
> <ows:WGS84BoundingBox>
> <ows:LowerCorner>-9.648588334999998 40.30276938</ows:LowerCorner>
> <ows:UpperCorner>0.4904789049999987 50.44183662</ows:UpperCorner>
> </ows:WGS84BoundingBox>
> </FeatureType>
> -
> <FeatureType>
> <Name>osmius:usuarios_servicios</Name>
> <Title>osm_vw_service_pnt_Type</Title>
> <Abstract>Generated from osmius</Abstract>
> -
> <ows:Keywords>
> <ows:Keyword>osmius</ows:Keyword>
> <ows:Keyword>osm_vw_service_pnt</ows:Keyword>
> </ows:Keywords>
> <DefaultSRS>urn:x-ogc:def:crs:EPSG:4326</DefaultSRS>
> -
> <ows:WGS84BoundingBox>
> <ows:LowerCorner>-3.813766 40.382172</ows:LowerCorner>
> <ows:UpperCorner>-3.613766 40.582172</ows:UpperCorner>
> </ows:WGS84BoundingBox>
> </FeatureType>
> </FeatureTypeList>
> -
>
> Thanks to all
>
>
>
>
>
> --
> # michogar
> # Analista Programador SIG
> # GNU/Linux Counter 462666
>
> Una visión personal:
> http://michogar.blogspot.com
>
> El día a día:
> http://twitter.com/michogar
>
>
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
>



-- 
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.



More information about the Users mailing list