[OpenLayers-Users] WFS & Spherical Mercator
Jennifer Strahan
jennifer at greeninfo.org
Tue Feb 12 17:26:15 EST 2008
Hello All,
I figured out what the issue is. For some reason the generated SQL has
the wrong SRID. I figured this out by adding a few lines to PostGIS.py
to write the sql to a file. The resulting SQL has 4326 for the SRID
when it should be 900913.
For example if my request is:
http://69.59.158.11/featureserver/featureserver.cgi/parkinfo_google?format=WFS&maxfeatures=50&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&SRS=EPSG%3A900913&BBOX=-40075016.6784,-40075016.50840001,40075016.6784,40075016.8484
The sql is:
SELECT AsText(the_geom_google) as fs_text_geom, gid, unit_name,
agncy_nam, access FROM "holdingsfeb08" WHERE the_geom_google &&
SetSRID('BOX3D(-40075016.678400 -40075016.508400,40075016.678400
40075016.848400)'::box3d, 4326) and intersects(the_geom_google,
SetSRID('BOX3D(-40075016.678400 -40075016.508400,40075016.678400
40075016.848400)'::box3d, 4326)) LIMIT 50
If I change line 28 from
def __init__(self, name, srid = 4326, fid = "ogc_fid", geometry =
"the_geom", order = "", attribute_cols = '*', writable = True, **args):
to
def __init__(self, name, srid = 900913, fid = "ogc_fid", geometry =
"the_geom", order = "", attribute_cols = '*', writable = True, **args):
All works fine. So it seems like the parameter from the URL is not
overwriting the initial value set here.
Jennifer
Jennifer Strahan
GIS Specialist
GreenInfo Network
116 New Montgomery St. Ste. 738
San Francisco, CA 94105
(415)979-0343x306
Jennifer Strahan wrote:
> Hi Josh,
>
> Thanks for taking a look at this. Thanks also for the tip regarding
> polygons vs. multipolygons and attribute_cols.
>
> I've updated to the latest trunk and installed simplejson (I just
> extracted it to the root of my FeatureServer install. No other config
> required, right?). I'm still having the same issue. I think the other
> person who had this problem had misspelled sphericalMercator. I'm not
> sure what's going on in my case. I should have mentioned before that
> everything works fine if I'm not using the sphericalMercator layer.
>
> Anything else I should try?
>
> Thanks,
> Jennifer
>
>
>
> Jennifer Strahan
> GIS Specialist
> GreenInfo Network
> 116 New Montgomery St. Ste. 738
> San Francisco, CA 94105
> (415)979-0343x306
>
>
>
> Josh Livni wrote:
>
>> At first glance I see a featureserver issue -- if you try the url that
>> gets loaded initially (I just checked the firebug console),
>> featureserver returns an error:
>> http://69.59.158.11/featureserver/featureserver.cgi/parkinfo_google?format=json&maxfeatures=50&SERVICE=WFS&VERSION=1.0.0&REQUEST=GetFeature&SRS=EPSG%3A900913&BBOX=-40075016.6784,-40075016.50840001,40075016.6784,40075016.8484
>>
>>
>> I note if you remove the bbox parameter from the url featureserver
>> works fine.
>>
>> I also note someone else had a similar problem the other day on the FS
>> list, but I don't know what happened with that. I recall he also
>> didn't have simplejson installed. Can you install that, and ensure
>> you are using the latest featureserver trunk?
>>
>> -Josh
>>
>> PS - you may wish to use polygons instead of multipolygons, since
>> featureserver does not support the latter (though I don't think this
>> is the problem at hand here), and if using the latest version you can
>> also put 'attribute_cols' in your config to limit the field results -
>> for example you may not need your original the_geom column being
>> returned...
>>
>>
>> Jennifer Strahan wrote:
>>
>>> Hello,
>>>
>>> I'm having trouble overlaying a WFS layer on the Google Spherical
>>> Mercator layers. For some reason, the BBox query fails. Not sure if
>>> it's an issue with my data or with the BBOX values that are added to
>>> the URL.
>>>
>>> Here's a link to my test code: http://69.59.158.11/TEST/wfs.html
>>> The data is in a PostGIS database and I'm using FeatureServer.
>>> Originally the SRID for the data I'm working with is 4326.
>>>
>>> In order to convert to 900913, I followed these steps:
>>>
>>> 1. Insert a reference to 900913 into spatial_ref_sys:
>>> INSERT into spatial_ref_sys (srid, auth_name, auth_srid, proj4text,
>>> srtext) values ( 900913, 'spatialreference.org', 900913, '+proj=merc
>>> +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0
>>> +units=m +nadgrids=@null +wktext +no_defs',
>>> 'PROJCS["unnamed",GEOGCS["unnamed
>>> ellipse",DATUM["unknown",SPHEROID["unnamed",6378137,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Mercator_2SP"],PARAMETER["standard_parallel_1",0],PARAMETER["central_meridian",0],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1],EXTENSION["PROJ4","+proj=merc
>>> +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0
>>> +units=m +nadgrids=@null +wktext +no_defs"]]');
>>>
>>> 2. Add a new geometry column to my table:
>>> select
>>> addGeometrycolumn('public','holdingsfeb08','the_geom_google',900913,'MULTIPOLYGON',2);
>>>
>>>
>>> 3. update holdingsfeb08 set the_geom_google = transform(the_geom,
>>> 900913);
>>>
>>> My FeatureServer config looks like this:
>>> [parkinfo_google]
>>> type=PostGIS
>>> dsn=dbname=parkinfo_review
>>> layer=holdingsfeb08
>>> fid=gid
>>> geometry=the_geom_google
>>>
>>> Anyone have any idea how I can get this working?
>>> Thanks,
>>> Jennifer
>>>
>>>
>>>
>
> _______________________________________________
> Users mailing list
> Users at openlayers.org
> http://openlayers.org/mailman/listinfo/users
>
More information about the Users
mailing list