fix duplicate feature to geojson code

This commit is contained in:
artemp 2016-11-17 10:33:05 +01:00
parent 190023a085
commit ca96d3e137
2 changed files with 12 additions and 22 deletions

View file

@ -2,7 +2,7 @@
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 Artem Pavlenko
* Copyright (C) 2016 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,23 +20,18 @@
*
*****************************************************************************/
#ifndef MAPNIK_FEATURE_TO_GEOJSON_HPP
#define MAPNIK_FEATURE_TO_GEOJSON_HPP
#ifndef MAPNIK_UTIL_FEATURE_TO_GEOJSON_HPP
#define MAPNIK_UTIL_FEATURE_TO_GEOJSON_HPP
// mapnik
#include <mapnik/json/feature_generator_grammar.hpp>
#include <mapnik/feature.hpp>
// stl
#include <string>
namespace mapnik { namespace util {
inline bool to_geojson(std::string & json, mapnik::feature_impl const& feat)
{
using sink_type = std::back_insert_iterator<std::string>;
static const mapnik::json::feature_generator_grammar<sink_type, mapnik::feature_impl> grammar;
sink_type sink(json);
return boost::spirit::karma::generate(sink, grammar, feat);
}
bool to_geojson(std::string & json, mapnik::feature_impl const& feat);
}}
#endif // MAPNIK_FEATURE_TO_GEOJSON_HPP
#endif // MAPNIK_UTIL_FEATURE_TO_GEOJSON_HPP

View file

@ -2,7 +2,7 @@
*
* This file is part of Mapnik (c++ mapping toolkit)
*
* Copyright (C) 2015 Artem Pavlenko
* Copyright (C) 2016 Artem Pavlenko
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@ -20,19 +20,16 @@
*
*****************************************************************************/
#ifndef MAPNIK_JSON_FEATURE_GENERATOR_HPP
#define MAPNIK_JSON_FEATURE_GENERATOR_HPP
// mapnik
#include <mapnik/feature.hpp>
#include <mapnik/util/feature_to_geojson.hpp>
#include <mapnik/json/feature_generator_grammar.hpp>
// boost
#include <boost/spirit/include/karma.hpp>
namespace mapnik { namespace json {
namespace mapnik { namespace util {
inline bool to_geojson(std::string & json, mapnik::feature_impl const& feature)
bool to_geojson(std::string & json, mapnik::feature_impl const& feature)
{
using sink_type = std::back_insert_iterator<std::string>;
static const mapnik::json::feature_generator_grammar<sink_type, mapnik::feature_impl> grammar;
@ -41,5 +38,3 @@ inline bool to_geojson(std::string & json, mapnik::feature_impl const& feature)
}
}}
#endif // MAPNIK_JSON_FEATURE_GENERATOR_HPP