Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
b99f528
Reject non-matching ids with a bit filter before binary search
claude Nov 20, 2026
e69776f
around: use fixed-size arrays for 3-D vectors
claude Nov 20, 2026
9e7e909
around: index the input set's geometry with a coarse grid
claude Nov 20, 2026
efe5a93
around: check the query's time limit while filtering candidates
claude Nov 20, 2026
87ddf8a
around: let the tag index drive queries whose around area is large
claude Nov 20, 2026
974fb79
Format output coordinates without general float formatting
claude Nov 21, 2026
f48bd10
Collect relation node members and way nodes in one pass
claude Nov 21, 2026
71283be
bbox filter: keep ways in inner tiles without loading their geometry
claude Nov 21, 2026
844005b
area queries: decode area blocks once per tile, skip blocks out of range
claude Nov 21, 2026
8241b3c
Meta_Collector: keep a tile's metadata in a sorted vector, not a std:…
claude Nov 21, 2026
62b76a2
around grid: test each entry once per lookup, tighter reach for segments
claude Nov 21, 2026
d28dddc
around: take candidate ranges for relation inputs from their members
claude Nov 21, 2026
8e02d2c
user: compute the ids of touched objects once per query
claude Nov 21, 2026
6a52565
query: run metadata-only filters before geometry filters
claude Nov 21, 2026
b7d862b
around: skip index entries without objects when computing candidate r…
claude Nov 21, 2026
eaa97d2
area and poly queries: decode each block once per tile for the segmen…
claude Nov 21, 2026
fba6d6e
Geometry stores: keep member node positions in 16 bytes, not 40
claude Nov 21, 2026
9076b4b
filter_attic_elements: per-index timestamps in a sorted vector, not a…
claude Nov 21, 2026
e888b4f
poly queries: test nodes against blocks decoded once per tile
claude Nov 21, 2026
c0317c3
area and poly queries: skip the segment test when bounding boxes don'…
claude Nov 21, 2026
6e0fba2
collect_items_range: keep the result size up to date instead of recou…
claude Nov 21, 2026
c3f7dc9
Segment pre-check: allow the 1-unit latitude slack intersects_inner uses
claude Nov 21, 2026
e1e42d4
Collect_Items: cap chunk size, and chunk queries at a past date
claude Nov 21, 2026
2faf872
keep_matching_skeletons: valid-until timestamps in a sorted vector, n…
claude Nov 21, 2026
c3e1681
user: keep touched ids for the whole query, whatever their number
claude Nov 21, 2026
ce74094
Collect relation node members and way nodes in one pass at past dates
claude Nov 21, 2026
2cd9448
filter_attic_elements: build and use the timestamps one index at a time
claude Nov 21, 2026
fed254e
changed: collect only the ids other constraints allow
claude Nov 21, 2026
bfe6b2b
bbox query: collect and filter nodes in chunks at a past date
claude Nov 21, 2026
5741a2d
around: weight the time-limit check by the work done, and check insid…
claude Nov 21, 2026
e9d268b
around: take candidate ranges for relations at a past date from their…
claude Nov 21, 2026
36b8967
around: look up the input relations' members once per input
claude Nov 21, 2026
3a0fdd7
Collect_Items: count elements, not only indexes, in way and relation …
claude Nov 22, 2026
cb088cb
bbox query: count the accumulated result in the chunk loop's size checks
claude Nov 22, 2026
bff1c65
print: reserve the id-sorted element references exactly
claude Nov 22, 2026
0126a31
collect_items_by_timestamp: keep the result size up to date instead o…
claude Nov 22, 2026
90a899e
tag_store: remove placeholder tags only from the entries just collected
claude Nov 22, 2026
e2a8b44
Filter bbox and past-date results in place, without vector slack
claude Nov 22, 2026
e9eb5de
Tag_Store: generate the id list once, and keep only a chunk's attic tags
claude Nov 22, 2026
438043b
area and poly queries: build each way's geometry once in collect_ways
claude Nov 22, 2026
958d3fc
tag_store: find tag entries' ids with a forward cursor instead of a b…
claude Nov 22, 2026
7e235b1
Tag_Store: keep only a chunk's ids when printing in chunks
claude Nov 22, 2026
df835cf
print: reference id-sorted elements in 8 bytes
claude Nov 22, 2026
f89c5c9
print: look up current and attic references the same way
claude Nov 22, 2026
ea395d1
query: narrow ranges to the candidates' cells inside them, not all ca…
claude Nov 23, 2026
dc3d2ed
query: merge overlapping ranges before filtering the candidates' cells
claude Nov 23, 2026
36ae3d4
around: build a polyline's candidate range directly
claude Nov 23, 2026
3518ebd
block iterators: compare index entries in place instead of decoding them
claude Nov 26, 2026
20f8ec5
block iterators: decode index entries and objects without a heap allo…
claude Nov 26, 2026
63cecf0
diff: move tags and geometry into the *_With_Context records
claude Nov 26, 2026
77f7956
diff: pass the input set's derived elements to compute_deriveds by re…
claude Nov 26, 2026
2a36c2e
collect_items: remember the last result slot while collecting
claude Nov 26, 2026
b791bc7
local tags: read an entry's cell from the raw index instead of decodi…
claude Nov 26, 2026
55d0e41
area queries: skip the way-area pass when the input holds no way-areas
claude Nov 26, 2026
51f7606
Collect_Items: end a chunk at 16 MiB accounted, not 64 MiB
claude Nov 26, 2026
00aa56c
query: build the late tag check's ids one cell at a time
claude Nov 26, 2026
54e269f
tag filters at a past date: don't add every candidate to the timestam…
claude Nov 26, 2026
013e411
query: run (if:) filters that need geometry after the other filters
claude Nov 26, 2026
b62782b
changed: reuse the ids found within the known ids in filter()
claude Nov 26, 2026
3289cfa
union: keep decompressed blocks while statements will re-read them
claude Nov 24, 2026
0c8a586
tags: run tag index regexes once per key and value, not per element
claude Nov 24, 2026
631fca7
query: read only the checked keys' tag entries in late tag checks
claude Nov 24, 2026
2100eab
regex: match plain word alternations without the regex library
claude Nov 24, 2026
ed5c1dc
tags: remove redundant sorts of the candidate ids for late tag checks
claude Nov 25, 2026
235f782
bbox: don't load the geometry of ways whose index lies inside the bbox
claude Nov 24, 2026
d9e2a5d
around: don't load the geometry of ways whose index lies within the r…
claude Nov 24, 2026
bf412ad
around: skip points too far apart in latitude before the distance test
claude Nov 24, 2026
9f4813c
recurse: handle wr(bn) in the query constraint
claude Nov 24, 2026
b9ae842
tags: bound the ids collected from attic tags, as for current data
claude Nov 24, 2026
f6fece3
changed: scan only the changelogs of element types in the set
claude Nov 24, 2026
910482d
recurse: skip the scan for parent relations of no relations
claude Nov 24, 2026
11cfa03
Write escaped strings in one pass, copying runs that need no escaping
claude Nov 24, 2026
0de947f
tag_store: build each element's tag list once, at its final size
claude Nov 25, 2026
a71b7e3
output: hand tags to output handlers by reference, without copying them
claude Nov 25, 2026
6f16ee2
query: drop tag-index candidates outside the query's ranges during th…
claude Nov 26, 2026
835abb5
query: collect few tag-index candidates by their exact indices
claude Nov 26, 2026
13f99e4
tags: reject entries of later keys with a bit filter before the binar…
claude Nov 26, 2026
3b6e5ba
tag_store: reject other elements' tag entries with a bit filter
claude Nov 26, 2026
af72b3c
block cache: don't keep global tag index blocks
claude Nov 27, 2026
02ea396
query: collect only the elements the local tag index says match
claude Nov 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ nobase_dist_HEADERS = \
overpass_api/core/index_computations.h\
overpass_api/core/parsed_query.h\
overpass_api/core/settings.h\
overpass_api/core/tag_list.h\
overpass_api/core/type_area.h\
overpass_api/core/type_node.h\
overpass_api/core/type_relation.h\
Expand Down Expand Up @@ -278,6 +279,7 @@ nobase_dist_HEADERS = \
overpass_api/osm-backend/way_updater.h\
overpass_api/output_formats/output_csv.h\
overpass_api/output_formats/output_custom.h\
overpass_api/output_formats/fixed7.h\
overpass_api/output_formats/output_json.h\
overpass_api/output_formats/output_popup.h\
overpass_api/output_formats/output_xml.h\
Expand Down
87 changes: 69 additions & 18 deletions src/expat/escape_json.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,31 +16,82 @@
* along with Overpass_API. If not, see <http://www.gnu.org/licenses/>.
*/

#include <ostream>
#include <string>

#include "escape_json.h"


std::string escape_cstr(const std::string& s)
namespace
{
std::string result;
result.reserve(s.length()*2);
for (std::string::size_type i(0); i < s.size(); ++i)

struct Replacements
{
Replacements()
{
for (int c = 0; c < 256; ++c)
replacement[c] = c < 32 ? "?" : 0;
replacement[(unsigned char)'\"'] = "\\\"";
replacement[(unsigned char)'\\'] = "\\\\";
replacement[(unsigned char)'\n'] = "\\n";
replacement[(unsigned char)'\t'] = "\\t";
replacement[(unsigned char)'\r'] = "\\r";
}

// What each byte is written as, or 0 if it is written as it is.
const char* replacement[256];
};


const Replacements& replacements()
{
static const Replacements result;
return result;
}


struct Stream_Sink
{
std::ostream& out;
void append(const char* s, std::string::size_type n) { out.write(s, n); }
void append(const char* s) { out<<s; }
};


template< typename Sink >
void write_escaped(const std::string& s, Sink& sink)
{
const Replacements& table = replacements();
const char* run = s.data();
const char* end = s.data() + s.size();
for (const char* pos = run; pos != end; ++pos)
{
if (s[i] == '\"')
result += "\\\"";
else if (s[i] == '\\')
result += "\\\\";
else if (s[i] == '\n')
result += "\\n";
else if (s[i] == '\t')
result += "\\t";
else if (s[i] == '\r')
result += "\\r";
else if ((unsigned char)s[i] < 32)
result += '?';
else
result += s[i];
const char* replacement = table.replacement[(unsigned char)*pos];
if (replacement)
{
sink.append(run, pos - run);
sink.append(replacement);
run = pos + 1;
}
}
sink.append(run, end - run);
}

}


std::string escape_cstr(const std::string& s)
{
std::string result;
result.reserve(s.size());
write_escaped(s, result);
return result;
}


std::ostream& operator<<(std::ostream& out, const Json_Escaped& e)
{
Stream_Sink sink{out};
write_escaped(e.s, sink);
return out;
}
11 changes: 11 additions & 0 deletions src/expat/escape_json.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,21 @@
#ifndef DE__OSM3S___EXPAT__ESCAPE_JSON_H
#define DE__OSM3S___EXPAT__ESCAPE_JSON_H

#include <ostream>
#include <string>


std::string escape_cstr(const std::string& s);


// Writes escape_cstr(s) to a stream without building the escaped copy. s must outlive the expression.
struct Json_Escaped
{
explicit Json_Escaped(const std::string& s_) : s(s_) {}
const std::string& s;
};

std::ostream& operator<<(std::ostream& out, const Json_Escaped& e);


#endif
88 changes: 68 additions & 20 deletions src/expat/escape_xml.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,36 +16,84 @@
* along with Overpass_API. If not, see <http://www.gnu.org/licenses/>.
*/

#include <ostream>
#include <string>

#include "escape_xml.h"


std::string escape_xml(const std::string& s)
namespace
{
const char* digit = "0123456789abcdef";

std::string result;
result.reserve(s.length()*2);
for (std::string::size_type i(0); i < s.size(); ++i)
struct Replacements
{
Replacements()
{
if (s[i] == '&')
result += "&amp;";
else if (s[i] == '\"')
result += "&quot;";
else if (s[i] == '<')
result += "&lt;";
else if (s[i] == '>')
result += "&gt;";
else if ((unsigned char)s[i] < 32)
for (int c = 0; c < 256; ++c)
replacement[c] = c < 32 ? "?" : 0;
replacement[(unsigned char)'&'] = "&amp;";
replacement[(unsigned char)'\"'] = "&quot;";
replacement[(unsigned char)'<'] = "&lt;";
replacement[(unsigned char)'>'] = "&gt;";
replacement[(unsigned char)'\t'] = "&#x09;";
replacement[(unsigned char)'\n'] = "&#x0a;";
replacement[(unsigned char)'\r'] = "&#x0d;";
}

// What each byte is written as, or 0 if it is written as it is.
const char* replacement[256];
};


const Replacements& replacements()
{
static const Replacements result;
return result;
}


struct Stream_Sink
{
std::ostream& out;
void append(const char* s, std::string::size_type n) { out.write(s, n); }
void append(const char* s) { out<<s; }
};


template< typename Sink >
void write_escaped(const std::string& s, Sink& sink)
{
const Replacements& table = replacements();
const char* run = s.data();
const char* end = s.data() + s.size();
for (const char* pos = run; pos != end; ++pos)
{
const char* replacement = table.replacement[(unsigned char)*pos];
if (replacement)
{
if ((s[i] == '\n') || (s[i] == '\t') || (s[i] == '\r'))
result += std::string("&#x") + digit[s[i] / 16] + digit[s[i] % 16] + ';';
else
result += '?';
sink.append(run, pos - run);
sink.append(replacement);
run = pos + 1;
}
else
result += s[i];
}
sink.append(run, end - run);
}

}


std::string escape_xml(const std::string& s)
{
std::string result;
result.reserve(s.size());
write_escaped(s, result);
return result;
}


std::ostream& operator<<(std::ostream& out, const Xml_Escaped& e)
{
Stream_Sink sink{out};
write_escaped(e.s, sink);
return out;
}
11 changes: 11 additions & 0 deletions src/expat/escape_xml.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,21 @@
#ifndef DE__OSM3S___EXPAT__ESCAPE_XML_H
#define DE__OSM3S___EXPAT__ESCAPE_XML_H

#include <ostream>
#include <string>


std::string escape_xml(const std::string& s);


// Writes escape_xml(s) to a stream without building the escaped copy. s must outlive the expression.
struct Xml_Escaped
{
explicit Xml_Escaped(const std::string& s_) : s(s_) {}
const std::string& s;
};

std::ostream& operator<<(std::ostream& out, const Xml_Escaped& e);


#endif
47 changes: 47 additions & 0 deletions src/overpass_api/core/tag_list.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/** Copyright 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018 Roland Olbricht et al.
*
* This file is part of Overpass_API.
*
* Overpass_API is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* Overpass_API 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 General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Overpass_API. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef DE__OSM3S___OVERPASS_API__CORE__TAG_LIST_H
#define DE__OSM3S___OVERPASS_API__CORE__TAG_LIST_H

#include <string>
#include <utility>
#include <vector>


// A tag that refers to a key and value stored elsewhere.
struct Tag_Ref
{
Tag_Ref(const std::string& first_, const std::string& second_) : first(first_), second(second_) {}
const std::string& first;
const std::string& second;
};

typedef std::vector< Tag_Ref > Tag_List;


inline void make_tag_list(const std::vector< std::pair< std::string, std::string > >& tags, Tag_List& result)
{
result.clear();
result.reserve(tags.size());
for (std::vector< std::pair< std::string, std::string > >::const_iterator it = tags.begin(); it != tags.end(); ++it)
result.push_back(Tag_Ref(it->first, it->second));
}


#endif
21 changes: 21 additions & 0 deletions src/overpass_api/core/type_node.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,33 @@ struct Node
};


// A node's id and position without Node's tag vector, so it takes 16 bytes instead of 40.
// The geometry stores keep many of these to look up the coordinates of way and relation members.
struct Node_Position
{
typedef Node::Id_Type Id_Type;

Id_Type id;
uint32 index;
uint32 ll_lower_;

Node_Position(Id_Type id_, uint32 ll_upper_, uint32 ll_lower__)
: id(id_), index(ll_upper_), ll_lower_(ll_lower__)
{}
};


struct Node_Comparator_By_Id {
bool operator() (const Node& a, const Node& b)
{
return (a.id.val() < b.id.val());
}

bool operator() (const Node_Position& a, const Node_Position& b)
{
return (a.id.val() < b.id.val());
}

bool operator() (const Node* a, const Node* b)
{
return (a->id.val() < b->id.val());
Expand Down
Loading