-bool Tag_Filter::matches(const std::vector< std::pair< std::string, std::string > >* tags) const
+bool Tag_Filter::matches(const Tag_List* tags) const
{
if (!tags)
return false;
- for (std::vector< std::pair< std::string, std::string > >::const_iterator it = tags->begin(); it != tags->end(); ++it)
+ for (Tag_List::const_iterator it = tags->begin(); it != tags->end(); ++it)
{
if (it->first == key && condition.matches(it->second))
return straight;
@@ -37,21 +37,21 @@ bool Tag_Filter::matches(const std::vector< std::pair< std::string, std::string
}
-std::string link_if_any(const std::vector< std::pair< std::string, std::string > >& tags)
+std::string link_if_any(const Tag_List& tags)
{
std::string link;
- for (std::vector< std::pair< std::string, std::string > >::const_iterator it = tags.begin(); it != tags.end(); ++it)
+ for (Tag_List::const_iterator it = tags.begin(); it != tags.end(); ++it)
{
if (it->second.find("www.") != std::string::npos)
link = "http://" + it->second;
}
- for (std::vector< std::pair< std::string, std::string > >::const_iterator it = tags.begin(); it != tags.end(); ++it)
+ for (Tag_List::const_iterator it = tags.begin(); it != tags.end(); ++it)
{
if (it->second.find("http://") != std::string::npos)
link = it->second;
}
- for (std::vector< std::pair< std::string, std::string > >::const_iterator it = tags.begin(); it != tags.end(); ++it)
+ for (Tag_List::const_iterator it = tags.begin(); it != tags.end(); ++it)
{
if (it->second.find("https://") != std::string::npos)
link = it->second;
@@ -62,11 +62,11 @@ std::string link_if_any(const std::vector< std::pair< std::string, std::string >
std::string title_if_any(const std::string& link, const std::string& title_key,
- const std::vector< std::pair< std::string, std::string > >& tags)
+ const Tag_List& tags)
{
std::string title;
- for (std::vector< std::pair< std::string, std::string > >::const_iterator it = tags.begin(); it != tags.end(); ++it)
+ for (Tag_List::const_iterator it = tags.begin(); it != tags.end(); ++it)
{
if (it->first == title_key)
{
@@ -105,7 +105,7 @@ template< > std::string elem_type< Relation_Skeleton >() { return "Relation"; }
template< typename TSkel >
std::string print(const std::string& title_key,
- const TSkel& skel, const std::vector< std::pair< std::string, std::string > >* tags)
+ const TSkel& skel, const Tag_List* tags)
{
std::string link = tags ? link_if_any(*tags) : "";
std::string result = "\n" + (tags ? title_if_any(link, title_key, *tags) : "");
@@ -124,7 +124,7 @@ std::string print(const std::string& title_key,
if (tags)
{
- for (std::vector< std::pair< std::string, std::string > >::const_iterator it = tags->begin();
+ for (Tag_List::const_iterator it = tags->begin();
it != tags->end(); ++it)
result += it->first + ": " + it->second + "
\n";
}
@@ -133,7 +133,7 @@ std::string print(const std::string& title_key,
bool Category_Filter::consider(const Node_Skeleton& skel,
- const std::vector< std::pair< std::string, std::string > >* tags)
+ const Tag_List* tags)
{
std::vector< std::vector< Tag_Filter* > >::const_iterator it_conj = filter_disjunction.begin();
for (; it_conj != filter_disjunction.end(); ++it_conj)
@@ -156,7 +156,7 @@ bool Category_Filter::consider(const Node_Skeleton& skel,
bool Category_Filter::consider(const Way_Skeleton& skel,
- const std::vector< std::pair< std::string, std::string > >* tags)
+ const Tag_List* tags)
{
std::vector< std::vector< Tag_Filter* > >::const_iterator it_conj = filter_disjunction.begin();
for (; it_conj != filter_disjunction.end(); ++it_conj)
@@ -179,7 +179,7 @@ bool Category_Filter::consider(const Way_Skeleton& skel,
bool Category_Filter::consider(const Relation_Skeleton& skel,
- const std::vector< std::pair< std::string, std::string > >* tags)
+ const Tag_List* tags)
{
std::vector< std::vector< Tag_Filter* > >::const_iterator it_conj = filter_disjunction.begin();
for (; it_conj != filter_disjunction.end(); ++it_conj)
@@ -247,14 +247,14 @@ void Output_Popup::write_footer()
void Output_Popup::print_item(const Node_Skeleton& skel,
const Opaque_Geometry& geometry,
- const std::vector< std::pair< std::string, std::string > >* tags,
+ const Tag_List* tags,
const OSM_Element_Metadata_Skeleton< Node::Id_Type >* meta,
const std::map< uint32, std::string >* users,
Output_Mode mode,
const Feature_Action& action,
const Node_Skeleton* new_skel,
const Opaque_Geometry* new_geometry,
- const std::vector< std::pair< std::string, std::string > >* new_tags,
+ const Tag_List* new_tags,
const OSM_Element_Metadata_Skeleton< Node::Id_Type >* new_meta)
{
for (std::vector< Category_Filter* >::iterator it = categories.begin(); it != categories.end(); ++it)
@@ -267,14 +267,14 @@ void Output_Popup::print_item(const Node_Skeleton& skel,
void Output_Popup::print_item(const Way_Skeleton& skel,
const Opaque_Geometry& geometry,
- const std::vector< std::pair< std::string, std::string > >* tags,
+ const Tag_List* tags,
const OSM_Element_Metadata_Skeleton< Way::Id_Type >* meta,
const std::map< uint32, std::string >* users,
Output_Mode mode,
const Feature_Action& action,
const Way_Skeleton* new_skel,
const Opaque_Geometry* new_geometry,
- const std::vector< std::pair< std::string, std::string > >* new_tags,
+ const Tag_List* new_tags,
const OSM_Element_Metadata_Skeleton< Way::Id_Type >* new_meta)
{
for (std::vector< Category_Filter* >::iterator it = categories.begin(); it != categories.end(); ++it)
@@ -287,7 +287,7 @@ void Output_Popup::print_item(const Way_Skeleton& skel,
void Output_Popup::print_item(const Relation_Skeleton& skel,
const Opaque_Geometry& geometry,
- const std::vector< std::pair< std::string, std::string > >* tags,
+ const Tag_List* tags,
const OSM_Element_Metadata_Skeleton< Relation::Id_Type >* meta,
const std::map< uint32, std::string >* roles,
const std::map< uint32, std::string >* users,
@@ -295,7 +295,7 @@ void Output_Popup::print_item(const Relation_Skeleton& skel,
const Feature_Action& action,
const Relation_Skeleton* new_skel,
const Opaque_Geometry* new_geometry,
- const std::vector< std::pair< std::string, std::string > >* new_tags,
+ const Tag_List* new_tags,
const OSM_Element_Metadata_Skeleton< Relation::Id_Type >* new_meta)
{
for (std::vector< Category_Filter* >::iterator it = categories.begin(); it != categories.end(); ++it)
@@ -308,7 +308,7 @@ void Output_Popup::print_item(const Relation_Skeleton& skel,
void Output_Popup::print_item(const Derived_Skeleton& skel,
const Opaque_Geometry& geometry,
- const std::vector< std::pair< std::string, std::string > >* tags,
+ const Tag_List* tags,
Output_Mode mode,
const Feature_Action& action)
{
diff --git a/src/overpass_api/output_formats/output_popup.h b/src/overpass_api/output_formats/output_popup.h
index 412ca3353..a402194f4 100644
--- a/src/overpass_api/output_formats/output_popup.h
+++ b/src/overpass_api/output_formats/output_popup.h
@@ -35,7 +35,7 @@ class Tag_Filter
Tag_Filter(const std::string& key_, const std::string& value_, bool straight_)
: key(key_), straight(straight_), condition(value_, true) {}
- bool matches(const std::vector< std::pair< std::string, std::string > >* tags) const;
+ bool matches(const Tag_List* tags) const;
private:
std::string key;
@@ -62,9 +62,9 @@ struct Category_Filter
void set_title_key(const std::string& title_key);
void add_filter(const std::vector< Tag_Filter* >& conjunction) { filter_disjunction.push_back(conjunction); }
- bool consider(const Node_Skeleton& skel, const std::vector< std::pair< std::string, std::string > >* tags);
- bool consider(const Way_Skeleton& skel, const std::vector< std::pair< std::string, std::string > >* tags);
- bool consider(const Relation_Skeleton& skel, const std::vector< std::pair< std::string, std::string > >* tags);
+ bool consider(const Node_Skeleton& skel, const Tag_List* tags);
+ bool consider(const Way_Skeleton& skel, const Tag_List* tags);
+ bool consider(const Relation_Skeleton& skel, const Tag_List* tags);
std::string result() const { return output; }
@@ -100,31 +100,31 @@ class Output_Popup : public Output_Handler
virtual void print_item(const Node_Skeleton& skel,
const Opaque_Geometry& geometry,
- const std::vector< std::pair< std::string, std::string > >* tags,
+ const Tag_List* tags,
const OSM_Element_Metadata_Skeleton< Node::Id_Type >* meta,
const std::map< uint32, std::string >* users,
Output_Mode mode,
const Feature_Action& action = keep,
const Node_Skeleton* new_skel = 0,
const Opaque_Geometry* new_geometry = 0,
- const std::vector< std::pair< std::string, std::string > >* new_tags = 0,
+ const Tag_List* new_tags = 0,
const OSM_Element_Metadata_Skeleton< Node::Id_Type >* new_meta = 0);
virtual void print_item(const Way_Skeleton& skel,
const Opaque_Geometry& geometry,
- const std::vector< std::pair< std::string, std::string > >* tags,
+ const Tag_List* tags,
const OSM_Element_Metadata_Skeleton< Way::Id_Type >* meta,
const std::map< uint32, std::string >* users,
Output_Mode mode,
const Feature_Action& action = keep,
const Way_Skeleton* new_skel = 0,
const Opaque_Geometry* new_geometry = 0,
- const std::vector< std::pair< std::string, std::string > >* new_tags = 0,
+ const Tag_List* new_tags = 0,
const OSM_Element_Metadata_Skeleton< Way::Id_Type >* new_meta = 0);
virtual void print_item(const Relation_Skeleton& skel,
const Opaque_Geometry& geometry,
- const std::vector< std::pair< std::string, std::string > >* tags,
+ const Tag_List* tags,
const OSM_Element_Metadata_Skeleton< Relation::Id_Type >* meta,
const std::map< uint32, std::string >* roles,
const std::map< uint32, std::string >* users,
@@ -132,12 +132,12 @@ class Output_Popup : public Output_Handler
const Feature_Action& action = keep,
const Relation_Skeleton* new_skel = 0,
const Opaque_Geometry* new_geometry = 0,
- const std::vector< std::pair< std::string, std::string > >* new_tags = 0,
+ const Tag_List* new_tags = 0,
const OSM_Element_Metadata_Skeleton< Relation::Id_Type >* new_meta = 0);
virtual void print_item(const Derived_Skeleton& skel,
const Opaque_Geometry& geometry,
- const std::vector< std::pair< std::string, std::string > >* tags,
+ const Tag_List* tags,
Output_Mode mode,
const Feature_Action& action = keep);
diff --git a/src/overpass_api/output_formats/output_xml.cc b/src/overpass_api/output_formats/output_xml.cc
index 6b8784ccc..464a17429 100644
--- a/src/overpass_api/output_formats/output_xml.cc
+++ b/src/overpass_api/output_formats/output_xml.cc
@@ -20,6 +20,7 @@
#include "../core/settings.h"
#include "../frontend/basic_formats.h"
#include "output_xml.h"
+#include "fixed7.h"
bool Output_XML::write_http_headers()
@@ -65,10 +66,10 @@ void Output_XML::display_error(const std::string& text)
void Output_XML::print_global_bbox(const Bbox_Double& bbox)
{
std::cout<<" \n\n";
}
@@ -81,7 +82,7 @@ void print_meta_xml(const OSM_Element_Metadata_Skeleton< Id_Type >& meta,
<<"\" changeset=\""<::const_iterator it = users.find(meta.user_id);
if (it != users.end())
- std::cout<<" user=\""<second)<<"\"";
+ std::cout<<" user=\""<second)<<"\"";
}
@@ -140,7 +141,7 @@ void append_action(const Output_Handler::Feature_Action& action, bool is_new = f
}
-void print_tags(const std::vector< std::pair< std::string, std::string > >* tags,
+void print_tags(const Tag_List* tags,
Output_Mode mode, bool& inner_tags_printed)
{
if ((mode.mode & Output_Mode::TAGS) && tags && !tags->empty())
@@ -150,9 +151,9 @@ void print_tags(const std::vector< std::pair< std::string, std::string > >* tags
std::cout<<">\n";
inner_tags_printed = true;
}
- for (std::vector< std::pair< std::string, std::string > >::const_iterator it = tags->begin();
+ for (Tag_List::const_iterator it = tags->begin();
it != tags->end(); ++it)
- std::cout<<" first)<<"\" v=\""<second)<<"\"/>\n";
+ std::cout<<" first)<<"\" v=\""<second)<<"\"/>\n";
}
}
@@ -167,10 +168,10 @@ void print_bounds(const Opaque_Geometry& geometry, Output_Mode mode, bool& inner
inner_tags_printed = true;
}
std::cout<<" \n";
}
else if ((mode.mode & Output_Mode::CENTER) && geometry.has_center())
@@ -181,8 +182,8 @@ void print_bounds(const Opaque_Geometry& geometry, Output_Mode mode, bool& inner
inner_tags_printed = true;
}
std::cout<<" \n";
}
}
@@ -219,8 +220,8 @@ void print_geometry(const Opaque_Geometry& geometry, Output_Mode mode, bool& inn
const std::vector< Point_Double >* line = geometry.get_line_geometry();
for (std::vector< Point_Double >::const_iterator it = line->begin(); it != line->end(); ++it)
std::cout<lat<<"\""
- " lon=\""<lon<<"\""
+ " lat=\""<lat)<<"\""
+ " lon=\""<lon)<<"\""
"/>\n";
}
else if ((mode.mode & Output_Mode::GEOMETRY) && geometry.has_multiline_geometry())
@@ -237,8 +238,8 @@ void print_geometry(const Opaque_Geometry& geometry, Output_Mode mode, bool& inn
std::cout<\n";
for (std::vector< Point_Double >::const_iterator it = iti->begin(); it != iti->end(); ++it)
std::cout<lat<<"\""
- " lon=\""<lon<<"\""
+ " lat=\""<lat)<<"\""
+ " lon=\""<lon)<<"\""
"/>\n";
std::cout<\n";
}
@@ -251,8 +252,8 @@ void print_geometry(const Opaque_Geometry& geometry, Output_Mode mode, bool& inn
inner_tags_printed = true;
}
std::cout<\n";
}
else if ((mode.mode & Output_Mode::BOUNDS) && geometry.has_bbox())
@@ -263,10 +264,10 @@ void print_geometry(const Opaque_Geometry& geometry, Output_Mode mode, bool& inn
inner_tags_printed = true;
}
std::cout<<" \n";
}
else if ((mode.mode & Output_Mode::CENTER) && geometry.has_center())
@@ -277,8 +278,8 @@ void print_geometry(const Opaque_Geometry& geometry, Output_Mode mode, bool& inn
inner_tags_printed = true;
}
std::cout<\n";
}
}
@@ -298,8 +299,8 @@ void print_members(const Way_Skeleton& skel, const Opaque_Geometry& geometry,
{
std::cout<<" \n";
}
}
@@ -322,13 +323,13 @@ void print_members(const Relation_Skeleton& skel, const Opaque_Geometry& geometr
std::map< uint32, std::string >::const_iterator it = roles.find(skel.members[i].role);
std::cout<<" second : "???")<<"\"";
+ <<"\" role=\""<second : "???")<<"\"";
if (skel.members[i].type == Relation_Entry::NODE)
{
if (geometry.has_faithful_relation_geometry() && geometry.relation_pos_is_valid(i))
- std::cout<<" lat=\""<\n";
}
else if (skel.members[i].type == Relation_Entry::WAY)
@@ -349,8 +350,8 @@ void print_members(const Relation_Skeleton& skel, const Opaque_Geometry& geometr
for (uint j = 0; j < geometry.relation_way_size(i); ++j)
{
if (geometry.relation_pos_is_valid(i, j))
- std::cout<<" \n";
+ std::cout<<" \n";
else
std::cout<<" \n";
}
@@ -367,7 +368,7 @@ void print_members(const Relation_Skeleton& skel, const Opaque_Geometry& geometr
void print_node(const Node_Skeleton& skel,
const Opaque_Geometry& geometry,
- const std::vector< std::pair< std::string, std::string > >* tags,
+ const Tag_List* tags,
const OSM_Element_Metadata_Skeleton< Node::Id_Type >* meta,
const std::map< uint32, std::string >* users,
Output_Mode mode)
@@ -377,8 +378,8 @@ void print_node(const Node_Skeleton& skel,
std::cout<<" id=\""< >* tags,
+ const Tag_List* tags,
const OSM_Element_Metadata_Skeleton< Way::Id_Type >* meta,
const std::map< uint32, std::string >* users,
Output_Mode mode)
@@ -417,7 +418,7 @@ void print_way(const Way_Skeleton& skel,
void print_relation(const Relation_Skeleton& skel,
const Opaque_Geometry& geometry,
- const std::vector< std::pair< std::string, std::string > >* tags,
+ const Tag_List* tags,
const OSM_Element_Metadata_Skeleton< Relation::Id_Type >* meta,
const std::map< uint32, std::string >* roles,
const std::map< uint32, std::string >* users,
@@ -463,14 +464,14 @@ void print_deleted(const std::string& type_name, const Id_Type& id,
void Output_XML::print_item(const Node_Skeleton& skel,
const Opaque_Geometry& geometry,
- const std::vector< std::pair< std::string, std::string > >* tags,
+ const Tag_List* tags,
const OSM_Element_Metadata_Skeleton< Node::Id_Type >* meta,
const std::map< uint32, std::string >* users,
Output_Mode mode,
const Feature_Action& action,
const Node_Skeleton* new_skel,
const Opaque_Geometry* new_geometry,
- const std::vector< std::pair< std::string, std::string > >* new_tags,
+ const Tag_List* new_tags,
const OSM_Element_Metadata_Skeleton< Node::Id_Type >* new_meta)
{
prepend_action(action);
@@ -493,14 +494,14 @@ void Output_XML::print_item(const Node_Skeleton& skel,
void Output_XML::print_item(const Way_Skeleton& skel,
const Opaque_Geometry& geometry,
- const std::vector< std::pair< std::string, std::string > >* tags,
+ const Tag_List* tags,
const OSM_Element_Metadata_Skeleton< Way::Id_Type >* meta,
const std::map< uint32, std::string >* users,
Output_Mode mode,
const Feature_Action& action,
const Way_Skeleton* new_skel,
const Opaque_Geometry* new_geometry,
- const std::vector< std::pair< std::string, std::string > >* new_tags,
+ const Tag_List* new_tags,
const OSM_Element_Metadata_Skeleton< Way::Id_Type >* new_meta)
{
prepend_action(action);
@@ -523,7 +524,7 @@ void Output_XML::print_item(const Way_Skeleton& skel,
void Output_XML::print_item(const Relation_Skeleton& skel,
const Opaque_Geometry& geometry,
- const std::vector< std::pair< std::string, std::string > >* tags,
+ const Tag_List* tags,
const OSM_Element_Metadata_Skeleton< Relation::Id_Type >* meta,
const std::map< uint32, std::string >* roles,
const std::map< uint32, std::string >* users,
@@ -531,7 +532,7 @@ void Output_XML::print_item(const Relation_Skeleton& skel,
const Feature_Action& action,
const Relation_Skeleton* new_skel,
const Opaque_Geometry* new_geometry,
- const std::vector< std::pair< std::string, std::string > >* new_tags,
+ const Tag_List* new_tags,
const OSM_Element_Metadata_Skeleton< Relation::Id_Type >* new_meta)
{
prepend_action(action);
@@ -554,7 +555,7 @@ void Output_XML::print_item(const Relation_Skeleton& skel,
void Output_XML::print_item(const Derived_Skeleton& skel,
const Opaque_Geometry& geometry,
- const std::vector< std::pair< std::string, std::string > >* tags,
+ const Tag_List* tags,
Output_Mode mode,
const Feature_Action& action)
{
diff --git a/src/overpass_api/output_formats/output_xml.h b/src/overpass_api/output_formats/output_xml.h
index cf5eb4f6d..2173d0256 100644
--- a/src/overpass_api/output_formats/output_xml.h
+++ b/src/overpass_api/output_formats/output_xml.h
@@ -54,31 +54,31 @@ class Output_XML : public Output_Handler
virtual void print_item(const Node_Skeleton& skel,
const Opaque_Geometry& geometry,
- const std::vector< std::pair< std::string, std::string > >* tags,
+ const Tag_List* tags,
const OSM_Element_Metadata_Skeleton< Node::Id_Type >* meta,
const std::map< uint32, std::string >* users,
Output_Mode mode,
const Feature_Action& action = keep,
const Node_Skeleton* new_skel = 0,
const Opaque_Geometry* new_geometry = 0,
- const std::vector< std::pair< std::string, std::string > >* new_tags = 0,
+ const Tag_List* new_tags = 0,
const OSM_Element_Metadata_Skeleton< Node::Id_Type >* new_meta = 0);
virtual void print_item(const Way_Skeleton& skel,
const Opaque_Geometry& geometry,
- const std::vector< std::pair< std::string, std::string > >* tags,
+ const Tag_List* tags,
const OSM_Element_Metadata_Skeleton< Way::Id_Type >* meta,
const std::map< uint32, std::string >* users,
Output_Mode mode,
const Feature_Action& action = keep,
const Way_Skeleton* new_skel = 0,
const Opaque_Geometry* new_geometry = 0,
- const std::vector< std::pair< std::string, std::string > >* new_tags = 0,
+ const Tag_List* new_tags = 0,
const OSM_Element_Metadata_Skeleton< Way::Id_Type >* new_meta = 0);
virtual void print_item(const Relation_Skeleton& skel,
const Opaque_Geometry& geometry,
- const std::vector< std::pair< std::string, std::string > >* tags,
+ const Tag_List* tags,
const OSM_Element_Metadata_Skeleton< Relation::Id_Type >* meta,
const std::map< uint32, std::string >* roles,
const std::map< uint32, std::string >* users,
@@ -86,12 +86,12 @@ class Output_XML : public Output_Handler
const Feature_Action& action = keep,
const Relation_Skeleton* new_skel = 0,
const Opaque_Geometry* new_geometry = 0,
- const std::vector< std::pair< std::string, std::string > >* new_tags = 0,
+ const Tag_List* new_tags = 0,
const OSM_Element_Metadata_Skeleton< Relation::Id_Type >* new_meta = 0);
virtual void print_item(const Derived_Skeleton& skel,
const Opaque_Geometry& geometry,
- const std::vector< std::pair< std::string, std::string > >* tags,
+ const Tag_List* tags,
Output_Mode mode,
const Feature_Action& action = keep);
};
diff --git a/src/overpass_api/statements/area_query.cc b/src/overpass_api/statements/area_query.cc
index 3e62b8799..a1897604f 100644
--- a/src/overpass_api/statements/area_query.cc
+++ b/src/overpass_api/statements/area_query.cc
@@ -31,6 +31,7 @@
#include "../core/index_computations.h"
#include "../data/collect_members.h"
#include "../data/tilewise_geometry.h"
+#include
#include "area_query.h"
#include "coord_query.h"
#include "make_area.h"
@@ -189,12 +190,17 @@ std::map< Uint31_Index, std::vector< Way_Skeleton > > ways_contained_in(
Tilewise_Const_Area_Iterator tai(potential_areas->ways, potential_areas->attic_ways, stmt, rman);
std::map< Uint31_Index, std::vector< Way_Skeleton > > result;
+ if (tai.is_end())
+ return result;
+
Tilewise_Way_Iterator twi(ways, std::map< Uint31_Index, std::vector< Attic< Way_Skeleton > > >(), stmt, rman);
while (!twi.is_end())
{
while (!tai.is_end() && tai.get_idx() < twi.get_idx())
tai.next();
- if (tai.is_end() || twi.get_idx() < tai.get_idx())
+ if (tai.is_end())
+ break;
+ if (twi.get_idx() < tai.get_idx())
{
twi.next();
continue;
@@ -229,12 +235,17 @@ std::map< Uint31_Index, std::vector< Attic< Way_Skeleton > > > ways_contained_in
Tilewise_Const_Area_Iterator tai(potential_areas->ways, potential_areas->attic_ways, stmt, rman);
std::map< Uint31_Index, std::vector< Attic< Way_Skeleton > > > result;
+ if (tai.is_end())
+ return result;
+
Tilewise_Way_Iterator twi(std::map< Uint31_Index, std::vector< Way_Skeleton > >(), ways, stmt, rman);
while (!twi.is_end())
{
while (!tai.is_end() && tai.get_idx() < twi.get_idx())
tai.next();
- if (tai.is_end() || twi.get_idx() < tai.get_idx())
+ if (tai.is_end())
+ break;
+ if (twi.get_idx() < tai.get_idx())
{
twi.next();
continue;
@@ -592,6 +603,15 @@ void Area_Query_Statement::collect_nodes
areas[area_it.object().id].push_back(area_it.object());
++area_it;
}
+ // The same blocks decoded once for this tile, for the point-in-area tests below.
+ std::map< Area_Skeleton::Id_Type, std::vector< Coord_Query_Statement::Decoded_Area_Block > > decoded;
+ for (std::map< Area_Skeleton::Id_Type, std::vector< Area_Block > >::const_iterator it = areas.begin();
+ it != areas.end(); ++it)
+ {
+ std::vector< Coord_Query_Statement::Decoded_Area_Block >& blocks = decoded[it->first];
+ for (std::vector< Area_Block >::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2)
+ blocks.push_back(Coord_Query_Statement::Decoded_Area_Block(current_idx, *it2));
+ }
while (nodes_it != nodes.end() && nodes_it->first.val() < current_idx)
{
@@ -613,12 +633,13 @@ void Area_Query_Statement::collect_nodes
it != areas.end(); ++it)
{
int inside = 0;
- for (std::vector< Area_Block >::const_iterator it2 = it->second.begin(); it2 != it->second.end();
- ++it2)
+ const std::vector< Coord_Query_Statement::Decoded_Area_Block >& blocks = decoded[it->first];
+ for (std::vector< Coord_Query_Statement::Decoded_Area_Block >::const_iterator it2 = blocks.begin();
+ it2 != blocks.end(); ++it2)
{
++loop_count;
- int check(Coord_Query_Statement::check_area_block(current_idx, *it2, ilat, ilon));
+ int check(Coord_Query_Statement::check_area_block(*it2, ilat, ilon));
if (check == Coord_Query_Statement::HIT && add_border)
{
inside = 1;
@@ -748,18 +769,31 @@ inline int longitude_a_intersects_inner
}
-int intersects_inner(const Area_Block& string_a, const Area_Block& string_b)
+void decode_coords(const Area_Block& block, Decoded_Coords& coords)
+{
+ coords.clear();
+ coords.reserve(block.coors.size());
+ for (std::vector< uint64 >::const_iterator it = block.coors.begin(); it != block.coors.end(); ++it)
+ coords.push_back(std::make_pair(::ilat(uint32((*it>>32)&0xff), uint32(*it & 0xffffffffull)),
+ ::ilon(uint32((*it>>32)&0xff), uint32(*it & 0xffffffffull))));
+}
+
+
+Coords_Bounds::Coords_Bounds(const Decoded_Coords& coords)
+ : min_lat(0xffffffffu), max_lat(0), min_lon(0xffffffffu), max_lon(0)
{
- std::vector< std::pair< uint32, uint32 > > coords_a;
- for (std::vector< uint64 >::const_iterator it = string_a.coors.begin(); it != string_a.coors.end(); ++it)
- coords_a.push_back(std::make_pair(::ilat(uint32((*it>>32)&0xff), uint32(*it & 0xffffffffull)),
- ::ilon(uint32((*it>>32)&0xff), uint32(*it & 0xffffffffull))));
+ for (Decoded_Coords::const_iterator it = coords.begin(); it != coords.end(); ++it)
+ {
+ min_lat = std::min(min_lat, it->first);
+ max_lat = std::max(max_lat, it->first);
+ min_lon = std::min(min_lon, it->second);
+ max_lon = std::max(max_lon, it->second);
+ }
+}
- std::vector< std::pair< uint32, uint32 > > coords_b;
- for (std::vector< uint64 >::const_iterator it = string_b.coors.begin(); it != string_b.coors.end(); ++it)
- coords_b.push_back(std::make_pair(::ilat(uint32((*it>>32)&0xff), uint32(*it & 0xffffffffull)),
- ::ilon(uint32((*it>>32)&0xff), uint32(*it & 0xffffffffull))));
+int intersects_inner(const Decoded_Coords& coords_a, const Decoded_Coords& coords_b)
+{
for (std::vector< std::pair< uint32, uint32 > >::size_type i = 0; i < coords_a.size()-1; ++i)
{
if (coords_a[i].second < coords_a[i+1].second)
@@ -799,12 +833,9 @@ int intersects_inner(const Area_Block& string_a, const Area_Block& string_b)
}
-void has_inner_points(const Area_Block& string_a, const Area_Block& string_b, int& inside)
+void has_inner_points(const Decoded_Coords& coords_a, const Coord_Query_Statement::Decoded_Area_Block& string_b,
+ int& inside)
{
- std::vector< std::pair< uint32, uint32 > > coords_a;
- for (std::vector< uint64 >::const_iterator it = string_a.coors.begin(); it != string_a.coors.end(); ++it)
- coords_a.push_back(std::make_pair(::ilat(uint32((*it>>32)&0xff), uint32(*it & 0xffffffffull)),
- ::ilon(uint32((*it>>32)&0xff), uint32(*it & 0xffffffffull))));
// Check additionally the middle of the segment to also get segments
// that run through the area
@@ -812,7 +843,7 @@ void has_inner_points(const Area_Block& string_a, const Area_Block& string_b, in
{
uint32 ilat = (coords_a[i].first + coords_a[i+1].first)/2;
uint32 ilon = (coords_a[i].second + coords_a[i+1].second)/2 + 0x80000000u;
- int check = Coord_Query_Statement::check_area_block(0, string_b, ilat, ilon);
+ int check = Coord_Query_Statement::check_area_block(string_b, ilat, ilon);
if (check & Coord_Query_Statement::HIT)
inside = check;
else if (check)
@@ -835,19 +866,15 @@ void Area_Query_Statement::collect_ways
std::map< Way::Id_Type, bool > ways_inside;
+ // Build each way's geometry once, for both its segments and its coordinates.
std::map< Uint31_Index, std::vector< Area_Block > > way_segments;
- for (typename std::map< Uint31_Index, std::vector< Way_Skeleton > >::iterator it = ways.begin(); it != ways.end(); ++it)
- {
- for (typename std::vector< Way_Skeleton >::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2)
- add_way_to_area_blocks(way_geometries.get_geometry(*it2), it2->id.val(), way_segments);
- }
-
std::map< uint32, std::vector< std::pair< uint32, Way::Id_Type > > > way_coords_to_id;
for (typename std::map< Uint31_Index, std::vector< Way_Skeleton > >::iterator it = ways.begin(); it != ways.end(); ++it)
{
for (typename std::vector< Way_Skeleton >::iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2)
{
std::vector< Quad_Coord > coords = way_geometries.get_geometry(*it2);
+ add_way_to_area_blocks(coords, it2->id.val(), way_segments);
for (std::vector< Quad_Coord >::const_iterator it3 = coords.begin(); it3 != coords.end(); ++it3)
way_coords_to_id[it3->ll_upper].push_back(std::make_pair(it3->ll_lower, it2->id));
}
@@ -875,6 +902,15 @@ void Area_Query_Statement::collect_ways
areas[area_it.object().id].push_back(area_it.object());
++area_it;
}
+ // The same blocks decoded once for this tile, for the point-in-area tests below.
+ std::map< Area_Skeleton::Id_Type, std::vector< Coord_Query_Statement::Decoded_Area_Block > > decoded;
+ for (std::map< Area_Skeleton::Id_Type, std::vector< Area_Block > >::const_iterator it = areas.begin();
+ it != areas.end(); ++it)
+ {
+ std::vector< Coord_Query_Statement::Decoded_Area_Block >& blocks = decoded[it->first];
+ for (std::vector< Area_Block >::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2)
+ blocks.push_back(Coord_Query_Statement::Decoded_Area_Block(current_idx, *it2));
+ }
// check nodes
while (nodes_it != way_coords_to_id.end() && nodes_it->first < current_idx)
@@ -892,12 +928,13 @@ void Area_Query_Statement::collect_ways
it != areas.end(); ++it)
{
int inside = 0;
- for (std::vector< Area_Block >::const_iterator it2 = it->second.begin(); it2 != it->second.end();
- ++it2)
+ const std::vector< Coord_Query_Statement::Decoded_Area_Block >& blocks = decoded[it->first];
+ for (std::vector< Coord_Query_Statement::Decoded_Area_Block >::const_iterator it2 = blocks.begin();
+ it2 != blocks.end(); ++it2)
{
++loop_count;
- int check(Coord_Query_Statement::check_area_block(current_idx, *it2, ilat, ilon));
+ int check(Coord_Query_Statement::check_area_block(*it2, ilat, ilon));
if (check == Coord_Query_Statement::HIT)
{
inside = Coord_Query_Statement::HIT;
@@ -913,10 +950,31 @@ void Area_Query_Statement::collect_ways
++nodes_it;
}
+ // has_inner_points tests segment midpoints against the blocks decoded with ll_index 0.
+ std::map< Area_Skeleton::Id_Type, std::vector< Coord_Query_Statement::Decoded_Area_Block > > decoded_zero;
+ std::map< Area_Skeleton::Id_Type, std::vector< Decoded_Coords > > area_coords;
+ std::map< Area_Skeleton::Id_Type, std::vector< Coords_Bounds > > area_bounds;
+ for (std::map< Area_Skeleton::Id_Type, std::vector< Area_Block > >::const_iterator it = areas.begin();
+ it != areas.end(); ++it)
+ {
+ std::vector< Coord_Query_Statement::Decoded_Area_Block >& blocks = decoded_zero[it->first];
+ std::vector< Decoded_Coords >& coords = area_coords[it->first];
+ for (std::vector< Area_Block >::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2)
+ {
+ blocks.push_back(Coord_Query_Statement::Decoded_Area_Block(0, *it2));
+ coords.push_back(Decoded_Coords());
+ decode_coords(*it2, coords.back());
+ area_bounds[it->first].push_back(Coords_Bounds(coords.back()));
+ }
+ }
+
// check segments
+ Decoded_Coords sit_coords;
for (std::vector< Area_Block >::const_iterator sit = way_segments[Uint31_Index(current_idx)].begin();
sit != way_segments[Uint31_Index(current_idx)].end(); ++sit)
{
+ decode_coords(*sit, sit_coords);
+ Coords_Bounds sit_bounds(sit_coords);
std::map< Area::Id_Type, int > area_status;
for (std::map< Area_Skeleton::Id_Type, std::vector< Area_Block > >::const_iterator it = areas.begin();
it != areas.end(); ++it)
@@ -931,7 +989,8 @@ void Area_Query_Statement::collect_ways
// The endpoints are properly handled via the point-in-area test
// Check additionally the middle of the segment to also get segments
// that run through the area
- int intersect = intersects_inner(*sit, *it2);
+ int intersect = sit_bounds.overlaps(area_bounds[it->first][it2 - it->second.begin()])
+ ? intersects_inner(sit_coords, area_coords[it->first][it2 - it->second.begin()]) : 0;
if (intersect == Coord_Query_Statement::INTERSECT)
{
ways_inside[Way::Id_Type(sit->id)] = true;
@@ -945,7 +1004,7 @@ void Area_Query_Statement::collect_ways
area_status[it2->id] = Coord_Query_Statement::HIT;
break;
}
- has_inner_points(*sit, *it2, area_status[it2->id]);
+ has_inner_points(sit_coords, decoded_zero[it->first][it2 - it->second.begin()], area_status[it2->id]);
}
}
for (std::map< Area::Id_Type, int >::const_iterator it = area_status.begin(); it != area_status.end(); ++it)
diff --git a/src/overpass_api/statements/area_query.h b/src/overpass_api/statements/area_query.h
index f47a3f047..5a62abb50 100644
--- a/src/overpass_api/statements/area_query.h
+++ b/src/overpass_api/statements/area_query.h
@@ -22,6 +22,7 @@
#include "../data/collect_members.h"
#include "../data/utils.h"
#include "../data/way_geometry_store.h"
+#include "coord_query.h"
#include "statement.h"
#include