+ geojson generator interface

This commit is contained in:
Artem Pavlenko 2012-02-20 10:53:58 +00:00
parent 8e40537c48
commit 3953a94636
4 changed files with 90 additions and 0 deletions

View file

@ -194,6 +194,7 @@ if env['HAS_PYCAIRO']:
py_env.ParseConfig('pkg-config --cflags pycairo')
py_env.Append(CXXFLAGS = '-DHAVE_PYCAIRO')
libraries.append('boost_thread%s' % env['BOOST_APPEND'])
_mapnik = py_env.LoadableModule('mapnik/_mapnik', sources, LIBS=libraries, LDMODULEPREFIX='', LDMODULESUFFIX='.so',LINKFLAGS=linkflags)
Depends(_mapnik, env.subst('../../src/%s' % env['MAPNIK_LIB_NAME']))

View file

@ -0,0 +1,48 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2012 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 MAPNIK_GEOJSON_GENERATOR_HPP
#define MAPNIK_GEOJSON_GENERATOR_HPP
#include <mapnik/feature.hpp>
#include <boost/scoped_ptr.hpp>
#include <string>
namespace mapnik { namespace json {
template <typename OutputIterator> struct feature_generator;
class geojson_generator
{
typedef std::back_insert_iterator<std::string> sink_type;
public:
geojson_generator();
~geojson_generator();
bool generate(std::string & geojson, mapnik::Feature const& f);
private:
boost::scoped_ptr<feature_generator<sink_type> > grammar_;
};
}}
#endif //MAPNIK_GEOJSON_GENERATOR_HPP

View file

@ -162,6 +162,7 @@ source = Split(
svg_transform_parser.cpp
warp.cpp
json/feature_collection_parser.cpp
json/geojson_generator.cpp
markers_placement.cpp
processed_text.cpp
formatting/base.cpp

View file

@ -0,0 +1,40 @@
/*****************************************************************************
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2012 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
*
*****************************************************************************/
#include <mapnik/json/geojson_generator.hpp>
#include <mapnik/json/feature_generator.hpp>
#include <boost/spirit/include/karma.hpp>
namespace mapnik { namespace json {
geojson_generator::geojson_generator()
: grammar_(new feature_generator<sink_type>()) {}
geojson_generator::~geojson_generator() {}
bool geojson_generator::generate(std::string & geojson, mapnik::Feature const& f)
{
sink_type sink(geojson);
return karma::generate(sink, *grammar_,f);
}
}}