- fix indentation and trailing spaces (generally coding style) in occi plugin partially related to #911

This commit is contained in:
kunitoki 2011-10-22 03:33:03 +02:00
parent 35739ae917
commit 26fbcb51ef
6 changed files with 414 additions and 398 deletions

View file

@ -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
@ -67,7 +67,6 @@ 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),
@ -124,15 +123,19 @@ 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_);
} }
} }
} }
}
void occi_datasource::bind() const void occi_datasource::bind() const
{ {
@ -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;
@ -317,13 +322,15 @@ 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 "
<< occi_enums::resolve_datatype(type_oid)
<< " (type_oid=" << type_oid << ")" << std::endl; << " (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;
} }
@ -356,7 +363,8 @@ box2d<double> occi_datasource::envelope() const
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)
{ {
@ -461,7 +469,9 @@ box2d<double> occi_datasource::envelope() const
} }
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_;
} }
@ -640,4 +650,3 @@ featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
row_prefetch_, row_prefetch_,
size); size);
} }

View file

@ -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
@ -48,6 +48,7 @@ class occi_datasource : public mapnik::datasource
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: private:
int type_; int type_;
mutable std::string table_; mutable std::string table_;
@ -68,5 +69,4 @@ class occi_datasource : public mapnik::datasource
static const std::string METADATA_TABLE; static const std::string METADATA_TABLE;
}; };
#endif // OCCI_DATASOURCE_HPP #endif // OCCI_DATASOURCE_HPP

View file

@ -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
@ -70,9 +70,13 @@ occi_featureset::occi_featureset(StatelessConnectionPool* pool,
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
{ {
@ -180,13 +184,15 @@ feature_ptr occi_featureset::next()
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 "
<< occi_enums::resolve_datatype(type_oid)
<< " (type_oid=" << type_oid << ")" << std::endl; << " (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;
} }
@ -207,17 +213,17 @@ void occi_featureset::convert_geometry (SDOGeometry* geom, feature_ptr feature,
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();
@ -313,7 +319,6 @@ void occi_featureset::convert_geometry (SDOGeometry* geom, feature_ptr feature,
is_point_type, is_point_type,
multiple_geometries); multiple_geometries);
} }
} }
break; break;
case SDO_GTYPE_MULTIPOLYGON: case SDO_GTYPE_MULTIPOLYGON:
@ -356,7 +361,8 @@ void occi_featureset::convert_geometry (SDOGeometry* geom, feature_ptr feature,
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> "
<< occi_enums::resolve_gtype(geomtype)
<< "(gtype=" << gtype << ")" << std::endl; << "(gtype=" << gtype << ")" << std::endl;
#endif #endif
break; break;
@ -433,14 +439,18 @@ 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));
@ -494,12 +504,15 @@ void occi_featureset::fill_geometry_type (geometry_type * geom,
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]);
} }
} }
}

View file

@ -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
@ -49,6 +49,7 @@ class occi_featureset : public mapnik::Featureset
unsigned num_attrs); unsigned num_attrs);
virtual ~occi_featureset(); virtual ~occi_featureset();
mapnik::feature_ptr next(); mapnik::feature_ptr next();
private: private:
void convert_geometry (SDOGeometry* geom, mapnik::feature_ptr feature, bool multiple_geometries); void convert_geometry (SDOGeometry* geom, mapnik::feature_ptr feature, bool multiple_geometries);
void convert_ordinates (mapnik::feature_ptr feature, void convert_ordinates (mapnik::feature_ptr feature,
@ -65,6 +66,7 @@ class occi_featureset : public mapnik::Featureset
const std::vector<oracle::occi::Number>& ordinates, const std::vector<oracle::occi::Number>& ordinates,
const int dimensions, const int dimensions,
const bool is_point_geom); const bool is_point_geom);
occi_connection_ptr conn_; occi_connection_ptr conn_;
oracle::occi::ResultSet* rs_; oracle::occi::ResultSet* rs_;
boost::scoped_ptr<mapnik::transcoder> tr_; boost::scoped_ptr<mapnik::transcoder> tr_;

View file

@ -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,7 +25,6 @@
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)
@ -92,4 +91,3 @@ std::string occi_enums::resolve_datatype(int type_id)
default: return "<unknown ATTR_DATA_TYPE>"; default: return "<unknown ATTR_DATA_TYPE>";
} }
} }

View file

@ -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,7 +78,6 @@ 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>;
@ -94,7 +92,7 @@ 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);
@ -126,7 +124,6 @@ private:
static oracle::occi::Environment* env_; static oracle::occi::Environment* env_;
}; };
class occi_connection_ptr class occi_connection_ptr
{ {
public: public:
@ -186,7 +183,6 @@ public:
} }
private: private:
void close_query(const bool release_connection) void close_query(const bool release_connection)
{ {
if (conn_) if (conn_)
@ -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