Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 10 additions & 4 deletions src/overpass_api/data/bbox_filter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,24 @@ void filter_by_bbox(const Bbox_Double& bbox, std::map< Index, std::vector< Coord

for (typename std::map< Index, std::vector< Coord > >::iterator it = nodes.begin(); it != nodes.end(); ++it)
{
std::vector< Coord > local_into;
for (typename std::vector< Coord >::const_iterator iit = it->second.begin();
// Compact in place, keeping the order, and drop the slack left by growing the vector.
typename std::vector< Coord >::iterator out = it->second.begin();
for (typename std::vector< Coord >::iterator iit = it->second.begin();
iit != it->second.end(); ++iit)
{
uint32 lat(::ilat(it->first.val(), iit->ll_lower));
int32 lon(::ilon(it->first.val(), iit->ll_lower));
if ((lat >= south) && (lat <= north) &&
(((lon >= west) && (lon <= east))
|| ((east < west) && ((lon >= west) || (lon <= east)))))
local_into.push_back(*iit);
{
if (out != iit)
*out = *iit;
++out;
}
}
it->second.swap(local_into);
it->second.erase(out, it->second.end());
it->second.shrink_to_fit();
}
}

Expand Down
33 changes: 21 additions & 12 deletions src/overpass_api/data/collect_members.h
Original file line number Diff line number Diff line change
Expand Up @@ -355,44 +355,53 @@ void filter_attic_elements
for (typename std::map< Index, std::vector< Skeleton > >::iterator it = current.begin();
it != current.end(); ++it)
{
std::vector< Skeleton > result;
std::map< typename Skeleton::Id_Type, std::pair< uint64, uint64 > >& entry
= timestamp_by_id_by_idx[it->first];

for (typename std::vector< Skeleton >::const_iterator it2 = it->second.begin();
// Compact in place, keeping the order, and drop the slack left by growing the vector.
typename std::vector< Skeleton >::iterator out = it->second.begin();
for (typename std::vector< Skeleton >::iterator it2 = it->second.begin();
it2 != it->second.end(); ++it2)
{
if (entry[it2->id].first > 0)
{
if (entry[it2->id].second == NOW)
result.push_back(*it2);
{
if (out != it2)
*out = std::move(*it2);
++out;
}
else
attic[it->first].push_back(Attic< Skeleton >(*it2, entry[it2->id].second));
}
}

result.swap(it->second);
it->second.erase(out, it->second.end());
it->second.shrink_to_fit();
}

// Filter attic: only keep elements that have already existed at timestamp
for (typename std::map< Index, std::vector< Attic< Skeleton > > >::iterator it = attic.begin();
it != attic.end(); ++it)
{
std::vector< Attic< Skeleton > > result;
std::map< typename Skeleton::Id_Type, std::pair< uint64, uint64 > >& entry
= timestamp_by_id_by_idx[it->first];

for (typename std::vector< Attic< Skeleton > >::const_iterator it2 = it->second.begin();
// Compact in place, as above.
typename std::vector< Attic< Skeleton > >::iterator out = it->second.begin();
for (typename std::vector< Attic< Skeleton > >::iterator it2 = it->second.begin();
it2 != it->second.end(); ++it2)
{
if (entry[it2->id].first > 0)
const std::pair< uint64, uint64 >& timestamps = entry[it2->id];
if (timestamps.first > 0)
{
result.push_back(*it2);
result.back().timestamp = entry[it2->id].second;
if (out != it2)
*out = std::move(*it2);
out->timestamp = timestamps.second;
++out;
}
}

result.swap(it->second);
it->second.erase(out, it->second.end());
it->second.shrink_to_fit();
}
}
}
Expand Down