+ consistent [h,c]pp files naming
This commit is contained in:
parent
df8022fb3f
commit
ec0436fcd9
7 changed files with 152 additions and 101 deletions
|
@ -28,8 +28,8 @@ plugin_env = env.Clone()
|
||||||
|
|
||||||
postgis_src = Split(
|
postgis_src = Split(
|
||||||
"""
|
"""
|
||||||
postgis.cpp
|
postgis_datasource.cpp
|
||||||
postgisfs.cpp
|
postgis_featureset.cpp
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,6 @@ extern "C"
|
||||||
|
|
||||||
#include "resultset.hpp"
|
#include "resultset.hpp"
|
||||||
|
|
||||||
class ResultSet;
|
|
||||||
class Connection
|
class Connection
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -32,7 +32,8 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "connection_manager.hpp"
|
#include "connection_manager.hpp"
|
||||||
#include "postgis.hpp"
|
#include "postgis_datasource.hpp"
|
||||||
|
#include "postgis_featureset.hpp"
|
||||||
|
|
||||||
// boost
|
// boost
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
|
@ -22,17 +22,17 @@
|
||||||
|
|
||||||
//$Id: postgis.hpp 44 2005-04-22 18:53:54Z pavlenko $
|
//$Id: postgis.hpp 44 2005-04-22 18:53:54Z pavlenko $
|
||||||
|
|
||||||
#ifndef POSTGIS_HPP
|
#ifndef POSTGIS_DATASOURCE_HPP
|
||||||
#define POSTGIS_HPP
|
#define POSTGIS_DATASOURCE_HPP
|
||||||
|
|
||||||
|
|
||||||
|
// mapnik
|
||||||
#include <mapnik/datasource.hpp>
|
#include <mapnik/datasource.hpp>
|
||||||
#include <mapnik/box2d.hpp>
|
#include <mapnik/box2d.hpp>
|
||||||
#include <mapnik/feature.hpp>
|
|
||||||
#include <mapnik/feature_layer_desc.hpp>
|
#include <mapnik/feature_layer_desc.hpp>
|
||||||
|
|
||||||
|
// boost
|
||||||
#include <boost/lexical_cast.hpp>
|
#include <boost/lexical_cast.hpp>
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
#include <set>
|
|
||||||
|
|
||||||
#include "connection_manager.hpp"
|
#include "connection_manager.hpp"
|
||||||
#include "resultset.hpp"
|
#include "resultset.hpp"
|
||||||
|
@ -48,7 +48,6 @@ using mapnik::query;
|
||||||
using mapnik::parameters;
|
using mapnik::parameters;
|
||||||
using mapnik::coord2d;
|
using mapnik::coord2d;
|
||||||
|
|
||||||
//class transcoder;
|
|
||||||
class postgis_datasource : public datasource
|
class postgis_datasource : public datasource
|
||||||
{
|
{
|
||||||
static const std::string GEOMETRY_COLUMNS;
|
static const std::string GEOMETRY_COLUMNS;
|
||||||
|
@ -98,25 +97,4 @@ class postgis_datasource : public datasource
|
||||||
postgis_datasource& operator=(const postgis_datasource&);
|
postgis_datasource& operator=(const postgis_datasource&);
|
||||||
};
|
};
|
||||||
|
|
||||||
class postgis_featureset : public mapnik::Featureset
|
#endif //POSTGIS_DATASOURCE_HPP
|
||||||
{
|
|
||||||
private:
|
|
||||||
boost::shared_ptr<IResultSet> rs_;
|
|
||||||
bool multiple_geometries_;
|
|
||||||
unsigned num_attrs_;
|
|
||||||
boost::scoped_ptr<mapnik::transcoder> tr_;
|
|
||||||
mutable int totalGeomSize_;
|
|
||||||
mutable int feature_id_;
|
|
||||||
public:
|
|
||||||
postgis_featureset(boost::shared_ptr<IResultSet> const& rs,
|
|
||||||
std::string const& encoding,
|
|
||||||
bool multiple_geometries,
|
|
||||||
unsigned num_attrs);
|
|
||||||
feature_ptr next();
|
|
||||||
~postgis_featureset();
|
|
||||||
private:
|
|
||||||
postgis_featureset(const postgis_featureset&);
|
|
||||||
const postgis_featureset& operator=(const postgis_featureset&);
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //POSTGIS_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) 2006 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
|
||||||
|
@ -20,18 +20,24 @@
|
||||||
*
|
*
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
//$Id: postgisfs.cc 34 2005-04-04 13:27:23Z pavlenko $
|
//$Id$
|
||||||
|
|
||||||
#include <boost/lexical_cast.hpp>
|
// mapnik
|
||||||
#include <boost/algorithm/string.hpp>
|
|
||||||
#include <mapnik/global.hpp>
|
#include <mapnik/global.hpp>
|
||||||
#include <mapnik/wkb.hpp>
|
#include <mapnik/wkb.hpp>
|
||||||
#include <mapnik/unicode.hpp>
|
#include <mapnik/unicode.hpp>
|
||||||
#include <mapnik/sql_utils.hpp>
|
#include <mapnik/sql_utils.hpp>
|
||||||
#include <mapnik/feature_factory.hpp>
|
#include <mapnik/feature_factory.hpp>
|
||||||
|
#include "postgis_featureset.hpp"
|
||||||
|
#include "resultset.hpp"
|
||||||
|
#include "cursorresultset.hpp"
|
||||||
|
|
||||||
#include "postgis.hpp"
|
// boost
|
||||||
|
#include <boost/lexical_cast.hpp>
|
||||||
|
#include <boost/algorithm/string.hpp>
|
||||||
|
// stl
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
using boost::lexical_cast;
|
using boost::lexical_cast;
|
||||||
using boost::bad_lexical_cast;
|
using boost::bad_lexical_cast;
|
||||||
|
@ -66,74 +72,74 @@ feature_ptr postgis_featureset::next()
|
||||||
|
|
||||||
for (unsigned pos=1;pos<num_attrs_+1;++pos)
|
for (unsigned pos=1;pos<num_attrs_+1;++pos)
|
||||||
{
|
{
|
||||||
std::string name = rs_->getFieldName(pos);
|
std::string name = rs_->getFieldName(pos);
|
||||||
|
|
||||||
if (!rs_->isNull(pos))
|
if (!rs_->isNull(pos))
|
||||||
{
|
{
|
||||||
const char* buf=rs_->getValue(pos);
|
const char* buf=rs_->getValue(pos);
|
||||||
int oid = rs_->getTypeOID(pos);
|
int oid = rs_->getTypeOID(pos);
|
||||||
|
|
||||||
if (oid==16) //bool
|
if (oid==16) //bool
|
||||||
{
|
{
|
||||||
boost::put(*feature,name,buf[0] != 0);
|
boost::put(*feature,name,buf[0] != 0);
|
||||||
}
|
}
|
||||||
else if (oid==23) //int4
|
else if (oid==23) //int4
|
||||||
{
|
{
|
||||||
int val = int4net(buf);
|
int val = int4net(buf);
|
||||||
boost::put(*feature,name,val);
|
|
||||||
}
|
|
||||||
else if (oid==21) //int2
|
|
||||||
{
|
|
||||||
int val = int2net(buf);
|
|
||||||
boost::put(*feature,name,val);
|
|
||||||
}
|
|
||||||
else if (oid==20) //int8/BigInt
|
|
||||||
{
|
|
||||||
int val = int8net(buf);
|
|
||||||
boost::put(*feature,name,val);
|
|
||||||
}
|
|
||||||
else if (oid == 700) // float4
|
|
||||||
{
|
|
||||||
float val;
|
|
||||||
float4net(val,buf);
|
|
||||||
boost::put(*feature,name,val);
|
|
||||||
}
|
|
||||||
else if (oid == 701) // float8
|
|
||||||
{
|
|
||||||
double val;
|
|
||||||
float8net(val,buf);
|
|
||||||
boost::put(*feature,name,val);
|
|
||||||
}
|
|
||||||
else if (oid==25 || oid==1043) // text or varchar
|
|
||||||
{
|
|
||||||
UnicodeString ustr = tr_->transcode(buf);
|
|
||||||
boost::put(*feature,name,ustr);
|
|
||||||
}
|
|
||||||
else if (oid==1042)
|
|
||||||
{
|
|
||||||
UnicodeString ustr = tr_->transcode(trim_copy(string(buf)).c_str()); // bpchar
|
|
||||||
boost::put(*feature,name,ustr);
|
|
||||||
}
|
|
||||||
else if (oid == 1700) // numeric
|
|
||||||
{
|
|
||||||
std::string str = mapnik::numeric2string(buf);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
double val = boost::lexical_cast<double>(str);
|
|
||||||
boost::put(*feature,name,val);
|
boost::put(*feature,name,val);
|
||||||
}
|
}
|
||||||
catch (boost::bad_lexical_cast & ex)
|
else if (oid==21) //int2
|
||||||
{
|
{
|
||||||
std::clog << ex.what() << "\n";
|
int val = int2net(buf);
|
||||||
}
|
boost::put(*feature,name,val);
|
||||||
}
|
}
|
||||||
else
|
else if (oid==20) //int8/BigInt
|
||||||
{
|
{
|
||||||
|
int val = int8net(buf);
|
||||||
|
boost::put(*feature,name,val);
|
||||||
|
}
|
||||||
|
else if (oid == 700) // float4
|
||||||
|
{
|
||||||
|
float val;
|
||||||
|
float4net(val,buf);
|
||||||
|
boost::put(*feature,name,val);
|
||||||
|
}
|
||||||
|
else if (oid == 701) // float8
|
||||||
|
{
|
||||||
|
double val;
|
||||||
|
float8net(val,buf);
|
||||||
|
boost::put(*feature,name,val);
|
||||||
|
}
|
||||||
|
else if (oid==25 || oid==1043) // text or varchar
|
||||||
|
{
|
||||||
|
UnicodeString ustr = tr_->transcode(buf);
|
||||||
|
boost::put(*feature,name,ustr);
|
||||||
|
}
|
||||||
|
else if (oid==1042)
|
||||||
|
{
|
||||||
|
UnicodeString ustr = tr_->transcode(trim_copy(std::string(buf)).c_str()); // bpchar
|
||||||
|
boost::put(*feature,name,ustr);
|
||||||
|
}
|
||||||
|
else if (oid == 1700) // numeric
|
||||||
|
{
|
||||||
|
std::string str = mapnik::numeric2string(buf);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
double val = boost::lexical_cast<double>(str);
|
||||||
|
boost::put(*feature,name,val);
|
||||||
|
}
|
||||||
|
catch (boost::bad_lexical_cast & ex)
|
||||||
|
{
|
||||||
|
std::clog << ex.what() << "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
#ifdef MAPNIK_DEBUG
|
#ifdef MAPNIK_DEBUG
|
||||||
std::clog << "Postgis Plugin: uknown OID = " << oid << " FIXME " << std::endl;
|
std::clog << "Postgis Plugin: uknown OID = " << oid << " FIXME " << std::endl;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return feature;
|
return feature;
|
||||||
}
|
}
|
64
plugins/input/postgis/postgis_featureset.hpp
Normal file
64
plugins/input/postgis/postgis_featureset.hpp
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
|
||||||
|
/*****************************************************************************
|
||||||
|
*
|
||||||
|
* This file is part of Mapnik (c++ mapping toolkit)
|
||||||
|
*
|
||||||
|
* Copyright (C) 2011 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
|
||||||
|
*
|
||||||
|
*****************************************************************************/
|
||||||
|
|
||||||
|
#ifndef POSTGIS_FEATURESET_HPP
|
||||||
|
#define POSTGIS_FEATURESET_HPP
|
||||||
|
|
||||||
|
// mapnik
|
||||||
|
#include <mapnik/box2d.hpp>
|
||||||
|
#include <mapnik/datasource.hpp>
|
||||||
|
#include <mapnik/feature.hpp>
|
||||||
|
|
||||||
|
// boost
|
||||||
|
|
||||||
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
|
||||||
|
using mapnik::Featureset;
|
||||||
|
using mapnik::box2d;
|
||||||
|
using mapnik::feature_ptr;
|
||||||
|
using mapnik::transcoder;
|
||||||
|
|
||||||
|
class IResultSet;
|
||||||
|
|
||||||
|
class postgis_featureset : public mapnik::Featureset
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
boost::shared_ptr<IResultSet> rs_;
|
||||||
|
bool multiple_geometries_;
|
||||||
|
unsigned num_attrs_;
|
||||||
|
boost::scoped_ptr<mapnik::transcoder> tr_;
|
||||||
|
int totalGeomSize_;
|
||||||
|
int feature_id_;
|
||||||
|
public:
|
||||||
|
postgis_featureset(boost::shared_ptr<IResultSet> const& rs,
|
||||||
|
std::string const& encoding,
|
||||||
|
bool multiple_geometries,
|
||||||
|
unsigned num_attrs);
|
||||||
|
mapnik::feature_ptr next();
|
||||||
|
~postgis_featureset();
|
||||||
|
private:
|
||||||
|
postgis_featureset(const postgis_featureset&);
|
||||||
|
const postgis_featureset& operator=(const postgis_featureset&);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // POSTGIS_FEATURESET_HPP
|
|
@ -26,7 +26,10 @@
|
||||||
#ifndef RESULTSET_HPP
|
#ifndef RESULTSET_HPP
|
||||||
#define RESULTSET_HPP
|
#define RESULTSET_HPP
|
||||||
|
|
||||||
#include "connection.hpp"
|
extern "C"
|
||||||
|
{
|
||||||
|
#include "libpq-fe.h"
|
||||||
|
}
|
||||||
|
|
||||||
class IResultSet
|
class IResultSet
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue