From 8c775a6da3c522e0d18460971b544f325183f707 Mon Sep 17 00:00:00 2001 From: Lucio Asnaghi Date: Tue, 31 Mar 2009 07:53:29 +0000 Subject: [PATCH] + added "encoding" datasource parameter to occi plugin + added factory methods with docstrings for occi plugin (closes #274) --- bindings/python/mapnik/__init__.py | 32 +++++++++++++++++++++++++- plugins/input/occi/occi_datasource.cpp | 2 +- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/bindings/python/mapnik/__init__.py b/bindings/python/mapnik/__init__.py index 50cf899ec..500954296 100644 --- a/bindings/python/mapnik/__init__.py +++ b/bindings/python/mapnik/__init__.py @@ -218,6 +218,36 @@ def Gdal(**keywords): keywords['type'] = 'gdal' return CreateDatasource(keywords) +def Occi(**keywords): + """Create a Oracle Spatial (10g) Vector Datasource. + + Required keyword arguments: + user -- database user to connect as + password -- password for database user + host -- oracle host to connect to (does not refer to SID in tsnames.ora) + table -- table name or subselect query + + Optional keyword arguments: + initial_size -- integer size of connection pool (default 1) + max_size -- integer max of connection pool (default 10) + extent -- manually specified data extent (comma delimited string, default None) + estimate_extent -- boolean, direct Oracle to use the faster, less accurate estimate_extent() over extent() (default False) + encoding -- file encoding (default 'utf-8') + geometry_field -- specify geometry field (default 'GEOLOC') + use_spatial_index -- boolean, force the use of the spatial index (default True) + multiple_geometries -- boolean, direct the Mapnik wkb reader to interpret as multigeometries (default False) + + >>> from mapnik import Occi, Layer + >>> params = dict(host='myoracle',user='scott',password='tiger',table='test') + >>> params['estimate_extent'] = False + >>> params['extent'] = '-20037508,-19929239,20037508,19929239' + >>> oracle = Occi(**params) + >>> lyr = Layer('Oracle Spatial Layer') + >>> lyr.datasource = oracle + """ + keywords['type'] = 'occi' + return CreateDatasource(keywords) + def Ogr(**keywords): """Create a OGR Vector Datasource. @@ -289,4 +319,4 @@ else: map(FontEngine.instance().register_font, fonts) #set dlopen flags back to the original -setdlopenflags(flags) \ No newline at end of file +setdlopenflags(flags) diff --git a/plugins/input/occi/occi_datasource.cpp b/plugins/input/occi/occi_datasource.cpp index 8ed34af96..523dadc4e 100644 --- a/plugins/input/occi/occi_datasource.cpp +++ b/plugins/input/occi/occi_datasource.cpp @@ -97,7 +97,7 @@ occi_datasource::occi_datasource(parameters const& params) geometry_field_(*params.get("geometry_field","GEOLOC")), type_(datasource::Vector), extent_initialized_(false), - desc_(*params.get("type"),"utf-8"), + desc_(*params.get("type"), *params.get("encoding","utf-8")), pool_(0) { boost::optional initial_size = params_.get("inital_size",1);