[FeatureServer] GeoAlchemy, what is the trick?

Iocast iocast at me.com
Tue Dec 4 23:34:15 PST 2012


Hi Gery

In the test files I found an example and tried to adapt it:

The config entry I changed as follow:
************************
[boreholes]
type=GeoAlchemy
dburi=postgresql://<user>:<password>@localhost:5432/map
model=model.boreholes_model
cls=Boreholes
fid=id
geometry=geom
************************
where the model is a subdirectory of the featureserver root directory and boreholes_model is a file called boreholes_model.py. I also added a __init__.py file in the model folder to be sure that it is recognised as a Python package.
cls is the class name of your model, so it should be Boreholes.

You could also look at the 'Road' example in the folder tests
DataSource.GeoAlchemy.txt and
geoalchemy_model.py for the model declaration

Hopefully it would help
Michel




On Dec 5, 2012, at 8:00 AM, Iocast <iocast at me.com> wrote:

> Hi Gery
> 
> I never tried/changed the GeoAlchemy data source, however I'm going to try your setup and have a look if I get the same error.
> 
> Cheers,
> Michel
> 
> 
>> I get this error recently, I'm not sure why, someone has an idea? thanks
>> 
>> An error occurred: 'NoneType' object has no attribute 'items'
>>   File "/var/www/html/mop/fs/web_request/handlers.py", line 236, in cgi
>>     for (key, value) in returned_data[2].items():
>> 
>> 
>> {}
> 
> 
> 
> 
> On Dec 4, 2012, at 10:31 AM, Gery . <gamejihou at hotmail.com> wrote:
> 
>> Hello,
>> 
>> I'm using GeoAlchemy with FeatureServer, but I'm new using both, so sorry for the very simple questions. This is my model (boreholes.model) for one of my PostGis tables:
>> 
>> *****************************
>> print "Content-type: text/html\n\n";
>> 
>> from sqlalchemy import *
>> from sqlalchemy.orm import *
>> from sqlalchemy.dialects.postgresql import *
>> from geoalchemy import *
>> from geoalchemy.postgis import *
>> 
>> engine = create_engine('postgresql://postgres:pass@localhost:5432/map', echo=False)
>> metadata = MetaData(engine)
>> 
>> session = sessionmaker(bind=engine)()
>> 
>> boreholes_table = Table('boreholes_point_wgs84', metadata,
>>                         Column('id', SMALLINT, primary_key=True),
>>                         Column('fid', SMALLINT),
>>                         Column('longitude', DOUBLE_PRECISION),
>>                         Column('latitude', DOUBLE_PRECISION),
>>                         Column('w_depth_m', DOUBLE_PRECISION),
>>                         Column('station', VARCHAR(150)),
>>                         Column('type', VARCHAR(150)),
>>                         Column('survey', VARCHAR(150)),
>>                         Column('source', VARCHAR(150)),
>>                         Column('max_pen_m', VARCHAR(150)),
>>                         Column('core_rec_m', VARCHAR(150)),
>>                         Column('t_g_ckm1', VARCHAR(150)),
>>                         Column('h_f_mwm2', VARCHAR(150)),
>>                         Column('comments', TEXT),
>>                         GeometryExtensionColumn('geom', Geometry(3)))
>> 
>> class Boreholes(object):
>>     def __init__ (self, id, fid, longitude, latitude, w_depth_m, station, type, survey, source, max_pen_m, core_rec_m, t_g_ckm1, h_f_mwm2, comments):
>>         self.id = id
>>         self.fid = fid
>>         self.longitude = longitude
>>         self.latitude = latitude
>>         self.w_depth_m = w_depth_m
>>         self.station = station
>>         self.type = type
>>         self.survey = survey
>>         self.source = source
>>         self.max_pen_m = max_pen_m
>>         self.core_rec_m = core_rec_m
>>         self.t_g_ckm1 = t_g_ckm1
>>         self.h_f_mwm2 = h_f_mwm2
>>         self.comments = comments
>> 
>> mapper(Boreholes, boreholes_table,
>>        properties={
>>                  'geom': GeometryColumn(boreholes_table.c.geom,
>>                                         comparator=PGComparator)
>>                   })
>> 
>> GeometryDDL(boreholes_table)
>> 
>> *****************************
>> 
>> and this is what I have in my featureserver.cfg:
>> 
>> *****************************
>> [boreholes]
>> type=GeoAlchemy
>> dburi=postgresql://postgres:pass@localhost:5432/map
>> model=../model/boreholes.model
>> cls=boreholes_point_wgs84
>> fid=id
>> geometry=geom
>> *****************************
>> 
>> so what I want is to query this table and output that in GeoJSON format. I'm doing the query in OpenLayers using GeoExt like this:
>> 
>> *****************************
>> var searchformPanel = new GeoExt.form.FormPanel(
>>         {
>>             width: 250,
>>             bodyStyle: 'padding:5px',
>>             labelAlign: 'top',
>>             defaults:
>>             {
>>                 anchor: '100%'
>>             },
>>             protocol: new OpenLayers.Protocol.HTTP(
>>             {
>>                 url: 'http://www.mop.org/fs/boreholes?format=GeoJSON',
>>                 format: new OpenLayers.Format.GeoJSON(
>>                 {
>>                     ignoreExtraDims: true,
>>                     'internalProjection': new OpenLayers.Projection("EPSG:900913"),
>>                     'externalProjection': new OpenLayers.Projection("EPSG:4326")
>>                 }
>>                 )
>>             }
>>             ),
>>             items:
>>             [
>>             {
>>                 xtype: 'textfield',
>>                 name: 'station__like',
>>                 fieldLabel: 'Enter a word',
>>                 allowBlank: false
>>             }
>>             ],
>> ...
>> ...
>> *****************************
>> 
>> by the way, this PostGis table is served by MarServer as WMS, but I think this has nothing to do with the query. So, to do this query I'm sure I need something else related to GeoAlchemy and featureserver itself but not sure what it is, I'd be grateful for some support on this, thanks in advance for any help.
>> 
>> Best regards,
>> 
>> Gery
>>  
>> 
>> __________________________________________________________________________________________
>> Piensa en el medio ambiente - mantenlo en la pantalla. NO lo imprimas si NO es necesario.
>> Think green - keep it on the screen. Do NOT print if it is NOT necessary.
>> Denken Sie an die Umwelt - bewahren Sie es auf dem Bildschirm. Drucken Sie NICHT, wenn es NICHT notwendig ist.
>> _______________________________________________
>> FeatureServer mailing list
>> FeatureServer at lists.osgeo.org
>> http://lists.osgeo.org/mailman/listinfo/featureserver
> 
> _______________________________________________
> FeatureServer mailing list
> FeatureServer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/featureserver

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/featureserver/attachments/20121205/32a26225/attachment-0001.html>


More information about the FeatureServer mailing list