[Geoserver-users] Reprojection and OpenLayers

Hi–

I’m having some difficulty getting GeoServer to do reprojection to an Albers Equal Area map. I think the correct codes are EPSG: 42303 and 45556 (though I could be wrong).

As a test, I’m using the states data that comes with Geoserver.

I’ve tried both WMS and WFS.

Here’s the code:

var map;
function init(){
map = new OpenLayers.Map(‘map’,{projection: new OpenLayers.Projection(“EPSG:42303”)}); // Note that I’ve also tried 45556
var political = new OpenLayers.Layer.WMS(
“State”,
“/geoserver/wms”,
{layers: ‘topp:states’,
format: ‘image/png’}
);

var states= new OpenLayers.Layer.WFS(
“States”,
“/geoserver/wfs”,
{typename: ‘topp:states’},
{
typename: ‘states’,
featureNS: ’ http://www.openplans.org/topp’,
extractAttributes: false,
isBaseLayer: true
}
);
states.style = OpenLayers.Util.applyDefaults({strokeColor: “#0000ff”},
OpenLayers.Feature.Vector.style[“default”]);

map.addLayers([political,states);

I’ve done testing just showing one layer at a time and here’s what happens:

1.political (WMS) with EPGS: 42303

Displays nothing. I se a JS error message:

userAgentButton is null
_hasString()()OpenLayers.js (line 224)
OpenLayers.js()()OpenLayers.js (line 223)
[]var factory=null;if(typeof GearsFactory!..documentElement.appendChild(factory);}}}

2.states (WFS) with EPGS: 42303

Query: http://localhost:8080/geoserver/wfs?typename=topp%3Astates&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&SRS=EPSG%3A42303&BBOX=-575,-306.801875,550,361.166875

I see the state outlines but it’s not an Albers projection.

3.political (WMS) with EPGS: 45556

I see the same JS error as in case 1, query to the db happens and I only see Kansas.

Note that if I remove the projection from OpenLayer.Map(… it works fine.

4.states (WFS) with EPGS: 45556

Query: http://localhost:8080/geoserver/wfs?typename=topp%3Astates&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&SRS=EPSG%3A45556&BBOX=-575,-306.801875,550,361.166875

Same as case 2, no Albers projection.

Any help and advice is greatly appreciated.

– Ethan

Hi Ethan,

You may get better luck on the open layers mailing list but a couple of things I noted.

I think you have to set the projection property on the wms layer, rather then the map. I also believe you will have to set the extent of the layer explicitly as well.

What version of openlayers are you using. Looking at the WFS request a few things are off. The first is the SRS parameter, in wfs this should be SRSNAME. I recognize this problem from a while back. I think you will get some better results with a more recent version of OL.

Also of note is that officially reprojection is not support with wfs version 1.0, only 1.1. Although GeoServer does support it for 1.0 as well.

-Justin

Ethan Goldstine wrote:

Hi--

I'm having some difficulty getting GeoServer to do reprojection to an Albers Equal Area map. I think the correct codes are EPSG: 42303 and 45556 (though I could be wrong).

As a test, I'm using the states data that comes with Geoserver.

I've tried both WMS and WFS.

Here's the code:

var map;
        function init(){
            map = new OpenLayers.Map('map',{projection: new OpenLayers.Projection("EPSG:42303")}); // Note that I've also tried 45556
            var political = new OpenLayers.Layer.WMS(
                "State",
                "/geoserver/wms",
                {layers: 'topp:states',
                 format: 'image/png'}
            );
                 var states= new OpenLayers.Layer.WFS(
                "States",
                "/geoserver/wfs",
                {typename: 'topp:states'},
                {
                    typename: 'states',
                    featureNS: ' http://www.openplans.org/topp’,
                    extractAttributes: false,
                    isBaseLayer: true
                }
            );
            states.style = OpenLayers.Util.applyDefaults({strokeColor: "#0000ff"},
                    OpenLayers.Feature.Vector.style["default"]);

            map.addLayers([political,states);

I've done testing just showing one layer at a time and here's what happens:

1. political (WMS) with EPGS: 42303

Displays nothing. I se a JS error message:

userAgentButton is null
_hasString() <??>()OpenLayers.js (line 224)
OpenLayers.js() <??>()OpenLayers.js (line 223)
var factory=null;if(typeof GearsFactory!...documentElement.appendChild(factory);}}}

2. states (WFS) with EPGS: 42303

Query: http://localhost:8080/geoserver/wfs?typename=topp%3Astates&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&SRS=EPSG%3A42303&BBOX=-575,-306.801875,550,361.166875

I see the state outlines but it's not an Albers projection.

3. political (WMS) with EPGS: 45556

I see the same JS error as in case 1, query to the db happens and I only see Kansas.

Note that if I remove the projection from OpenLayer.Map(... it works fine.

4. states (WFS) with EPGS: 45556

Query: http://localhost:8080/geoserver/wfs?typename=topp%3Astates&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&SRS=EPSG%3A45556&BBOX=-575,-306.801875,550,361.166875

Same as case 2, no Albers projection.

Any help and advice is greatly appreciated.

-- Ethan

Ethan Goldstine
Producer, kapow, inc.
ethan@anonymised.com

------------------------------------------------------------------------

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com

------------------------------------------------------------------------

_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

Hi, Justin--

Thanks for the advice. I'll post my question in an OL forum.

I'm using the latest stable version of OL adn WFS 1.1.

-- Ethan

At 08:57 PM 3/18/2009, Justin Deoliveira wrote:

Hi Ethan,

You may get better luck on the open layers mailing list but a couple of things I noted.

I think you have to set the projection property on the wms layer, rather then the map. I also believe you will have to set the extent of the layer explicitly as well.

What version of openlayers are you using. Looking at the WFS request a few things are off. The first is the SRS parameter, in wfs this should be SRSNAME. I recognize this problem from a while back. I think you will get some better results with a more recent version of OL.

Also of note is that officially reprojection is not support with wfs version 1.0, only 1.1. Although GeoServer does support it for 1.0 as well.

-Justin

Ethan Goldstine wrote:

Hi--
I'm having some difficulty getting GeoServer to do reprojection to an Albers Equal Area map. I think the correct codes are EPSG: 42303 and 45556 (though I could be wrong).
As a test, I'm using the states data that comes with Geoserver.
I've tried both WMS and WFS.
Here's the code:
var map;
        function init(){
            map = new OpenLayers.Map('map',{projection: new OpenLayers.Projection("EPSG:42303")}); // Note that I've also tried 45556
            var political = new OpenLayers.Layer.WMS(
                "State",
                "/geoserver/wms",
                {layers: 'topp:states',
                 format: 'image/png'}
            );

            var states= new OpenLayers.Layer.WFS(
                "States",
                "/geoserver/wfs",
                {typename: 'topp:states'},
                {
                    typename: 'states',
                    featureNS: ' http://www.openplans.org/topp’,
                    extractAttributes: false,
                    isBaseLayer: true
                }
            );
            states.style = OpenLayers.Util.applyDefaults({strokeColor: "#0000ff"},
                    OpenLayers.Feature.Vector.style["default"]);
            map.addLayers([political,states);

I've done testing just showing one layer at a time and here's what happens:
1. political (WMS) with EPGS: 42303
Displays nothing. I se a JS error message:
userAgentButton is null
_hasString() <??>()OpenLayers.js (line 224)
OpenLayers.js() <??>()OpenLayers.js (line 223)
var factory=null;if(typeof GearsFactory!...documentElement.appendChild(factory);}}}

2. states (WFS) with EPGS: 42303
Query: http://localhost:8080/geoserver/wfs?typename=topp%3Astates&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&SRS=EPSG%3A42303&BBOX=-575,-306.801875,550,361.166875

I see the state outlines but it's not an Albers projection.
3. political (WMS) with EPGS: 45556
I see the same JS error as in case 1, query to the db happens and I only see Kansas.
Note that if I remove the projection from OpenLayer.Map(... it works fine.
4. states (WFS) with EPGS: 45556
Query: http://localhost:8080/geoserver/wfs?typename=topp%3Astates&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&SRS=EPSG%3A45556&BBOX=-575,-306.801875,550,361.166875

Same as case 2, no Albers projection.
Any help and advice is greatly appreciated.
-- Ethan
Ethan Goldstine
Producer, kapow, inc.
ethan@anonymised.com

------------------------------------------------------------------------
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com

------------------------------------------------------------------------
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

Ethan Goldstine
Producer, kapow, inc.
ethan@anonymised.com

310.394.5276 (394-KAPOW)

Hi--

Thanks for your advice.

I decided to do another test and take OL out of the equation.

I started with this link from the built-in demo:

http://localhost:8080/geoserver/wms?bbox=-127.61950064999999,23.7351786,-64.08177035,50.592523400000005&styles=&Format=image/svg%2Bxml&request=GetMap&version=1.1.1&layers=topp:states&width=800&height=317&srs=EPSG:4326

That worked.

I then changed the srs to 45556 and all I see is Kansas. (It's a peach-colored rectangle labeled KS... not sure if it's the right dimensions of Kansas.)

When I change the srs to 42303 I get nothing.

Do you see anything strange in the SVG request?

-- Ethan

At 08:57 PM 3/18/2009, you wrote:

Hi Ethan,

You may get better luck on the open layers mailing list but a couple of things I noted.

I think you have to set the projection property on the wms layer, rather then the map. I also believe you will have to set the extent of the layer explicitly as well.

What version of openlayers are you using. Looking at the WFS request a few things are off. The first is the SRS parameter, in wfs this should be SRSNAME. I recognize this problem from a while back. I think you will get some better results with a more recent version of OL.

Also of note is that officially reprojection is not support with wfs version 1.0, only 1.1. Although GeoServer does support it for 1.0 as well.

-Justin

Ethan Goldstine wrote:

Hi--
I'm having some difficulty getting GeoServer to do reprojection to an Albers Equal Area map. I think the correct codes are EPSG: 42303 and 45556 (though I could be wrong).
As a test, I'm using the states data that comes with Geoserver.
I've tried both WMS and WFS.
Here's the code:
var map;
        function init(){
            map = new OpenLayers.Map('map',{projection: new OpenLayers.Projection("EPSG:42303")}); // Note that I've also tried 45556
            var political = new OpenLayers.Layer.WMS(
                "State",
                "/geoserver/wms",
                {layers: 'topp:states',
                 format: 'image/png'}
            );

            var states= new OpenLayers.Layer.WFS(
                "States",
                "/geoserver/wfs",
                {typename: 'topp:states'},
                {
                    typename: 'states',
                    featureNS: ' http://www.openplans.org/topp’,
                    extractAttributes: false,
                    isBaseLayer: true
                }
            );
            states.style = OpenLayers.Util.applyDefaults({strokeColor: "#0000ff"},
                    OpenLayers.Feature.Vector.style["default"]);
            map.addLayers([political,states);

I've done testing just showing one layer at a time and here's what happens:
1. political (WMS) with EPGS: 42303
Displays nothing. I se a JS error message:
userAgentButton is null
_hasString() <??>()OpenLayers.js (line 224)
OpenLayers.js() <??>()OpenLayers.js (line 223)
var factory=null;if(typeof GearsFactory!...documentElement.appendChild(factory);}}}

2. states (WFS) with EPGS: 42303
Query: http://localhost:8080/geoserver/wfs?typename=topp%3Astates&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&SRS=EPSG%3A42303&BBOX=-575,-306.801875,550,361.166875

I see the state outlines but it's not an Albers projection.
3. political (WMS) with EPGS: 45556
I see the same JS error as in case 1, query to the db happens and I only see Kansas.
Note that if I remove the projection from OpenLayer.Map(... it works fine.
4. states (WFS) with EPGS: 45556
Query: http://localhost:8080/geoserver/wfs?typename=topp%3Astates&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&SRS=EPSG%3A45556&BBOX=-575,-306.801875,550,361.166875

Same as case 2, no Albers projection.
Any help and advice is greatly appreciated.
-- Ethan
Ethan Goldstine
Producer, kapow, inc.
ethan@anonymised.com

------------------------------------------------------------------------
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com

------------------------------------------------------------------------
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

Ethan Goldstine
Producer, kapow, inc.
ethan@anonymised.com

310.394.5276 (394-KAPOW)

On Thu, Mar 19, 2009 at 2:49 PM, Ethan Goldstine <ethan@anonymised.com> wrote:

Hi--

Thanks for your advice.

I decided to do another test and take OL out of the equation.

I started with this link from the built-in demo:

http://localhost:8080/geoserver/wms?bbox=-127.61950064999999,23.7351786,-64.08177035,50.592523400000005&styles=&Format=image/svg%2Bxml&request=GetMap&version=1.1.1&layers=topp:states&width=800&height=317&srs=EPSG:4326

That worked.

I then changed the srs to 45556 and all I see is Kansas. (It's a
peach-colored rectangle labeled KS... not sure if it's the right
dimensions of Kansas.)

When I change the srs to 42303 I get nothing.

Are you sure 42303 is a valid EPSG code? I looked on
Spatial Reference List -- Spatial Reference and it says nothing
found. This may explain why you get nothing back.

Ian
--

Ian Turton
http://www.geotools.org
http://pennspace.blogspot.com/

Hi, Ian--

Good thought...

Strange that it's not on the spacialreference list. It shows up when I click the SRS List link in GeoServer. And often if you give GS an SRS code it doesn't know it spits out an error message.

Best,

Ethan

  At 10:47 AM 3/20/2009, Ian Turton wrote:

On Thu, Mar 19, 2009 at 2:49 PM, Ethan Goldstine <ethan@anonymised.com> wrote:
> Hi--
>
> Thanks for your advice.
>
> I decided to do another test and take OL out of the equation.
>
> I started with this link from the built-in demo:
>
> http://localhost:8080/geoserver/wms?bbox=-127.61950064999999,23.7351786,-64.08177035,50.592523400000005&styles=&Format=image/svg%2Bxml&request=GetMap&version=1.1.1&layers=topp:states&width=800&height=317&srs=EPSG:4326
>
> That worked.
>
> I then changed the srs to 45556 and all I see is Kansas. (It's a
> peach-colored rectangle labeled KS... not sure if it's the right
> dimensions of Kansas.)
>
> When I change the srs to 42303 I get nothing.

Are you sure 42303 is a valid EPSG code? I looked on
http://spatialreference.org/ref/?search=42303 and it says nothing
found. This may explain why you get nothing back.

Ian
--

Ian Turton
http://www.geotools.org
http://pennspace.blogspot.com/

Ethan Goldstine
Producer, kapow, inc.
ethan@anonymised.com

310.394.5276 (394-KAPOW)

Hi Ethan,

I believe this problem is occurring because you are still using geographic coordinates for the bounding box, but specifying the srs to the albers projection. To get it right you have to convert the bbox coordinates to albers.

Now luckily there is a tool in GeoServer that can help --> the wms reflector. It is a convenience for making wms requests that prevents you from having to fill out all the parameters. It will also set up the bbox parameter in the proper coordinates based on the srs.

So... the following request is the states in geographic (EPSG:4326)

http://localhost:8080/geoserver/wms/reflect?layers=topp:states&format=image/svg+xml

To change to the albers projection just add the srs parameter:

http://localhost:8080/geoserver/wms/reflect?layers=topp:states&format=image/svg+xml&srs=epsg:45556

Or 42303, i tried both and they both worked for me.

If you do need to make the full WMS requests you need to change the bbox parameter so its in albers coordinates. For instance:

bbox=-2353760.17599943,-1294266.91959374,2253944.09170884,1561261.68522241&srs=epsg:45556

in the request you showed above should get you the results you are looking for.

-Justin

Ethan Goldstine wrote:

Hi--

Thanks for your advice.

I decided to do another test and take OL out of the equation.

I started with this link from the built-in demo:

http://localhost:8080/geoserver/wms?bbox=-127.61950064999999,23.7351786,-64.08177035,50.592523400000005&styles=&Format=image/svg%2Bxml&request=GetMap&version=1.1.1&layers=topp:states&width=800&height=317&srs=EPSG:4326

That worked.

I then changed the srs to 45556 and all I see is Kansas. (It's a peach-colored rectangle labeled KS... not sure if it's the right dimensions of Kansas.)

When I change the srs to 42303 I get nothing.

Do you see anything strange in the SVG request?

-- Ethan

At 08:57 PM 3/18/2009, you wrote:

Hi Ethan,

You may get better luck on the open layers mailing list but a couple of things I noted.

I think you have to set the projection property on the wms layer, rather then the map. I also believe you will have to set the extent of the layer explicitly as well.

What version of openlayers are you using. Looking at the WFS request a few things are off. The first is the SRS parameter, in wfs this should be SRSNAME. I recognize this problem from a while back. I think you will get some better results with a more recent version of OL.

Also of note is that officially reprojection is not support with wfs version 1.0, only 1.1. Although GeoServer does support it for 1.0 as well.

-Justin

Ethan Goldstine wrote:

Hi--
I'm having some difficulty getting GeoServer to do reprojection to an Albers Equal Area map. I think the correct codes are EPSG: 42303 and 45556 (though I could be wrong).
As a test, I'm using the states data that comes with Geoserver.
I've tried both WMS and WFS.
Here's the code:
var map;
        function init(){
            map = new OpenLayers.Map('map',{projection: new OpenLayers.Projection("EPSG:42303")}); // Note that I've also tried 45556
            var political = new OpenLayers.Layer.WMS(
                "State",
                "/geoserver/wms",
                {layers: 'topp:states',
                 format: 'image/png'}
            );

            var states= new OpenLayers.Layer.WFS(
                "States",
                "/geoserver/wfs",
                {typename: 'topp:states'},
                {
                    typename: 'states',
                    featureNS: ' http://www.openplans.org/topp’,
                    extractAttributes: false,
                    isBaseLayer: true
                }
            );
            states.style = OpenLayers.Util.applyDefaults({strokeColor: "#0000ff"},
                    OpenLayers.Feature.Vector.style["default"]);
            map.addLayers([political,states);

I've done testing just showing one layer at a time and here's what happens:
1. political (WMS) with EPGS: 42303
Displays nothing. I se a JS error message:
userAgentButton is null
_hasString() <??>()OpenLayers.js (line 224)
OpenLayers.js() <??>()OpenLayers.js (line 223)
var factory=null;if(typeof GearsFactory!...documentElement.appendChild(factory);}}}

2. states (WFS) with EPGS: 42303
Query: http://localhost:8080/geoserver/wfs?typename=topp%3Astates&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&SRS=EPSG%3A42303&BBOX=-575,-306.801875,550,361.166875

I see the state outlines but it's not an Albers projection.
3. political (WMS) with EPGS: 45556
I see the same JS error as in case 1, query to the db happens and I only see Kansas.
Note that if I remove the projection from OpenLayer.Map(... it works fine.
4. states (WFS) with EPGS: 45556
Query: http://localhost:8080/geoserver/wfs?typename=topp%3Astates&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&SRS=EPSG%3A45556&BBOX=-575,-306.801875,550,361.166875

Same as case 2, no Albers projection.
Any help and advice is greatly appreciated.
-- Ethan
Ethan Goldstine
Producer, kapow, inc.
ethan@anonymised.com

------------------------------------------------------------------------
------------------------------------------------------------------------------

Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com

------------------------------------------------------------------------
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

Ethan Goldstine
Producer, kapow, inc.
ethan@anonymised.com

310.394.5276 (394-KAPOW)

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

Hi, Justin--

Thanks so much, this is exactly what I need!

Have a good weekend.

-- Ethan

At 04:00 PM 3/20/2009, Justin Deoliveira wrote:

Hi Ethan,

I believe this problem is occurring because you are still using geographic coordinates for the bounding box, but specifying the srs to the albers projection. To get it right you have to convert the bbox coordinates to albers.

Now luckily there is a tool in GeoServer that can help --> the wms reflector. It is a convenience for making wms requests that prevents you from having to fill out all the parameters. It will also set up the bbox parameter in the proper coordinates based on the srs.

So... the following request is the states in geographic (EPSG:4326)

http://localhost:8080/geoserver/wms/reflect?layers=topp:states&format=image/svg+xml

To change to the albers projection just add the srs parameter:

http://localhost:8080/geoserver/wms/reflect?layers=topp:states&format=image/svg+xml&srs=epsg:45556

Or 42303, i tried both and they both worked for me.

If you do need to make the full WMS requests you need to change the bbox parameter so its in albers coordinates. For instance:

bbox=-2353760.17599943,-1294266.91959374,2253944.09170884,1561261.68522241&srs=epsg:45556

in the request you showed above should get you the results you are looking for.

-Justin

Ethan Goldstine wrote:

Hi--
Thanks for your advice.
I decided to do another test and take OL out of the equation.
I started with this link from the built-in demo:
http://localhost:8080/geoserver/wms?bbox=-127.61950064999999,23.7351786,-64.08177035,50.592523400000005&styles=&Format=image/svg%2Bxml&request=GetMap&version=1.1.1&layers=topp:states&width=800&height=317&srs=EPSG:4326

That worked.
I then changed the srs to 45556 and all I see is Kansas. (It's a peach-colored rectangle labeled KS... not sure if it's the right dimensions of Kansas.)
When I change the srs to 42303 I get nothing.
Do you see anything strange in the SVG request?
-- Ethan

At 08:57 PM 3/18/2009, you wrote:

Hi Ethan,

You may get better luck on the open layers mailing list but a couple of things I noted.

I think you have to set the projection property on the wms layer, rather then the map. I also believe you will have to set the extent of the layer explicitly as well.

What version of openlayers are you using. Looking at the WFS request a few things are off. The first is the SRS parameter, in wfs this should be SRSNAME. I recognize this problem from a while back. I think you will get some better results with a more recent version of OL.

Also of note is that officially reprojection is not support with wfs version 1.0, only 1.1. Although GeoServer does support it for 1.0 as well.

-Justin

Ethan Goldstine wrote:

Hi--
I'm having some difficulty getting GeoServer to do reprojection to an Albers Equal Area map. I think the correct codes are EPSG: 42303 and 45556 (though I could be wrong).
As a test, I'm using the states data that comes with Geoserver.
I've tried both WMS and WFS.
Here's the code:
var map;
        function init(){
            map = new OpenLayers.Map('map',{projection: new OpenLayers.Projection("EPSG:42303")}); // Note that I've also tried 45556
            var political = new OpenLayers.Layer.WMS(
                "State",
                "/geoserver/wms",
                {layers: 'topp:states',
                 format: 'image/png'}
            );

            var states= new OpenLayers.Layer.WFS(
                "States",
                "/geoserver/wfs",
                {typename: 'topp:states'},
                {
                    typename: 'states',
                    featureNS: ' http://www.openplans.org/topp’,
                    extractAttributes: false,
                    isBaseLayer: true
                }
            );
            states.style = OpenLayers.Util.applyDefaults({strokeColor: "#0000ff"},
                    OpenLayers.Feature.Vector.style["default"]);
            map.addLayers([political,states);

I've done testing just showing one layer at a time and here's what happens:
1. political (WMS) with EPGS: 42303
Displays nothing. I se a JS error message:
userAgentButton is null
_hasString() <??>()OpenLayers.js (line 224)
OpenLayers.js() <??>()OpenLayers.js (line 223)
var factory=null;if(typeof GearsFactory!...documentElement.appendChild(factory);}}}

2. states (WFS) with EPGS: 42303
Query: http://localhost:8080/geoserver/wfs?typename=topp%3Astates&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&SRS=EPSG%3A42303&BBOX=-575,-306.801875,550,361.166875

I see the state outlines but it's not an Albers projection.
3. political (WMS) with EPGS: 45556
I see the same JS error as in case 1, query to the db happens and I only see Kansas.
Note that if I remove the projection from OpenLayer.Map(... it works fine.
4. states (WFS) with EPGS: 45556
Query: http://localhost:8080/geoserver/wfs?typename=topp%3Astates&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&SRS=EPSG%3A45556&BBOX=-575,-306.801875,550,361.166875

Same as case 2, no Albers projection.
Any help and advice is greatly appreciated.
-- Ethan
Ethan Goldstine
Producer, kapow, inc.
ethan@anonymised.com

------------------------------------------------------------------------
------------------------------------------------------------------------------

Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com

------------------------------------------------------------------------
_______________________________________________
Geoserver-users mailing list
Geoserver-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/geoserver-users

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

Ethan Goldstine
Producer, kapow, inc.
ethan@anonymised.com
310.394.5276 (394-KAPOW)

--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.

Ethan Goldstine
Producer, kapow, inc.
ethan@anonymised.com

310.394.5276 (394-KAPOW)