1.Added support for building on Darwin (Xcode 2.4.1, gcc4.0.1).
Mainly taming gcc4.0.1 (anonymous enum bug) 2.Input plug-ins now have .input extension on all platforms
This commit is contained in:
parent
0b11a73df4
commit
e0d243dcec
39 changed files with 286 additions and 195 deletions
67
SConstruct
67
SConstruct
|
@ -33,7 +33,7 @@ opts.Add(PathOption('BOOST_INCLUDES', 'Search path for boost include files', '/u
|
|||
opts.Add(PathOption('BOOST_LIBS', 'Search path for boost library files', '/usr/' + LIBDIR_SCHEMA))
|
||||
opts.Add('BOOST_TOOLKIT','Specify boost toolkit e.g. gcc41.','',False)
|
||||
|
||||
opts.Add(PathOption('FREETYPE_CONFIG', 'The path to the freetype-config executable.', '/usr/bin/freetype-config'))
|
||||
opts.Add(PathOption('FREETYPE_CONFIG', 'The path to the freetype-config executable.', '/usr/local/bin/freetype-config'))
|
||||
opts.Add(PathOption('FRIBIDI_INCLUDES', 'Search path for fribidi include files', '/usr/include'))
|
||||
opts.Add(PathOption('FRIBIDI_LIBS','Search path for fribidi include files','/usr/' + LIBDIR_SCHEMA))
|
||||
opts.Add(PathOption('PNG_INCLUDES', 'Search path for libpng include files', '/usr/include'))
|
||||
|
@ -55,7 +55,8 @@ opts.Add('BIDI', 'BIDI support', '')
|
|||
|
||||
env = Environment(ENV=os.environ, options=opts)
|
||||
env['LIBDIR_SCHEMA'] = LIBDIR_SCHEMA
|
||||
|
||||
env['PLATFORM'] = platform.uname()[0]
|
||||
print "Building on %s ..." % env['PLATFORM']
|
||||
Help(opts.GenerateHelpText(env))
|
||||
|
||||
conf = Configure(env)
|
||||
|
@ -107,7 +108,7 @@ if env['BIDI'] : C_LIBSHEADERS.append(['fribidi','fribidi/fribidi.h',True])
|
|||
|
||||
BOOST_LIBSHEADERS = [
|
||||
['thread', 'boost/thread/mutex.hpp', True],
|
||||
#['system', 'boost/system/system_error.hpp', True],
|
||||
['system', 'boost/system/system_error.hpp', True],
|
||||
['filesystem', 'boost/filesystem/operations.hpp', True],
|
||||
['regex', 'boost/regex.hpp', True],
|
||||
['program_options', 'boost/program_options.hpp', False]
|
||||
|
@ -121,10 +122,10 @@ for libinfo in C_LIBSHEADERS:
|
|||
env['BOOST_APPEND'] = ''
|
||||
|
||||
if len(env['BOOST_TOOLKIT']): toolkit = env['BOOST_TOOLKIT']
|
||||
else: toolkit = env['CC']
|
||||
else: toolkit = '' #toolkit = env['CC']
|
||||
|
||||
for count, libinfo in enumerate(BOOST_LIBSHEADERS):
|
||||
if not conf.CheckLibWithHeader('boost_%s%s' % (libinfo[0], env['BOOST_APPEND']), libinfo[1], 'C++'):
|
||||
if not conf.CheckLibWithHeader('boost_%s%s-mt' % (libinfo[0], env['BOOST_APPEND']), libinfo[1], 'C++'):
|
||||
if not conf.CheckLibWithHeader('boost_%s-%s-mt' % (libinfo[0], toolkit), libinfo[1], 'C++') and libinfo[2] and count == 0:
|
||||
print 'Could not find header or shared library for boost %s, exiting!' % libinfo[0]
|
||||
Exit(1)
|
||||
|
@ -137,6 +138,33 @@ inputplugins = [ driver.strip() for driver in Split(env['INPUT_PLUGINS'])]
|
|||
|
||||
bindings = [ binding.strip() for binding in Split(env['BINDINGS'])]
|
||||
|
||||
|
||||
# Build agg first, doesn't need anything special
|
||||
|
||||
SConscript('agg/SConscript')
|
||||
|
||||
# Build the core library
|
||||
|
||||
SConscript('src/SConscript')
|
||||
|
||||
# Build shapeindex and remove its dependency from the LIBS
|
||||
|
||||
if 'boost_program_options%s-mt' % env['BOOST_APPEND'] in env['LIBS']:
|
||||
SConscript('utils/shapeindex/SConscript')
|
||||
env['LIBS'].remove('boost_program_options%s-mt' % env['BOOST_APPEND'])
|
||||
|
||||
# Build the input plug-ins
|
||||
|
||||
if 'postgis' in inputplugins and 'pq' in env['LIBS']:
|
||||
SConscript('plugins/input/postgis/SConscript')
|
||||
env['LIBS'].remove('pq')
|
||||
|
||||
if 'shape' in inputplugins:
|
||||
SConscript('plugins/input/shape/SConscript')
|
||||
|
||||
if 'raster' in inputplugins:
|
||||
SConscript('plugins/input/raster/SConscript')
|
||||
|
||||
# Check out the Python situation
|
||||
|
||||
if 'python' in env['BINDINGS']:
|
||||
|
@ -165,35 +193,10 @@ env = conf.Finish()
|
|||
# Setup the c++ args for our own codebase
|
||||
|
||||
if env['DEBUG']:
|
||||
env.Append(CXXFLAGS = '-ansi -Wall -ftemplate-depth-100 -O0 -fno-inline -g -pthread -DDEBUG -DMAPNIK_DEBUG -DBOOST_PROPERTY_TREE_XML_PARSER_TINYXML -DTIXML_USE_STL')
|
||||
env.Append(CXXFLAGS = '-ansi -Wall -ftemplate-depth-100 -O0 -fno-inline -g -DDEBUG -DMAPNIK_DEBUG -D%s -DBOOST_PROPERTY_TREE_XML_PARSER_TINYXML -DTIXML_USE_STL' % env['PLATFORM'].upper() )
|
||||
else:
|
||||
env.Append(CXXFLAGS = '-ansi -Wall -ftemplate-depth-100 -O3 -finline-functions -Wno-inline -pthread -DNDEBUG -DBOOST_PROPERTY_TREE_XML_PARSER_TINYXML -DTIXML_USE_STL')
|
||||
env.Append(CXXFLAGS = '-ansi -Wall -ftemplate-depth-100 -O3 -finline-functions -Wno-inline -DNDEBUG -D%s -DBOOST_PROPERTY_TREE_XML_PARSER_TINYXML -DTIXML_USE_STL' % env['PLATFORM'].upper())
|
||||
|
||||
# Build agg first, doesn't need anything special
|
||||
|
||||
SConscript('agg/SConscript')
|
||||
|
||||
# Build shapeindex and remove its dependency from the LIBS
|
||||
|
||||
if 'boost_program_options%s' % env['BOOST_APPEND'] in env['LIBS']:
|
||||
SConscript('utils/shapeindex/SConscript')
|
||||
env['LIBS'].remove('boost_program_options%s' % env['BOOST_APPEND'])
|
||||
|
||||
# Build the input plug-ins
|
||||
|
||||
if 'postgis' in inputplugins and 'pq' in env['LIBS']:
|
||||
SConscript('plugins/input/postgis/SConscript')
|
||||
env['LIBS'].remove('pq')
|
||||
|
||||
if 'shape' in inputplugins:
|
||||
SConscript('plugins/input/shape/SConscript')
|
||||
|
||||
if 'raster' in inputplugins:
|
||||
SConscript('plugins/input/raster/SConscript')
|
||||
|
||||
# Build the core library
|
||||
|
||||
SConscript('src/SConscript')
|
||||
|
||||
# Install some free default fonts
|
||||
|
||||
|
|
|
@ -27,9 +27,16 @@ prefix = env['PYTHON_PREFIX'] + '/'+ 'lib' + '/python' + env['PYTHON_VERSION'] +
|
|||
install_prefix = env['DESTDIR'] + '/' + prefix
|
||||
|
||||
libraries = ['mapnik', 'boost_python%s' % env['BOOST_APPEND']]
|
||||
|
||||
if env['PLATFORM'] == 'Darwin':
|
||||
libraries.append('boost_regex%s' % env['BOOST_APPEND'])
|
||||
linkflags = '-F/ -framework Python'
|
||||
else :
|
||||
linkflags = ''
|
||||
|
||||
headers = [env['PYTHON_PREFIX'] + '/include/python' + env['PYTHON_VERSION']] + env['CPPPATH']
|
||||
|
||||
_mapnik = env.SharedLibrary('_mapnik', glob.glob('*.cpp'), LIBS=libraries, SHLIBPREFIX='', CPPPATH=headers)
|
||||
_mapnik = env.SharedLibrary('_mapnik', glob.glob('*.cpp'), LIBS=libraries, SHLIBPREFIX='', SHLIBSUFFIX='.so', CPPPATH=headers,LINKFLAGS=linkflags)
|
||||
|
||||
paths = """
|
||||
mapniklibpath = '%s'
|
||||
|
|
|
@ -117,10 +117,10 @@ namespace mapnik {
|
|||
|
||||
inline std::string to_hex_string() const
|
||||
{
|
||||
return (boost::format("#%1$02x%2$02x%3$02x")
|
||||
% red()
|
||||
% green()
|
||||
% blue() ).str();
|
||||
return (boost::format("#%1$02x%2$02x%3$02x")
|
||||
% red()
|
||||
% green()
|
||||
% blue() ).str();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace mapnik {
|
|||
class MAPNIK_DECL datasource : private boost::noncopyable
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
enum datasource_t {
|
||||
Vector,
|
||||
Raster
|
||||
};
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace mapnik
|
|||
using std::vector;
|
||||
using std::clog;
|
||||
|
||||
enum {
|
||||
enum eAttributeType {
|
||||
Integer=1,
|
||||
Float =2,
|
||||
Double =3,
|
||||
|
|
|
@ -126,7 +126,7 @@ namespace mapnik
|
|||
class node_data
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
enum node_e {
|
||||
Unknown=0,
|
||||
Integer=1,
|
||||
Real =2,
|
||||
|
|
|
@ -328,9 +328,9 @@ namespace mapnik
|
|||
FT_Vector start;
|
||||
unsigned height = pixmap_.height();
|
||||
|
||||
start.x = unsigned(x0 * (1 << 6));
|
||||
start.y = unsigned((height - y0) * (1 << 6));
|
||||
|
||||
start.x = x0 * (1 << 6);
|
||||
start.y = (height - y0) * (1 << 6);
|
||||
|
||||
// std::clog << "Render text at: " << x0 << "," << y0 << " " << start.x << "," << start.y << std::endl;
|
||||
|
||||
// now render transformed glyphs
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include <mapnik/geom_util.hpp>
|
||||
|
||||
namespace mapnik {
|
||||
enum {
|
||||
enum GeomType {
|
||||
Point = 1,
|
||||
LineString = 2,
|
||||
Polygon = 3
|
||||
|
@ -62,7 +62,7 @@ namespace mapnik {
|
|||
{
|
||||
Envelope<double> result;
|
||||
double x,y;
|
||||
rewind(0);
|
||||
rewind(0);
|
||||
for (unsigned i=0;i<num_points();++i)
|
||||
{
|
||||
vertex(&x,&y);
|
||||
|
@ -167,11 +167,12 @@ namespace mapnik {
|
|||
|
||||
void label_position(double *x, double *y) const
|
||||
{
|
||||
|
||||
unsigned size = cont_.size();
|
||||
if (size < 4)
|
||||
if (size < 3)
|
||||
{
|
||||
x=0;y=0;
|
||||
return;
|
||||
cont_.get_vertex(0,x,y);
|
||||
return;
|
||||
}
|
||||
|
||||
double ai;
|
||||
|
@ -184,7 +185,7 @@ namespace mapnik {
|
|||
double y1 =0;
|
||||
|
||||
unsigned i,j;
|
||||
for (i = size-2,j = 0; j < size-1; i = j, ++j)
|
||||
for (i = size-1,j = 0; j < size; i = j, ++j)
|
||||
{
|
||||
cont_.get_vertex(i,&x0,&y0);
|
||||
cont_.get_vertex(j,&x1,&y1);
|
||||
|
|
|
@ -29,7 +29,9 @@
|
|||
|
||||
namespace mapnik
|
||||
{
|
||||
using namespace boost;
|
||||
using boost::int32_t;
|
||||
using boost::uint8_t;
|
||||
|
||||
#define int2net(A) (int32_t) (((uint32_t) ((uint8_t) (A)[1])) | \
|
||||
(((uint32_t) ((uint8_t) (A)[0])) << 8))
|
||||
|
||||
|
|
|
@ -163,14 +163,17 @@ namespace mapnik {
|
|||
public:
|
||||
explicit transcoder (std::string const& encoding)
|
||||
{
|
||||
desc_ = iconv_open("UCS-2",encoding.c_str());
|
||||
//desc_ = iconv_open("UCS-2",encoding.c_str());
|
||||
}
|
||||
|
||||
std::wstring transcode(std::string const& input) const
|
||||
{
|
||||
//return to_unicode(input);
|
||||
return to_unicode(input);
|
||||
/*
|
||||
std::string buf(input.size() * 2,0);
|
||||
size_t inleft = input.size();
|
||||
char * in = const_cast<char*>(input.data());
|
||||
const char * in = input.data();
|
||||
size_t outleft = buf.size();
|
||||
char * out = const_cast<char*>(buf.data());
|
||||
|
||||
|
@ -207,11 +210,12 @@ namespace mapnik {
|
|||
}
|
||||
#endif
|
||||
return unicode;
|
||||
*/
|
||||
}
|
||||
|
||||
~transcoder()
|
||||
{
|
||||
iconv_close(desc_);
|
||||
//iconv_close(desc_);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
@ -527,14 +527,14 @@ namespace mapnik {
|
|||
return value(boost::apply_visitor(impl::div<value>(),p1.base_, p2.base_));
|
||||
}
|
||||
|
||||
template <typename charT, typename traits>
|
||||
inline std::basic_ostream<charT,traits>&
|
||||
operator << (std::basic_ostream<charT,traits>& out,
|
||||
value const& v)
|
||||
{
|
||||
out << v.to_string();
|
||||
return out;
|
||||
}
|
||||
template <typename charT, typename traits>
|
||||
inline std::basic_ostream<charT,traits>&
|
||||
operator << (std::basic_ostream<charT,traits>& out,
|
||||
value const& v)
|
||||
{
|
||||
out << v.to_string();
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
||||
#endif //VALUE_HPP
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
namespace mapnik
|
||||
{
|
||||
enum {
|
||||
enum CommandType {
|
||||
SEG_END =0,
|
||||
SEG_MOVETO=1,
|
||||
SEG_LINETO=2,
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace mapnik
|
|||
{
|
||||
typedef typename T::type value_type;
|
||||
typedef vertex<value_type,2> vertex_type;
|
||||
enum {
|
||||
enum block_e {
|
||||
block_shift = 8,
|
||||
block_size = 1<<block_shift,
|
||||
block_mask = block_size - 1,
|
||||
|
|
|
@ -31,7 +31,13 @@ postgis_src = Split(
|
|||
"""
|
||||
)
|
||||
|
||||
postgis_inputdriver = env.SharedLibrary('postgis', source=postgis_src, SHLIBPREFIX='', LIBS='pq')
|
||||
libraries = ['pq']
|
||||
|
||||
if env['PLATFORM'] == 'Darwin':
|
||||
libraries.append('mapnik')
|
||||
libraries.append('iconv')
|
||||
|
||||
postgis_inputdriver = env.SharedLibrary('postgis', source=postgis_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries)
|
||||
|
||||
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + '/mapnik/input', postgis_inputdriver)
|
||||
env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + '/mapnik/input')
|
||||
|
|
|
@ -32,10 +32,7 @@ extern "C"
|
|||
|
||||
#include "resultset.hpp"
|
||||
|
||||
using namespace mapnik;
|
||||
|
||||
class ResultSet;
|
||||
|
||||
class Connection
|
||||
{
|
||||
private:
|
||||
|
|
|
@ -32,8 +32,11 @@
|
|||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
using namespace mapnik;
|
||||
using mapnik::Pool;
|
||||
using mapnik::singleton;
|
||||
using mapnik::CreateStatic;
|
||||
using std::string;
|
||||
using boost::mutex;
|
||||
|
||||
template <typename T>
|
||||
class ConnectionCreator
|
||||
|
|
|
@ -43,6 +43,9 @@ using boost::lexical_cast;
|
|||
using boost::bad_lexical_cast;
|
||||
using boost::shared_ptr;
|
||||
|
||||
using mapnik::PoolGuard;
|
||||
using mapnik::attribute_descriptor;
|
||||
|
||||
postgis_datasource::postgis_datasource(parameters const& params)
|
||||
: datasource (params),
|
||||
table_(params.get("table")),
|
||||
|
|
|
@ -29,15 +29,24 @@
|
|||
#include <mapnik/datasource.hpp>
|
||||
#include <mapnik/envelope.hpp>
|
||||
#include <mapnik/feature.hpp>
|
||||
|
||||
#include <mapnik/feature_layer_desc.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
#include <set>
|
||||
|
||||
#include "connection_manager.hpp"
|
||||
|
||||
using namespace mapnik;
|
||||
class mapnik::transcoder;
|
||||
using mapnik::transcoder;
|
||||
using mapnik::datasource;
|
||||
using mapnik::Envelope;
|
||||
using mapnik::layer_descriptor;
|
||||
using mapnik::featureset_ptr;
|
||||
using mapnik::feature_ptr;
|
||||
using mapnik::query;
|
||||
using mapnik::parameters;
|
||||
using mapnik::coord2d;
|
||||
|
||||
class transcoder;
|
||||
class postgis_datasource : public datasource
|
||||
{
|
||||
static const std::string GEOMETRY_COLUMNS;
|
||||
|
@ -69,7 +78,7 @@ class postgis_datasource : public datasource
|
|||
postgis_datasource& operator=(const postgis_datasource&);
|
||||
};
|
||||
|
||||
class postgis_featureset : public Featureset
|
||||
class postgis_featureset : public mapnik::Featureset
|
||||
{
|
||||
private:
|
||||
boost::shared_ptr<ResultSet> rs_;
|
||||
|
|
|
@ -32,6 +32,10 @@ using boost::lexical_cast;
|
|||
using boost::bad_lexical_cast;
|
||||
using boost::trim;
|
||||
using std::string;
|
||||
using mapnik::Feature;
|
||||
using mapnik::geometry_ptr;
|
||||
using mapnik::byte;
|
||||
using mapnik::geometry_utils;
|
||||
|
||||
postgis_featureset::postgis_featureset(boost::shared_ptr<ResultSet> const& rs,
|
||||
std::string const& encoding,
|
||||
|
@ -48,8 +52,8 @@ feature_ptr postgis_featureset::next()
|
|||
{
|
||||
feature_ptr feature(new Feature(count_));
|
||||
int size=rs_->getFieldLength(0);
|
||||
const char *data=rs_->getValue(0);
|
||||
geometry_ptr geom=geometry_utils::from_wkb(data,size,-1);
|
||||
const char *data = rs_->getValue(0);
|
||||
geometry_ptr geom = geometry_utils::from_wkb(data,size,-1);
|
||||
totalGeomSize_+=size;
|
||||
|
||||
if (geom)
|
||||
|
|
|
@ -32,7 +32,11 @@ raster_src = Split(
|
|||
"""
|
||||
)
|
||||
|
||||
raster_inputdriver = env.SharedLibrary('raster', source=raster_src, SHLIBPREFIX='', LIBS=[])
|
||||
libraries = []
|
||||
if env['PLATFORM'] == 'Darwin':
|
||||
libraries.append('mapnik')
|
||||
|
||||
raster_inputdriver = env.SharedLibrary('raster', source=raster_src, SHLIBPREFIX='', SHLIBSUFFIX='.input', LIBS=libraries)
|
||||
|
||||
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + '/mapnik/input', raster_inputdriver)
|
||||
env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + '/mapnik/input')
|
||||
|
|
|
@ -30,12 +30,19 @@
|
|||
|
||||
#include "raster_datasource.hpp"
|
||||
|
||||
using mapnik::datasource;
|
||||
using mapnik::parameters;
|
||||
|
||||
DATASOURCE_PLUGIN(raster_datasource)
|
||||
|
||||
using std::clog;
|
||||
using std::endl;
|
||||
using boost::lexical_cast;
|
||||
using boost::bad_lexical_cast;
|
||||
using mapnik::layer_descriptor;
|
||||
using mapnik::featureset_ptr;
|
||||
using mapnik::query;
|
||||
using mapnik::coord2d;
|
||||
|
||||
raster_datasource::raster_datasource(const parameters& params)
|
||||
: datasource (params),
|
||||
|
|
|
@ -28,30 +28,28 @@
|
|||
#include <mapnik/feature.hpp>
|
||||
#include <mapnik/datasource.hpp>
|
||||
|
||||
using namespace mapnik;
|
||||
|
||||
class raster_datasource : public datasource
|
||||
class raster_datasource : public mapnik::datasource
|
||||
{
|
||||
private:
|
||||
std::string filename_;
|
||||
std::string format_;
|
||||
mapnik::Envelope<double> extent_;
|
||||
layer_descriptor desc_;
|
||||
static std::string name_;
|
||||
public:
|
||||
raster_datasource(const parameters& params);
|
||||
virtual ~raster_datasource();
|
||||
int type() const;
|
||||
static std::string name();
|
||||
featureset_ptr features(const query& q) const;
|
||||
featureset_ptr features_at_point(coord2d const& pt) const;
|
||||
mapnik::Envelope<double> envelope() const;
|
||||
layer_descriptor get_descriptor() const;
|
||||
private:
|
||||
//no copying
|
||||
raster_datasource(const raster_datasource&);
|
||||
raster_datasource& operator=(const raster_datasource&);
|
||||
//
|
||||
private:
|
||||
std::string filename_;
|
||||
std::string format_;
|
||||
mapnik::Envelope<double> extent_;
|
||||
mapnik::layer_descriptor desc_;
|
||||
static std::string name_;
|
||||
public:
|
||||
raster_datasource(const mapnik::parameters& params);
|
||||
virtual ~raster_datasource();
|
||||
int type() const;
|
||||
static std::string name();
|
||||
mapnik::featureset_ptr features(const mapnik::query& 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:
|
||||
//no copying
|
||||
raster_datasource(const raster_datasource&);
|
||||
raster_datasource& operator=(const raster_datasource&);
|
||||
//
|
||||
};
|
||||
|
||||
#endif //RASTER_DATASOURCE_H
|
||||
|
|
|
@ -25,14 +25,22 @@
|
|||
|
||||
#include "raster_featureset.hpp"
|
||||
|
||||
using mapnik::query;
|
||||
using mapnik::CoordTransform;
|
||||
using mapnik::ImageReader;
|
||||
using mapnik::Feature;
|
||||
using mapnik::feature_ptr;
|
||||
using mapnik::ImageData32;
|
||||
using mapnik::raster;
|
||||
|
||||
template <typename LookupPolicy>
|
||||
raster_featureset<LookupPolicy>::raster_featureset(LookupPolicy const& policy,
|
||||
query const& q)
|
||||
: policy_(policy),
|
||||
id_(1),
|
||||
extent_(q.get_bbox()),
|
||||
curIter_(policy_.query(extent_)),
|
||||
endIter_(policy_.end())
|
||||
: policy_(policy),
|
||||
id_(1),
|
||||
extent_(q.get_bbox()),
|
||||
curIter_(policy_.query(extent_)),
|
||||
endIter_(policy_.end())
|
||||
{}
|
||||
|
||||
template <typename LookupPolicy>
|
||||
|
@ -41,35 +49,35 @@ raster_featureset<LookupPolicy>::~raster_featureset() {}
|
|||
template <typename LookupPolicy>
|
||||
feature_ptr raster_featureset<LookupPolicy>::next()
|
||||
{
|
||||
if (curIter_!=endIter_)
|
||||
{
|
||||
feature_ptr feature(new Feature(+id_));
|
||||
try
|
||||
{
|
||||
std::auto_ptr<ImageReader> reader(get_image_reader(curIter_->format(),curIter_->file()));
|
||||
if (reader.get())
|
||||
if (curIter_!=endIter_)
|
||||
{
|
||||
feature_ptr feature(new Feature(+id_));
|
||||
try
|
||||
{
|
||||
std::auto_ptr<ImageReader> reader(mapnik::get_image_reader(curIter_->format(),curIter_->file()));
|
||||
if (reader.get())
|
||||
{
|
||||
int image_width=reader->width();
|
||||
int image_height=reader->height();
|
||||
if (image_width>0 && image_height>0)
|
||||
{
|
||||
int image_width=reader->width();
|
||||
int image_height=reader->height();
|
||||
if (image_width>0 && image_height>0)
|
||||
{
|
||||
CoordTransform t(image_width,image_height,curIter_->envelope(),0,0);
|
||||
Envelope<double> intersect=extent_.intersect(curIter_->envelope());
|
||||
Envelope<double> ext=t.forward(intersect);
|
||||
CoordTransform t(image_width,image_height,curIter_->envelope(),0,0);
|
||||
Envelope<double> intersect=extent_.intersect(curIter_->envelope());
|
||||
Envelope<double> ext=t.forward(intersect);
|
||||
|
||||
ImageData32 image((int)ext.width(),(int)ext.height());
|
||||
reader->read((int)ext.minx(),(int)ext.miny(),image);
|
||||
feature->set_raster(raster_ptr(new raster(intersect,image)));
|
||||
}
|
||||
ImageData32 image((int)ext.width(),(int)ext.height());
|
||||
reader->read((int)ext.minx(),(int)ext.miny(),image);
|
||||
feature->set_raster(mapnik::raster_ptr(new raster(intersect,image)));
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
++curIter_;
|
||||
return feature;
|
||||
}
|
||||
return feature_ptr();
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
}
|
||||
++curIter_;
|
||||
return feature;
|
||||
}
|
||||
return feature_ptr();
|
||||
}
|
||||
|
||||
template class raster_featureset<single_file_policy>;
|
||||
|
|
|
@ -27,15 +27,13 @@
|
|||
#include "raster_datasource.hpp"
|
||||
#include "raster_info.hpp"
|
||||
|
||||
using std::vector;
|
||||
|
||||
class single_file_policy
|
||||
{
|
||||
raster_info info_;
|
||||
public:
|
||||
class const_iterator
|
||||
{
|
||||
enum {start,end};
|
||||
enum iterator_e {start,end};
|
||||
bool status_;
|
||||
const single_file_policy* p_;
|
||||
public:
|
||||
|
@ -96,18 +94,18 @@ public:
|
|||
};
|
||||
|
||||
template <typename LookupPolicy>
|
||||
class raster_featureset : public Featureset
|
||||
class raster_featureset : public mapnik::Featureset
|
||||
{
|
||||
typedef typename LookupPolicy::const_iterator iterator_type;
|
||||
LookupPolicy policy_;
|
||||
size_t id_;
|
||||
Envelope<double> extent_;
|
||||
iterator_type curIter_;
|
||||
iterator_type endIter_;
|
||||
typedef typename LookupPolicy::const_iterator iterator_type;
|
||||
LookupPolicy policy_;
|
||||
size_t id_;
|
||||
mapnik::Envelope<double> extent_;
|
||||
iterator_type curIter_;
|
||||
iterator_type endIter_;
|
||||
public:
|
||||
raster_featureset(LookupPolicy const& policy,query const& q);
|
||||
virtual ~raster_featureset();
|
||||
feature_ptr next();
|
||||
raster_featureset(LookupPolicy const& policy,mapnik::query const& q);
|
||||
virtual ~raster_featureset();
|
||||
mapnik::feature_ptr next();
|
||||
};
|
||||
|
||||
#endif //RASTER_FEATURESET_HH
|
||||
|
|
|
@ -37,7 +37,12 @@ shape_src = Split(
|
|||
"""
|
||||
)
|
||||
|
||||
shape_inputdriver = env.SharedLibrary('shape', source=shape_src, SHLIBPREFIX='', LIBS=[])
|
||||
libraries = []
|
||||
if env['PLATFORM'] == 'Darwin':
|
||||
libraries.append('mapnik')
|
||||
libraries.append('iconv')
|
||||
|
||||
shape_inputdriver = env.SharedLibrary('shape', SHLIBSUFFIX='.input', source=shape_src, SHLIBPREFIX='', LIBS = libraries)
|
||||
|
||||
env.Install(install_prefix + '/' + env['LIBDIR_SCHEMA'] + '/mapnik/input', shape_inputdriver)
|
||||
env.Alias('install', install_prefix + '/' + env['LIBDIR_SCHEMA'] + '/mapnik/input')
|
||||
|
|
|
@ -30,9 +30,10 @@
|
|||
|
||||
#include <mapnik/feature.hpp>
|
||||
|
||||
using namespace mapnik;
|
||||
|
||||
using mapnik::transcoder;
|
||||
using mapnik::Feature;
|
||||
class mapnik::transcoder;
|
||||
|
||||
struct field_descriptor
|
||||
{
|
||||
int index_;
|
||||
|
|
|
@ -26,11 +26,18 @@
|
|||
#include <mapnik/geom_util.hpp>
|
||||
#include "shape_featureset.hpp"
|
||||
#include "shape_index_featureset.hpp"
|
||||
|
||||
#include "shape.hpp"
|
||||
|
||||
DATASOURCE_PLUGIN(shape_datasource)
|
||||
|
||||
using mapnik::String;
|
||||
using mapnik::Double;
|
||||
using mapnik::Integer;
|
||||
using mapnik::datasource_exception;
|
||||
using mapnik::filter_in_box;
|
||||
using mapnik::filter_at_point;
|
||||
using mapnik::attribute_descriptor;
|
||||
|
||||
shape_datasource::shape_datasource(const parameters ¶ms)
|
||||
: datasource (params) ,
|
||||
shape_name_(params.get("file")),
|
||||
|
@ -55,18 +62,18 @@ shape_datasource::shape_datasource(const parameters ¶ms)
|
|||
case 'D':
|
||||
case 'M':
|
||||
case 'L':
|
||||
desc_.add_descriptor(attribute_descriptor(fld_name,mapnik::String));
|
||||
//desc_.add_descriptor(attribute_descriptor(fld_name, String));
|
||||
break;
|
||||
case 'N':
|
||||
case 'F':
|
||||
{
|
||||
if (fd.dec_>0)
|
||||
{
|
||||
desc_.add_descriptor(attribute_descriptor(fld_name,mapnik::Double,false,8));
|
||||
//desc_.add_descriptor(attribute_descriptor(fld_name,Double,false,8));
|
||||
}
|
||||
else
|
||||
{
|
||||
desc_.add_descriptor(attribute_descriptor(fld_name,mapnik::Integer,false,4));
|
||||
//desc_.add_descriptor(attribute_descriptor(fld_name,Integer,false,4));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -114,6 +121,7 @@ void shape_datasource::init(shape_io& shape)
|
|||
#else
|
||||
shape.shp().skip(4);
|
||||
#endif
|
||||
|
||||
shape.shp().read_envelope(extent_);
|
||||
shape.shp().skip(4*8);
|
||||
|
||||
|
@ -125,7 +133,7 @@ void shape_datasource::init(shape_io& shape)
|
|||
indexed_=true;
|
||||
file.close();
|
||||
}
|
||||
|
||||
|
||||
#ifdef MAPNIK_DEBUG
|
||||
std::clog << extent_ << std::endl;
|
||||
std::clog << "file_length=" << file_length_ << std::endl;
|
||||
|
|
|
@ -30,7 +30,12 @@
|
|||
|
||||
#include "shape_io.hpp"
|
||||
|
||||
using namespace mapnik;
|
||||
using mapnik::datasource;
|
||||
using mapnik::parameters;
|
||||
using mapnik::query;
|
||||
using mapnik::featureset_ptr;
|
||||
using mapnik::layer_descriptor;
|
||||
using mapnik::coord2d;
|
||||
|
||||
class shape_datasource : public datasource
|
||||
{
|
||||
|
|
|
@ -58,6 +58,8 @@ shape_featureset<filterT>::shape_featureset(const filterT& filter,
|
|||
template <typename filterT>
|
||||
feature_ptr shape_featureset<filterT>::next()
|
||||
{
|
||||
|
||||
using mapnik::point_impl;
|
||||
std::streampos pos=shape_.shp().pos();
|
||||
|
||||
if (pos < std::streampos(file_length_ * 2))
|
||||
|
@ -194,7 +196,7 @@ feature_ptr shape_featureset<filterT>::next()
|
|||
template <typename filterT>
|
||||
shape_featureset<filterT>::~shape_featureset() {}
|
||||
|
||||
template class shape_featureset<filter_in_box>;
|
||||
template class shape_featureset<filter_at_point>;
|
||||
template class shape_featureset<mapnik::filter_in_box>;
|
||||
template class shape_featureset<mapnik::filter_at_point>;
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,9 @@
|
|||
#include <mapnik/geom_util.hpp>
|
||||
#include "shape.hpp"
|
||||
|
||||
using namespace mapnik;
|
||||
using mapnik::Featureset;
|
||||
using mapnik::Envelope;
|
||||
using mapnik::feature_ptr;
|
||||
|
||||
template <typename filterT>
|
||||
class shape_featureset : public Featureset
|
||||
|
|
|
@ -71,12 +71,14 @@ shape_index_featureset<filterT>::shape_index_featureset(const filterT& filter,
|
|||
template <typename filterT>
|
||||
feature_ptr shape_index_featureset<filterT>::next()
|
||||
{
|
||||
|
||||
if (itr_!=ids_.end())
|
||||
using mapnik::feature_factory;
|
||||
using mapnik::point_impl;
|
||||
if (itr_!=ids_.end())
|
||||
{
|
||||
int pos=*itr_++;
|
||||
shape_.move_to(pos);
|
||||
int type=shape_.type();
|
||||
|
||||
feature_ptr feature(feature_factory::create(shape_.id_));
|
||||
|
||||
if (type==shape_io::shape_point)
|
||||
|
@ -198,6 +200,6 @@ feature_ptr shape_index_featureset<filterT>::next()
|
|||
template <typename filterT>
|
||||
shape_index_featureset<filterT>::~shape_index_featureset() {}
|
||||
|
||||
template class shape_index_featureset<filter_in_box>;
|
||||
template class shape_index_featureset<filter_at_point>;
|
||||
template class shape_index_featureset<mapnik::filter_in_box>;
|
||||
template class shape_index_featureset<mapnik::filter_at_point>;
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "shape.hpp"
|
||||
|
||||
|
||||
using mapnik::datasource_exception;
|
||||
const std::string shape_io::SHP = ".shp";
|
||||
const std::string shape_io::DBF = ".dbf";
|
||||
|
||||
|
@ -91,6 +92,7 @@ dbf_file& shape_io::dbf()
|
|||
|
||||
geometry_ptr shape_io::read_polyline()
|
||||
{
|
||||
using mapnik::line_string_impl;
|
||||
shape_record record(reclength_*2-36);
|
||||
shp_.read_record(record);
|
||||
int num_parts=record.read_ndr_integer();
|
||||
|
@ -145,6 +147,7 @@ geometry_ptr shape_io::read_polyline()
|
|||
|
||||
geometry_ptr shape_io::read_polylinem()
|
||||
{
|
||||
using mapnik::line_string_impl;
|
||||
shape_record record(reclength_*2-36);
|
||||
shp_.read_record(record);
|
||||
int num_parts=record.read_ndr_integer();
|
||||
|
@ -206,7 +209,8 @@ geometry_ptr shape_io::read_polylinem()
|
|||
}
|
||||
|
||||
geometry_ptr shape_io::read_polylinez()
|
||||
{
|
||||
{
|
||||
using mapnik::line_string_impl;
|
||||
shape_record record(reclength_*2-36);
|
||||
shp_.read_record(record);
|
||||
int num_parts=record.read_ndr_integer();
|
||||
|
@ -276,6 +280,7 @@ geometry_ptr shape_io::read_polylinez()
|
|||
|
||||
geometry_ptr shape_io::read_polygon()
|
||||
{
|
||||
using mapnik::polygon_impl;
|
||||
shape_record record(reclength_*2-36);
|
||||
shp_.read_record(record);
|
||||
int num_parts=record.read_ndr_integer();
|
||||
|
@ -316,6 +321,7 @@ geometry_ptr shape_io::read_polygon()
|
|||
|
||||
geometry_ptr shape_io::read_polygonm()
|
||||
{
|
||||
using mapnik::polygon_impl;
|
||||
shape_record record(reclength_*2-36);
|
||||
shp_.read_record(record);
|
||||
int num_parts=record.read_ndr_integer();
|
||||
|
@ -364,6 +370,7 @@ geometry_ptr shape_io::read_polygonm()
|
|||
|
||||
geometry_ptr shape_io::read_polygonz()
|
||||
{
|
||||
using mapnik::polygon_impl;
|
||||
shape_record record(reclength_*2-36);
|
||||
shp_.read_record(record);
|
||||
int num_parts=record.read_ndr_integer();
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include <mapnik/envelope.hpp>
|
||||
|
||||
using namespace mapnik;
|
||||
using mapnik::Envelope;
|
||||
|
||||
struct shape_record
|
||||
{
|
||||
|
|
|
@ -76,5 +76,5 @@ void shp_index<filterT>::read_envelope(std::ifstream& file,Envelope<double>& env
|
|||
file.read(reinterpret_cast<char*>(&envelope),sizeof(envelope));
|
||||
}
|
||||
|
||||
template class shp_index<filter_in_box>;
|
||||
template class shp_index<filter_at_point>;
|
||||
template class shp_index<mapnik::filter_in_box>;
|
||||
template class shp_index<mapnik::filter_at_point>;
|
||||
|
|
|
@ -30,7 +30,8 @@
|
|||
#include <mapnik/envelope.hpp>
|
||||
#include <mapnik/query.hpp>
|
||||
|
||||
using namespace mapnik;
|
||||
using mapnik::Envelope;
|
||||
using mapnik::query;
|
||||
|
||||
template <typename filterT>
|
||||
class shp_index
|
||||
|
|
|
@ -29,7 +29,10 @@ install_prefix = env['DESTDIR'] + '/' + prefix
|
|||
|
||||
libraries = ['agg'] + env['LIBS']
|
||||
|
||||
linkflags = '-Wl,-rpath-link,. -Wl,-soname,libmapnik.so'
|
||||
if env['PLATFORM'] == 'Darwin':
|
||||
linkflags = ' '
|
||||
else: # Linux and others
|
||||
linkflags = '-Wl,-rpath-link,. -Wl,-soname,libmapnik.so'
|
||||
|
||||
source = Split(
|
||||
"""
|
||||
|
|
|
@ -47,7 +47,7 @@ namespace mapnik
|
|||
|
||||
std::map<string,boost::shared_ptr<PluginInfo> > datasource_cache::plugins_;
|
||||
bool datasource_cache::registered_=false;
|
||||
|
||||
|
||||
datasource_ptr datasource_cache::create(const parameters& params)
|
||||
{
|
||||
datasource_ptr ds;
|
||||
|
@ -108,7 +108,7 @@ namespace mapnik
|
|||
{
|
||||
if (!is_directory( *itr ) && itr->leaf()[0]!='.')
|
||||
{
|
||||
lt_dlhandle module=lt_dlopenext(itr->string().c_str());
|
||||
lt_dlhandle module=lt_dlopen(itr->string().c_str());
|
||||
if (module)
|
||||
{
|
||||
datasource_name* ds_name =
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace mapnik
|
|||
int tile_width_;
|
||||
int tile_height_;
|
||||
public:
|
||||
enum {
|
||||
enum TiffType {
|
||||
generic=1,
|
||||
stripped,
|
||||
tiled
|
||||
|
|
|
@ -21,51 +21,52 @@
|
|||
*****************************************************************************/
|
||||
//$Id: quadtree.hh 17 2005-03-08 23:58:43Z pavlenko $
|
||||
|
||||
#ifndef QUADTREE_HH
|
||||
#define QUADTREE_HH
|
||||
#ifndef QUADTREE_HPP
|
||||
#define QUADTREE_HPP
|
||||
// stl
|
||||
#include <vector>
|
||||
#include <fstream>
|
||||
// mapnik
|
||||
#include <mapnik/envelope.hpp>
|
||||
|
||||
using namespace mapnik;
|
||||
using mapnik::Envelope;
|
||||
using mapnik::coord2d;
|
||||
|
||||
template <typename T>
|
||||
struct quadtree_node
|
||||
{
|
||||
Envelope<double> ext_;
|
||||
std::vector<T> data_;
|
||||
quadtree_node<T>* children_[4];
|
||||
quadtree_node(const Envelope<double>& ext)
|
||||
: ext_(ext),data_()
|
||||
{
|
||||
memset(children_,0,sizeof(quadtree_node<T>*)*4);
|
||||
}
|
||||
Envelope<double> ext_;
|
||||
std::vector<T> data_;
|
||||
quadtree_node<T>* children_[4];
|
||||
quadtree_node(const Envelope<double>& ext)
|
||||
: ext_(ext),data_()
|
||||
{
|
||||
memset(children_,0,sizeof(quadtree_node<T>*)*4);
|
||||
}
|
||||
|
||||
~quadtree_node()
|
||||
{
|
||||
for (int i=0;i<4;++i)
|
||||
{
|
||||
~quadtree_node()
|
||||
{
|
||||
for (int i=0;i<4;++i)
|
||||
{
|
||||
if (children_[i])
|
||||
{
|
||||
delete children_[i],children_[i]=0;
|
||||
delete children_[i],children_[i]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int num_subnodes() const
|
||||
{
|
||||
int count=0;
|
||||
for (int i=0;i<4;++i)
|
||||
{
|
||||
int num_subnodes() const
|
||||
{
|
||||
int count=0;
|
||||
for (int i=0;i<4;++i)
|
||||
{
|
||||
if (children_[i])
|
||||
{
|
||||
++count;
|
||||
++count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
@ -294,4 +295,4 @@ private:
|
|||
}
|
||||
}
|
||||
};
|
||||
#endif //QUADTREE_HH
|
||||
#endif //QUADTREE_HPP
|
||||
|
|
Loading…
Reference in a new issue