[Featureserver] Fwd: postgis connection

Bobby Braswell rob.braswell at unh.edu
Fri Oct 19 16:37:41 EDT 2007


Thanks very much for the quick reply. I changed my table definition  
to the following:

createdb -U postgres mydata -T template_postgis
psql -U postgres -d mydata
# CREATE TABLE mylayer (ogc_fid SERIAL NOT NULL, CONSTRAINT  
mylayer_ogc_fid
# PRIMARY KEY (ogc_fid));
# GRANT ALL ON TABLE mylayer TO www;
# GRANT ALL ON mylayer_ogc_fid_seq TO www;
# SELECT AddGeometryColumn('','mylayer','wkb_geometry','4326','POINT', 
2);

Now I can successfully do the following manual upload:

  % echo '{"id":1, "geometry":{"type":"Point", "coordinates": 
[-70,43]}}' | curl -k -d @- https://portsmouthresponse.unh.edu/cgi/ 
featureserver.cgi/scribble/
{"crs": {"type": "none", "properties": {"info": "No CRS information  
has been provided with this data."}}, "type": "FeatureCollection",  
"features": [{"geometry": {"type": "Point", "coordinates": [0.0,  
5.0]}, "type": "Feature", "id": 1, "properties": {}}]}

And the point appears on my test OpenLayers map: https:// 
portsmouthresponse.unh.edu/testmap.html

which is great. However, I can't add a new feature from the map, as I  
had done before with the DBM database, via a simple 'post' of:

{"type":"FeatureCollection","features": 
[{"type":"Feature","id":"OpenLayers.Feature.Vector_289","properties": 
{},"geometry":{"type":"Point","coordinates": 
[-70.87003784179687,43.2922607421875]}}],"crs": 
{"type":"OGC","properties":{"urn":"urn:ogc:def:crs:OGC:1.3:CRS84"}}}
Features: 134

Here is where I think I'm getting into the "new GeoJSON" issue.

I tried removing the "default_service" line from my config file with  
no effect.

Sorry for not completely understand your previous answer. I think the  
problem is now more boiled down to a single knowledge gap on my part  
regarding the AJAX request.

Best,
Rob Braswell



On Oct 19, 2007, at 3:27 PM, Christopher Schmidt wrote:

> On Fri, Oct 19, 2007 at 03:19:46PM -0400, Bobby Braswell wrote:
>>
>> Hi-
>>
>> Update on my previous question, sorry for not including his piece of
>> information. This is the error I get when I try to manually upload a
>> point to my postgis featureserver instance:
>>
>> % echo '{"id":1, "geometry":{"type":"Point", "coordinates":[[0,5]]}}'
>> | curl -k -d @- https://portsmouthresponse.unh.edu/cgi/
>> featureserver.cgi/scribble/
>> An error occurred: float argument required
>>   File "/sw/lib/python2.5/site-packages/FeatureServer/Server.py",
>> line 273, in cgiHandler
>>     format, content = service.dispatchRequest( params, path_info,
>> host, post_data, request_method, accepts )
>>   File "/sw/lib/python2.5/site-packages/FeatureServer/Server.py",
>> line 137, in dispatchRequest
>>     result = method(action)
>>   File "/sw/lib/python2.5/site-packages/FeatureServer/DataSource/
>> PostGIS.py", line 113, in create
>>     values = ", ".join(self.value_formats(feature)+["SetSRID('%
>> s'::geometry, %s) " % (self.to_wkt(feature.geometry), self.srid)])
>>   File "/sw/lib/python2.5/site-packages/FeatureServer/DataSource/
>> PostGIS.py", line 70, in to_wkt
>>     return "POINT(%s)" % coords_to_wkt(coords)
>>   File "/sw/lib/python2.5/site-packages/FeatureServer/DataSource/
>> PostGIS.py", line 67, in coords_to_wkt
>>     return ",".join(["%f %f" % tuple(c) for c in coords])
>>
>> In particular, I'm not sure what the "float argument required"
>> message means.
>
> I'm assuming you've updated your code to a newer FeatureServer. If so,
> you'll see there is a default_service=GeoJSON -- this sets the default
> service to be *real* GeoJSON, as opposed to the hacked up version that
> FeatureServer has always used. This is the default since OpenLayers  
> 2.5 is
> now using real GeoJSON -- but it means that the above is not valid. It
> should be:
>
> % echo '{"id":1, "geometry":{"type":"Point", "coordinates":[0,5]}}'
>
> That is -- the point coordinates changed format.
>
> Alternatively, if your app uses the old GeoJSON, you can drop back by
> killing the default_service= line from your FS config, or changing  
> it to
> "JSON", since at some point in the future GeoJSON will likely  
> become the
> default.
>
> Regards,
> -- 
> Christopher Schmidt
> MetaCarta




More information about the Featureserver mailing list