+ apply patch for Oracle 10g support from kunitoki - see #212

This commit is contained in:
Dane Springmeyer 2009-02-03 17:06:23 +00:00
parent 29cc79b9cf
commit fbe4c41700
14 changed files with 1590 additions and 4 deletions

View file

@ -93,13 +93,15 @@ opts.Add(BoolVariable('INTERNAL_LIBAGG', 'Use provided libagg', 'True'))
# Note: cairo, cairomm, and pycairo all optional but configured automatically through pkg-config # Note: cairo, cairomm, and pycairo all optional but configured automatically through pkg-config
# Therefore, we use a single boolean for whether to attempt to build cairo support. # Therefore, we use a single boolean for whether to attempt to build cairo support.
opts.Add(BoolVariable('CAIRO', 'Attempt to build with Cairo rendering support', 'True')) opts.Add(BoolVariable('CAIRO', 'Attempt to build with Cairo rendering support', 'True'))
opts.Add(ListVariable('INPUT_PLUGINS','Input drivers to include','all',['postgis','shape','raster','gdal','ogr'])) opts.Add(ListVariable('INPUT_PLUGINS','Input drivers to include','all',['postgis','shape','raster','gdal','ogr','occi']))
opts.Add(PathVariable('PGSQL_INCLUDES', 'Search path for PostgreSQL include files', '/usr/include/postgresql', PathVariable.PathAccept)) opts.Add(PathVariable('PGSQL_INCLUDES', 'Search path for PostgreSQL include files', '/usr/include/postgresql', PathVariable.PathAccept))
opts.Add(PathVariable('PGSQL_LIBS', 'Search path for PostgreSQL library files', '/usr/' + LIBDIR_SCHEMA)) opts.Add(PathVariable('PGSQL_LIBS', 'Search path for PostgreSQL library files', '/usr/' + LIBDIR_SCHEMA))
opts.Add(PathVariable('GDAL_INCLUDES', 'Search path for GDAL include files', '/usr/local/include', PathVariable.PathAccept)) opts.Add(PathVariable('GDAL_INCLUDES', 'Search path for GDAL include files', '/usr/local/include', PathVariable.PathAccept))
opts.Add(PathVariable('GDAL_LIBS', 'Search path for GDAL library files', '/usr/local/' + LIBDIR_SCHEMA)) opts.Add(PathVariable('GDAL_LIBS', 'Search path for GDAL library files', '/usr/local/' + LIBDIR_SCHEMA))
opts.Add(PathVariable('OGR_INCLUDES', 'Search path for OGR include files', '/usr/local/include', PathVariable.PathAccept)) opts.Add(PathVariable('OGR_INCLUDES', 'Search path for OGR include files', '/usr/local/include', PathVariable.PathAccept))
opts.Add(PathVariable('OGR_LIBS', 'Search path for OGR library files', '/usr/local/' + LIBDIR_SCHEMA)) opts.Add(PathVariable('OGR_LIBS', 'Search path for OGR library files', '/usr/local/' + LIBDIR_SCHEMA))
opts.Add(PathVariable('OCCI_INCLUDES', 'Search path for OCCI include files', '/usr/lib/oracle/10.2.0.3/client/include/', PathVariable.PathAccept))
opts.Add(PathVariable('OCCI_LIBS', 'Search path for OCCI library files', '/usr/lib/oracle/10.2.0.3/client/'+ LIBDIR_SCHEMA, PathVariable.PathAccept))
# Other variables # Other variables
opts.Add(PathVariable('PYTHON','Python executable', sys.executable)) opts.Add(PathVariable('PYTHON','Python executable', sys.executable))
@ -238,7 +240,7 @@ else:
# Adding the prerequisite library directories to the include path for # Adding the prerequisite library directories to the include path for
# compiling and the library path for linking, respectively. # compiling and the library path for linking, respectively.
for prereq in ('BOOST', 'PNG', 'JPEG', 'TIFF', 'PGSQL', 'PROJ', 'GDAL', 'OGR',): for prereq in ('BOOST', 'PNG', 'JPEG', 'TIFF', 'PGSQL', 'PROJ', 'GDAL', 'OGR', 'OCCI'):
inc_path = env['%s_INCLUDES' % prereq] inc_path = env['%s_INCLUDES' % prereq]
lib_path = env['%s_LIBS' % prereq] lib_path = env['%s_LIBS' % prereq]
uniq_add(env, 'CPPPATH', inc_path) uniq_add(env, 'CPPPATH', inc_path)
@ -278,7 +280,8 @@ else:
CXX_LIBSHEADERS = [ CXX_LIBSHEADERS = [
['icuuc','unicode/unistr.h',True], ['icuuc','unicode/unistr.h',True],
['icudata','unicode/utypes.h' , True], ['icudata','unicode/utypes.h' , True],
['gdal', ['gdal_priv.h', 'ogrsf_frmts.h'],False] ['gdal', ['gdal_priv.h', 'ogrsf_frmts.h'], False],
['occi', ['occi.h'], False]
] ]
@ -440,6 +443,9 @@ else:
if 'gdal' in inputplugins and 'gdal' in env['LIBS']: if 'gdal' in inputplugins and 'gdal' in env['LIBS']:
SConscript('plugins/input/gdal/SConscript') SConscript('plugins/input/gdal/SConscript')
if 'occi' in inputplugins and 'occi' in env['LIBS']:
SConscript('plugins/input/occi/SConscript')
if 'ogr' in inputplugins and 'gdal' in env['LIBS']: if 'ogr' in inputplugins and 'gdal' in env['LIBS']:
SConscript('plugins/input/ogr/SConscript') SConscript('plugins/input/ogr/SConscript')

View file

@ -0,0 +1,26 @@
if HAVE_OCCI
pkglib_LTLIBRARIES = \
occi.la
occi_la_SOURCES = \
occi_datasource.cpp\
occi_featureset.cpp\
spatial_classesm.cpp\
spatial_classeso.cpp
occi_la_LIBADD = \
${OCCI_LDFLAGS}
occi_la_CXXFLAGS = \
${OCCI_CFLAGS} \
-I../../../include
occi_la_LDFLAGS = \
-module \
-avoid-version \
-shrext .input
endif
## File created by the gnome-build tools

View file

@ -0,0 +1,8 @@
#
# To regenerate C++ class declarations & implementations for the Spatial
# object types of your database you should execute OTT
#
ott userid=scott/tiger attraccess=private intype=spatial_types.typ code=cpp \
cppfile=spatial_classeso.cpp hfile=spatial_classesh.h mapfile=spatial_classesm.cpp \
mapfunc=RegisterClasses

View file

@ -0,0 +1,45 @@
#
# This file is part of Mapnik (c++ mapping toolkit)
#
# Copyright (C) 2007 Artem Pavlenko, Jean-Francois Doyon
#
# Mapnik is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# $Id$
Import ('env')
prefix = env['PREFIX']
install_prefix = env['DESTDIR'] + '/' + prefix
occi_src = Split(
"""
occi_datasource.cpp
occi_featureset.cpp
spatial_classesm.cpp
spatial_classeso.cpp
"""
)
libraries = [ 'occi' ]
if env['PLATFORM'] == 'Darwin':
libraries.append('mapnik')
libraries.append('icuuc')
libraries.append('icudata')
occi_inputdriver = env.SharedLibrary('occi', source=occi_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries)
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + '/mapnik/input', occi_inputdriver)
env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + '/mapnik/input')

View file

@ -0,0 +1,304 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2007 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
// $Id$
#include "occi_datasource.hpp"
#include "occi_featureset.hpp"
// mapnik
#include <mapnik/ptree_helpers.hpp>
// boost
#include <boost/lexical_cast.hpp>
#include <boost/tokenizer.hpp>
// stl
#include <string>
#include <algorithm>
#include <set>
#include <sstream>
#include <iomanip>
using std::clog;
using std::endl;
using std::vector;
using mapnik::datasource;
using mapnik::parameters;
using mapnik::query;
using mapnik::featureset_ptr;
using mapnik::layer_descriptor;
using mapnik::attribute_descriptor;
using mapnik::datasource_exception;
using mapnik::Envelope;
using mapnik::coord2d;
using oracle::occi::Environment;
using oracle::occi::Connection;
using oracle::occi::Statement;
using oracle::occi::ResultSet;
using oracle::occi::MetaData;
using oracle::occi::SQLException;
using oracle::occi::Type;
using oracle::occi::StatelessConnectionPool;
DATASOURCE_PLUGIN(occi_datasource)
occi_datasource::occi_datasource(parameters const& params)
: datasource (params),
table_(*params.get<std::string>("table","")),
geometry_field_(*params.get<std::string>("geometry_field","")),
type_(datasource::Vector),
extent_initialized_(false),
desc_(*params.get<std::string>("type"),"utf-8")
{
boost::optional<int> initial_size = params_.get<int>("inital_size",1);
boost::optional<int> max_size = params_.get<int>("max_size",10);
multiple_geometries_ = *params_.get<mapnik::boolean>("multiple_geometries",false);
boost::optional<std::string> ext = params_.get<std::string>("extent");
if (ext)
{
boost::char_separator<char> sep(",");
boost::tokenizer<boost::char_separator<char> > tok(*ext,sep);
unsigned i = 0;
bool success = false;
double d[4];
for (boost::tokenizer<boost::char_separator<char> >::iterator beg=tok.begin();
beg!=tok.end();++beg)
{
try
{
d[i] = boost::lexical_cast<double>(*beg);
}
catch (boost::bad_lexical_cast & ex)
{
std::clog << ex.what() << "\n";
break;
}
if (i==3)
{
success = true;
break;
}
++i;
}
if (success)
{
extent_.init(d[0],d[1],d[2],d[3]);
extent_initialized_ = true;
}
}
// connect to environment
try
{
env_ = Environment::createEnvironment ((Environment::Mode) Environment::OBJECT); // Environment::THREADED_MUTEXED
RegisterClasses (env_);
pool_ = env_->createStatelessConnectionPool(
*params.get<std::string>("user"),
*params.get<std::string>("password"),
*params.get<std::string>("host"),
*max_size,
*initial_size,
1,
StatelessConnectionPool::HOMOGENEOUS);
}
catch (SQLException &ex)
{
throw datasource_exception(ex.getMessage());
}
// get SRID from geometry metadata
{
Connection* conn = pool_->getConnection ();
std::ostringstream s;
s << "select srid from " << SDO_GEOMETRY_METADATA_TABLE << " where";
s << " lower(table_name) = lower('" << table_ << "') and";
s << " lower(column_name) = lower('" << geometry_field_ << "')";
try
{
Statement* stmt = conn->createStatement (s.str());
ResultSet* rs = stmt->executeQuery();
if (rs->next ())
{
srid_ = rs->getInt(1);
}
stmt->closeResultSet (rs);
conn->terminateStatement (stmt);
}
catch (SQLException &ex)
{
throw datasource_exception(ex.getMessage());
}
pool_->releaseConnection (conn);
}
// get table metadata
Connection* conn = pool_->getConnection ();
MetaData metadata = conn->getMetaData(table_.c_str(), MetaData::PTYPE_TABLE);
vector<MetaData> listOfColumns = metadata.getVector(MetaData::ATTR_LIST_COLUMNS);
for (unsigned int i=0;i<listOfColumns.size();++i)
{
MetaData columnObj = listOfColumns[i];
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)
{
case oracle::occi::OCCIINT:
case oracle::occi::OCCIUNSIGNED_INT:
desc_.add_descriptor(attribute_descriptor(fld_name,mapnik::Integer));
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:
desc_.add_descriptor(attribute_descriptor(fld_name,mapnik::Double));
break;
case oracle::occi::OCCICHAR:
case oracle::occi::OCCISTRING:
case oracle::occi::OCCI_SQLT_AFC:
case oracle::occi::OCCI_SQLT_AVC:
case oracle::occi::OCCI_SQLT_CHR:
case oracle::occi::OCCI_SQLT_LVC:
case oracle::occi::OCCI_SQLT_STR:
case oracle::occi::OCCI_SQLT_VCS:
case oracle::occi::OCCI_SQLT_VNU:
case oracle::occi::OCCI_SQLT_VBI:
case oracle::occi::OCCI_SQLT_VST:
case oracle::occi::OCCI_SQLT_RDD:
desc_.add_descriptor(attribute_descriptor(fld_name,mapnik::String));
break;
case oracle::occi::OCCIDATE:
case oracle::occi::OCCITIMESTAMP:
case oracle::occi::OCCI_SQLT_DAT:
case oracle::occi::OCCI_SQLT_TIMESTAMP:
case oracle::occi::OCCI_SQLT_TIMESTAMP_LTZ:
case oracle::occi::OCCI_SQLT_TIMESTAMP_TZ:
case oracle::occi::OCCIPOBJECT:
#ifdef MAPNIK_DEBUG
clog << "unsupported type_oid="<<type_oid<<endl;
#endif
break;
default: // shouldn't get here
#ifdef MAPNIK_DEBUG
clog << "unknown type_oid="<<type_oid<<endl;
#endif
break;
}
}
pool_->releaseConnection (conn);
}
occi_datasource::~occi_datasource()
{
if (env_)
{
env_->terminateStatelessConnectionPool (pool_);
Environment::terminateEnvironment (env_);
}
}
std::string const occi_datasource::name_="occi";
std::string occi_datasource::name()
{
return name_;
}
int occi_datasource::type() const
{
return type_;
}
Envelope<double> occi_datasource::envelope() const
{
return extent_;
}
layer_descriptor occi_datasource::get_descriptor() const
{
return desc_;
}
featureset_ptr occi_datasource::features(query const& q) const
{
if (env_ && pool_)
{
Envelope<double> const& box=q.get_bbox();
std::ostringstream s;
s << "select " << geometry_field_ << " as geom";
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<<"\"";
++pos;
}
s << " from " << table_ << " where sdo_filter(" << geometry_field_ << ",";
s << " mdsys.sdo_geometry(" << SDO_GTYPE_2DPOLYGON << "," << srid_ << ",NULL,";
s << " mdsys.sdo_elem_info_array(1," << SDO_ETYPE_POLYGON << "," << SDO_INTERPRETATION_RECTANGLE << "),";
s << " mdsys.sdo_ordinate_array(";
s << std::setprecision(16);
s << box.minx() << "," << box.miny() << ", ";
s << box.maxx() << "," << box.maxy() << ")), 'querytype=WINDOW') = 'TRUE'";
#ifdef MAPNIK_DEBUG
clog << s.str() << endl;
#endif
return featureset_ptr(new occi_featureset(pool_,s.str(),desc_.get_encoding(),multiple_geometries_,props.size()));
}
return featureset_ptr();
}
featureset_ptr occi_datasource::features_at_point(coord2d const& pt) const
{
return featureset_ptr();
}

View file

@ -0,0 +1,69 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2007 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
#ifndef OCCI_DATASOURCE_HPP
#define OCCI_DATASOURCE_HPP
// mapnik
#include <mapnik/datasource.hpp>
#include <mapnik/envelope.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/feature_layer_desc.hpp>
// boost
#include <boost/shared_ptr.hpp>
// oci
#include "occi_types.hpp"
class occi_datasource : public mapnik::datasource
{
public:
occi_datasource(mapnik::parameters const& params);
virtual ~occi_datasource ();
int type() const;
static std::string name();
mapnik::featureset_ptr features(mapnik::query const& q) const;
mapnik::featureset_ptr features_at_point(mapnik::coord2d const& pt) const;
mapnik::Envelope<double> envelope() const;
mapnik::layer_descriptor get_descriptor() const;
private:
const std::string uri_;
const std::string username_;
const std::string password_;
const std::string table_;
const std::string geometry_field_;
std::string geometryColumn_;
int type_;
int srid_;
mutable bool extent_initialized_;
mutable mapnik::Envelope<double> extent_;
mapnik::layer_descriptor desc_;
oracle::occi::Environment* env_;
oracle::occi::StatelessConnectionPool* pool_;
bool multiple_geometries_;
static const std::string name_;
};
#endif // OCCI_DATASOURCE_HPP

View file

@ -0,0 +1,485 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2007 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
#include <mapnik/global.hpp>
#include <mapnik/datasource.hpp>
#include <mapnik/envelope.hpp>
#include <mapnik/geometry.hpp>
#include <mapnik/feature.hpp>
#include <mapnik/feature_layer_desc.hpp>
#include <mapnik/wkb.hpp>
#include <mapnik/unicode.hpp>
// ogr
#include "occi_featureset.hpp"
using std::clog;
using std::endl;
using std::vector;
using mapnik::query;
using mapnik::Envelope;
using mapnik::CoordTransform;
using mapnik::Feature;
using mapnik::feature_ptr;
using mapnik::point_impl;
using mapnik::line_string_impl;
using mapnik::polygon_impl;
using mapnik::geometry2d;
using mapnik::geometry_utils;
using mapnik::transcoder;
using mapnik::datasource_exception;
using oracle::occi::Connection;
using oracle::occi::Statement;
using oracle::occi::ResultSet;
using oracle::occi::StatelessConnectionPool;
using oracle::occi::MetaData;
using oracle::occi::SQLException;
using oracle::occi::Type;
using oracle::occi::Number;
occi_featureset::occi_featureset(StatelessConnectionPool * pool,
std::string const& sqlstring,
std::string const& encoding,
bool multiple_geometries,
unsigned num_attrs)
: pool_(pool),
tr_(new transcoder(encoding)),
multiple_geometries_(multiple_geometries),
num_attrs_(num_attrs),
count_(0)
{
try
{
conn_ = pool_->getConnection();
stmt_ = conn_->createStatement (sqlstring);
rs_ = stmt_->executeQuery();
}
catch (SQLException &ex)
{
throw datasource_exception(ex.getMessage());
}
}
occi_featureset::~occi_featureset()
{
stmt_->closeResultSet (rs_);
conn_->terminateStatement (stmt_);
pool_->releaseConnection (conn_);
}
feature_ptr occi_featureset::next()
{
if (rs_->next())
{
feature_ptr feature(new Feature(count_));
SDOGeometry* geom = (SDOGeometry*) rs_->getObject(1);
if (geom)
{
convert_geometry (geom, feature);
delete geom;
}
vector<MetaData> listOfColumns = rs_->getColumnListMetaData();
for (unsigned int i=1;i<listOfColumns.size();++i)
{
MetaData columnObj = listOfColumns[i];
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)
{
case oracle::occi::OCCIINT:
case oracle::occi::OCCIUNSIGNED_INT:
{
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:
case oracle::occi::OCCI_SQLT_AVC:
case oracle::occi::OCCI_SQLT_CHR:
case oracle::occi::OCCI_SQLT_LVC:
case oracle::occi::OCCI_SQLT_STR:
case oracle::occi::OCCI_SQLT_VCS:
case oracle::occi::OCCI_SQLT_VNU:
case oracle::occi::OCCI_SQLT_VBI:
case oracle::occi::OCCI_SQLT_VST:
case oracle::occi::OCCI_SQLT_RDD:
{
UnicodeString ustr = tr_->transcode (rs_->getString (i + 1).c_str());
boost::put(*feature,fld_name,ustr);
break;
}
case oracle::occi::OCCIDATE:
case oracle::occi::OCCITIMESTAMP:
case oracle::occi::OCCI_SQLT_DAT:
case oracle::occi::OCCI_SQLT_TIMESTAMP:
case oracle::occi::OCCI_SQLT_TIMESTAMP_LTZ:
case oracle::occi::OCCI_SQLT_TIMESTAMP_TZ:
case oracle::occi::OCCIPOBJECT:
{
#ifdef MAPNIK_DEBUG
clog << "unsupported type_oid="<<type_oid<<endl;
#endif
break;
}
default: // shouldn't get here
{
#ifdef MAPNIK_DEBUG
clog << "unknown type_oid="<<type_oid<<endl;
#endif
break;
}
}
}
++count_;
return feature;
}
return feature_ptr();
}
void occi_featureset::convert_geometry (SDOGeometry* geom, feature_ptr feature)
{
int gtype = (int) geom->getSdo_gtype();
int dimensions = gtype / 1000;
int lrsvalue = (gtype - dimensions * 1000) / 100;
int geomtype = (gtype - dimensions * 1000 - lrsvalue * 100);
#ifdef MAPNIK_DEBUG
clog << "-----------Geometry Object ------------" << endl;
clog << "SDO GTYPE = " << gtype << endl;
clog << "SDO DIMENSIONS = " << dimensions << endl;
clog << "SDO LRS = " << lrsvalue << endl;
clog << "SDO GEOMETRY TYPE = " << geomtype << endl;
Number sdo_srid = geom->getSdo_srid();
if (sdo_srid.isNull())
clog << "SDO SRID = " << "Null" << endl;
else
clog << "SDO SRID = " << (int) sdo_srid << endl;
#endif
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:
convert_multipoint (geom, feature, dimensions);
break;
case SDO_GTYPE_MULTILINE:
convert_multilinestring (geom, feature, dimensions);
break;
case SDO_GTYPE_MULTIPOLYGON:
convert_multipolygon (geom, feature, dimensions);
break;
case SDO_GTYPE_COLLECTION:
#ifdef MAPNIK_DEBUG
clog << "unsupported <occi> collection" << endl;
#endif
break;
case SDO_GTYPE_UNKNOWN:
default:
#ifdef MAPNIK_DEBUG
clog << "unknown <occi> geometry_type=" << 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())
{
geometry2d* point = new point_impl;
point->move_to (sdopoint->getX(), sdopoint->getY());
feature->add_geometry (point);
}
}
void occi_featureset::convert_linestring (SDOGeometry* geom, feature_ptr feature, int dimensions)
{
const vector<Number>& elem_info = geom->getSdo_elem_info();
const vector<Number>& ordinates = geom->getSdo_ordinates();
int ord_size = ordinates.size();
if (ord_size >= dimensions)
{
geometry2d * line = new line_string_impl;
line->set_capacity (ord_size);
fill_geometry2d (line, dimensions, elem_info, ordinates, false);
feature->add_geometry (line);
}
}
void occi_featureset::convert_polygon (SDOGeometry* geom, feature_ptr feature, int dimensions)
{
const vector<Number>& elem_info = geom->getSdo_elem_info();
const vector<Number>& ordinates = geom->getSdo_ordinates();
int ord_size = ordinates.size();
if (ord_size >= dimensions)
{
geometry2d * poly = new polygon_impl;
poly->set_capacity (ord_size);
fill_geometry2d (poly, dimensions, elem_info, ordinates, false);
feature->add_geometry (poly);
}
}
void occi_featureset::convert_multipoint (SDOGeometry* geom, feature_ptr feature, int dimensions)
{
const vector<Number>& elem_info = geom->getSdo_elem_info();
const vector<Number>& ordinates = geom->getSdo_ordinates();
int ord_size = ordinates.size();
if (ord_size >= dimensions)
{
geometry2d * point = new point_impl;
fill_geometry2d (point, dimensions, elem_info, ordinates, true);
feature->add_geometry (point);
}
}
/*
void occi_featureset::convert_multipoint_2 (SDOGeometry* geom, feature_ptr feature, int dimensions)
{
int num_geometries = geom->getNumGeometries ();
for (int i=0;i<num_geometries;i++)
{
convert_point (static_cast<OGRPoint*>(geom->getGeometryRef (i)), feature);
}
}
*/
void occi_featureset::convert_multilinestring (SDOGeometry* geom, feature_ptr feature, int dimensions)
{
const vector<Number>& elem_info = geom->getSdo_elem_info();
const vector<Number>& ordinates = geom->getSdo_ordinates();
int ord_size = ordinates.size();
if (ord_size >= dimensions)
{
geometry2d * line = new line_string_impl;
line->set_capacity (ord_size);
fill_geometry2d (line, dimensions, elem_info, ordinates, false);
feature->add_geometry (line);
}
}
/*
void occi_featureset::convert_multilinestring_2 (SDOGeometry* geom, feature_ptr feature, int dimensions)
{
int num_geometries = geom->getNumGeometries ();
for (int i=0;i<num_geometries;i++)
{
convert_linestring (static_cast<OGRLineString*>(geom->getGeometryRef (i)), feature);
}
}
*/
void occi_featureset::convert_multipolygon (SDOGeometry* geom, feature_ptr feature, int dimensions)
{
const vector<Number>& elem_info = geom->getSdo_elem_info();
const vector<Number>& ordinates = geom->getSdo_ordinates();
int ord_size = ordinates.size();
if (ord_size >= dimensions)
{
geometry2d * poly = new polygon_impl;
poly->set_capacity (ord_size);
fill_geometry2d (poly, dimensions, elem_info, ordinates, false);
feature->add_geometry (poly);
}
}
/*
void occi_featureset::convert_multipolygon_2 (SDOGeometry* geom, feature_ptr feature, int dimensions)
{
int num_geometries = geom->getNumGeometries ();
for (int i=0;i<num_geometries;i++)
{
convert_polygon (static_cast<OGRPolygon*>(geom->getGeometryRef (i)), feature);
}
}
*/
/*
void occi_featureset::convert_collection (SDOGeometry* geom, feature_ptr feature, int dimensions)
{
int num_geometries = geom->getNumGeometries ();
for (int i=0;i<num_geometries;i++)
{
OGRGeometry* g = geom->getGeometryRef (i);
if (g != NULL)
{
convert_geometry (g, feature);
}
}
}
*/
void occi_featureset::fill_geometry2d (geometry2d * geom,
const int dimensions,
const vector<Number>& elem_info,
const vector<Number>& ordinates,
const bool is_point_geom)
{
int elem_size = elem_info.size();
int ord_size = ordinates.size();
int offset, etype, interp;
if (elem_size >= 0)
{
offset = elem_info [0];
etype = elem_info [1];
interp = elem_info [2];
if (elem_size > SDO_ELEM_INFO_SIZE)
{
for (int i = SDO_ELEM_INFO_SIZE; i < elem_size; i+=3)
{
int next_offset = elem_info [i];
int next_etype = elem_info [i + 1];
int next_interp = elem_info [i + 2];
bool is_linear_element = true;
bool is_unknown_etype = false;
switch (etype)
{
case SDO_ETYPE_POINT:
if (interp == SDO_INTERPRETATION_POINT) {}
if (interp > SDO_INTERPRETATION_POINT) {}
break;
case SDO_ETYPE_LINESTRING:
if (interp == SDO_INTERPRETATION_STRAIGHT) {}
if (interp == SDO_INTERPRETATION_CIRCULAR) {}
break;
case SDO_ETYPE_POLYGON:
case SDO_ETYPE_POLYGON_INTERIOR:
if (interp == SDO_INTERPRETATION_STRAIGHT) {}
if (interp == SDO_INTERPRETATION_CIRCULAR) {}
if (interp == SDO_INTERPRETATION_RECTANGLE) {}
if (interp == SDO_INTERPRETATION_CIRCLE) {}
break;
case SDO_ETYPE_COMPOUND_LINESTRING:
case SDO_ETYPE_COMPOUND_POLYGON:
case SDO_ETYPE_COMPOUND_POLYGON_INTERIOR:
// interp = next ETYPE to consider
is_linear_element = false;
break;
case SDO_ETYPE_UNKNOWN: // unknown
default:
is_unknown_etype = true;
break;
}
if (is_unknown_etype)
break;
if (is_linear_element)
{
geom->move_to ((double) ordinates[offset - 1], (double) ordinates[offset]);
if (is_point_geom)
for (int p = offset + 1; p < next_offset; p += dimensions)
geom->move_to ((double) ordinates[p], (double) ordinates[p + 1]);
else
for (int p = offset + 1; p < next_offset; p += dimensions)
geom->line_to ((double) ordinates[p], (double) ordinates[p + 1]);
}
offset = next_offset;
etype = next_etype;
interp = next_interp;
}
}
else
{
geom->move_to ((double) ordinates[offset - 1], (double) ordinates[offset]);
if (is_point_geom)
for (int p = dimensions; p < ord_size; p += dimensions)
geom->move_to ((double) ordinates[p], (double) ordinates[p + 1]);
else
for (int p = dimensions; p < ord_size; p += dimensions)
geom->line_to ((double) ordinates[p], (double) ordinates[p + 1]);
}
}
}

View file

@ -0,0 +1,75 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2007 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
#ifndef OCCI_FEATURESET_HPP
#define OCCI_FEATURESET_HPP
// mapnik
#include <mapnik/datasource.hpp>
#include <mapnik/unicode.hpp>
// boost
#include <boost/scoped_ptr.hpp>
// oci
#include "occi_types.hpp"
class occi_featureset : public mapnik::Featureset
{
public:
occi_featureset(oracle::occi::StatelessConnectionPool * pool,
std::string const& sqlstring,
std::string const& encoding,
bool multiple_geometries,
unsigned num_attrs);
virtual ~occi_featureset();
mapnik::feature_ptr next();
private:
void convert_geometry (SDOGeometry* geom, mapnik::feature_ptr feature);
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);
// void convert_multipoint_2 (SDOGeometry* geom, mapnik::feature_ptr feature, int dims);
void convert_multilinestring (SDOGeometry* geom, mapnik::feature_ptr feature, int dims);
// void convert_multilinestring_2 (SDOGeometry* geom, mapnik::feature_ptr feature, int dims);
void convert_multipolygon (SDOGeometry* geom, mapnik::feature_ptr feature, int dims);
// void convert_multipolygon_2 (SDOGeometry* geom, mapnik::feature_ptr feature, int dims);
// void convert_collection (SDOGeometry* geom, mapnik::feature_ptr feature, int dims);
void fill_geometry2d (mapnik::geometry2d * geom,
const int dimensions,
const std::vector<oracle::occi::Number>& elem_info,
const std::vector<oracle::occi::Number>& ordinates,
const bool is_point_geom);
oracle::occi::StatelessConnectionPool* pool_;
oracle::occi::Connection* conn_;
oracle::occi::Statement* stmt_;
oracle::occi::ResultSet* rs_;
boost::scoped_ptr<mapnik::transcoder> tr_;
const char* fidcolumn_;
bool multiple_geometries_;
unsigned num_attrs_;
mutable int count_;
};
#endif // OCCI_FEATURESET_HPP

View file

@ -0,0 +1,78 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2007 Artem Pavlenko
*
* This library is free software, you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation, either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY, without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library, if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*****************************************************************************/
//$Id$
#ifndef OCCI_TYPES_HPP
#define OCCI_TYPES_HPP
// main OCCI include
#include <occi.h>
// OTT generated SDOGeometry classes
#include "spatial_classesh.h"
#include "spatial_classesm.h"
#if OCCI_MAJOR_VERSION == 10 && OCCI_MINOR_VERSION >= 1
// Support ORACLE 10g (>= 10.2.0.X)
#else
#error Only ORACLE 10g (>= 10.2.0.X) is supported !
#endif
#define SDO_GEOMETRY_METADATA_TABLE "ALL_SDO_GEOM_METADATA"
enum
{
SDO_GTYPE_UNKNOWN = 0,
SDO_GTYPE_POINT = 1,
SDO_GTYPE_LINE = 2,
SDO_GTYPE_POLYGON = 3,
SDO_GTYPE_COLLECTION = 4,
SDO_GTYPE_MULTIPOINT = 5,
SDO_GTYPE_MULTILINE = 6,
SDO_GTYPE_MULTIPOLYGON = 7,
SDO_GTYPE_2DPOINT = 2001,
SDO_GTYPE_2DLINE = 2002,
SDO_GTYPE_2DPOLYGON = 2003,
SDO_GTYPE_2DMULTIPOINT = 2005,
SDO_GTYPE_2DMULTILINE = 2006,
SDO_GTYPE_2DMULTIPOLYGON = 2007,
SDO_ELEM_INFO_SIZE = 3,
SDO_ETYPE_UNKNOWN = 0,
SDO_ETYPE_POINT = 1,
SDO_ETYPE_LINESTRING = 2,
SDO_ETYPE_POLYGON = 1003,
SDO_ETYPE_POLYGON_INTERIOR = 2003,
SDO_ETYPE_COMPOUND_LINESTRING = 4,
SDO_ETYPE_COMPOUND_POLYGON = 1005,
SDO_ETYPE_COMPOUND_POLYGON_INTERIOR = 2005,
SDO_INTERPRETATION_POINT = 1,
SDO_INTERPRETATION_RECTANGLE = 3,
SDO_INTERPRETATION_CIRCLE = 4,
SDO_INTERPRETATION_STRAIGHT = 1,
SDO_INTERPRETATION_CIRCULAR = 2
};
#endif // OCCI_TYPES_HPP

View file

@ -0,0 +1,147 @@
#ifndef SPATIAL_CLASSESH_ORACLE
# define SPATIAL_CLASSESH_ORACLE
#ifndef OCCI_ORACLE
# include <occi.h>
#endif
class SDOPointType;
class SDOGeometry;
/************************************************************/
// generated declarations for the SDO_POINT_TYPE object type.
/************************************************************/
class SDOPointType : public oracle::occi::PObject {
private:
oracle::occi::Number X;
oracle::occi::Number Y;
oracle::occi::Number Z;
public:
oracle::occi::Number getX() const;
void setX(const oracle::occi::Number &value);
oracle::occi::Number getY() const;
void setY(const oracle::occi::Number &value);
oracle::occi::Number getZ() const;
void setZ(const oracle::occi::Number &value);
void *operator new(size_t size);
void *operator new(size_t size, const oracle::occi::Connection * sess,
const OCCI_STD_NAMESPACE::string& table);
void *operator new(size_t, void *ctxOCCI_);
void *operator new(size_t size, const oracle::occi::Connection *sess,
const OCCI_STD_NAMESPACE::string &tableName,
const OCCI_STD_NAMESPACE::string &typeName,
const OCCI_STD_NAMESPACE::string &tableSchema,
const OCCI_STD_NAMESPACE::string &typeSchema);
OCCI_STD_NAMESPACE::string getSQLTypeName() const;
void getSQLTypeName(oracle::occi::Environment *env, void **schemaName,
unsigned int &schemaNameLen, void **typeName,
unsigned int &typeNameLen) const;
SDOPointType();
SDOPointType(void *ctxOCCI_) : oracle::occi::PObject (ctxOCCI_) { };
static void *readSQL(void *ctxOCCI_);
virtual void readSQL(oracle::occi::AnyData& streamOCCI_);
static void writeSQL(void *objOCCI_, void *ctxOCCI_);
virtual void writeSQL(oracle::occi::AnyData& streamOCCI_);
~SDOPointType();
};
/************************************************************/
// generated declarations for the SDO_GEOMETRY object type.
/************************************************************/
class SDOGeometry : public oracle::occi::PObject {
private:
oracle::occi::Number SDO_GTYPE;
oracle::occi::Number SDO_SRID;
SDOPointType * SDO_POINT;
OCCI_STD_NAMESPACE::vector< oracle::occi::Number > SDO_ELEM_INFO;
OCCI_STD_NAMESPACE::vector< oracle::occi::Number > SDO_ORDINATES;
public:
oracle::occi::Number getSdo_gtype() const;
void setSdo_gtype(const oracle::occi::Number &value);
oracle::occi::Number getSdo_srid() const;
void setSdo_srid(const oracle::occi::Number &value);
SDOPointType * getSdo_point() const;
void setSdo_point(SDOPointType * value);
OCCI_STD_NAMESPACE::vector< oracle::occi::Number >& getSdo_elem_info();
const OCCI_STD_NAMESPACE::vector< oracle::occi::Number >& getSdo_elem_info() const;
void setSdo_elem_info(const OCCI_STD_NAMESPACE::vector< oracle::occi::Number > &value);
OCCI_STD_NAMESPACE::vector< oracle::occi::Number >& getSdo_ordinates();
const OCCI_STD_NAMESPACE::vector< oracle::occi::Number >& getSdo_ordinates() const;
void setSdo_ordinates(const OCCI_STD_NAMESPACE::vector< oracle::occi::Number > &value);
void *operator new(size_t size);
void *operator new(size_t size, const oracle::occi::Connection * sess,
const OCCI_STD_NAMESPACE::string& table);
void *operator new(size_t, void *ctxOCCI_);
void *operator new(size_t size, const oracle::occi::Connection *sess,
const OCCI_STD_NAMESPACE::string &tableName,
const OCCI_STD_NAMESPACE::string &typeName,
const OCCI_STD_NAMESPACE::string &tableSchema,
const OCCI_STD_NAMESPACE::string &typeSchema);
OCCI_STD_NAMESPACE::string getSQLTypeName() const;
void getSQLTypeName(oracle::occi::Environment *env, void **schemaName,
unsigned int &schemaNameLen, void **typeName,
unsigned int &typeNameLen) const;
SDOGeometry();
SDOGeometry(void *ctxOCCI_) : oracle::occi::PObject (ctxOCCI_) { };
static void *readSQL(void *ctxOCCI_);
virtual void readSQL(oracle::occi::AnyData& streamOCCI_);
static void writeSQL(void *objOCCI_, void *ctxOCCI_);
virtual void writeSQL(oracle::occi::AnyData& streamOCCI_);
~SDOGeometry();
};
#endif

View file

@ -0,0 +1,11 @@
#ifndef SPATIAL_CLASSESM_ORACLE
# include "spatial_classesm.h"
#endif
void RegisterClasses(oracle::occi::Environment* envOCCI_)
{
oracle::occi::Map *mapOCCI_ = envOCCI_->getMap();
mapOCCI_->put("MDSYS.SDO_POINT_TYPE", &SDOPointType::readSQL, &SDOPointType::writeSQL);
mapOCCI_->put("MDSYS.SDO_GEOMETRY", &SDOGeometry::readSQL, &SDOGeometry::writeSQL);
}

View file

@ -0,0 +1,14 @@
#ifndef SPATIAL_CLASSESM_ORACLE
# define SPATIAL_CLASSESM_ORACLE
#ifndef OCCI_ORACLE
# include <occi.h>
#endif
#ifndef SPATIAL_CLASSESH_ORACLE
# include "spatial_classesh.h"
#endif
void RegisterClasses(oracle::occi::Environment* envOCCI_);
#endif

View file

@ -0,0 +1,314 @@
#ifndef SPATIAL_CLASSESH_ORACLE
# include "spatial_classesh.h"
#endif
/*****************************************************************/
// generated method implementations for the SDO_POINT_TYPE object type.
/*****************************************************************/
oracle::occi::Number SDOPointType::getX() const
{
return X;
}
void SDOPointType::setX(const oracle::occi::Number &value)
{
X = value;
}
oracle::occi::Number SDOPointType::getY() const
{
return Y;
}
void SDOPointType::setY(const oracle::occi::Number &value)
{
Y = value;
}
oracle::occi::Number SDOPointType::getZ() const
{
return Z;
}
void SDOPointType::setZ(const oracle::occi::Number &value)
{
Z = value;
}
void *SDOPointType::operator new(size_t size)
{
return oracle::occi::PObject::operator new(size);
}
void *SDOPointType::operator new(size_t size, const oracle::occi::Connection * sess,
const OCCI_STD_NAMESPACE::string& table)
{
return oracle::occi::PObject::operator new(size, sess, table,
(char *) "MDSYS.SDO_POINT_TYPE");
}
void *SDOPointType::operator new(size_t size, void *ctxOCCI_)
{
return oracle::occi::PObject::operator new(size, ctxOCCI_);
}
void *SDOPointType::operator new(size_t size,
const oracle::occi::Connection *sess,
const OCCI_STD_NAMESPACE::string &tableName,
const OCCI_STD_NAMESPACE::string &typeName,
const OCCI_STD_NAMESPACE::string &tableSchema,
const OCCI_STD_NAMESPACE::string &typeSchema)
{
return oracle::occi::PObject::operator new(size, sess, tableName,
typeName, tableSchema, typeSchema);
}
OCCI_STD_NAMESPACE::string SDOPointType::getSQLTypeName() const
{
return OCCI_STD_NAMESPACE::string("MDSYS.SDO_POINT_TYPE");
}
void SDOPointType::getSQLTypeName(oracle::occi::Environment *env, void **schemaName,
unsigned int &schemaNameLen, void **typeName, unsigned int &typeNameLen) const
{
PObject::getSQLTypeName(env, &SDOPointType::readSQL, schemaName,
schemaNameLen, typeName, typeNameLen);
}
SDOPointType::SDOPointType()
{
}
void *SDOPointType::readSQL(void *ctxOCCI_)
{
SDOPointType *objOCCI_ = new(ctxOCCI_) SDOPointType(ctxOCCI_);
oracle::occi::AnyData streamOCCI_(ctxOCCI_);
try
{
if (streamOCCI_.isNull())
objOCCI_->setNull();
else
objOCCI_->readSQL(streamOCCI_);
}
catch (oracle::occi::SQLException& excep)
{
delete objOCCI_;
excep.setErrorCtx(ctxOCCI_);
return (void *)NULL;
}
return (void *)objOCCI_;
}
void SDOPointType::readSQL(oracle::occi::AnyData& streamOCCI_)
{
X = streamOCCI_.getNumber();
Y = streamOCCI_.getNumber();
Z = streamOCCI_.getNumber();
}
void SDOPointType::writeSQL(void *objectOCCI_, void *ctxOCCI_)
{
SDOPointType *objOCCI_ = (SDOPointType *) objectOCCI_;
oracle::occi::AnyData streamOCCI_(ctxOCCI_);
try
{
if (objOCCI_->isNull())
streamOCCI_.setNull();
else
objOCCI_->writeSQL(streamOCCI_);
}
catch (oracle::occi::SQLException& excep)
{
excep.setErrorCtx(ctxOCCI_);
}
return;
}
void SDOPointType::writeSQL(oracle::occi::AnyData& streamOCCI_)
{
streamOCCI_.setNumber(X);
streamOCCI_.setNumber(Y);
streamOCCI_.setNumber(Z);
}
SDOPointType::~SDOPointType()
{
int i;
}
/*****************************************************************/
// generated method implementations for the SDO_GEOMETRY object type.
/*****************************************************************/
oracle::occi::Number SDOGeometry::getSdo_gtype() const
{
return SDO_GTYPE;
}
void SDOGeometry::setSdo_gtype(const oracle::occi::Number &value)
{
SDO_GTYPE = value;
}
oracle::occi::Number SDOGeometry::getSdo_srid() const
{
return SDO_SRID;
}
void SDOGeometry::setSdo_srid(const oracle::occi::Number &value)
{
SDO_SRID = value;
}
SDOPointType * SDOGeometry::getSdo_point() const
{
return SDO_POINT;
}
void SDOGeometry::setSdo_point(SDOPointType * value)
{
SDO_POINT = value;
}
OCCI_STD_NAMESPACE::vector< oracle::occi::Number >& SDOGeometry::getSdo_elem_info()
{
return SDO_ELEM_INFO;
}
const OCCI_STD_NAMESPACE::vector< oracle::occi::Number >& SDOGeometry::getSdo_elem_info() const
{
return SDO_ELEM_INFO;
}
void SDOGeometry::setSdo_elem_info(const OCCI_STD_NAMESPACE::vector< oracle::occi::Number > &value)
{
SDO_ELEM_INFO = value;
}
OCCI_STD_NAMESPACE::vector< oracle::occi::Number >& SDOGeometry::getSdo_ordinates()
{
return SDO_ORDINATES;
}
const OCCI_STD_NAMESPACE::vector< oracle::occi::Number >& SDOGeometry::getSdo_ordinates() const
{
return SDO_ORDINATES;
}
void SDOGeometry::setSdo_ordinates(const OCCI_STD_NAMESPACE::vector< oracle::occi::Number > &value)
{
SDO_ORDINATES = value;
}
void *SDOGeometry::operator new(size_t size)
{
return oracle::occi::PObject::operator new(size);
}
void *SDOGeometry::operator new(size_t size, const oracle::occi::Connection * sess,
const OCCI_STD_NAMESPACE::string& table)
{
return oracle::occi::PObject::operator new(size, sess, table,
(char *) "MDSYS.SDO_GEOMETRY");
}
void *SDOGeometry::operator new(size_t size, void *ctxOCCI_)
{
return oracle::occi::PObject::operator new(size, ctxOCCI_);
}
void *SDOGeometry::operator new(size_t size,
const oracle::occi::Connection *sess,
const OCCI_STD_NAMESPACE::string &tableName,
const OCCI_STD_NAMESPACE::string &typeName,
const OCCI_STD_NAMESPACE::string &tableSchema,
const OCCI_STD_NAMESPACE::string &typeSchema)
{
return oracle::occi::PObject::operator new(size, sess, tableName,
typeName, tableSchema, typeSchema);
}
OCCI_STD_NAMESPACE::string SDOGeometry::getSQLTypeName() const
{
return OCCI_STD_NAMESPACE::string("MDSYS.SDO_GEOMETRY");
}
void SDOGeometry::getSQLTypeName(oracle::occi::Environment *env, void **schemaName,
unsigned int &schemaNameLen, void **typeName, unsigned int &typeNameLen) const
{
PObject::getSQLTypeName(env, &SDOGeometry::readSQL, schemaName,
schemaNameLen, typeName, typeNameLen);
}
SDOGeometry::SDOGeometry()
{
SDO_POINT = (SDOPointType *) 0;
}
void *SDOGeometry::readSQL(void *ctxOCCI_)
{
SDOGeometry *objOCCI_ = new(ctxOCCI_) SDOGeometry(ctxOCCI_);
oracle::occi::AnyData streamOCCI_(ctxOCCI_);
try
{
if (streamOCCI_.isNull())
objOCCI_->setNull();
else
objOCCI_->readSQL(streamOCCI_);
}
catch (oracle::occi::SQLException& excep)
{
delete objOCCI_;
excep.setErrorCtx(ctxOCCI_);
return (void *)NULL;
}
return (void *)objOCCI_;
}
void SDOGeometry::readSQL(oracle::occi::AnyData& streamOCCI_)
{
SDO_GTYPE = streamOCCI_.getNumber();
SDO_SRID = streamOCCI_.getNumber();
SDO_POINT = (SDOPointType *) streamOCCI_.getObject(&SDOPointType::readSQL);
oracle::occi::getVector(streamOCCI_, SDO_ELEM_INFO);
oracle::occi::getVector(streamOCCI_, SDO_ORDINATES);
}
void SDOGeometry::writeSQL(void *objectOCCI_, void *ctxOCCI_)
{
SDOGeometry *objOCCI_ = (SDOGeometry *) objectOCCI_;
oracle::occi::AnyData streamOCCI_(ctxOCCI_);
try
{
if (objOCCI_->isNull())
streamOCCI_.setNull();
else
objOCCI_->writeSQL(streamOCCI_);
}
catch (oracle::occi::SQLException& excep)
{
excep.setErrorCtx(ctxOCCI_);
}
return;
}
void SDOGeometry::writeSQL(oracle::occi::AnyData& streamOCCI_)
{
streamOCCI_.setNumber(SDO_GTYPE);
streamOCCI_.setNumber(SDO_SRID);
streamOCCI_.setObject(SDO_POINT);
oracle::occi::setVector(streamOCCI_, SDO_ELEM_INFO);
oracle::occi::setVector(streamOCCI_, SDO_ORDINATES);
}
SDOGeometry::~SDOGeometry()
{
int i;
delete SDO_POINT;
}

View file

@ -0,0 +1,4 @@
TYPE MDSYS.SDO_POINT_TYPE AS SDOPointType
TYPE MDSYS.SDO_GEOMETRY AS SDOGeometry