[Featureserver] Problem with PostGIS

Paolo Corti pcorti at gmail.com
Fri Feb 8 09:08:26 EST 2008


Josh,
thanks, your fix solved the problem, now I successfully can query and
delete PostGIS features.

But if i try to create a feature I get this error:

curl -d @2.json  http://featureserver/featureserver.cgi/pgzone/create.json
An error occurred: ERROR:  new row for relation "zone2" violates check
constraint "enforce_geotype_the_geom"

INSERT INTO "zone2" (shape_area, objectid, tipo, lottoid, classe,
shape_len, cod, codarea, numlott, the_geom) VALUES (6655.166888,
46935, 7, 2801110.000000, 1, 394.268254, 107, 2801, 110,
SetSRID('POLYGON((1145392.331960 4419206.321830,1145410.958420
4419160.221360,1145273.122670 4419106.204650,1145261.108610
4419137.403950,1145300.876090 4419153.515840,1145295.195020
4419168.323860,1145392.331960 4419206.321830))'::geometry, 4326) )
  File "/home/corti/public_html/featureserversvn/trunk/featureserver/FeatureServer/Server.py",
line 296, in cgiHandler
    format, content = service.dispatchRequest( params, path_info,
host, post_data, request_method, accepts )
  File "/home/corti/public_html/featureserversvn/trunk/featureserver/FeatureServer/Server.py",
line 145, in dispatchRequest
    result = method(action)
  File "/home/corti/public_html/featureserversvn/trunk/featureserver/FeatureServer/DataSource/PostGIS.py",
line 142, in create
    cursor.execute(str(sql), self.feature_values(feature))

this is because the geometry_type of my layer is MULTIPOLYGON. If i
drop the check constraint "enforce_geotype_the_geom" i get this error
related to srid (the srid of layer is enforced to a different value, I
do not know why):

An error occurred: ERROR:  new row for relation "zone2" violates check
constraint "enforce_srid_the_geom"

INSERT INTO "zone2" (shape_area, objectid, tipo, lottoid, classe,
shape_len, cod, codarea, numlott, the_geom) VALUES (6655.166888,
46935, 7, 2801110.000000, 1, 394.268254, 107, 2801, 110,
SetSRID('POLYGON((1145392.331960 4419206.321830,1145410.958420
4419160.221360,1145273.122670 4419106.204650,1145261.108610
4419137.403950,1145300.876090 4419153.515840,1145295.195020
4419168.323860,1145392.331960 4419206.321830))'::geometry, 4326) )
  File "/home/corti/public_html/featureserversvn/trunk/featureserver/FeatureServer/Server.py",
line 296, in cgiHandler
    format, content = service.dispatchRequest( params, path_info,
host, post_data, request_method, accepts )
  File "/home/corti/public_html/featureserversvn/trunk/featureserver/FeatureServer/Server.py",
line 145, in dispatchRequest
    result = method(action)
  File "/home/corti/public_html/featureserversvn/trunk/featureserver/FeatureServer/DataSource/PostGIS.py",
line 142, in create
    cursor.execute(str(sql), self.feature_values(feature))

If I remove also the check constraint "enforce_srid_the_geom" finally
featureserver will let me to delete features, but the the PostGIS
layer is unusable, ie with QGIS

Another question:
is it possible in the dsn to specify a schema different then public?

thanks again
Paolo


On Feb 7, 2008 6:49 PM, Josh Livni <mailing_lists at umbrellaconsulting.com> wrote:
> Paolo,
>
> Thanks for the details.  I don't know about the ogr issue, but I did
> notice an issue in the trunk that would cause the postgis issue you
> mentioned.  I've commited a fix - please update from svn and let us know
> if you still have this error with the postgis layer.
>
>   -Josh
>
>
>
> Paolo Corti wrote:
> > Now I have installed featureserver from svn
> >
> > The demo is working perfectly
> >
> > I have 2 problems with my dataset:
> >
> > 1) with shapefile I can correctly query it, but I get in problems if I
> > try to update it, like:
> >
> > #test shape
> > [zone]
> > type=OGR
> > dsn=/home/corti/temp/testfeatureserver/zone.shp
> > layer=zone
> >
> >  curl -X DELETE http://featureserver/featureserver.cgi/zone/1.json
> > An error occurred: Delete error on FID 1: Unknown failure
> >   File "/home/corti/public_html/featureserversvn/trunk/featureserver/FeatureServer/Server.py",
> > line 296, in cgiHandler
> >     format, content = service.dispatchRequest( params, path_info,
> > host, post_data, request_method, accepts )
> >   File "/home/corti/public_html/featureserversvn/trunk/featureserver/FeatureServer/Server.py",
> > line 145, in dispatchRequest
> >     result = method(action)
> >   File "/home/corti/public_html/featureserversvn/trunk/featureserver/FeatureServer/DataSource/OGR.py",
> > line 89, in delete
> >     % (action.id, self.error_msgs[err]))
> >
> > 2) with PostGIS it seems I get in this not understandable issue -
> > every query gives the same message:
> >
> > #test postgis
> > [zone2]
> > type=PostGIS
> > dsn=host=localhost dbname=gisdb user=gis password=gis
> > layer=zone2
> > fid=gid
> > geometry=the_geom
> > #attribute_cols=name,some_interesting_column #optional
> > #order=cost #optional
> >
> > http://featureserver/featureserver.cgi/zone2/all.gml
> >
> > An error occurred: local variable 'props' referenced before assignment
> >   File "/home/corti/public_html/featureserversvn/trunk/featureserver/FeatureServer/Server.py",
> > line 296, in cgiHandler
> >     format, content = service.dispatchRequest( params, path_info,
> > host, post_data, request_method, accepts )
> >   File "/home/corti/public_html/featureserversvn/trunk/featureserver/FeatureServer/Server.py",
> > line 145, in dispatchRequest
> >     result = method(action)
> >   File "/home/corti/public_html/featureserversvn/trunk/featureserver/FeatureServer/DataSource/PostGIS.py",
> > line 211, in select
> >     if not props['fs_text_geom']: continue
> >
> > Let me know
> >
> > BTW: should I keep writing you or should I post the messages to the list?
> > Is there a way to search the list except then with google?
> > http://featureserver.org/pipermail/featureserver/
> >
> > thanks again
> > Paolo
> >
> > On Feb 7, 2008 5:14 PM, Paolo Corti <pcorti at gmail.com> wrote:
> >
> >> Thanks!
> >>
> >> I wasn't using featureserver from svn, so the PostGIS sample was
> >> without user and password (and from the python script I could not
> >> figure out how to connect with a different user than www-data).
> >> Anyway also with other queries I get the same error.
> >>
> >> http://featureserver/featureserver.cgi/zone2/all.json?maxfeatures=5
> >>
> >> An error occurred: ERROR:  current transaction is aborted, commands
> >> ignored until end of transaction block
> >>
> >> SELECT AsText(the_geom) as fs_text_geom, * FROM "zone2" LIMIT 5
> >>   File "/home/corti/public_html/featureserver/FeatureServer/Server.py",
> >> line 281, in cgiHandler
> >>     format, content = service.dispatchRequest( params, path_info,
> >> host, post_data, request_method, accepts )
> >>   File "/home/corti/public_html/featureserver/FeatureServer/Server.py",
> >> line 145, in dispatchRequest
> >>     result = method(action)
> >>   File "/home/corti/public_html/featureserver/FeatureServer/DataSource/PostGIS.py",
> >> line 201, in select
> >>     cursor.execute(str(sql), attrs)
> >>
> >> Now I am going to try with featureserver from svn, maybe that will
> >> solve this issue.
> >>
> >> thanks
> >> Paolo
> >>
> >>
> >> On Feb 7, 2008 4:39 PM, Josh Livni <josh at umbrellaconsulting.com> wrote:
> >>
> >>> Paolo,
> >>>
> >>> You can have featureserver connect  to the database with any user - just
> >>> change the dsn line.  The postgis example in the docs shows you an
> >>> example of this.
> >>>
> >>> That said, I'm not sure what's causing this error.  Can you try another
> >>> type of query, such as
> >>>
> >>> /featureserver.cgi/zone2/all.json?maxfeatures=5
> >>>
> >>>   -Josh
> >>>
> >>>
> >>>
> >>> Paolo Corti wrote:
> >>>
>
> >>>> Hi!
> >>>>
> >>>> I am totally new to featureserver, but since what I am seeing looks an
> >>>> amazing project.
> >>>> I like the REST-Pythonic architecture
> >>>>
> >>>> I have successfully installed it, and I can use the demo, query the
> >>>> layers, and and edit features.
> >>>>
> >>>> Now I am trying to use some personal dataset, to test it more deeply.
> >>>> I could add shapefiles with no troubles, the issues came when I tried
> >>>> to add PostGIS layers.
> >>>>
> >>>> first I have added this layer to featureserver.cfg:
> >>>>
> >>>> [zone2]
> >>>> type=PostGIS
> >>>> dsn=dbname=gisdb
> >>>> layer=zone2
> >>>> fid=gid
> >>>> geometry=the_geom
> >>>>
> >>>> first I had problems with accessing the database, I had to create a
> >>>> www-data role (looks from sources that there is no way to use a
> >>>> specific postgres user in the featureserver.cfg, so featureserver is
> >>>> accessing postgis as the www-data user - I am using Apache CGI).
> >>>>
> >>>> After adding the www-data role, I had this new error:
> >>>>
> >>>> http://featureserver/featureserver.cgi/zone2/1.gml
> >>>>
> >>>> I get:
> >>>>
> >>>> An error occurred: ERROR:  current transaction is aborted, commands
> >>>> ignored until end of transaction block
> >>>>
> >>>> SELECT AsText(the_geom) as fs_text_geom, * FROM "zone2" WHERE gid = 1
> >>>>   File "/home/corti/public_html/featureserver/FeatureServer/Server.py",
> >>>> line 281, in cgiHandler
> >>>>     format, content = service.dispatchRequest( params, path_info,
> >>>> host, post_data, request_method, accepts )
> >>>>   File "/home/corti/public_html/featureserver/FeatureServer/Server.py",
> >>>> line 145, in dispatchRequest
> >>>>     result = method(action)
> >>>>   File "/home/corti/public_html/featureserver/FeatureServer/DataSource/PostGIS.py",
> >>>> line 172, in select
> >>>>     cursor.execute(str(sql), {self.fid_col: action.id})
> >>>>
> >>>> If I query PostGIS wit the SELECT is causing the error, I correctly
> >>>> get the feature (with gid=1).
> >>>>
> >>>> Could you give me some help?
> >>>>
> >>>> thanks, and again congrats for the wonderfull project!
> >>>>
> >>>> Paolo
> >>>>
> >>>>
> >>>>
> >>>>
> >>>>
> >>
> >>
> >> --
> >> Paolo Corti
> >> http://www.paolocorti.net
> >>
> >>
> >
> >
> >
> >
>



-- 
Paolo Corti
http://www.paolocorti.net



More information about the Featureserver mailing list