Overpass API regression suite coverage (Saxony) / overpass_api/statements/item_geometry.h
overpass_api/statements/item_geometry.h
83 of 122 instrumented lines run by the suite (68.0%) at 8edf11b0419c (this file on GitHub).
runnever runcolumns: line, executions, queries (click for the queries that run the line)
1/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al.2 *3 * This file is part of Overpass_API.4 *5 * Overpass_API is free software: you can redistribute it and/or modify6 * it under the terms of the GNU Affero General Public License as7 * published by the Free Software Foundation, either version 3 of the8 * License, or (at your option) any later version.9 *10 * Overpass_API is distributed in the hope that it will be useful,11 * but WITHOUT ANY WARRANTY; without even the implied warranty of12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * GNU General Public License for more details.14 *15 * You should have received a copy of the GNU Affero General Public License16 * along with Overpass_API. If not, see <http://www.gnu.org/licenses/>.17 */19#ifndef DE__OSM3S___OVERPASS_API__STATEMENTS__ITEM_GEOMETRY_H20#define DE__OSM3S___OVERPASS_API__STATEMENTS__ITEM_GEOMETRY_H23#include "../../expat/escape_json.h"24#include "../../expat/escape_xml.h"25#include "../data/tag_store.h"26#include "../data/utils.h"27#include "evaluator.h"28#include "statement.h"30#include <map>31#include <string>32#include <vector>35/* === Geometry Related Operators ===38==== Closedness ====40The operator <em>is_closed</em> returns whether the element is a closed way.41The operator is undefined for any other type of element.42For ways, it returns "1" if the first member of the way is equal to the last member of the way43and "0" otherwise.44The operators takes no parameters.46The syntax is48 is_closed()49*/51struct Is_Closed_Eval_Task : public Eval_Task52{55 virtual std::string eval(const Element_With_Context< Node_Skeleton >& data, const std::string* key) const57 virtual std::string eval(const Element_With_Context< Attic< Node_Skeleton > >& data, const std::string* key) const59 virtual std::string eval(const Element_With_Context< Way_Skeleton >& data, const std::string* key) const601063169 q { return !data.object->nds.empty() && data.object->nds.front() == data.object->nds.back() ? "1" : "0"; }61 virtual std::string eval(const Element_With_Context< Attic< Way_Skeleton > >& data, const std::string* key) const62125132 q { return !data.object->nds.empty() && data.object->nds.front() == data.object->nds.back() ? "1" : "0"; }63 virtual std::string eval(const Element_With_Context< Relation_Skeleton >& data, const std::string* key) const65 virtual std::string eval(const Element_With_Context< Attic< Relation_Skeleton > >& data, const std::string* key) const67 virtual std::string eval(const Element_With_Context< Area_Skeleton >& data, const std::string* key) const69 virtual std::string eval(const Element_With_Context< Derived_Skeleton >& data, const std::string* key) const71};74class Evaluator_Is_Closed : public Evaluator75{76public:77 struct Statement_Maker : public Generic_Statement_Maker< Evaluator_Is_Closed >78 {80 };81 static Statement_Maker statement_maker;82 static Element_Function_Maker< Evaluator_Is_Closed > evaluator_maker;852222 q virtual std::string dump_xml(const std::string& indent) const { return indent + "<eval-is-closed/>\n"; }88 Evaluator_Is_Closed(int line_number_, const std::map< std::string, std::string >& input_attributes,89 Parsed_Query& global_settings);952121 q virtual Requested_Context request_context() const { return Requested_Context().add_usage(Set_Usage::SKELETON); }98 virtual Eval_Task* get_string_task(Prepare_Task_Context& context, const std::string* key)100};103/* ==== Geometry ====105The <em>geometry</em> operator returns the geometry of a single object106as a geometry that can be put into the other geometry converting operators.108Its syntax is:110 geom()111*/113struct Geometry_Geometry_Task : Eval_Geometry_Task114{119 virtual Opaque_Geometry* eval(const Element_With_Context< Node_Skeleton >& data) const121 virtual Opaque_Geometry* eval(const Element_With_Context< Attic< Node_Skeleton > >& data) const123 virtual Opaque_Geometry* eval(const Element_With_Context< Way_Skeleton >& data) const125 virtual Opaque_Geometry* eval(const Element_With_Context< Attic< Way_Skeleton > >& data) const127 virtual Opaque_Geometry* eval(const Element_With_Context< Relation_Skeleton >& data) const129 virtual Opaque_Geometry* eval(const Element_With_Context< Attic< Relation_Skeleton > >& data) const131 virtual Opaque_Geometry* eval(const Element_With_Context< Area_Skeleton >& data) const133 virtual Opaque_Geometry* eval(const Element_With_Context< Derived_Skeleton >& data) const135};138class Evaluator_Geometry : public Evaluator139{140public:141 struct Statement_Maker : public Generic_Statement_Maker< Evaluator_Geometry >142 {144 };145 static Statement_Maker statement_maker;146 static Element_Function_Maker< Evaluator_Geometry > evaluator_maker;149 virtual std::string dump_xml(const std::string& indent) const151 virtual std::string dump_compact_ql(const std::string&) const154 Evaluator_Geometry(int line_number_, const std::map< std::string, std::string >& input_attributes,155 Parsed_Query& global_settings);1614238 q virtual Requested_Context request_context() const { return Requested_Context().add_usage(Set_Usage::GEOMETRY); }164 virtual Eval_Task* get_string_task(Prepare_Task_Context& context, const std::string* key)166 virtual Eval_Geometry_Task* get_geometry_task(Prepare_Task_Context& context)169};172/* ==== Length ====174The length operator returns the length of the element.175For ways this is the length of the way.176For relations this is the sum of the lengthes of the members of type way.177For nodes it is always zero.179Its syntax is:181 length()182*/184struct Length_Eval_Task : public Eval_Task185{190 virtual std::string eval(const Element_With_Context< Node_Skeleton >& data, const std::string* key) const192 virtual std::string eval(const Element_With_Context< Attic< Node_Skeleton > >& data, const std::string* key) const194 virtual std::string eval(const Element_With_Context< Way_Skeleton >& data, const std::string* key) const196 virtual std::string eval(const Element_With_Context< Attic< Way_Skeleton > >& data, const std::string* key) const198 virtual std::string eval(const Element_With_Context< Relation_Skeleton >& data, const std::string* key) const200 virtual std::string eval(const Element_With_Context< Attic< Relation_Skeleton > >& data, const std::string* key) const202 virtual std::string eval(const Element_With_Context< Area_Skeleton >& data, const std::string* key) const204 virtual std::string eval(const Element_With_Context< Derived_Skeleton >& data, const std::string* key) const206};209class Evaluator_Length : public Evaluator210{211public:212 struct Statement_Maker : public Generic_Statement_Maker< Evaluator_Length >213 {215 };216 static Statement_Maker statement_maker;217 static Element_Function_Maker< Evaluator_Length > evaluator_maker;220 virtual std::string dump_xml(const std::string& indent) const222 virtual std::string dump_compact_ql(const std::string&) const225 Evaluator_Length(int line_number_, const std::map< std::string, std::string >& input_attributes,226 Parsed_Query& global_settings);2322521 q virtual Requested_Context request_context() const { return Requested_Context().add_usage(Set_Usage::GEOMETRY); }235 virtual Eval_Task* get_string_task(Prepare_Task_Context& context, const std::string* key)237};240/* ==== Latitude and Longitude ====242The latitude and longitude operators return the respective coordinate of the element or the element's center.243For nodes it is the latitude resp. longitude of the node's coordinate.244For ways and relations it refers to the coordinate derived from the center of the bounding box.246Their syntaxes are:248 lat()250resp.252 lon()253*/255struct Latitude_Eval_Task : public Eval_Task256{261 virtual std::string eval(const Element_With_Context< Node_Skeleton >& data, const std::string* key) const263197224 q data.geometry->has_center() ? fixed_to_string(data.geometry->center_lat(), 7) : "NaN"; }264 virtual std::string eval(const Element_With_Context< Attic< Node_Skeleton > >& data, const std::string* key) const267 virtual std::string eval(const Element_With_Context< Way_Skeleton >& data, const std::string* key) const269733264 q data.geometry->has_center() ? fixed_to_string(data.geometry->center_lat(), 7) : "NaN"; }270 virtual std::string eval(const Element_With_Context< Attic< Way_Skeleton > >& data, const std::string* key) const273 virtual std::string eval(const Element_With_Context< Relation_Skeleton >& data, const std::string* key) const276 virtual std::string eval(const Element_With_Context< Attic< Relation_Skeleton > >& data, const std::string* key) const279 virtual std::string eval(const Element_With_Context< Area_Skeleton >& data, const std::string* key) const282 virtual std::string eval(const Element_With_Context< Derived_Skeleton >& data, const std::string* key) const2843711452 q data.geometry->has_center() ? fixed_to_string(data.geometry->center_lat(), 7) : "NaN"; }285};288class Evaluator_Latitude : public Evaluator289{290public:291 struct Statement_Maker : public Generic_Statement_Maker< Evaluator_Latitude >292 {294 };295 static Statement_Maker statement_maker;296 static Element_Function_Maker< Evaluator_Latitude > evaluator_maker;299 virtual std::string dump_xml(const std::string& indent) const301 virtual std::string dump_compact_ql(const std::string&) const304 Evaluator_Latitude(int line_number_, const std::map< std::string, std::string >& input_attributes,305 Parsed_Query& global_settings);3111813 q virtual Requested_Context request_context() const { return Requested_Context().add_usage(Set_Usage::GEOMETRY); }314 virtual Eval_Task* get_string_task(Prepare_Task_Context& context, const std::string* key)316};319struct Longitude_Eval_Task : public Eval_Task320{325 virtual std::string eval(const Element_With_Context< Node_Skeleton >& data, const std::string* key) const328 virtual std::string eval(const Element_With_Context< Attic< Node_Skeleton > >& data, const std::string* key) const331 virtual std::string eval(const Element_With_Context< Way_Skeleton >& data, const std::string* key) const333776535 q data.geometry->has_center() ? fixed_to_string(data.geometry->center_lon(), 7) : "NaN"; }334 virtual std::string eval(const Element_With_Context< Attic< Way_Skeleton > >& data, const std::string* key) const337 virtual std::string eval(const Element_With_Context< Relation_Skeleton >& data, const std::string* key) const340 virtual std::string eval(const Element_With_Context< Attic< Relation_Skeleton > >& data, const std::string* key) const343 virtual std::string eval(const Element_With_Context< Area_Skeleton >& data, const std::string* key) const346 virtual std::string eval(const Element_With_Context< Derived_Skeleton >& data, const std::string* key) const349};352class Evaluator_Longitude : public Evaluator353{354public:355 struct Statement_Maker : public Generic_Statement_Maker< Evaluator_Longitude >356 {358 };359 static Statement_Maker statement_maker;360 static Element_Function_Maker< Evaluator_Longitude > evaluator_maker;363 virtual std::string dump_xml(const std::string& indent) const365 virtual std::string dump_compact_ql(const std::string&) const368 Evaluator_Longitude(int line_number_, const std::map< std::string, std::string >& input_attributes,369 Parsed_Query& global_settings);3751211 q virtual Requested_Context request_context() const { return Requested_Context().add_usage(Set_Usage::GEOMETRY); }378 virtual Eval_Task* get_string_task(Prepare_Task_Context& context, const std::string* key)380};383#endif