This file is indexed.

/usr/include/mapnik/wkt/wkt_grammar.hpp is in libmapnik-dev 2.2.0+ds1-6build2.

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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
/*****************************************************************************
 *
 * 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 MAPNIK_WKT_GRAMMAR_HPP
#define MAPNIK_WKT_GRAMMAR_HPP

#include <boost/assert.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
// spirit::qi
#include <boost/spirit/include/qi.hpp>
// spirit::phoenix
#include <boost/spirit/include/phoenix_function.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/phoenix_fusion.hpp>
#include <boost/spirit/include/phoenix_object.hpp>
#include <boost/spirit/include/phoenix_stl.hpp>
// mapnik
#include <mapnik/geometry.hpp>

namespace mapnik { namespace wkt {

    using namespace boost::spirit;
    using namespace boost::fusion;
    using namespace boost::phoenix;

    struct push_vertex
    {
        template <typename T0,typename T1, typename T2, typename T3>
        struct result
        {
            typedef void type;
        };

        template <typename T0,typename T1, typename T2, typename T3>
        void operator() (T0 c, T1 path, T2 x, T3 y) const
        {
            BOOST_ASSERT( path!=0 );
            path->push_vertex(x,y,c);
        }
    };

    struct close_path
    {
        template <typename T>
        struct result
        {
            typedef void type;
        };

        template <typename T>
        void operator() (T path) const
        {
            BOOST_ASSERT( path!=0 );
            path->close_path();
        }
    };

    struct cleanup
    {
        template <typename T0>
        struct result
        {
            typedef void type;
        };

        template <typename T0>
        void operator() (T0 & path) const
        {
            if (path)  delete path,path=0;
        }
    };

    template <typename Iterator>
    struct wkt_grammar : qi::grammar<Iterator,  boost::ptr_vector<mapnik::geometry_type>() , ascii::space_type>
    {
        wkt_grammar()
            : wkt_grammar::base_type(geometry_tagged_text)
        {
            using qi::no_case;
            using qi::_1;
            using qi::_2;
            using boost::phoenix::push_back;

            geometry_tagged_text = point_tagged_text
                | linestring_tagged_text
                | polygon_tagged_text
                | multipoint_tagged_text
                | multilinestring_tagged_text
                | multipolygon_tagged_text
                ;

            // <point tagged text> ::= point <point text>
            point_tagged_text = no_case[lit("POINT")] [ _a = new_<geometry_type>(Point) ]
                >> ( point_text(_a) [push_back(_val,_a)]
                     | eps[cleanup_(_a)][_pass = false])
                ;

            // <point text> ::= <empty set> | <left paren> <point> <right paren>
            point_text = (lit("(") >> point(SEG_MOVETO,_r1) >> lit(')'))
                | empty_set
                ;

            // <linestring tagged text> ::= linestring <linestring text>
            linestring_tagged_text = no_case[lit("LINESTRING")] [ _a = new_<geometry_type>(LineString) ]
                >> (linestring_text(_a)[push_back(_val,_a)]
                    | eps[cleanup_(_a)][_pass = false])
                ;

            // <linestring text> ::= <empty set> | <left paren> <point> {<comma> <point>}* <right paren>
            linestring_text = points(_r1) | empty_set
                ;

            // <polygon tagged text> ::= polygon <polygon text>
            polygon_tagged_text = no_case[lit("POLYGON")] [ _a = new_<geometry_type>(Polygon) ]
                >> ( polygon_text(_a)[push_back(_val,_a)]
                     | eps[cleanup_(_a)][_pass = false])
                ;

            // <polygon text> ::= <empty set> | <left paren> <linestring text> {<comma> <linestring text>}* <right paren>
            polygon_text = (lit('(') >> linestring_text(_r1)[close_path_(_r1)] % lit(',') >> lit(')')) | empty_set;


            //<multipoint tagged text> ::= multipoint <multipoint text>
            multipoint_tagged_text = no_case[lit("MULTIPOINT")]
                >>  multipoint_text
                ;

            // <multipoint text> ::= <empty set> | <left paren> <point text> {<comma> <point text>}* <right paren>
            multipoint_text = (lit('(')
                               >> ((eps[_a = new_<geometry_type>(Point)]
                                    >> (point_text(_a) | empty_set) [push_back(_val,_a)]
                                    | eps[cleanup_(_a)][_pass = false]) % lit(','))
                               >> lit(')')) | empty_set
                ;

            // <multilinestring tagged text> ::= multilinestring <multilinestring text>
            multilinestring_tagged_text = no_case[lit("MULTILINESTRING")]
                >> multilinestring_text ;

            // <multilinestring text> ::= <empty set> | <left paren> <linestring text> {<comma> <linestring text>}* <right paren>
            multilinestring_text = (lit('(')
                                    >> ((eps[_a = new_<geometry_type>(LineString)]
                                         >> ( points(_a)[push_back(_val,_a)]
                                              | eps[cleanup_(_a)][_pass = false]))
                                        % lit(','))
                                    >> lit(')')) | empty_set;

            // <multipolygon tagged text> ::= multipolygon <multipolygon text>
            multipolygon_tagged_text = no_case[lit("MULTIPOLYGON")]
                >> multipolygon_text ;

            // <multipolygon text> ::= <empty set> | <left paren> <polygon text> {<comma> <polygon text>}* <right paren>

            multipolygon_text = (lit('(')
                                 >> ((eps[_a = new_<geometry_type>(Polygon)]
                                      >> ( polygon_text(_a)[push_back(_val,_a)]
                                           | eps[cleanup_(_a)][_pass = false]))
                                     % lit(','))
                                 >> lit(')')) | empty_set;

            // points
            points = lit('(')[_a = SEG_MOVETO] >> point (_a,_r1) % lit(',') [_a = SEG_LINETO]  >> lit(')');
            // point
            point = (double_ >> double_) [push_vertex_(_r1,_r2,_1,_2)];

            // <empty set>
            empty_set = no_case[lit("EMPTY")];

        }

        // start
        qi::rule<Iterator,boost::ptr_vector<geometry_type>(),ascii::space_type> geometry_tagged_text;

        qi::rule<Iterator,qi::locals<geometry_type*>,boost::ptr_vector<geometry_type>(),ascii::space_type> point_tagged_text;
        qi::rule<Iterator,qi::locals<geometry_type*>,boost::ptr_vector<geometry_type>(),ascii::space_type> linestring_tagged_text;
        qi::rule<Iterator,qi::locals<geometry_type*>,boost::ptr_vector<geometry_type>(),ascii::space_type> polygon_tagged_text;
        qi::rule<Iterator,boost::ptr_vector<geometry_type>(),ascii::space_type> multipoint_tagged_text;
        qi::rule<Iterator,boost::ptr_vector<geometry_type>(),ascii::space_type> multilinestring_tagged_text;
        qi::rule<Iterator,boost::ptr_vector<geometry_type>(),ascii::space_type> multipolygon_tagged_text;
        //
        qi::rule<Iterator,void(geometry_type*),ascii::space_type> point_text;
        qi::rule<Iterator,void(geometry_type*),ascii::space_type> linestring_text;
        qi::rule<Iterator,void(geometry_type*),ascii::space_type> polygon_text;
        qi::rule<Iterator, qi::locals<geometry_type*>, boost::ptr_vector<geometry_type>(),ascii::space_type> multipoint_text;
        qi::rule<Iterator, qi::locals<geometry_type*>, boost::ptr_vector<geometry_type>(),ascii::space_type> multilinestring_text;
        qi::rule<Iterator, qi::locals<geometry_type*>, boost::ptr_vector<geometry_type>(),ascii::space_type> multipolygon_text;
        //
        qi::rule<Iterator,void(CommandType,geometry_type*),ascii::space_type> point;
        qi::rule<Iterator,qi::locals<CommandType>,void(geometry_type*),ascii::space_type> points;
        qi::rule<Iterator,ascii::space_type> empty_set;
        boost::phoenix::function<push_vertex> push_vertex_;
        boost::phoenix::function<close_path> close_path_;
        boost::phoenix::function<cleanup> cleanup_;
    };


template <typename Iterator>
struct wkt_collection_grammar : qi::grammar<Iterator, boost::ptr_vector<mapnik::geometry_type>(), ascii::space_type>
{
    wkt_collection_grammar()
        :  wkt_collection_grammar::base_type(start)
    {
        using qi::_1;
        using qi::_val;
        using qi::no_case;
        using boost::phoenix::push_back;
        start = wkt | no_case[lit("GEOMETRYCOLLECTION")]
            >> (lit("(") >> wkt % lit(",") >> lit(")"));
    }

    qi::rule<Iterator,boost::ptr_vector<mapnik::geometry_type>(),ascii::space_type> start;
    wkt_grammar<Iterator> wkt;
};

template <typename Iterator>
struct wkt_stream_grammar : qi::grammar<Iterator, boost::ptr_vector<mapnik::geometry_type>(), ascii::space_type>
{
    wkt_stream_grammar()
        :  wkt_stream_grammar::base_type(start)
    {
        start = *wkt_collection;
    }

    qi::rule<Iterator,boost::ptr_vector<mapnik::geometry_type>(),ascii::space_type> start;
    wkt_collection_grammar<Iterator> wkt_collection;
};

}}

#endif // MAPNIK_WKT_GRAMMAR_HPP