- fix indentation and trailing spaces (generally coding style) in occi plugin partially related to #911
This commit is contained in:
parent
35739ae917
commit
26fbcb51ef
6 changed files with 414 additions and 398 deletions
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -63,30 +63,29 @@ using oracle::occi::SQLException;
|
||||||
using oracle::occi::Type;
|
using oracle::occi::Type;
|
||||||
using oracle::occi::StatelessConnectionPool;
|
using oracle::occi::StatelessConnectionPool;
|
||||||
|
|
||||||
const std::string occi_datasource::METADATA_TABLE="USER_SDO_GEOM_METADATA";
|
const std::string occi_datasource::METADATA_TABLE = "USER_SDO_GEOM_METADATA";
|
||||||
|
|
||||||
DATASOURCE_PLUGIN(occi_datasource)
|
DATASOURCE_PLUGIN(occi_datasource)
|
||||||
|
|
||||||
|
|
||||||
occi_datasource::occi_datasource(parameters const& params, bool bind)
|
occi_datasource::occi_datasource(parameters const& params, bool bind)
|
||||||
: datasource (params),
|
: datasource (params),
|
||||||
type_(datasource::Vector),
|
type_(datasource::Vector),
|
||||||
fields_(*params_.get<std::string>("fields","*")),
|
fields_(*params_.get<std::string>("fields", "*")),
|
||||||
geometry_field_(*params_.get<std::string>("geometry_field","")),
|
geometry_field_(*params_.get<std::string>("geometry_field", "")),
|
||||||
srid_initialized_(false),
|
srid_initialized_(false),
|
||||||
extent_initialized_(false),
|
extent_initialized_(false),
|
||||||
desc_(*params_.get<std::string>("type"), *params_.get<std::string>("encoding","utf-8")),
|
desc_(*params_.get<std::string>("type"), *params_.get<std::string>("encoding", "utf-8")),
|
||||||
row_limit_(*params_.get<int>("row_limit",0)),
|
row_limit_(*params_.get<int>("row_limit", 0)),
|
||||||
row_prefetch_(*params_.get<int>("row_prefetch",100)),
|
row_prefetch_(*params_.get<int>("row_prefetch", 100)),
|
||||||
pool_(0),
|
pool_(0),
|
||||||
conn_(0)
|
conn_(0)
|
||||||
{
|
{
|
||||||
if (! params_.get<std::string>("user")) throw datasource_exception("OCCI Plugin: no <user> 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>("password")) throw datasource_exception("OCCI Plugin: no <password> specified");
|
||||||
if (! params_.get<std::string>("host")) throw datasource_exception("OCCI Plugin: no <host> string 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");
|
boost::optional<std::string> table = params_.get<std::string>("table");
|
||||||
if (!table)
|
if (! table)
|
||||||
{
|
{
|
||||||
throw datasource_exception("OCCI Plugin: no <table> parameter specified");
|
throw datasource_exception("OCCI Plugin: no <table> parameter specified");
|
||||||
}
|
}
|
||||||
|
@ -124,12 +123,16 @@ occi_datasource::~occi_datasource()
|
||||||
if (use_connection_pool_)
|
if (use_connection_pool_)
|
||||||
{
|
{
|
||||||
if (pool_ != 0)
|
if (pool_ != 0)
|
||||||
env->terminateStatelessConnectionPool (pool_, StatelessConnectionPool::SPD_FORCE);
|
{
|
||||||
|
env->terminateStatelessConnectionPool(pool_, StatelessConnectionPool::SPD_FORCE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (conn_ != 0)
|
if (conn_ != 0)
|
||||||
|
{
|
||||||
env->terminateConnection(conn_);
|
env->terminateConnection(conn_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -149,12 +152,12 @@ void occi_datasource::bind() const
|
||||||
*params_.get<std::string>("user"),
|
*params_.get<std::string>("user"),
|
||||||
*params_.get<std::string>("password"),
|
*params_.get<std::string>("password"),
|
||||||
*params_.get<std::string>("host"),
|
*params_.get<std::string>("host"),
|
||||||
*params_.get<int>("max_size",10),
|
*params_.get<int>("max_size", 10),
|
||||||
*params_.get<int>("initial_size",1),
|
*params_.get<int>("initial_size", 1),
|
||||||
1,
|
1,
|
||||||
StatelessConnectionPool::HOMOGENEOUS);
|
StatelessConnectionPool::HOMOGENEOUS);
|
||||||
}
|
}
|
||||||
catch (SQLException &ex)
|
catch (SQLException& ex)
|
||||||
{
|
{
|
||||||
throw datasource_exception("OCCI Plugin: " + ex.getMessage());
|
throw datasource_exception("OCCI Plugin: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -170,7 +173,7 @@ void occi_datasource::bind() const
|
||||||
*params_.get<std::string>("password"),
|
*params_.get<std::string>("password"),
|
||||||
*params_.get<std::string>("host"));
|
*params_.get<std::string>("host"));
|
||||||
}
|
}
|
||||||
catch (SQLException &ex)
|
catch (SQLException& ex)
|
||||||
{
|
{
|
||||||
throw datasource_exception("OCCI Plugin: " + ex.getMessage());
|
throw datasource_exception("OCCI Plugin: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -186,7 +189,9 @@ void occi_datasource::bind() const
|
||||||
s << " LOWER(table_name) = LOWER('" << table_name << "')";
|
s << " LOWER(table_name) = LOWER('" << table_name << "')";
|
||||||
|
|
||||||
if (geometry_field_ != "")
|
if (geometry_field_ != "")
|
||||||
|
{
|
||||||
s << " AND LOWER(column_name) = LOWER('" << geometry_field_ << "')";
|
s << " AND LOWER(column_name) = LOWER('" << geometry_field_ << "')";
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef MAPNIK_DEBUG
|
#ifdef MAPNIK_DEBUG
|
||||||
std::clog << "OCCI Plugin: " << s.str() << std::endl;
|
std::clog << "OCCI Plugin: " << s.str() << std::endl;
|
||||||
|
@ -198,7 +203,7 @@ void occi_datasource::bind() const
|
||||||
if (use_connection_pool_) conn.set_pool(pool_);
|
if (use_connection_pool_) conn.set_pool(pool_);
|
||||||
else conn.set_connection(conn_, false);
|
else conn.set_connection(conn_, false);
|
||||||
|
|
||||||
ResultSet* rs = conn.execute_query (s.str());
|
ResultSet* rs = conn.execute_query(s.str());
|
||||||
if (rs && rs->next ())
|
if (rs && rs->next ())
|
||||||
{
|
{
|
||||||
if (! srid_initialized_)
|
if (! srid_initialized_)
|
||||||
|
@ -213,7 +218,7 @@ void occi_datasource::bind() const
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SQLException &ex)
|
catch (SQLException& ex)
|
||||||
{
|
{
|
||||||
throw datasource_exception("OCCI Plugin: " + ex.getMessage());
|
throw datasource_exception("OCCI Plugin: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -234,7 +239,7 @@ void occi_datasource::bind() const
|
||||||
if (use_connection_pool_) conn.set_pool(pool_);
|
if (use_connection_pool_) conn.set_pool(pool_);
|
||||||
else conn.set_connection(conn_, false);
|
else conn.set_connection(conn_, false);
|
||||||
|
|
||||||
ResultSet* rs = conn.execute_query (s.str());
|
ResultSet* rs = conn.execute_query(s.str());
|
||||||
if (rs)
|
if (rs)
|
||||||
{
|
{
|
||||||
std::vector<MetaData> listOfColumns = rs->getColumnListMetaData();
|
std::vector<MetaData> listOfColumns = rs->getColumnListMetaData();
|
||||||
|
@ -317,20 +322,22 @@ void occi_datasource::bind() const
|
||||||
case oracle::occi::OCCI_SQLT_BLOB:
|
case oracle::occi::OCCI_SQLT_BLOB:
|
||||||
case oracle::occi::OCCI_SQLT_RSET:
|
case oracle::occi::OCCI_SQLT_RSET:
|
||||||
#ifdef MAPNIK_DEBUG
|
#ifdef MAPNIK_DEBUG
|
||||||
std::clog << "OCCI Plugin: unsupported datatype " << occi_enums::resolve_datatype(type_oid)
|
std::clog << "OCCI Plugin: unsupported datatype "
|
||||||
<< " (type_oid=" << type_oid << ")" << std::endl;
|
<< occi_enums::resolve_datatype(type_oid)
|
||||||
|
<< " (type_oid=" << type_oid << ")" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
#ifdef MAPNIK_DEBUG
|
#ifdef MAPNIK_DEBUG
|
||||||
std::clog << "OCCI Plugin: unknown datatype (type_oid=" << type_oid << ")" << std::endl;
|
std::clog << "OCCI Plugin: unknown datatype "
|
||||||
|
<< "(type_oid=" << type_oid << ")" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SQLException &ex)
|
catch (SQLException& ex)
|
||||||
{
|
{
|
||||||
throw datasource_exception(ex.getMessage());
|
throw datasource_exception(ex.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -352,11 +359,12 @@ int occi_datasource::type() const
|
||||||
box2d<double> occi_datasource::envelope() const
|
box2d<double> occi_datasource::envelope() const
|
||||||
{
|
{
|
||||||
if (extent_initialized_) return extent_;
|
if (extent_initialized_) return extent_;
|
||||||
if (!is_bound_) bind();
|
if (! is_bound_) bind();
|
||||||
|
|
||||||
double lox = 0.0, loy = 0.0, hix = 0.0, hiy = 0.0;
|
double lox = 0.0, loy = 0.0, hix = 0.0, hiy = 0.0;
|
||||||
|
|
||||||
boost::optional<mapnik::boolean> estimate_extent = params_.get<mapnik::boolean>("estimate_extent",false);
|
boost::optional<mapnik::boolean> estimate_extent =
|
||||||
|
params_.get<mapnik::boolean>("estimate_extent",false);
|
||||||
|
|
||||||
if (estimate_extent && *estimate_extent)
|
if (estimate_extent && *estimate_extent)
|
||||||
{
|
{
|
||||||
|
@ -375,8 +383,8 @@ box2d<double> occi_datasource::envelope() const
|
||||||
if (use_connection_pool_) conn.set_pool(pool_);
|
if (use_connection_pool_) conn.set_pool(pool_);
|
||||||
else conn.set_connection(conn_, false);
|
else conn.set_connection(conn_, false);
|
||||||
|
|
||||||
ResultSet* rs = conn.execute_query (s.str());
|
ResultSet* rs = conn.execute_query(s.str());
|
||||||
if (rs && rs->next ())
|
if (rs && rs->next())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -384,16 +392,16 @@ box2d<double> occi_datasource::envelope() const
|
||||||
loy = lexical_cast<double>(rs->getDouble(2));
|
loy = lexical_cast<double>(rs->getDouble(2));
|
||||||
hix = lexical_cast<double>(rs->getDouble(3));
|
hix = lexical_cast<double>(rs->getDouble(3));
|
||||||
hiy = lexical_cast<double>(rs->getDouble(4));
|
hiy = lexical_cast<double>(rs->getDouble(4));
|
||||||
extent_.init (lox,loy,hix,hiy);
|
extent_.init(lox, loy, hix, hiy);
|
||||||
extent_initialized_ = true;
|
extent_initialized_ = true;
|
||||||
}
|
}
|
||||||
catch (bad_lexical_cast &ex)
|
catch (bad_lexical_cast& ex)
|
||||||
{
|
{
|
||||||
std::clog << "OCCI Plugin: " << ex.what() << std::endl;
|
std::clog << "OCCI Plugin: " << ex.what() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SQLException &ex)
|
catch (SQLException& ex)
|
||||||
{
|
{
|
||||||
throw datasource_exception("OCCI Plugin: " + ex.getMessage());
|
throw datasource_exception("OCCI Plugin: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
|
@ -421,63 +429,65 @@ box2d<double> occi_datasource::envelope() const
|
||||||
if (use_connection_pool_) conn.set_pool(pool_);
|
if (use_connection_pool_) conn.set_pool(pool_);
|
||||||
else conn.set_connection(conn_, false);
|
else conn.set_connection(conn_, false);
|
||||||
|
|
||||||
ResultSet* rs = conn.execute_query (s.str());
|
ResultSet* rs = conn.execute_query(s.str());
|
||||||
if (rs)
|
if (rs)
|
||||||
{
|
{
|
||||||
if (rs->next ())
|
if (rs->next())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
lox = lexical_cast<double>(rs->getDouble(1));
|
lox = lexical_cast<double>(rs->getDouble(1));
|
||||||
hix = lexical_cast<double>(rs->getDouble(2));
|
hix = lexical_cast<double>(rs->getDouble(2));
|
||||||
}
|
}
|
||||||
catch (bad_lexical_cast &ex)
|
catch (bad_lexical_cast& ex)
|
||||||
{
|
{
|
||||||
std::clog << "OCCI Plugin: " << ex.what() << std::endl;
|
std::clog << "OCCI Plugin: " << ex.what() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rs->next ())
|
if (rs->next())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
loy = lexical_cast<double>(rs->getDouble(1));
|
loy = lexical_cast<double>(rs->getDouble(1));
|
||||||
hiy = lexical_cast<double>(rs->getDouble(2));
|
hiy = lexical_cast<double>(rs->getDouble(2));
|
||||||
}
|
}
|
||||||
catch (bad_lexical_cast &ex)
|
catch (bad_lexical_cast& ex)
|
||||||
{
|
{
|
||||||
std::clog << "OCCI Plugin: " << ex.what() << std::endl;
|
std::clog << "OCCI Plugin: " << ex.what() << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extent_.init (lox,loy,hix,hiy);
|
extent_.init(lox, loy, hix, hiy);
|
||||||
extent_initialized_ = true;
|
extent_initialized_ = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (SQLException &ex)
|
catch (SQLException& ex)
|
||||||
{
|
{
|
||||||
throw datasource_exception("OCCI Plugin: " + ex.getMessage());
|
throw datasource_exception("OCCI Plugin: " + ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! extent_initialized_)
|
if (! extent_initialized_)
|
||||||
|
{
|
||||||
throw datasource_exception("OCCI Plugin: 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_;
|
return extent_;
|
||||||
}
|
}
|
||||||
|
|
||||||
layer_descriptor occi_datasource::get_descriptor() const
|
layer_descriptor occi_datasource::get_descriptor() const
|
||||||
{
|
{
|
||||||
if (!is_bound_) bind();
|
if (! is_bound_) bind();
|
||||||
|
|
||||||
return desc_;
|
return desc_;
|
||||||
}
|
}
|
||||||
|
|
||||||
featureset_ptr occi_datasource::features(query const& q) const
|
featureset_ptr occi_datasource::features(query const& q) const
|
||||||
{
|
{
|
||||||
if (!is_bound_) bind();
|
if (! is_bound_) bind();
|
||||||
|
|
||||||
box2d<double> const& box=q.get_bbox();
|
box2d<double> const& box = q.get_bbox();
|
||||||
|
|
||||||
std::ostringstream s;
|
std::ostringstream s;
|
||||||
s << "SELECT " << geometry_field_;
|
s << "SELECT " << geometry_field_;
|
||||||
|
@ -492,7 +502,7 @@ featureset_ptr occi_datasource::features(query const& q) const
|
||||||
|
|
||||||
s << " FROM ";
|
s << " FROM ";
|
||||||
|
|
||||||
std::string query (table_);
|
std::string query(table_);
|
||||||
std::string table_name = mapnik::table_from_sql(query);
|
std::string table_name = mapnik::table_from_sql(query);
|
||||||
|
|
||||||
if (use_spatial_index_)
|
if (use_spatial_index_)
|
||||||
|
@ -549,24 +559,24 @@ featureset_ptr occi_datasource::features(query const& q) const
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return boost::make_shared<occi_featureset>(pool_,
|
return boost::make_shared<occi_featureset>(pool_,
|
||||||
conn_,
|
conn_,
|
||||||
s.str(),
|
s.str(),
|
||||||
desc_.get_encoding(),
|
desc_.get_encoding(),
|
||||||
multiple_geometries_,
|
multiple_geometries_,
|
||||||
use_connection_pool_,
|
use_connection_pool_,
|
||||||
row_prefetch_,
|
row_prefetch_,
|
||||||
props.size());
|
props.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
|
featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
|
||||||
{
|
{
|
||||||
if (!is_bound_) bind();
|
if (! is_bound_) bind();
|
||||||
|
|
||||||
std::ostringstream s;
|
std::ostringstream s;
|
||||||
s << "SELECT " << geometry_field_;
|
s << "SELECT " << geometry_field_;
|
||||||
std::vector<attribute_descriptor>::const_iterator itr = desc_.get_descriptors().begin();
|
std::vector<attribute_descriptor>::const_iterator itr = desc_.get_descriptors().begin();
|
||||||
std::vector<attribute_descriptor>::const_iterator end = desc_.get_descriptors().end();
|
std::vector<attribute_descriptor>::const_iterator end = desc_.get_descriptors().end();
|
||||||
unsigned size=0;
|
unsigned size = 0;
|
||||||
while (itr != end)
|
while (itr != end)
|
||||||
{
|
{
|
||||||
s << ", " << itr->get_name();
|
s << ", " << itr->get_name();
|
||||||
|
@ -576,7 +586,7 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
|
||||||
|
|
||||||
s << " FROM ";
|
s << " FROM ";
|
||||||
|
|
||||||
std::string query (table_);
|
std::string query(table_);
|
||||||
std::string table_name = mapnik::table_from_sql(query);
|
std::string table_name = mapnik::table_from_sql(query);
|
||||||
|
|
||||||
if (use_spatial_index_)
|
if (use_spatial_index_)
|
||||||
|
@ -593,7 +603,7 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
|
||||||
{
|
{
|
||||||
boost::algorithm::ireplace_first(query, "WHERE", spatial_sql.str() + " AND ");
|
boost::algorithm::ireplace_first(query, "WHERE", spatial_sql.str() + " AND ");
|
||||||
}
|
}
|
||||||
else if (boost::algorithm::ifind_first(query,table_name))
|
else if (boost::algorithm::ifind_first(query, table_name))
|
||||||
{
|
{
|
||||||
boost::algorithm::ireplace_first(query, table_name, table_name + " " + spatial_sql.str());
|
boost::algorithm::ireplace_first(query, table_name, table_name + " " + spatial_sql.str());
|
||||||
}
|
}
|
||||||
|
@ -632,12 +642,11 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return boost::make_shared<occi_featureset>(pool_,
|
return boost::make_shared<occi_featureset>(pool_,
|
||||||
conn_,
|
conn_,
|
||||||
s.str(),
|
s.str(),
|
||||||
desc_.get_encoding(),
|
desc_.get_encoding(),
|
||||||
multiple_geometries_,
|
multiple_geometries_,
|
||||||
use_connection_pool_,
|
use_connection_pool_,
|
||||||
row_prefetch_,
|
row_prefetch_,
|
||||||
size);
|
size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -38,35 +38,35 @@
|
||||||
|
|
||||||
class occi_datasource : public mapnik::datasource
|
class occi_datasource : public mapnik::datasource
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
occi_datasource(mapnik::parameters const& params, bool bind=true);
|
occi_datasource(mapnik::parameters const& params, bool bind = true);
|
||||||
virtual ~occi_datasource ();
|
virtual ~occi_datasource ();
|
||||||
int type() const;
|
int type() const;
|
||||||
static std::string name();
|
static std::string name();
|
||||||
mapnik::featureset_ptr features(mapnik::query const& q) const;
|
mapnik::featureset_ptr features(mapnik::query const& q) const;
|
||||||
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt) const;
|
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt) const;
|
||||||
mapnik::box2d<double> envelope() const;
|
mapnik::box2d<double> envelope() const;
|
||||||
mapnik::layer_descriptor get_descriptor() const;
|
mapnik::layer_descriptor get_descriptor() const;
|
||||||
void bind() const;
|
void bind() const;
|
||||||
private:
|
|
||||||
int type_;
|
private:
|
||||||
mutable std::string table_;
|
int type_;
|
||||||
mutable std::string fields_;
|
mutable std::string table_;
|
||||||
mutable std::string geometry_field_;
|
mutable std::string fields_;
|
||||||
mutable int srid_;
|
mutable std::string geometry_field_;
|
||||||
mutable bool srid_initialized_;
|
mutable int srid_;
|
||||||
mutable bool extent_initialized_;
|
mutable bool srid_initialized_;
|
||||||
mutable mapnik::box2d<double> extent_;
|
mutable bool extent_initialized_;
|
||||||
mutable mapnik::layer_descriptor desc_;
|
mutable mapnik::box2d<double> extent_;
|
||||||
int row_limit_;
|
mutable mapnik::layer_descriptor desc_;
|
||||||
int row_prefetch_;
|
int row_limit_;
|
||||||
mutable oracle::occi::StatelessConnectionPool* pool_;
|
int row_prefetch_;
|
||||||
mutable oracle::occi::Connection* conn_;
|
mutable oracle::occi::StatelessConnectionPool* pool_;
|
||||||
bool use_connection_pool_;
|
mutable oracle::occi::Connection* conn_;
|
||||||
bool multiple_geometries_;
|
bool use_connection_pool_;
|
||||||
bool use_spatial_index_;
|
bool multiple_geometries_;
|
||||||
static const std::string METADATA_TABLE;
|
bool use_spatial_index_;
|
||||||
|
static const std::string METADATA_TABLE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // OCCI_DATASOURCE_HPP
|
#endif // OCCI_DATASOURCE_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -64,19 +64,23 @@ occi_featureset::occi_featureset(StatelessConnectionPool* pool,
|
||||||
bool use_connection_pool,
|
bool use_connection_pool,
|
||||||
unsigned prefetch_rows,
|
unsigned prefetch_rows,
|
||||||
unsigned num_attrs)
|
unsigned num_attrs)
|
||||||
: tr_(new transcoder(encoding)),
|
: tr_(new transcoder(encoding)),
|
||||||
multiple_geometries_(multiple_geometries),
|
multiple_geometries_(multiple_geometries),
|
||||||
num_attrs_(num_attrs),
|
num_attrs_(num_attrs),
|
||||||
feature_id_(1)
|
feature_id_(1)
|
||||||
{
|
{
|
||||||
if (use_connection_pool)
|
if (use_connection_pool)
|
||||||
|
{
|
||||||
conn_.set_pool(pool);
|
conn_.set_pool(pool);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
conn_.set_connection(conn, false);
|
conn_.set_connection(conn, false);
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
rs_ = conn_.execute_query (sqlstring, prefetch_rows);
|
rs_ = conn_.execute_query(sqlstring, prefetch_rows);
|
||||||
}
|
}
|
||||||
catch (SQLException &ex)
|
catch (SQLException &ex)
|
||||||
{
|
{
|
||||||
|
@ -95,10 +99,10 @@ feature_ptr occi_featureset::next()
|
||||||
feature_ptr feature(feature_factory::create(feature_id_));
|
feature_ptr feature(feature_factory::create(feature_id_));
|
||||||
++feature_id_;
|
++feature_id_;
|
||||||
|
|
||||||
boost::scoped_ptr<SDOGeometry> geom (dynamic_cast<SDOGeometry*> (rs_->getObject(1)));
|
boost::scoped_ptr<SDOGeometry> geom(dynamic_cast<SDOGeometry*>(rs_->getObject(1)));
|
||||||
if (geom.get())
|
if (geom.get())
|
||||||
{
|
{
|
||||||
convert_geometry (geom.get(), feature, multiple_geometries_);
|
convert_geometry(geom.get(), feature, multiple_geometries_);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<MetaData> listOfColumns = rs_->getColumnListMetaData();
|
std::vector<MetaData> listOfColumns = rs_->getColumnListMetaData();
|
||||||
|
@ -120,75 +124,77 @@ feature_ptr occi_featureset::next()
|
||||||
|
|
||||||
switch (type_oid)
|
switch (type_oid)
|
||||||
{
|
{
|
||||||
case oracle::occi::OCCIBOOL:
|
case oracle::occi::OCCIBOOL:
|
||||||
case oracle::occi::OCCIINT:
|
case oracle::occi::OCCIINT:
|
||||||
case oracle::occi::OCCIUNSIGNED_INT:
|
case oracle::occi::OCCIUNSIGNED_INT:
|
||||||
case oracle::occi::OCCIROWID:
|
case oracle::occi::OCCIROWID:
|
||||||
boost::put(*feature,fld_name,rs_->getInt (i + 1));
|
boost::put(*feature,fld_name,rs_->getInt (i + 1));
|
||||||
break;
|
break;
|
||||||
case oracle::occi::OCCIFLOAT:
|
case oracle::occi::OCCIFLOAT:
|
||||||
case oracle::occi::OCCIBFLOAT:
|
case oracle::occi::OCCIBFLOAT:
|
||||||
case oracle::occi::OCCIDOUBLE:
|
case oracle::occi::OCCIDOUBLE:
|
||||||
case oracle::occi::OCCIBDOUBLE:
|
case oracle::occi::OCCIBDOUBLE:
|
||||||
case oracle::occi::OCCINUMBER:
|
case oracle::occi::OCCINUMBER:
|
||||||
case oracle::occi::OCCI_SQLT_NUM:
|
case oracle::occi::OCCI_SQLT_NUM:
|
||||||
boost::put(*feature,fld_name,rs_->getDouble (i + 1));
|
boost::put(*feature,fld_name,rs_->getDouble (i + 1));
|
||||||
break;
|
break;
|
||||||
case oracle::occi::OCCICHAR:
|
case oracle::occi::OCCICHAR:
|
||||||
case oracle::occi::OCCISTRING:
|
case oracle::occi::OCCISTRING:
|
||||||
case oracle::occi::OCCI_SQLT_AFC:
|
case oracle::occi::OCCI_SQLT_AFC:
|
||||||
case oracle::occi::OCCI_SQLT_AVC:
|
case oracle::occi::OCCI_SQLT_AVC:
|
||||||
case oracle::occi::OCCI_SQLT_CHR:
|
case oracle::occi::OCCI_SQLT_CHR:
|
||||||
case oracle::occi::OCCI_SQLT_LVC:
|
case oracle::occi::OCCI_SQLT_LVC:
|
||||||
case oracle::occi::OCCI_SQLT_RDD:
|
case oracle::occi::OCCI_SQLT_RDD:
|
||||||
case oracle::occi::OCCI_SQLT_STR:
|
case oracle::occi::OCCI_SQLT_STR:
|
||||||
case oracle::occi::OCCI_SQLT_VCS:
|
case oracle::occi::OCCI_SQLT_VCS:
|
||||||
case oracle::occi::OCCI_SQLT_VNU:
|
case oracle::occi::OCCI_SQLT_VNU:
|
||||||
case oracle::occi::OCCI_SQLT_VBI:
|
case oracle::occi::OCCI_SQLT_VBI:
|
||||||
case oracle::occi::OCCI_SQLT_VST:
|
case oracle::occi::OCCI_SQLT_VST:
|
||||||
boost::put(*feature,fld_name,(UnicodeString) tr_->transcode (rs_->getString (i + 1).c_str()));
|
boost::put(*feature,fld_name,(UnicodeString) tr_->transcode (rs_->getString (i + 1).c_str()));
|
||||||
break;
|
break;
|
||||||
case oracle::occi::OCCIDATE:
|
case oracle::occi::OCCIDATE:
|
||||||
case oracle::occi::OCCITIMESTAMP:
|
case oracle::occi::OCCITIMESTAMP:
|
||||||
case oracle::occi::OCCIINTERVALDS:
|
case oracle::occi::OCCIINTERVALDS:
|
||||||
case oracle::occi::OCCIINTERVALYM:
|
case oracle::occi::OCCIINTERVALYM:
|
||||||
case oracle::occi::OCCI_SQLT_DAT:
|
case oracle::occi::OCCI_SQLT_DAT:
|
||||||
case oracle::occi::OCCI_SQLT_DATE:
|
case oracle::occi::OCCI_SQLT_DATE:
|
||||||
case oracle::occi::OCCI_SQLT_TIME:
|
case oracle::occi::OCCI_SQLT_TIME:
|
||||||
case oracle::occi::OCCI_SQLT_TIME_TZ:
|
case oracle::occi::OCCI_SQLT_TIME_TZ:
|
||||||
case oracle::occi::OCCI_SQLT_TIMESTAMP:
|
case oracle::occi::OCCI_SQLT_TIMESTAMP:
|
||||||
case oracle::occi::OCCI_SQLT_TIMESTAMP_LTZ:
|
case oracle::occi::OCCI_SQLT_TIMESTAMP_LTZ:
|
||||||
case oracle::occi::OCCI_SQLT_TIMESTAMP_TZ:
|
case oracle::occi::OCCI_SQLT_TIMESTAMP_TZ:
|
||||||
case oracle::occi::OCCI_SQLT_INTERVAL_YM:
|
case oracle::occi::OCCI_SQLT_INTERVAL_YM:
|
||||||
case oracle::occi::OCCI_SQLT_INTERVAL_DS:
|
case oracle::occi::OCCI_SQLT_INTERVAL_DS:
|
||||||
case oracle::occi::OCCIANYDATA:
|
case oracle::occi::OCCIANYDATA:
|
||||||
case oracle::occi::OCCIBLOB:
|
case oracle::occi::OCCIBLOB:
|
||||||
case oracle::occi::OCCIBFILE:
|
case oracle::occi::OCCIBFILE:
|
||||||
case oracle::occi::OCCIBYTES:
|
case oracle::occi::OCCIBYTES:
|
||||||
case oracle::occi::OCCICLOB:
|
case oracle::occi::OCCICLOB:
|
||||||
case oracle::occi::OCCIVECTOR:
|
case oracle::occi::OCCIVECTOR:
|
||||||
case oracle::occi::OCCIMETADATA:
|
case oracle::occi::OCCIMETADATA:
|
||||||
case oracle::occi::OCCIPOBJECT:
|
case oracle::occi::OCCIPOBJECT:
|
||||||
case oracle::occi::OCCIREF:
|
case oracle::occi::OCCIREF:
|
||||||
case oracle::occi::OCCIREFANY:
|
case oracle::occi::OCCIREFANY:
|
||||||
case oracle::occi::OCCISTREAM:
|
case oracle::occi::OCCISTREAM:
|
||||||
case oracle::occi::OCCICURSOR:
|
case oracle::occi::OCCICURSOR:
|
||||||
case oracle::occi::OCCI_SQLT_FILE:
|
case oracle::occi::OCCI_SQLT_FILE:
|
||||||
case oracle::occi::OCCI_SQLT_CFILE:
|
case oracle::occi::OCCI_SQLT_CFILE:
|
||||||
case oracle::occi::OCCI_SQLT_REF:
|
case oracle::occi::OCCI_SQLT_REF:
|
||||||
case oracle::occi::OCCI_SQLT_CLOB:
|
case oracle::occi::OCCI_SQLT_CLOB:
|
||||||
case oracle::occi::OCCI_SQLT_BLOB:
|
case oracle::occi::OCCI_SQLT_BLOB:
|
||||||
case oracle::occi::OCCI_SQLT_RSET:
|
case oracle::occi::OCCI_SQLT_RSET:
|
||||||
#ifdef MAPNIK_DEBUG
|
#ifdef MAPNIK_DEBUG
|
||||||
std::clog << "OCCI Plugin: unsupported datatype " << occi_enums::resolve_datatype(type_oid)
|
std::clog << "OCCI Plugin: unsupported datatype "
|
||||||
<< " (type_oid=" << type_oid << ")" << std::endl;
|
<< occi_enums::resolve_datatype(type_oid)
|
||||||
|
<< " (type_oid=" << type_oid << ")" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
default: // shouldn't get here
|
default: // shouldn't get here
|
||||||
#ifdef MAPNIK_DEBUG
|
#ifdef MAPNIK_DEBUG
|
||||||
std::clog << "OCCI Plugin: unknown datatype (type_oid=" << type_oid << ")" << std::endl;
|
std::clog << "OCCI Plugin: unknown datatype "
|
||||||
|
<< "(type_oid=" << type_oid << ")" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -199,30 +205,30 @@ feature_ptr occi_featureset::next()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void occi_featureset::convert_geometry (SDOGeometry* geom, feature_ptr feature, bool multiple_geometries)
|
void occi_featureset::convert_geometry(SDOGeometry* geom, feature_ptr feature, bool multiple_geometries)
|
||||||
{
|
{
|
||||||
int gtype = (int) geom->getSdo_gtype();
|
int gtype = (int)geom->getSdo_gtype();
|
||||||
int dimensions = gtype / 1000;
|
int dimensions = gtype / 1000;
|
||||||
int lrsvalue = (gtype - dimensions * 1000) / 100;
|
int lrsvalue = (gtype - dimensions * 1000) / 100;
|
||||||
int geomtype = (gtype - dimensions * 1000 - lrsvalue * 100);
|
int geomtype = (gtype - dimensions * 1000 - lrsvalue * 100);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
clog << "-----------Geometry Object ------------" << endl;
|
std::clog << "-----------Geometry Object ------------" << std::endl;
|
||||||
clog << "SDO GTYPE = " << gtype << endl;
|
std::clog << "SDO GTYPE = " << gtype << std::endl;
|
||||||
clog << "SDO DIMENSIONS = " << dimensions << endl;
|
std::clog << "SDO DIMENSIONS = " << dimensions << std::endl;
|
||||||
clog << "SDO LRS = " << lrsvalue << endl;
|
std::clog << "SDO LRS = " << lrsvalue << std::endl;
|
||||||
clog << "SDO GEOMETRY TYPE = " << geomtype << endl;
|
std::clog << "SDO GEOMETRY TYPE = " << geomtype << std::endl;
|
||||||
|
|
||||||
Number sdo_srid = geom->getSdo_srid();
|
Number sdo_srid = geom->getSdo_srid();
|
||||||
if (sdo_srid.isNull())
|
if (sdo_srid.isNull())
|
||||||
clog << "SDO SRID = " << "Null" << endl;
|
std::clog << "SDO SRID = " << "Null" << std::endl;
|
||||||
else
|
else
|
||||||
clog << "SDO SRID = " << (int) sdo_srid << endl;
|
std::clog << "SDO SRID = " << (int)sdo_srid << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const std::vector<Number>& elem_info = geom->getSdo_elem_info();
|
const std::vector<Number>& elem_info = geom->getSdo_elem_info();
|
||||||
const std::vector<Number>& ordinates = geom->getSdo_ordinates();
|
const std::vector<Number>& ordinates = geom->getSdo_ordinates();
|
||||||
const int ordinates_size = (int) ordinates.size();
|
const int ordinates_size = (int)ordinates.size();
|
||||||
|
|
||||||
switch (geomtype)
|
switch (geomtype)
|
||||||
{
|
{
|
||||||
|
@ -232,8 +238,8 @@ void occi_featureset::convert_geometry (SDOGeometry* geom, feature_ptr feature,
|
||||||
if (sdopoint && ! sdopoint->isNull())
|
if (sdopoint && ! sdopoint->isNull())
|
||||||
{
|
{
|
||||||
geometry_type* point = new geometry_type(mapnik::Point);
|
geometry_type* point = new geometry_type(mapnik::Point);
|
||||||
point->move_to (sdopoint->getX(), sdopoint->getY());
|
point->move_to(sdopoint->getX(), sdopoint->getY());
|
||||||
feature->add_geometry (point);
|
feature->add_geometry(point);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -245,14 +251,14 @@ void occi_featureset::convert_geometry (SDOGeometry* geom, feature_ptr feature,
|
||||||
const bool is_point_type = false;
|
const bool is_point_type = false;
|
||||||
const bool multiple_geoms = false;
|
const bool multiple_geoms = false;
|
||||||
|
|
||||||
convert_ordinates (feature,
|
convert_ordinates(feature,
|
||||||
mapnik::LineString,
|
mapnik::LineString,
|
||||||
elem_info,
|
elem_info,
|
||||||
ordinates,
|
ordinates,
|
||||||
dimensions,
|
dimensions,
|
||||||
is_single_geom,
|
is_single_geom,
|
||||||
is_point_type,
|
is_point_type,
|
||||||
multiple_geoms);
|
multiple_geoms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -264,14 +270,14 @@ void occi_featureset::convert_geometry (SDOGeometry* geom, feature_ptr feature,
|
||||||
const bool is_point_type = false;
|
const bool is_point_type = false;
|
||||||
const bool multiple_geoms = false;
|
const bool multiple_geoms = false;
|
||||||
|
|
||||||
convert_ordinates (feature,
|
convert_ordinates(feature,
|
||||||
mapnik::Polygon,
|
mapnik::Polygon,
|
||||||
elem_info,
|
elem_info,
|
||||||
ordinates,
|
ordinates,
|
||||||
dimensions,
|
dimensions,
|
||||||
is_single_geom,
|
is_single_geom,
|
||||||
is_point_type,
|
is_point_type,
|
||||||
multiple_geoms);
|
multiple_geoms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -286,14 +292,14 @@ void occi_featureset::convert_geometry (SDOGeometry* geom, feature_ptr feature,
|
||||||
// Todo - force using true as multiple_geometries until we have proper multipoint handling
|
// Todo - force using true as multiple_geometries until we have proper multipoint handling
|
||||||
// http://trac.mapnik.org/ticket/458
|
// http://trac.mapnik.org/ticket/458
|
||||||
|
|
||||||
convert_ordinates (feature,
|
convert_ordinates(feature,
|
||||||
mapnik::Point,
|
mapnik::Point,
|
||||||
elem_info,
|
elem_info,
|
||||||
ordinates,
|
ordinates,
|
||||||
dimensions,
|
dimensions,
|
||||||
is_single_geom,
|
is_single_geom,
|
||||||
is_point_type,
|
is_point_type,
|
||||||
multiple_geoms);
|
multiple_geoms);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -304,16 +310,15 @@ void occi_featureset::convert_geometry (SDOGeometry* geom, feature_ptr feature,
|
||||||
const bool is_single_geom = false;
|
const bool is_single_geom = false;
|
||||||
const bool is_point_type = false;
|
const bool is_point_type = false;
|
||||||
|
|
||||||
convert_ordinates (feature,
|
convert_ordinates(feature,
|
||||||
mapnik::LineString,
|
mapnik::LineString,
|
||||||
elem_info,
|
elem_info,
|
||||||
ordinates,
|
ordinates,
|
||||||
dimensions,
|
dimensions,
|
||||||
is_single_geom,
|
is_single_geom,
|
||||||
is_point_type,
|
is_point_type,
|
||||||
multiple_geometries);
|
multiple_geometries);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDO_GTYPE_MULTIPOLYGON:
|
case SDO_GTYPE_MULTIPOLYGON:
|
||||||
|
@ -323,14 +328,14 @@ void occi_featureset::convert_geometry (SDOGeometry* geom, feature_ptr feature,
|
||||||
const bool is_single_geom = false;
|
const bool is_single_geom = false;
|
||||||
const bool is_point_type = false;
|
const bool is_point_type = false;
|
||||||
|
|
||||||
convert_ordinates (feature,
|
convert_ordinates(feature,
|
||||||
mapnik::Polygon,
|
mapnik::Polygon,
|
||||||
elem_info,
|
elem_info,
|
||||||
ordinates,
|
ordinates,
|
||||||
dimensions,
|
dimensions,
|
||||||
is_single_geom,
|
is_single_geom,
|
||||||
is_point_type,
|
is_point_type,
|
||||||
multiple_geometries);
|
multiple_geometries);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -342,55 +347,56 @@ void occi_featureset::convert_geometry (SDOGeometry* geom, feature_ptr feature,
|
||||||
const bool is_single_geom = false;
|
const bool is_single_geom = false;
|
||||||
const bool is_point_type = false;
|
const bool is_point_type = false;
|
||||||
|
|
||||||
convert_ordinates (feature,
|
convert_ordinates(feature,
|
||||||
mapnik::Polygon,
|
mapnik::Polygon,
|
||||||
elem_info,
|
elem_info,
|
||||||
ordinates,
|
ordinates,
|
||||||
dimensions,
|
dimensions,
|
||||||
is_single_geom,
|
is_single_geom,
|
||||||
is_point_type,
|
is_point_type,
|
||||||
multiple_geometries);
|
multiple_geometries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SDO_GTYPE_UNKNOWN:
|
case SDO_GTYPE_UNKNOWN:
|
||||||
default:
|
default:
|
||||||
#ifdef MAPNIK_DEBUG
|
#ifdef MAPNIK_DEBUG
|
||||||
std::clog << "OCCI Plugin: unknown <occi> " << occi_enums::resolve_gtype(geomtype)
|
std::clog << "OCCI Plugin: unknown <occi> "
|
||||||
<< "(gtype=" << gtype << ")" << std::endl;
|
<< occi_enums::resolve_gtype(geomtype)
|
||||||
|
<< "(gtype=" << gtype << ")" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void occi_featureset::convert_ordinates (mapnik::feature_ptr feature,
|
void occi_featureset::convert_ordinates(mapnik::feature_ptr feature,
|
||||||
const mapnik::eGeomType& geom_type,
|
const mapnik::eGeomType& geom_type,
|
||||||
const std::vector<Number>& elem_info,
|
const std::vector<Number>& elem_info,
|
||||||
const std::vector<Number>& ordinates,
|
const std::vector<Number>& ordinates,
|
||||||
const int dimensions,
|
const int dimensions,
|
||||||
const bool is_single_geom,
|
const bool is_single_geom,
|
||||||
const bool is_point_geom,
|
const bool is_point_geom,
|
||||||
const bool multiple_geometries)
|
const bool multiple_geometries)
|
||||||
{
|
{
|
||||||
const int elem_size = elem_info.size();
|
const int elem_size = elem_info.size();
|
||||||
const int ord_size = ordinates.size();
|
const int ord_size = ordinates.size();
|
||||||
|
|
||||||
if (elem_size >= 0)
|
if (elem_size >= 0)
|
||||||
{
|
{
|
||||||
int offset = elem_info [0];
|
int offset = elem_info[0];
|
||||||
int etype = elem_info [1];
|
int etype = elem_info[1];
|
||||||
int interp = elem_info [2];
|
int interp = elem_info[2];
|
||||||
|
|
||||||
if (! is_single_geom && elem_size > SDO_ELEM_INFO_SIZE)
|
if (! is_single_geom && elem_size > SDO_ELEM_INFO_SIZE)
|
||||||
{
|
{
|
||||||
geometry_type* geom = multiple_geometries ? 0 : new geometry_type(geom_type);
|
geometry_type* geom = multiple_geometries ? 0 : new geometry_type(geom_type);
|
||||||
if (geom) geom->set_capacity (ord_size);
|
if (geom) geom->set_capacity(ord_size);
|
||||||
|
|
||||||
for (int i = SDO_ELEM_INFO_SIZE; i < elem_size; i+=3)
|
for (int i = SDO_ELEM_INFO_SIZE; i < elem_size; i+=3)
|
||||||
{
|
{
|
||||||
int next_offset = elem_info [i];
|
int next_offset = elem_info[i];
|
||||||
int next_etype = elem_info [i + 1];
|
int next_etype = elem_info[i + 1];
|
||||||
int next_interp = elem_info [i + 2];
|
int next_interp = elem_info[i + 2];
|
||||||
bool is_linear_element = true;
|
bool is_linear_element = true;
|
||||||
bool is_unknown_etype = false;
|
bool is_unknown_etype = false;
|
||||||
mapnik::eGeomType gtype = mapnik::Point;
|
mapnik::eGeomType gtype = mapnik::Point;
|
||||||
|
@ -398,14 +404,14 @@ void occi_featureset::convert_ordinates (mapnik::feature_ptr feature,
|
||||||
switch (etype)
|
switch (etype)
|
||||||
{
|
{
|
||||||
case SDO_ETYPE_POINT:
|
case SDO_ETYPE_POINT:
|
||||||
if (interp == SDO_INTERPRETATION_POINT) {}
|
if (interp == SDO_INTERPRETATION_POINT) {}
|
||||||
if (interp > SDO_INTERPRETATION_POINT) {}
|
if (interp > SDO_INTERPRETATION_POINT) {}
|
||||||
gtype = mapnik::Point;
|
gtype = mapnik::Point;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SDO_ETYPE_LINESTRING:
|
case SDO_ETYPE_LINESTRING:
|
||||||
if (interp == SDO_INTERPRETATION_STRAIGHT) {}
|
if (interp == SDO_INTERPRETATION_STRAIGHT) {}
|
||||||
if (interp == SDO_INTERPRETATION_CIRCULAR) {}
|
if (interp == SDO_INTERPRETATION_CIRCULAR) {}
|
||||||
gtype = mapnik::LineString;
|
gtype = mapnik::LineString;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -433,25 +439,29 @@ void occi_featureset::convert_ordinates (mapnik::feature_ptr feature,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_unknown_etype)
|
if (is_unknown_etype)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (is_linear_element)
|
if (is_linear_element)
|
||||||
{
|
{
|
||||||
if (multiple_geometries)
|
if (multiple_geometries)
|
||||||
{
|
{
|
||||||
if (geom)
|
if (geom)
|
||||||
feature->add_geometry (geom);
|
{
|
||||||
|
feature->add_geometry(geom);
|
||||||
|
}
|
||||||
|
|
||||||
geom = new geometry_type(gtype);
|
geom = new geometry_type(gtype);
|
||||||
geom->set_capacity ((next_offset - 1) - (offset - 1 - dimensions));
|
geom->set_capacity((next_offset - 1) - (offset - 1 - dimensions));
|
||||||
}
|
}
|
||||||
|
|
||||||
fill_geometry_type (geom,
|
fill_geometry_type(geom,
|
||||||
offset - 1,
|
offset - 1,
|
||||||
next_offset - 1,
|
next_offset - 1,
|
||||||
ordinates,
|
ordinates,
|
||||||
dimensions,
|
dimensions,
|
||||||
is_point_geom);
|
is_point_geom);
|
||||||
}
|
}
|
||||||
|
|
||||||
offset = next_offset;
|
offset = next_offset;
|
||||||
|
@ -461,45 +471,48 @@ void occi_featureset::convert_ordinates (mapnik::feature_ptr feature,
|
||||||
|
|
||||||
if (geom)
|
if (geom)
|
||||||
{
|
{
|
||||||
feature->add_geometry (geom);
|
feature->add_geometry(geom);
|
||||||
geom = 0;
|
geom = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
geometry_type * geom = new geometry_type(geom_type);
|
geometry_type * geom = new geometry_type(geom_type);
|
||||||
geom->set_capacity (ord_size);
|
geom->set_capacity(ord_size);
|
||||||
|
|
||||||
fill_geometry_type (geom,
|
fill_geometry_type(geom,
|
||||||
offset - 1,
|
offset - 1,
|
||||||
ord_size,
|
ord_size,
|
||||||
ordinates,
|
ordinates,
|
||||||
dimensions,
|
dimensions,
|
||||||
is_point_geom);
|
is_point_geom);
|
||||||
|
|
||||||
feature->add_geometry (geom);
|
feature->add_geometry(geom);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void occi_featureset::fill_geometry_type (geometry_type * geom,
|
void occi_featureset::fill_geometry_type(geometry_type* geom,
|
||||||
const int real_offset,
|
const int real_offset,
|
||||||
const int next_offset,
|
const int next_offset,
|
||||||
const std::vector<Number>& ordinates,
|
const std::vector<Number>& ordinates,
|
||||||
const int dimensions,
|
const int dimensions,
|
||||||
const bool is_point_geom)
|
const bool is_point_geom)
|
||||||
{
|
{
|
||||||
geom->move_to ((double) ordinates[real_offset], (double) ordinates[real_offset + 1]);
|
geom->move_to((double) ordinates[real_offset], (double) ordinates[real_offset + 1]);
|
||||||
|
|
||||||
if (is_point_geom)
|
if (is_point_geom)
|
||||||
{
|
{
|
||||||
for (int p = real_offset + dimensions; p < next_offset; p += dimensions)
|
for (int p = real_offset + dimensions; p < next_offset; p += dimensions)
|
||||||
geom->move_to ((double) ordinates[p], (double) ordinates[p + 1]);
|
{
|
||||||
|
geom->move_to((double) ordinates[p], (double) ordinates[p + 1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int p = real_offset + dimensions; p < next_offset; p += dimensions)
|
for (int p = real_offset + dimensions; p < next_offset; p += dimensions)
|
||||||
geom->line_to ((double) ordinates[p], (double) ordinates[p + 1]);
|
{
|
||||||
|
geom->line_to((double) ordinates[p], (double) ordinates[p + 1]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -38,40 +38,42 @@
|
||||||
|
|
||||||
class occi_featureset : public mapnik::Featureset
|
class occi_featureset : public mapnik::Featureset
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
occi_featureset(oracle::occi::StatelessConnectionPool* pool,
|
occi_featureset(oracle::occi::StatelessConnectionPool* pool,
|
||||||
oracle::occi::Connection* conn,
|
oracle::occi::Connection* conn,
|
||||||
std::string const& sqlstring,
|
std::string const& sqlstring,
|
||||||
std::string const& encoding,
|
std::string const& encoding,
|
||||||
bool multiple_geometries,
|
bool multiple_geometries,
|
||||||
bool use_connection_pool,
|
bool use_connection_pool,
|
||||||
unsigned prefetch_rows,
|
unsigned prefetch_rows,
|
||||||
unsigned num_attrs);
|
unsigned num_attrs);
|
||||||
virtual ~occi_featureset();
|
virtual ~occi_featureset();
|
||||||
mapnik::feature_ptr next();
|
mapnik::feature_ptr next();
|
||||||
private:
|
|
||||||
void convert_geometry (SDOGeometry* geom, mapnik::feature_ptr feature, bool multiple_geometries);
|
private:
|
||||||
void convert_ordinates (mapnik::feature_ptr feature,
|
void convert_geometry (SDOGeometry* geom, mapnik::feature_ptr feature, bool multiple_geometries);
|
||||||
const mapnik::eGeomType& geom_type,
|
void convert_ordinates (mapnik::feature_ptr feature,
|
||||||
const std::vector<oracle::occi::Number>& elem_info,
|
const mapnik::eGeomType& geom_type,
|
||||||
const std::vector<oracle::occi::Number>& ordinates,
|
const std::vector<oracle::occi::Number>& elem_info,
|
||||||
const int dimensions,
|
const std::vector<oracle::occi::Number>& ordinates,
|
||||||
const bool is_single_geom,
|
const int dimensions,
|
||||||
const bool is_point_geom,
|
const bool is_single_geom,
|
||||||
const bool multiple_geometries);
|
const bool is_point_geom,
|
||||||
void fill_geometry_type (mapnik::geometry_type * geom,
|
const bool multiple_geometries);
|
||||||
const int real_offset,
|
void fill_geometry_type (mapnik::geometry_type* geom,
|
||||||
const int next_offset,
|
const int real_offset,
|
||||||
const std::vector<oracle::occi::Number>& ordinates,
|
const int next_offset,
|
||||||
const int dimensions,
|
const std::vector<oracle::occi::Number>& ordinates,
|
||||||
const bool is_point_geom);
|
const int dimensions,
|
||||||
occi_connection_ptr conn_;
|
const bool is_point_geom);
|
||||||
oracle::occi::ResultSet* rs_;
|
|
||||||
boost::scoped_ptr<mapnik::transcoder> tr_;
|
occi_connection_ptr conn_;
|
||||||
const char* fidcolumn_;
|
oracle::occi::ResultSet* rs_;
|
||||||
bool multiple_geometries_;
|
boost::scoped_ptr<mapnik::transcoder> tr_;
|
||||||
unsigned num_attrs_;
|
const char* fidcolumn_;
|
||||||
mutable int feature_id_;
|
bool multiple_geometries_;
|
||||||
|
unsigned num_attrs_;
|
||||||
|
mutable int feature_id_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // OCCI_FEATURESET_HPP
|
#endif // OCCI_FEATURESET_HPP
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software, you can redistribute it and/or
|
* This library is free software, you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -25,71 +25,69 @@
|
||||||
|
|
||||||
oracle::occi::Environment* occi_environment::env_ = 0;
|
oracle::occi::Environment* occi_environment::env_ = 0;
|
||||||
|
|
||||||
|
|
||||||
std::string occi_enums::resolve_gtype(int gtype)
|
std::string occi_enums::resolve_gtype(int gtype)
|
||||||
{
|
{
|
||||||
switch(gtype)
|
switch (gtype)
|
||||||
{
|
{
|
||||||
case SDO_GTYPE_UNKNOWN: return "SDO_GTYPE_UNKNOWN";
|
case SDO_GTYPE_UNKNOWN: return "SDO_GTYPE_UNKNOWN";
|
||||||
case SDO_GTYPE_POINT: return "SDO_GTYPE_POINT";
|
case SDO_GTYPE_POINT: return "SDO_GTYPE_POINT";
|
||||||
case SDO_GTYPE_LINE: return "SDO_GTYPE_LINE";
|
case SDO_GTYPE_LINE: return "SDO_GTYPE_LINE";
|
||||||
case SDO_GTYPE_POLYGON: return "SDO_GTYPE_POLYGON";
|
case SDO_GTYPE_POLYGON: return "SDO_GTYPE_POLYGON";
|
||||||
case SDO_GTYPE_MULTIPOINT: return "SDO_GTYPE_MULTIPOINT";
|
case SDO_GTYPE_MULTIPOINT: return "SDO_GTYPE_MULTIPOINT";
|
||||||
case SDO_GTYPE_MULTILINE: return "SDO_GTYPE_MULTILINE";
|
case SDO_GTYPE_MULTILINE: return "SDO_GTYPE_MULTILINE";
|
||||||
case SDO_GTYPE_MULTIPOLYGON: return "SDO_GTYPE_MULTIPOLYGON";
|
case SDO_GTYPE_MULTIPOLYGON: return "SDO_GTYPE_MULTIPOLYGON";
|
||||||
case SDO_GTYPE_COLLECTION: return "SDO_GTYPE_COLLECTION";
|
case SDO_GTYPE_COLLECTION: return "SDO_GTYPE_COLLECTION";
|
||||||
default: return "<unknown SDO_GTYPE>";
|
default: return "<unknown SDO_GTYPE>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string occi_enums::resolve_etype(int etype)
|
std::string occi_enums::resolve_etype(int etype)
|
||||||
{
|
{
|
||||||
switch(etype)
|
switch (etype)
|
||||||
{
|
{
|
||||||
case SDO_ETYPE_UNKNOWN: return "SDO_ETYPE_UNKNOWN";
|
case SDO_ETYPE_UNKNOWN: return "SDO_ETYPE_UNKNOWN";
|
||||||
case SDO_ETYPE_POINT: return "SDO_ETYPE_POINT";
|
case SDO_ETYPE_POINT: return "SDO_ETYPE_POINT";
|
||||||
case SDO_ETYPE_LINESTRING: return "SDO_ETYPE_LINESTRING";
|
case SDO_ETYPE_LINESTRING: return "SDO_ETYPE_LINESTRING";
|
||||||
case SDO_ETYPE_POLYGON: return "SDO_ETYPE_POLYGON";
|
case SDO_ETYPE_POLYGON: return "SDO_ETYPE_POLYGON";
|
||||||
case SDO_ETYPE_POLYGON_INTERIOR: return "SDO_ETYPE_POLYGON_INTERIOR";
|
case SDO_ETYPE_POLYGON_INTERIOR: return "SDO_ETYPE_POLYGON_INTERIOR";
|
||||||
case SDO_ETYPE_COMPOUND_LINESTRING: return "SDO_ETYPE_COMPOUND_LINESTRING";
|
case SDO_ETYPE_COMPOUND_LINESTRING: return "SDO_ETYPE_COMPOUND_LINESTRING";
|
||||||
case SDO_ETYPE_COMPOUND_POLYGON: return "SDO_ETYPE_COMPOUND_POLYGON";
|
case SDO_ETYPE_COMPOUND_POLYGON: return "SDO_ETYPE_COMPOUND_POLYGON";
|
||||||
case SDO_ETYPE_COMPOUND_POLYGON_INTERIOR: return "SDO_ETYPE_COMPOUND_POLYGON_INTERIOR";
|
case SDO_ETYPE_COMPOUND_POLYGON_INTERIOR: return "SDO_ETYPE_COMPOUND_POLYGON_INTERIOR";
|
||||||
default: return "<unknown SDO_ETYPE>";
|
default: return "<unknown SDO_ETYPE>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string occi_enums::resolve_datatype(int type_id)
|
std::string occi_enums::resolve_datatype(int type_id)
|
||||||
{
|
{
|
||||||
switch(type_id)
|
switch (type_id)
|
||||||
{
|
{
|
||||||
case oracle::occi::OCCIINT: return "OCCIINT";
|
case oracle::occi::OCCIINT: return "OCCIINT";
|
||||||
case oracle::occi::OCCIUNSIGNED_INT: return "OCCIUNSIGNED_INT";
|
case oracle::occi::OCCIUNSIGNED_INT: return "OCCIUNSIGNED_INT";
|
||||||
case oracle::occi::OCCIFLOAT: return "OCCIFLOAT";
|
case oracle::occi::OCCIFLOAT: return "OCCIFLOAT";
|
||||||
case oracle::occi::OCCIBFLOAT: return "OCCIBFLOAT";
|
case oracle::occi::OCCIBFLOAT: return "OCCIBFLOAT";
|
||||||
case oracle::occi::OCCIDOUBLE: return "OCCIDOUBLE";
|
case oracle::occi::OCCIDOUBLE: return "OCCIDOUBLE";
|
||||||
case oracle::occi::OCCIBDOUBLE: return "OCCIBDOUBLE";
|
case oracle::occi::OCCIBDOUBLE: return "OCCIBDOUBLE";
|
||||||
case oracle::occi::OCCINUMBER: return "OCCINUMBER";
|
case oracle::occi::OCCINUMBER: return "OCCINUMBER";
|
||||||
case oracle::occi::OCCI_SQLT_NUM: return "OCCI_SQLT_NUM";
|
case oracle::occi::OCCI_SQLT_NUM: return "OCCI_SQLT_NUM";
|
||||||
case oracle::occi::OCCICHAR: return "OCCICHAR";
|
case oracle::occi::OCCICHAR: return "OCCICHAR";
|
||||||
case oracle::occi::OCCISTRING: return "OCCISTRING";
|
case oracle::occi::OCCISTRING: return "OCCISTRING";
|
||||||
case oracle::occi::OCCI_SQLT_AFC: return "OCCI_SQLT_AFC";
|
case oracle::occi::OCCI_SQLT_AFC: return "OCCI_SQLT_AFC";
|
||||||
case oracle::occi::OCCI_SQLT_AVC: return "OCCI_SQLT_AVC";
|
case oracle::occi::OCCI_SQLT_AVC: return "OCCI_SQLT_AVC";
|
||||||
case oracle::occi::OCCI_SQLT_CHR: return "OCCI_SQLT_CHR";
|
case oracle::occi::OCCI_SQLT_CHR: return "OCCI_SQLT_CHR";
|
||||||
case oracle::occi::OCCI_SQLT_LVC: return "OCCI_SQLT_LVC";
|
case oracle::occi::OCCI_SQLT_LVC: return "OCCI_SQLT_LVC";
|
||||||
case oracle::occi::OCCI_SQLT_STR: return "OCCI_SQLT_STR";
|
case oracle::occi::OCCI_SQLT_STR: return "OCCI_SQLT_STR";
|
||||||
case oracle::occi::OCCI_SQLT_VCS: return "OCCI_SQLT_VCS";
|
case oracle::occi::OCCI_SQLT_VCS: return "OCCI_SQLT_VCS";
|
||||||
case oracle::occi::OCCI_SQLT_VNU: return "OCCI_SQLT_VNU";
|
case oracle::occi::OCCI_SQLT_VNU: return "OCCI_SQLT_VNU";
|
||||||
case oracle::occi::OCCI_SQLT_VBI: return "OCCI_SQLT_VBI";
|
case oracle::occi::OCCI_SQLT_VBI: return "OCCI_SQLT_VBI";
|
||||||
case oracle::occi::OCCI_SQLT_VST: return "OCCI_SQLT_VST";
|
case oracle::occi::OCCI_SQLT_VST: return "OCCI_SQLT_VST";
|
||||||
case oracle::occi::OCCI_SQLT_RDD: return "OCCI_SQLT_RDD";
|
case oracle::occi::OCCI_SQLT_RDD: return "OCCI_SQLT_RDD";
|
||||||
case oracle::occi::OCCIDATE: return "OCCIDATE";
|
case oracle::occi::OCCIDATE: return "OCCIDATE";
|
||||||
case oracle::occi::OCCITIMESTAMP: return "OCCITIMESTAMP";
|
case oracle::occi::OCCITIMESTAMP: return "OCCITIMESTAMP";
|
||||||
case oracle::occi::OCCI_SQLT_DAT: return "OCCI_SQLT_DAT";
|
case oracle::occi::OCCI_SQLT_DAT: return "OCCI_SQLT_DAT";
|
||||||
case oracle::occi::OCCI_SQLT_TIMESTAMP: return "OCCI_SQLT_TIMESTAMP";
|
case oracle::occi::OCCI_SQLT_TIMESTAMP: return "OCCI_SQLT_TIMESTAMP";
|
||||||
case oracle::occi::OCCI_SQLT_TIMESTAMP_LTZ: return "OCCI_SQLT_TIMESTAMP_LTZ";
|
case oracle::occi::OCCI_SQLT_TIMESTAMP_LTZ: return "OCCI_SQLT_TIMESTAMP_LTZ";
|
||||||
case oracle::occi::OCCI_SQLT_TIMESTAMP_TZ: return "OCCI_SQLT_TIMESTAMP_TZ";
|
case oracle::occi::OCCI_SQLT_TIMESTAMP_TZ: return "OCCI_SQLT_TIMESTAMP_TZ";
|
||||||
case oracle::occi::OCCIPOBJECT: return "OCCIPOBJECT";
|
case oracle::occi::OCCIPOBJECT: return "OCCIPOBJECT";
|
||||||
default: return "<unknown ATTR_DATA_TYPE>";
|
default: return "<unknown ATTR_DATA_TYPE>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
*
|
*
|
||||||
* This file is part of Mapnik (c++ mapping toolkit)
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007 Artem Pavlenko
|
* Copyright (C) 2011 Artem Pavlenko
|
||||||
*
|
*
|
||||||
* This library is free software, you can redistribute it and/or
|
* This library is free software, you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU Lesser General Public
|
* modify it under the terms of the GNU Lesser General Public
|
||||||
|
@ -41,7 +41,6 @@
|
||||||
#error Only ORACLE 10g >= 10.2.0.X is supported !
|
#error Only ORACLE 10g >= 10.2.0.X is supported !
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// geometry types definitions
|
// geometry types definitions
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
|
@ -79,14 +78,13 @@ enum
|
||||||
SDO_INTERPRETATION_CIRCULAR = 2
|
SDO_INTERPRETATION_CIRCULAR = 2
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class occi_environment : public mapnik::singleton<occi_environment, mapnik::CreateStatic>
|
||||||
class occi_environment : public mapnik::singleton<occi_environment,mapnik::CreateStatic>
|
|
||||||
{
|
{
|
||||||
friend class mapnik::CreateStatic<occi_environment>;
|
friend class mapnik::CreateStatic<occi_environment>;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static oracle::occi::Environment* get_environment ()
|
static oracle::occi::Environment* get_environment()
|
||||||
{
|
{
|
||||||
if (env_ == 0)
|
if (env_ == 0)
|
||||||
{
|
{
|
||||||
|
@ -94,11 +92,11 @@ public:
|
||||||
std::clog << "OCCI Plugin: occi_environment constructor" << std::endl;
|
std::clog << "OCCI Plugin: occi_environment constructor" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int mode = oracle::occi::Environment::OBJECT
|
const int mode = oracle::occi::Environment::OBJECT
|
||||||
| oracle::occi::Environment::THREADED_MUTEXED;
|
| oracle::occi::Environment::THREADED_MUTEXED;
|
||||||
|
|
||||||
env_ = oracle::occi::Environment::createEnvironment ((oracle::occi::Environment::Mode) mode);
|
env_ = oracle::occi::Environment::createEnvironment((oracle::occi::Environment::Mode) mode);
|
||||||
RegisterClasses (env_);
|
RegisterClasses(env_);
|
||||||
}
|
}
|
||||||
|
|
||||||
return env_;
|
return env_;
|
||||||
|
@ -118,7 +116,7 @@ private:
|
||||||
std::clog << "OCCI Plugin: occi_environment destructor" << std::endl;
|
std::clog << "OCCI Plugin: occi_environment destructor" << std::endl;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
oracle::occi::Environment::terminateEnvironment (env_);
|
oracle::occi::Environment::terminateEnvironment(env_);
|
||||||
env_ = 0;
|
env_ = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,28 +124,27 @@ private:
|
||||||
static oracle::occi::Environment* env_;
|
static oracle::occi::Environment* env_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class occi_connection_ptr
|
class occi_connection_ptr
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit occi_connection_ptr ()
|
explicit occi_connection_ptr()
|
||||||
: env_ (occi_environment::get_environment()),
|
: env_(occi_environment::get_environment()),
|
||||||
pool_ (0),
|
pool_(0),
|
||||||
conn_ (0),
|
conn_(0),
|
||||||
stmt_ (0),
|
stmt_(0),
|
||||||
rs_ (0),
|
rs_(0),
|
||||||
owns_connection_ (false)
|
owns_connection_(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~occi_connection_ptr ()
|
~occi_connection_ptr()
|
||||||
{
|
{
|
||||||
close_query (true);
|
close_query(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void set_pool(oracle::occi::StatelessConnectionPool* pool)
|
void set_pool(oracle::occi::StatelessConnectionPool* pool)
|
||||||
{
|
{
|
||||||
close_query (true);
|
close_query(true);
|
||||||
|
|
||||||
pool_ = pool;
|
pool_ = pool;
|
||||||
conn_ = pool_->getConnection();
|
conn_ = pool_->getConnection();
|
||||||
|
@ -156,26 +153,26 @@ public:
|
||||||
|
|
||||||
void set_connection(oracle::occi::Connection* conn, bool owns_connection)
|
void set_connection(oracle::occi::Connection* conn, bool owns_connection)
|
||||||
{
|
{
|
||||||
close_query (true);
|
close_query(true);
|
||||||
|
|
||||||
pool_ = 0;
|
pool_ = 0;
|
||||||
conn_ = conn;
|
conn_ = conn;
|
||||||
owns_connection_ = owns_connection;
|
owns_connection_ = owns_connection;
|
||||||
}
|
}
|
||||||
|
|
||||||
oracle::occi::ResultSet* execute_query (const std::string& s, const unsigned prefetch = 0)
|
oracle::occi::ResultSet* execute_query(const std::string& s, const unsigned prefetch = 0)
|
||||||
{
|
{
|
||||||
close_query (false);
|
close_query(false);
|
||||||
|
|
||||||
stmt_ = conn_->createStatement (s);
|
stmt_ = conn_->createStatement(s);
|
||||||
|
|
||||||
if (prefetch > 0)
|
if (prefetch > 0)
|
||||||
{
|
{
|
||||||
stmt_->setPrefetchMemorySize (0);
|
stmt_->setPrefetchMemorySize(0);
|
||||||
stmt_->setPrefetchRowCount (prefetch);
|
stmt_->setPrefetchRowCount(prefetch);
|
||||||
}
|
}
|
||||||
|
|
||||||
rs_ = stmt_->executeQuery ();
|
rs_ = stmt_->executeQuery();
|
||||||
|
|
||||||
return rs_;
|
return rs_;
|
||||||
}
|
}
|
||||||
|
@ -186,8 +183,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void close_query(const bool release_connection)
|
||||||
void close_query (const bool release_connection)
|
|
||||||
{
|
{
|
||||||
if (conn_)
|
if (conn_)
|
||||||
{
|
{
|
||||||
|
@ -195,11 +191,11 @@ private:
|
||||||
{
|
{
|
||||||
if (rs_)
|
if (rs_)
|
||||||
{
|
{
|
||||||
stmt_->closeResultSet (rs_);
|
stmt_->closeResultSet(rs_);
|
||||||
rs_ = 0;
|
rs_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
conn_->terminateStatement (stmt_);
|
conn_->terminateStatement(stmt_);
|
||||||
stmt_ = 0;
|
stmt_ = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,7 +203,7 @@ private:
|
||||||
{
|
{
|
||||||
if (pool_)
|
if (pool_)
|
||||||
{
|
{
|
||||||
pool_->releaseConnection (conn_);
|
pool_->releaseConnection(conn_);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -230,7 +226,6 @@ private:
|
||||||
bool owns_connection_;
|
bool owns_connection_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class occi_enums
|
class occi_enums
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -240,5 +235,4 @@ public:
|
||||||
static std::string resolve_datatype(int type_id);
|
static std::string resolve_datatype(int type_id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // OCCI_TYPES_HPP
|
#endif // OCCI_TYPES_HPP
|
||||||
|
|
Loading…
Reference in a new issue