[Gfoss] Problema Proiezioni wfs+OSM in GeoExt

Ciao a tutti,
ho un problema di proiezione tra un layer OSM e un wfs proveniente da Geoserver. Il tutto è visualizzato in un MapPanel di GeoExt.
Il problema è che mentre OSM è puntato sulla zona giusta (Napoli) i punti si trovano sovrapposti di fronte all’Africa!!
Vi posto un po’ di codice,se qualcuno può darci uno sguardo,gli sarei molto grato :

Ext.onReady(function(){

var lat=40.85000;
var lon=14.25622;
var zoom=14;

var map = new OpenLayers.Map (“map”, {

maxExtent: new OpenLayers.Bounds(-19602834.611,-6328326.120,19259229.394,15761277.666),

maxResolution: 156543.0399,

units: ‘m’,
projection: new OpenLayers.Projection(“EPSG:900913”),

displayProjection: new OpenLayers.Projection(“EPSG:4326”)
});

var openstreetmap = new OpenLayers.Layer.OSM();

var vecLayer = new OpenLayers.Layer.Vector(“vector”);
map.addLayers([openstreetmap,vecLayer]);

// create feature store, binding it to the vector layer
var store = new GeoExt.data.FeatureStore({
layer: vecLayer,
fields: [
{name: ‘id’, type: ‘integer’},

],
proxy: new GeoExt.data.ProtocolProxy({
protocol: new OpenLayers.Protocol.WFS({
url: “http://localhost/proxy.php?url=http://odata.it:8080/geoserver/wfs”,
featureType: “prova”,
featureNS: “http://www.openplans.org/topp”,
srs: ‘EPSG:4326’,
geometryName: “the_geom”,
schema: “http://localhost/proxy.php?url=http://localhost/geoserver/wfs/DescribeFeatureType?version=1.1.0&typename=topp:prova

/* new OpenLayers.Protocol.HTTP({
url: “store.json”,
format: new OpenLayers.Format.GeoJSON()*/
})
}),
autoLoad: true
});

var mapPanel= new GeoExt.MapPanel({
renderTo:‘mainpanel’,
height: 300,
width: 950,
map: map,
center:new OpenLayers.LonLat( lon ,lat ).transform( new OpenLayers.Projection(“EPSG:4326”), map.getProjectionObject()),
zoom:13,
title: 'Mappa ’
});

Cordiali Saluti,Nicola.

Ciao Nicola,
il tuo geoserver riconosce la proj EPSG:900913 ? (mi pare sia built in ma non ricordo da quale versione…)

se no, devi inserirgliela tu…altrimenti il server non riesce a riproiettare lo strato vettoriale WFS:
http://docs.openlayers.org/library/spherical_mercator.html

Il giorno 28 novembre 2011 11:54, Nicola De Innocentis <deinnocentis.nicola@gmail.com> ha scritto:

Ciao a tutti,
ho un problema di proiezione tra un layer OSM e un wfs proveniente da Geoserver. Il tutto è visualizzato in un MapPanel di GeoExt.
Il problema è che mentre OSM è puntato sulla zona giusta (Napoli) i punti si trovano sovrapposti di fronte all’Africa!!
Vi posto un po’ di codice,se qualcuno può darci uno sguardo,gli sarei molto grato :

Ext.onReady(function(){

var lat=40.85000;
var lon=14.25622;
var zoom=14;

var map = new OpenLayers.Map (“map”, {

maxExtent: new OpenLayers.Bounds(-19602834.611,-6328326.120,19259229.394,15761277.666),

maxResolution: 156543.0399,

units: ‘m’,
projection: new OpenLayers.Projection(“EPSG:900913”),

displayProjection: new OpenLayers.Projection(“EPSG:4326”)
});

var openstreetmap = new OpenLayers.Layer.OSM();

var vecLayer = new OpenLayers.Layer.Vector(“vector”);
map.addLayers([openstreetmap,vecLayer]);

// create feature store, binding it to the vector layer
var store = new GeoExt.data.FeatureStore({
layer: vecLayer,
fields: [
{name: ‘id’, type: ‘integer’},

],
proxy: new GeoExt.data.ProtocolProxy({
protocol: new OpenLayers.Protocol.WFS({
url: “http://localhost/proxy.php?url=http://odata.it:8080/geoserver/wfs”,
featureType: “prova”,
featureNS: “http://www.openplans.org/topp”,
srs: ‘EPSG:4326’,
geometryName: “the_geom”,
schema: “http://localhost/proxy.php?url=http://localhost/geoserver/wfs/DescribeFeatureType?version=1.1.0&typename=topp:prova

/* new OpenLayers.Protocol.HTTP({
url: “store.json”,
format: new OpenLayers.Format.GeoJSON()*/
})
}),
autoLoad: true
});

var mapPanel= new GeoExt.MapPanel({
renderTo:‘mainpanel’,
height: 300,
width: 950,
map: map,
center:new OpenLayers.LonLat( lon ,lat ).transform( new OpenLayers.Projection(“EPSG:4326”), map.getProjectionObject()),
zoom:13,
title: 'Mappa ’
});

Cordiali Saluti,Nicola.


Iscriviti all’associazione GFOSS.it: http://www.gfoss.it/drupal/iscrizione
Gfoss@lists.gfoss.it
http://lists.gfoss.it/cgi-bin/mailman/listinfo/gfoss
Questa e’ una lista di discussione pubblica aperta a tutti.
Non inviate messaggi commerciali.
I messaggi di questa lista non rispecchiano necessariamente
le posizioni dell’Associazione GFOSS.it.
540 iscritti al 4.11.2011

Il 28 novembre 2011 11:54, Nicola De Innocentis
<deinnocentis.nicola@gmail.com> ha scritto:

Ciao a tutti,

ciao

var vecLayer = new OpenLayers.Layer.Vector("vector");

prova con

var vecLayer = new OpenLayers.Layer.Vector("vector", {projection:
map.displayProjection});

map.addLayers([openstreetmap,vecLayer]);

Cordiali Saluti,Nicola.

--
ciao
Luca

http://gis.cri.fmach.it/delucchi/
www.lucadelu.org

Risolto!
In effetti su Geoserver basta cambiare il codice EPSG da 4326 a 900913 dell’SRS declared, ed inserire nel menu a tendina, immediatamente sotto ,la voce “Reproject native to declared”,
infine salvare il tutto.
Rilanciando la pagina vedo i miei due punti riproiettati perfettamente sulla mappa.
Grazie ad entrambi!Sempre gentilissimi!
Salutoni…Nicola.

2011/11/28 Luca Delucchi <lucadeluge@gmail.com>

Il 28 novembre 2011 11:54, Nicola De Innocentis

<deinnocentis.nicola@gmail.com> ha scritto:

Ciao a tutti,

ciao

var vecLayer = new OpenLayers.Layer.Vector(“vector”);

prova con

var vecLayer = new OpenLayers.Layer.Vector(“vector”, {projection:
map.displayProjection});

map.addLayers([openstreetmap,vecLayer]);

Cordiali Saluti,Nicola.


ciao
Luca

http://gis.cri.fmach.it/delucchi/
www.lucadelu.org


Nicola De Innocentis

www.nicoladeinnocentis.it