I tried #1 below and it works sometimes. The key was setting the srsName. That was the whole trick. Are those options like ‘typeName’, ‘srsName’, etc. case sensitive?
Trouble is, my WFS layer only shows at small scales but not when zoomed in…what other things can I check. Is that a server side issue?
David A. Hollema
GIS Analyst
United Power, Inc.
From: Jimmy Aumard [mailto:jimmy.aumard@anonymised.com]
Sent: Thursday, April 09, 2009 1:06 AM
To: David Hollema
Cc: Andrea Aime; users@anonymised.com; geoserver-users@lists.sourceforge.net
Subject: Re: [Geoserver-users] [OpenLayers-Users] wfs, state plane, and spherical mercator
Hi david!
for wfs I make this:
var France = new OpenLayers.Layer.WFS(
“France WFS”,“http://localhost:8080/geoserver/wfs”,
{
typeName: ‘dep’,
featureNS: ‘http://www.openplans.org/topp’,
//style:fStyle,
extractAttributes: true ,
srsName: “EPSG:900913”
},
{‘reproject’: true}
);
or
var wfs = new OpenLayers.Layer.Vector(
“France2 wfs”,
{
strategies: [new OpenLayers.Strategy.BBOX(), saveStrategy],
projection: new OpenLayers.Projection(“EPSG:900913”),
protocol: new OpenLayers.Protocol.WFS({
srsName: “EPSG:900913”,
url: “http://localhost:8080/geoserver/wfs”,
featureType: “dep”,
version:‘1.1.0’,
featureNS: “http://www.openplans.org/topp”,
})
}
);
try and tell me if it’s works.
Jim
2009/4/8 David Hollema <dhollema@anonymised.com>
Here is my code. WMS reprojects fine b/c my understanding is geoserver
receives the base map projection (900913) and reprojects accordingly. I
would figure that geoserver would do the same thing to the WFS but it
doesn’t. My SRS handling in geoserver is set to force declared (default
setting) and my declared is correct, 2231 in this case. For WMS, it’s
not even necessary to set the srs in the layer constructor b/c geoserver
just figures it out.
It’s important to note that I even tried with my source data in 4326
(lat/long) and WMS still worked fine but WFS fails. It doesn’t seem to
be due to State Plane issues but it’s more fundamental than that.
var bounds = new OpenLayers.Bounds
(-20037508.34, -20037508.34, 20037508.34, 20037508.34);
var options2 = {
units: ‘m’,
projection: ‘EPSG:900913’,
maxExtent: bounds
};
format = ‘image/gif’;
map2 = new OpenLayers.Map(‘map2’,
options2);
velayer = new
OpenLayers.Layer.VirtualEarth( “VE”,
{ ‘type’: VEMapStyle.Roads,
‘sphericalMercator’: true});
layerWMS = new OpenLayers.Layer.WMS(
“Joint Use Photos”,
“http://upigis:8080/geoserver/wms”,
{layers: ‘sde:jointusepicture’,
format: format,
transparent: true
},
{opacity: 1.0,
isBaseLayer: false, ‘singleTile’: true
});
layerWFS = new OpenLayers.Layer.WFS(
“Joint Use Photos WFS”,
“http://upigis:8080/geoserver/wfs”,
{
typename:
“sde:jointusepicture”},
{extractAttributes: true}
);
David A. Hollema
GIS Analyst
United Power, Inc.
-----Original Message-----
From: users-bounces@anonymised.com [mailto:users-bounces@anonymised.com.]
On Behalf Of Andrea Aime
Sent: Tuesday, April 07, 2009 1:36 AM
To: David Hollema
Cc: users@anonymised.com; geoserver-users@anonymised.com.sourceforge.net
Subject: Re: [OpenLayers-Users] [Geoserver-users] wfs, state plane,and
spherical mercator
David Hollema ha scritto:
Here’s my dilemma. I have a map with projection defined as spherical
Mercator, EPSG 900913. I have a geoserver WMS layer whose native
projection is state plane Colorado north (EPSG 2231). With help from
the lists, I’m able to overlay the WMS fine on a Virtual Earth map.
When I add a new WFS layer (pointing at the same geoserver data) using
similar constructor as the WMS, the WFS layer does not overlay fine,
it’s shifted way off. That’s problem 1. I can’t figure out how to
get
the WFS to overlay.
Please share the request you’re making. The WFS and WMS reprojection
syntaxes are not equal. Also, what is the SRS handling you chose
in your feature type configuration?
Next question. I want to recenter the map based on a feature created
from a separate WFS request. I use OL.Format.GML and the read method
to create a new feature from the responseXML. When I look at the
geometry of the point feature, the x,y cords are in the native
coordinates. I tried point.transform(“EPSG:2231”,“EPSG:900913”) but
the
transformation never works properly. All the examples I see go from
4326 to 900913. My data are in State Plane. I would expect that the
underlying transformation library could handle this transformation but
maybe not?
You can also have GeoServer do the reprojection for you. You just
have to add &srsName=EPSG:900913 to your request, keeping the eventual
bbox in 2231, or have the bbox in 900913 too, but state it explicitly
with &bbox=x0,y0,x1,y1,EPSG:900913
Cheers
Andrea
–
Andrea Aime
OpenGeo - http://opengeo.org
Expert service straight from the developers.
Users mailing list
Users@anonymised.com
http://openlayers.org/mailman/listinfo/users
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
Geoserver-users mailing list
Geoserver-users@anonymised.comsts.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users