+ improved and cleaned up occi plugin
This commit is contained in:
parent
6713df5937
commit
1d7acffadb
5 changed files with 286 additions and 342 deletions
|
@ -40,10 +40,6 @@
|
|||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
using std::clog;
|
||||
using std::endl;
|
||||
using std::vector;
|
||||
|
||||
using boost::lexical_cast;
|
||||
using boost::bad_lexical_cast;
|
||||
|
||||
|
@ -66,13 +62,14 @@ using oracle::occi::SQLException;
|
|||
using oracle::occi::Type;
|
||||
using oracle::occi::StatelessConnectionPool;
|
||||
|
||||
const std::string occi_datasource::METADATA_TABLE="USER_SDO_GEOM_METADATA";
|
||||
|
||||
DATASOURCE_PLUGIN(occi_datasource)
|
||||
|
||||
|
||||
occi_datasource::occi_datasource(parameters const& params, bool bind)
|
||||
: datasource (params),
|
||||
type_(datasource::Vector),
|
||||
table_(*params_.get<std::string>("table","")),
|
||||
fields_(*params_.get<std::string>("fields","*")),
|
||||
geometry_field_(*params_.get<std::string>("geometry_field","")),
|
||||
srid_initialized_(false),
|
||||
|
@ -80,12 +77,22 @@ occi_datasource::occi_datasource(parameters const& params, bool bind)
|
|||
desc_(*params_.get<std::string>("type"), *params_.get<std::string>("encoding","utf-8")),
|
||||
row_limit_(*params_.get<int>("row_limit",0)),
|
||||
row_prefetch_(*params_.get<int>("row_prefetch",100)),
|
||||
pool_(NULL),
|
||||
conn_(NULL)
|
||||
pool_(0),
|
||||
conn_(0)
|
||||
{
|
||||
if (! params_.get<std::string>("user")) throw datasource_exception("No <user> specified");
|
||||
if (! params_.get<std::string>("password")) throw datasource_exception("No <password> specified");
|
||||
if (! params_.get<std::string>("host")) throw datasource_exception("No <host> string specified");
|
||||
if (! params_.get<std::string>("user")) throw datasource_exception("OCCI Plugin: no <user> specified");
|
||||
if (! params_.get<std::string>("password")) throw datasource_exception("OCCI Plugin: no <password> specified");
|
||||
if (! params_.get<std::string>("host")) throw datasource_exception("OCCI Plugin: no <host> string specified");
|
||||
|
||||
boost::optional<std::string> table = params_.get<std::string>("table");
|
||||
if (!table)
|
||||
{
|
||||
throw datasource_exception("OCCI Plugin: no <table> parameter specified");
|
||||
}
|
||||
else
|
||||
{
|
||||
table_ = *table;
|
||||
}
|
||||
|
||||
multiple_geometries_ = *params_.get<mapnik::boolean>("multiple_geometries",false);
|
||||
use_spatial_index_ = *params_.get<mapnik::boolean>("use_spatial_index",true);
|
||||
|
@ -115,12 +122,12 @@ occi_datasource::~occi_datasource()
|
|||
|
||||
if (use_connection_pool_)
|
||||
{
|
||||
if (pool_ != NULL)
|
||||
env->terminateStatelessConnectionPool (pool_);
|
||||
if (pool_ != 0)
|
||||
env->terminateStatelessConnectionPool (pool_, StatelessConnectionPool::SPD_FORCE);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (conn_ != NULL)
|
||||
if (conn_ != 0)
|
||||
env->terminateConnection(conn_);
|
||||
}
|
||||
}
|
||||
|
@ -148,7 +155,7 @@ void occi_datasource::bind() const
|
|||
}
|
||||
catch (SQLException &ex)
|
||||
{
|
||||
throw datasource_exception(ex.getMessage());
|
||||
throw datasource_exception("OCCI Plugin: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -164,7 +171,7 @@ void occi_datasource::bind() const
|
|||
}
|
||||
catch (SQLException &ex)
|
||||
{
|
||||
throw datasource_exception(ex.getMessage());
|
||||
throw datasource_exception("OCCI Plugin: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -174,12 +181,16 @@ void occi_datasource::bind() const
|
|||
if (! srid_initialized_ || geometry_field_ == "")
|
||||
{
|
||||
std::ostringstream s;
|
||||
s << "SELECT srid, column_name FROM " << SDO_GEOMETRY_METADATA_TABLE << " WHERE";
|
||||
s << "SELECT srid, column_name FROM " << METADATA_TABLE << " WHERE";
|
||||
s << " LOWER(table_name) = LOWER('" << table_name << "')";
|
||||
|
||||
if (geometry_field_ != "")
|
||||
s << " AND LOWER(column_name) = LOWER('" << geometry_field_ << "')";
|
||||
|
||||
#ifdef MAPNIK_DEBUG
|
||||
std::clog << "OCCI Plugin: " << s.str() << std::endl;
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
occi_connection_ptr conn;
|
||||
|
@ -203,7 +214,7 @@ void occi_datasource::bind() const
|
|||
}
|
||||
catch (SQLException &ex)
|
||||
{
|
||||
throw datasource_exception(ex.getMessage());
|
||||
throw datasource_exception("OCCI Plugin: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -212,6 +223,10 @@ void occi_datasource::bind() const
|
|||
std::ostringstream s;
|
||||
s << "SELECT " << fields_ << " FROM (" << table_name << ") WHERE rownum < 1";
|
||||
|
||||
#ifdef MAPNIK_DEBUG
|
||||
std::clog << "OCCI Plugin: " << s.str() << std::endl;
|
||||
#endif
|
||||
|
||||
try
|
||||
{
|
||||
occi_connection_ptr conn;
|
||||
|
@ -230,14 +245,14 @@ void occi_datasource::bind() const
|
|||
std::string fld_name = columnObj.getString(MetaData::ATTR_NAME);
|
||||
int type_oid = columnObj.getInt(MetaData::ATTR_DATA_TYPE);
|
||||
|
||||
#if 0
|
||||
/*
|
||||
int type_code = columnObj.getInt(MetaData::ATTR_TYPECODE);
|
||||
if (type_code == OCCI_TYPECODE_OBJECT)
|
||||
{
|
||||
desc_.add_descriptor(attribute_descriptor(fld_name,mapnik::Object));
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
switch (type_oid)
|
||||
{
|
||||
|
@ -301,14 +316,13 @@ void occi_datasource::bind() const
|
|||
case oracle::occi::OCCI_SQLT_BLOB:
|
||||
case oracle::occi::OCCI_SQLT_RSET:
|
||||
#ifdef MAPNIK_DEBUG
|
||||
clog << "unsupported datatype " << occi_enums::resolve_datatype(type_oid)
|
||||
<< " (type_oid=" << type_oid << ")" << endl;
|
||||
std::clog << "OCCI Plugin: unsupported datatype " << occi_enums::resolve_datatype(type_oid)
|
||||
<< " (type_oid=" << type_oid << ")" << std::endl;
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
#ifdef MAPNIK_DEBUG
|
||||
clog << "unknown datatype " << occi_enums::resolve_datatype(type_oid)
|
||||
<< " (type_oid=" << type_oid << ")" << endl;
|
||||
std::clog << "OCCI Plugin: unknown datatype (type_oid=" << type_oid << ")" << std::endl;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
@ -351,7 +365,7 @@ box2d<double> occi_datasource::envelope() const
|
|||
s << " TABLE(SDO_UTIL.GETVERTICES(a.shape)) c";
|
||||
|
||||
#ifdef MAPNIK_DEBUG
|
||||
clog << s.str() << endl;
|
||||
std::clog << "OCCI Plugin: " << s.str() << std::endl;
|
||||
#endif
|
||||
|
||||
try
|
||||
|
@ -374,13 +388,13 @@ box2d<double> occi_datasource::envelope() const
|
|||
}
|
||||
catch (bad_lexical_cast &ex)
|
||||
{
|
||||
clog << ex.what() << endl;
|
||||
std::clog << "OCCI Plugin: " << ex.what() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException &ex)
|
||||
{
|
||||
throw datasource_exception(ex.getMessage());
|
||||
throw datasource_exception("OCCI Plugin: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
else if (use_spatial_index_)
|
||||
|
@ -389,15 +403,15 @@ box2d<double> occi_datasource::envelope() const
|
|||
|
||||
std::ostringstream s;
|
||||
s << "SELECT dim.sdo_lb, dim.sdo_ub FROM ";
|
||||
s << SDO_GEOMETRY_METADATA_TABLE << " m, TABLE(m.diminfo) dim ";
|
||||
s << METADATA_TABLE << " m, TABLE(m.diminfo) dim ";
|
||||
s << " WHERE LOWER(m.table_name) = LOWER('" << table_name << "') AND dim.sdo_dimname = 'X'";
|
||||
s << " UNION ";
|
||||
s << "SELECT dim.sdo_lb, dim.sdo_ub FROM ";
|
||||
s << SDO_GEOMETRY_METADATA_TABLE << " m, TABLE(m.diminfo) dim ";
|
||||
s << METADATA_TABLE << " m, TABLE(m.diminfo) dim ";
|
||||
s << " WHERE LOWER(m.table_name) = LOWER('" << table_name << "') AND dim.sdo_dimname = 'Y'";
|
||||
|
||||
#ifdef MAPNIK_DEBUG
|
||||
clog << s.str() << endl;
|
||||
std::clog << "OCCI Plugin: " << s.str() << std::endl;
|
||||
#endif
|
||||
|
||||
try
|
||||
|
@ -418,7 +432,7 @@ box2d<double> occi_datasource::envelope() const
|
|||
}
|
||||
catch (bad_lexical_cast &ex)
|
||||
{
|
||||
clog << ex.what() << endl;
|
||||
std::clog << "OCCI Plugin: " << ex.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -431,7 +445,7 @@ box2d<double> occi_datasource::envelope() const
|
|||
}
|
||||
catch (bad_lexical_cast &ex)
|
||||
{
|
||||
clog << ex.what() << endl;
|
||||
std::clog << "OCCI Plugin: " << ex.what() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -441,12 +455,12 @@ box2d<double> occi_datasource::envelope() const
|
|||
}
|
||||
catch (SQLException &ex)
|
||||
{
|
||||
throw datasource_exception(ex.getMessage());
|
||||
throw datasource_exception("OCCI Plugin: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
if (! extent_initialized_)
|
||||
throw datasource_exception("Unable to determine the extent of a <occi> table");
|
||||
throw datasource_exception("OCCI Plugin: unable to determine the extent of a <occi> table");
|
||||
|
||||
return extent_;
|
||||
}
|
||||
|
@ -465,13 +479,13 @@ featureset_ptr occi_datasource::features(query const& q) const
|
|||
box2d<double> const& box=q.get_bbox();
|
||||
|
||||
std::ostringstream s;
|
||||
s << "SELECT " << geometry_field_ << " AS geom";
|
||||
s << "SELECT " << geometry_field_;
|
||||
std::set<std::string> const& props = q.property_names();
|
||||
std::set<std::string>::const_iterator pos = props.begin();
|
||||
std::set<std::string>::const_iterator end = props.end();
|
||||
while (pos != end)
|
||||
{
|
||||
s << ",\"" << *pos << "\"";
|
||||
s << ", " << *pos;
|
||||
++pos;
|
||||
}
|
||||
|
||||
|
@ -502,7 +516,7 @@ featureset_ptr occi_datasource::features(query const& q) const
|
|||
else
|
||||
{
|
||||
#ifdef MAPNIK_DEBUG
|
||||
clog << "Cannot determine where to add the spatial filter declaration" << endl;
|
||||
std::clog << "OCCI Plugin: cannot determine where to add the spatial filter declaration" << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -522,7 +536,7 @@ featureset_ptr occi_datasource::features(query const& q) const
|
|||
else
|
||||
{
|
||||
#ifdef MAPNIK_DEBUG
|
||||
clog << "Cannot determine where to add the row limit declaration" << endl;
|
||||
std::clog << "OCCI Plugin: cannot determine where to add the row limit declaration" << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -530,7 +544,7 @@ featureset_ptr occi_datasource::features(query const& q) const
|
|||
s << query;
|
||||
|
||||
#ifdef MAPNIK_DEBUG
|
||||
clog << s.str() << endl;
|
||||
std::clog << "OCCI Plugin: " << s.str() << std::endl;
|
||||
#endif
|
||||
|
||||
return featureset_ptr (new occi_featureset (pool_,
|
||||
|
@ -548,13 +562,13 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
|
|||
if (!is_bound_) bind();
|
||||
|
||||
std::ostringstream s;
|
||||
s << "SELECT " << geometry_field_ << " AS geom";
|
||||
s << "SELECT " << geometry_field_;
|
||||
std::vector<attribute_descriptor>::const_iterator itr = desc_.get_descriptors().begin();
|
||||
std::vector<attribute_descriptor>::const_iterator end = desc_.get_descriptors().end();
|
||||
unsigned size=0;
|
||||
while (itr != end)
|
||||
{
|
||||
s << ",\"" << itr->get_name() << "\"";
|
||||
s << ", " << itr->get_name();
|
||||
++itr;
|
||||
++size;
|
||||
}
|
||||
|
@ -585,7 +599,7 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
|
|||
else
|
||||
{
|
||||
#ifdef MAPNIK_DEBUG
|
||||
clog << "Cannot determine where to add the spatial filter declaration" << endl;
|
||||
std::clog << "OCCI Plugin: cannot determine where to add the spatial filter declaration" << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -605,7 +619,7 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
|
|||
else
|
||||
{
|
||||
#ifdef MAPNIK_DEBUG
|
||||
clog << "Cannot determine where to add the row limit declaration" << endl;
|
||||
std::clog << "OCCI Plugin: cannot determine where to add the row limit declaration" << std::endl;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
@ -613,7 +627,7 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
|
|||
s << query;
|
||||
|
||||
#ifdef MAPNIK_DEBUG
|
||||
clog << s.str() << endl;
|
||||
std::clog << "OCCI Plugin: " << s.str() << std::endl;
|
||||
#endif
|
||||
|
||||
return featureset_ptr (new occi_featureset (pool_,
|
||||
|
@ -625,3 +639,4 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
|
|||
row_prefetch_,
|
||||
size));
|
||||
}
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ class occi_datasource : public mapnik::datasource
|
|||
bool use_connection_pool_;
|
||||
bool multiple_geometries_;
|
||||
bool use_spatial_index_;
|
||||
static const std::string METADATA_TABLE;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
*****************************************************************************/
|
||||
//$Id$
|
||||
|
||||
// mapnik
|
||||
#include <mapnik/global.hpp>
|
||||
#include <mapnik/datasource.hpp>
|
||||
#include <mapnik/box2d.hpp>
|
||||
|
@ -30,12 +31,12 @@
|
|||
#include <mapnik/wkb.hpp>
|
||||
#include <mapnik/unicode.hpp>
|
||||
|
||||
// boost
|
||||
#include <boost/shared_array.hpp>
|
||||
|
||||
// ogr
|
||||
#include "occi_featureset.hpp"
|
||||
|
||||
using std::clog;
|
||||
using std::endl;
|
||||
|
||||
using mapnik::query;
|
||||
using mapnik::box2d;
|
||||
using mapnik::CoordTransform;
|
||||
|
@ -54,6 +55,7 @@ using oracle::occi::MetaData;
|
|||
using oracle::occi::SQLException;
|
||||
using oracle::occi::Type;
|
||||
using oracle::occi::Number;
|
||||
using oracle::occi::Blob;
|
||||
|
||||
occi_featureset::occi_featureset(StatelessConnectionPool* pool,
|
||||
Connection* conn,
|
||||
|
@ -79,7 +81,7 @@ occi_featureset::occi_featureset(StatelessConnectionPool* pool,
|
|||
}
|
||||
catch (SQLException &ex)
|
||||
{
|
||||
throw datasource_exception(ex.getMessage());
|
||||
std::clog << "OCCI Plugin: error processing " << sqlstring << " : " << ex.getMessage() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -108,13 +110,13 @@ feature_ptr occi_featureset::next()
|
|||
std::string fld_name = columnObj.getString(MetaData::ATTR_NAME);
|
||||
int type_oid = columnObj.getInt(MetaData::ATTR_DATA_TYPE);
|
||||
|
||||
#if 0
|
||||
/*
|
||||
int type_code = columnObj.getInt(MetaData::ATTR_TYPECODE);
|
||||
if (type_code == OCCI_TYPECODE_OBJECT)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
switch (type_oid)
|
||||
{
|
||||
|
@ -122,22 +124,16 @@ feature_ptr occi_featureset::next()
|
|||
case oracle::occi::OCCIINT:
|
||||
case oracle::occi::OCCIUNSIGNED_INT:
|
||||
case oracle::occi::OCCIROWID:
|
||||
{
|
||||
boost::put(*feature,fld_name,rs_->getInt (i + 1));
|
||||
break;
|
||||
}
|
||||
|
||||
case oracle::occi::OCCIFLOAT:
|
||||
case oracle::occi::OCCIBFLOAT:
|
||||
case oracle::occi::OCCIDOUBLE:
|
||||
case oracle::occi::OCCIBDOUBLE:
|
||||
case oracle::occi::OCCINUMBER:
|
||||
case oracle::occi::OCCI_SQLT_NUM:
|
||||
{
|
||||
boost::put(*feature,fld_name,rs_->getDouble (i + 1));
|
||||
break;
|
||||
}
|
||||
|
||||
case oracle::occi::OCCICHAR:
|
||||
case oracle::occi::OCCISTRING:
|
||||
case oracle::occi::OCCI_SQLT_AFC:
|
||||
|
@ -150,12 +146,8 @@ feature_ptr occi_featureset::next()
|
|||
case oracle::occi::OCCI_SQLT_VNU:
|
||||
case oracle::occi::OCCI_SQLT_VBI:
|
||||
case oracle::occi::OCCI_SQLT_VST:
|
||||
{
|
||||
UnicodeString ustr = tr_->transcode (rs_->getString (i + 1).c_str());
|
||||
boost::put(*feature,fld_name,ustr);
|
||||
boost::put(*feature,fld_name,(UnicodeString) tr_->transcode (rs_->getString (i + 1).c_str()));
|
||||
break;
|
||||
}
|
||||
|
||||
case oracle::occi::OCCIDATE:
|
||||
case oracle::occi::OCCITIMESTAMP:
|
||||
case oracle::occi::OCCIINTERVALDS:
|
||||
|
@ -187,24 +179,18 @@ feature_ptr occi_featureset::next()
|
|||
case oracle::occi::OCCI_SQLT_CLOB:
|
||||
case oracle::occi::OCCI_SQLT_BLOB:
|
||||
case oracle::occi::OCCI_SQLT_RSET:
|
||||
{
|
||||
#ifdef MAPNIK_DEBUG
|
||||
clog << "unsupported datatype " << occi_enums::resolve_datatype(type_oid)
|
||||
<< " (type_oid=" << type_oid << ")" << endl;
|
||||
std::clog << "OCCI Plugin: unsupported datatype " << occi_enums::resolve_datatype(type_oid)
|
||||
<< " (type_oid=" << type_oid << ")" << std::endl;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
default: // shouldn't get here
|
||||
{
|
||||
#ifdef MAPNIK_DEBUG
|
||||
clog << "unknown datatype " << occi_enums::resolve_datatype(type_oid)
|
||||
<< " (type_oid=" << type_oid << ")" << endl;
|
||||
std::clog << "OCCI Plugin: unknown datatype (type_oid=" << type_oid << ")" << std::endl;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
++count_;
|
||||
return feature;
|
||||
|
@ -235,148 +221,109 @@ void occi_featureset::convert_geometry (SDOGeometry* geom, feature_ptr feature,
|
|||
clog << "SDO SRID = " << (int) sdo_srid << endl;
|
||||
#endif
|
||||
|
||||
const std::vector<Number>& elem_info = geom->getSdo_elem_info();
|
||||
const std::vector<Number>& ordinates = geom->getSdo_ordinates();
|
||||
const int ordinates_size = (int) ordinates.size();
|
||||
|
||||
switch (geomtype)
|
||||
{
|
||||
case SDO_GTYPE_POINT:
|
||||
convert_point (geom, feature, dimensions);
|
||||
break;
|
||||
case SDO_GTYPE_LINE:
|
||||
convert_linestring (geom, feature, dimensions);
|
||||
break;
|
||||
case SDO_GTYPE_POLYGON:
|
||||
convert_polygon (geom, feature, dimensions);
|
||||
break;
|
||||
case SDO_GTYPE_MULTIPOINT:
|
||||
// Todo - using convert_multipoint_2 until we have proper multipoint handling in convert_multipoint
|
||||
// http://trac.mapnik.org/ticket/458
|
||||
//convert_multipoint (geom, feature, dimensions, multiple_geometries);
|
||||
convert_multipoint (geom, feature, dimensions, true);
|
||||
break;
|
||||
case SDO_GTYPE_MULTILINE:
|
||||
convert_multilinestring (geom, feature, dimensions, multiple_geometries);
|
||||
break;
|
||||
case SDO_GTYPE_MULTIPOLYGON:
|
||||
convert_multipolygon (geom, feature, dimensions, multiple_geometries);
|
||||
break;
|
||||
case SDO_GTYPE_COLLECTION:
|
||||
convert_collection (geom, feature, dimensions, multiple_geometries);
|
||||
break;
|
||||
case SDO_GTYPE_UNKNOWN:
|
||||
default:
|
||||
#ifdef MAPNIK_DEBUG
|
||||
clog << "unknown <occi> " << occi_enums::resolve_gtype(geomtype)
|
||||
<< "(gtype=" << gtype << ")" << endl;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void occi_featureset::convert_point (SDOGeometry* geom, feature_ptr feature, int dimensions)
|
||||
{
|
||||
{
|
||||
SDOPointType* sdopoint = geom->getSdo_point();
|
||||
|
||||
if (sdopoint && ! sdopoint->isNull())
|
||||
{
|
||||
geometry_type* point = new geometry_type(mapnik::Point);
|
||||
|
||||
point->move_to (sdopoint->getX(), sdopoint->getY());
|
||||
|
||||
feature->add_geometry (point);
|
||||
}
|
||||
}
|
||||
|
||||
void occi_featureset::convert_linestring (SDOGeometry* geom, feature_ptr feature, int dimensions)
|
||||
{
|
||||
const std::vector<Number>& elem_info = geom->getSdo_elem_info();
|
||||
const std::vector<Number>& ordinates = geom->getSdo_ordinates();
|
||||
|
||||
if ((int) ordinates.size() >= dimensions)
|
||||
}
|
||||
break;
|
||||
case SDO_GTYPE_LINE:
|
||||
{
|
||||
if (ordinates_size >= dimensions)
|
||||
{
|
||||
const bool is_single_geom = true;
|
||||
const bool is_point_type = false;
|
||||
const bool multiple_geometries = false;
|
||||
|
||||
convert_ordinates (feature,
|
||||
mapnik::LineString,
|
||||
elem_info,
|
||||
ordinates,
|
||||
dimensions,
|
||||
is_single_geom,
|
||||
is_point_type,
|
||||
multiple_geometries);
|
||||
true, // is_single_geom
|
||||
false, // is_point_type
|
||||
false); // multiple_geometries
|
||||
}
|
||||
}
|
||||
|
||||
void occi_featureset::convert_polygon (SDOGeometry* geom, feature_ptr feature, int dimensions)
|
||||
{
|
||||
const std::vector<Number>& elem_info = geom->getSdo_elem_info();
|
||||
const std::vector<Number>& ordinates = geom->getSdo_ordinates();
|
||||
|
||||
if ((int) ordinates.size() >= dimensions)
|
||||
}
|
||||
break;
|
||||
case SDO_GTYPE_POLYGON:
|
||||
{
|
||||
if (ordinates_size >= dimensions)
|
||||
{
|
||||
const bool is_single_geom = true;
|
||||
const bool is_point_type = false;
|
||||
const bool multiple_geometries = false;
|
||||
|
||||
convert_ordinates (feature,
|
||||
mapnik::Polygon,
|
||||
elem_info,
|
||||
ordinates,
|
||||
dimensions,
|
||||
is_single_geom,
|
||||
is_point_type,
|
||||
multiple_geometries);
|
||||
true, // is_single_geom
|
||||
false, // is_point_type
|
||||
false); // multiple_geometries
|
||||
}
|
||||
}
|
||||
|
||||
void occi_featureset::convert_multipoint (SDOGeometry* geom, feature_ptr feature, int dimensions, bool multiple_geometries)
|
||||
{
|
||||
const std::vector<Number>& elem_info = geom->getSdo_elem_info();
|
||||
const std::vector<Number>& ordinates = geom->getSdo_ordinates();
|
||||
|
||||
if ((int) ordinates.size() >= dimensions)
|
||||
}
|
||||
break;
|
||||
case SDO_GTYPE_MULTIPOINT:
|
||||
{
|
||||
if (ordinates_size >= dimensions)
|
||||
{
|
||||
const bool is_single_geom = false;
|
||||
const bool is_point_type = true;
|
||||
|
||||
// Todo - force using true as multiple_geometries until we have proper multipoint handling
|
||||
// http://trac.mapnik.org/ticket/458
|
||||
|
||||
convert_ordinates (feature,
|
||||
mapnik::Point,
|
||||
elem_info,
|
||||
ordinates,
|
||||
dimensions,
|
||||
is_single_geom,
|
||||
is_point_type,
|
||||
multiple_geometries);
|
||||
false, // is_single_geom
|
||||
true, // is_point_type
|
||||
true); // multiple_geometries
|
||||
}
|
||||
}
|
||||
|
||||
void occi_featureset::convert_multilinestring (SDOGeometry* geom, feature_ptr feature, int dimensions, bool multiple_geometries)
|
||||
{
|
||||
const std::vector<Number>& elem_info = geom->getSdo_elem_info();
|
||||
const std::vector<Number>& ordinates = geom->getSdo_ordinates();
|
||||
|
||||
if ((int) ordinates.size() >= dimensions)
|
||||
}
|
||||
break;
|
||||
case SDO_GTYPE_MULTILINE:
|
||||
{
|
||||
if (ordinates_size >= dimensions)
|
||||
{
|
||||
const bool is_single_geom = false;
|
||||
const bool is_point_type = false;
|
||||
|
||||
convert_ordinates (feature,
|
||||
mapnik::LineString,
|
||||
elem_info,
|
||||
ordinates,
|
||||
dimensions,
|
||||
is_single_geom,
|
||||
is_point_type,
|
||||
false, // is_single_geom
|
||||
false, // is_point_type
|
||||
multiple_geometries);
|
||||
}
|
||||
}
|
||||
|
||||
void occi_featureset::convert_multipolygon (SDOGeometry* geom, feature_ptr feature, int dimensions, bool multiple_geometries)
|
||||
{
|
||||
const std::vector<Number>& elem_info = geom->getSdo_elem_info();
|
||||
const std::vector<Number>& ordinates = geom->getSdo_ordinates();
|
||||
}
|
||||
break;
|
||||
case SDO_GTYPE_MULTIPOLYGON:
|
||||
{
|
||||
if (ordinates_size >= dimensions)
|
||||
{
|
||||
convert_ordinates (feature,
|
||||
mapnik::Polygon,
|
||||
elem_info,
|
||||
ordinates,
|
||||
dimensions,
|
||||
false, // is_single_geom
|
||||
false, // is_point_type
|
||||
multiple_geometries);
|
||||
}
|
||||
|
||||
if ((int) ordinates.size() >= dimensions)
|
||||
}
|
||||
break;
|
||||
case SDO_GTYPE_COLLECTION:
|
||||
{
|
||||
if (ordinates_size >= dimensions)
|
||||
{
|
||||
const bool is_single_geom = false;
|
||||
const bool is_point_type = false;
|
||||
|
@ -386,30 +333,19 @@ void occi_featureset::convert_multipolygon (SDOGeometry* geom, feature_ptr featu
|
|||
elem_info,
|
||||
ordinates,
|
||||
dimensions,
|
||||
is_single_geom,
|
||||
is_point_type,
|
||||
false, // is_single_geom,
|
||||
false, // is_point_type
|
||||
multiple_geometries);
|
||||
}
|
||||
}
|
||||
|
||||
void occi_featureset::convert_collection (SDOGeometry* geom, feature_ptr feature, int dimensions, bool multiple_geometries)
|
||||
{
|
||||
const std::vector<Number>& elem_info = geom->getSdo_elem_info();
|
||||
const std::vector<Number>& ordinates = geom->getSdo_ordinates();
|
||||
|
||||
if ((int) ordinates.size() >= dimensions)
|
||||
{
|
||||
const bool is_single_geom = false;
|
||||
const bool is_point_type = false;
|
||||
|
||||
convert_ordinates (feature,
|
||||
mapnik::Polygon,
|
||||
elem_info,
|
||||
ordinates,
|
||||
dimensions,
|
||||
is_single_geom,
|
||||
is_point_type,
|
||||
multiple_geometries);
|
||||
}
|
||||
break;
|
||||
case SDO_GTYPE_UNKNOWN:
|
||||
default:
|
||||
#ifdef MAPNIK_DEBUG
|
||||
std::clog << "OCCI Plugin: unknown <occi> " << occi_enums::resolve_gtype(geomtype)
|
||||
<< "(gtype=" << gtype << ")" << std::endl;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -552,3 +488,4 @@ void occi_featureset::fill_geometry_type (geometry_type * geom,
|
|||
geom->line_to ((double) ordinates[p], (double) ordinates[p + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,13 +50,6 @@ class occi_featureset : public mapnik::Featureset
|
|||
virtual ~occi_featureset();
|
||||
mapnik::feature_ptr next();
|
||||
private:
|
||||
void convert_point (SDOGeometry* geom, mapnik::feature_ptr feature, int dims);
|
||||
void convert_linestring (SDOGeometry* geom, mapnik::feature_ptr feature, int dims);
|
||||
void convert_polygon (SDOGeometry* geom, mapnik::feature_ptr feature, int dims);
|
||||
void convert_multipoint (SDOGeometry* geom, mapnik::feature_ptr feature, int dims, bool multiple_geometries);
|
||||
void convert_multilinestring (SDOGeometry* geom, mapnik::feature_ptr feature, int dims, bool multiple_geometries);
|
||||
void convert_multipolygon (SDOGeometry* geom, mapnik::feature_ptr feature, int dims, bool multiple_geometries);
|
||||
void convert_collection (SDOGeometry* geom, mapnik::feature_ptr feature, int dims, bool multiple_geometries);
|
||||
void convert_geometry (SDOGeometry* geom, mapnik::feature_ptr feature, bool multiple_geometries);
|
||||
void convert_ordinates (mapnik::feature_ptr feature,
|
||||
const mapnik::eGeomType& geom_type,
|
||||
|
|
|
@ -36,15 +36,13 @@
|
|||
|
||||
// check for oracle support
|
||||
#if OCCI_MAJOR_VERSION >= 10 && OCCI_MINOR_VERSION >= 1
|
||||
// Only ORACLE 10g (>= 10.2.0.X) is supported !
|
||||
// We have at least ORACLE 10g >= 10.2.0.X
|
||||
#else
|
||||
#error Only ORACLE 10g (>= 10.2.0.X) is supported !
|
||||
#error Only ORACLE 10g >= 10.2.0.X is supported !
|
||||
#endif
|
||||
|
||||
|
||||
#define SDO_GEOMETRY_METADATA_TABLE "USER_SDO_GEOM_METADATA"
|
||||
|
||||
|
||||
// geometry types definitions
|
||||
enum
|
||||
{
|
||||
SDO_GTYPE_UNKNOWN = 0,
|
||||
|
@ -93,7 +91,7 @@ public:
|
|||
if (env_ == 0)
|
||||
{
|
||||
#ifdef MAPNIK_DEBUG
|
||||
std::clog << "occi_environment constructor" << std::endl;
|
||||
std::clog << "OCCI Plugin: occi_environment constructor" << std::endl;
|
||||
#endif
|
||||
|
||||
int mode = oracle::occi::Environment::OBJECT
|
||||
|
@ -117,7 +115,7 @@ private:
|
|||
if (env_)
|
||||
{
|
||||
#ifdef MAPNIK_DEBUG
|
||||
std::clog << "occi_environment destructor" << std::endl;
|
||||
std::clog << "OCCI Plugin: occi_environment destructor" << std::endl;
|
||||
#endif
|
||||
|
||||
oracle::occi::Environment::terminateEnvironment (env_);
|
||||
|
|
Loading…
Reference in a new issue