1.added Describe() to Datasource, return list of attributes/types.

2.modified WMS to work with new Projection
This commit is contained in:
Artem Pavlenko 2006-10-16 21:34:09 +00:00
parent c195e1d24d
commit 2351cb38d0
3 changed files with 30 additions and 5 deletions

View file

@ -65,10 +65,16 @@ class _Projection(Projection,_injector):
def inverse(self,pt): def inverse(self,pt):
return inverse(pt,self) return inverse(pt,self)
class _Datasource(Datasource,_injector):
def describe(self):
return Describe(self)
def Datasource (**keywords): def Datasource (**keywords):
return CreateDatasource(keywords) return CreateDatasource(keywords)
#register datasources #register datasources
from mapnik import DatasourceCache from mapnik import DatasourceCache
DatasourceCache.instance().register_datasources('%s' % inputpluginspath) DatasourceCache.instance().register_datasources('%s' % inputpluginspath)

View file

@ -255,12 +255,12 @@ class CRS:
def Inverse(self, x, y): def Inverse(self, x, y):
if not self.proj: if not self.proj:
self.proj = Projection(['init=%s' % str(self).lower()]) self.proj = Projection('init=%s' % str(self).lower())
return self.proj.Inverse(x, y) return self.proj.Inverse(x, y)
def Forward(self, x, y): def Forward(self, x, y):
if not self.proj: if not self.proj:
self.proj = Projection(['init=%s' % str(self).lower()]) self.proj = Projection('init=%s' % str(self).lower())
return self.proj.Forward(x, y) return self.proj.Forward(x, y)
class CRSFactory: class CRSFactory:

View file

@ -20,11 +20,15 @@
* *
*****************************************************************************/ *****************************************************************************/
//$Id$ //$Id$
// stl
#include <sstream>
// boost
#include <boost/python.hpp> #include <boost/python.hpp>
// mapnik
#include <mapnik/envelope.hpp> #include <mapnik/envelope.hpp>
#include <mapnik/datasource.hpp> #include <mapnik/datasource.hpp>
#include <mapnik/datasource_cache.hpp> #include <mapnik/datasource_cache.hpp>
#include <mapnik/feature_layer_desc.hpp>
namespace namespace
{ {
@ -47,6 +51,20 @@ namespace
return mapnik::datasource_cache::create(params); return mapnik::datasource_cache::create(params);
} }
std::string describe(boost::shared_ptr<mapnik::datasource> const& ds)
{
std::stringstream ss;
if (ds)
{
ss << ds->get_descriptor() << "\n";
}
else
{
ss << "Null\n";
}
return ss.str();
}
} }
void export_datasource() void export_datasource()
@ -64,5 +82,6 @@ void export_datasource()
"These vary depending on the type of data source.") "These vary depending on the type of data source.")
; ;
def("Describe",&describe);
def("CreateDatasource",&create_datasource); def("CreateDatasource",&create_datasource);
} }