/usr/include/mapnik/json/feature_collection_grammar.hpp is in libmapnik-dev 2.2.0+ds1-7+b2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 | /*****************************************************************************
*
* 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_FEATURE_COLLECTION_GRAMMAR_HPP
#define MAPNIK_FEATURE_COLLECTION_GRAMMAR_HPP
// mapnik
#include <mapnik/unicode.hpp>
#include <mapnik/json/feature_grammar.hpp>
#include <mapnik/feature.hpp>
// spirit::qi
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
namespace mapnik { namespace json {
namespace qi = boost::spirit::qi;
namespace phoenix = boost::phoenix;
namespace standard_wide = boost::spirit::standard_wide;
using standard_wide::space_type;
struct generate_id
{
typedef int result_type;
generate_id(int start)
: id_(start) {}
int operator() () const
{
return id_++;
}
mutable int id_;
};
template <typename Iterator, typename FeatureType>
struct feature_collection_grammar :
qi::grammar<Iterator, std::vector<feature_ptr>(), space_type>
{
feature_collection_grammar(context_ptr const& ctx, mapnik::transcoder const& tr)
: feature_collection_grammar::base_type(feature_collection,"feature-collection"),
ctx_(ctx),
feature_g(tr),
generate_id_(1)
{
qi::lit_type lit;
qi::eps_type eps;
qi::_4_type _4;
qi::_3_type _2;
qi::_2_type _3;
qi::_a_type _a;
qi::_val_type _val;
qi::_r1_type _r1;
using phoenix::push_back;
using phoenix::construct;
using phoenix::new_;
using phoenix::val;
feature_collection = lit('{') >> (type | features) % lit(",") >> lit('}')
;
type = lit("\"type\"") > lit(":") > lit("\"FeatureCollection\"")
;
features = lit("\"features\"")
> lit(":")
> lit('[')
> -(feature(_val) % lit(','))
> lit(']')
;
feature = eps[_a = phoenix::construct<mapnik::feature_ptr>(new_<mapnik::feature_impl>(ctx_,generate_id_()))]
>> feature_g(*_a)[push_back(_r1,_a)]
;
type.name("type");
features.name("features");
feature.name("feature");
feature_g.name("feature-grammar");
qi::on_error<qi::fail>
(
feature_collection
, std::clog
<< phoenix::val("Error parsing GeoJSON ")
<< _4
<< phoenix::val(" here: \"")
<< construct<std::string>(_3, _2)
<< phoenix::val("\"")
<< std::endl
);
}
context_ptr ctx_;
qi::rule<Iterator, std::vector<feature_ptr>(), space_type> feature_collection; // START
qi::rule<Iterator, space_type> type;
qi::rule<Iterator, std::vector<feature_ptr>(), space_type> features;
qi::rule<Iterator, qi::locals<feature_ptr,int>, void(std::vector<feature_ptr>&), space_type> feature;
feature_grammar<Iterator,FeatureType> feature_g;
boost::phoenix::function<generate_id> generate_id_;
};
}}
#endif // MAPNIK_FEATURE_COLLECTION_GRAMMAR_HPP
|