Skip to content

Commit

Permalink
[generator] add tool for post processing borders.
Browse files Browse the repository at this point in the history
  • Loading branch information
gmoryes authored and mpimenov committed Mar 4, 2020
1 parent 4683f80 commit 0e21eff
Show file tree
Hide file tree
Showing 16 changed files with 1,561 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ IncludeBlocks: Regroup
IncludeCategories:
# Tests --------------------------------------------------------------------------------------------
- Regex: '^"track_analyzing/track_analyzing_tests/'
Priority: 4730

- Regex: '^"poly_borders/poly_borders_tests/'
Priority: 4740

- Regex: '^"generator/generator_integration_tests/'
Expand Down Expand Up @@ -191,6 +194,9 @@ IncludeCategories:

# Libraries ----------------------------------------------------------------------------------------

- Regex: '^"poly_borders/'
Priority: 46700

- Regex: '^"track_analyzing/'
Priority: 46800

Expand Down
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ if (PLATFORM_DESKTOP)
add_subdirectory(feature_list)
add_subdirectory(generator)
add_subdirectory(openlr)
add_subdirectory(poly_borders)
add_subdirectory(topography_generator)
add_subdirectory(track_analyzing)
add_subdirectory(track_generator)
Expand Down
14 changes: 12 additions & 2 deletions base/non_intersecting_intervals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class NonIntersectingIntervals
/// \brief Adds new interval to set if it doesn't intersect with any that has been already added.
/// \return true if there are no such intervals, that intersect the [left, right] interval.
bool AddInterval(T left, T right);
bool Intersects(T left, T right) const;

private:
struct Interval
Expand All @@ -40,14 +41,23 @@ class NonIntersectingIntervals
};

template <typename T>
bool NonIntersectingIntervals<T>::AddInterval(T left, T right)
bool NonIntersectingIntervals<T>::Intersects(T left, T right) const
{
Interval interval(left, right);
auto it = m_leftEnds.lower_bound(interval);
if (it != m_leftEnds.end() && interval.Intersects(*it))
return false;
return true;

if (it != m_leftEnds.begin() && interval.Intersects(*std::prev(it)))
return true;

return false;
}

template <typename T>
bool NonIntersectingIntervals<T>::AddInterval(T left, T right)
{
if (Intersects(left, right))
return false;

m_leftEnds.emplace(left, right);
Expand Down
2 changes: 2 additions & 0 deletions generator/borders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ void DumpBorderToPolyFile(std::string const & targetDir, storage::CountryId cons
std::ofstream poly(filePath);
CHECK(poly.good(), ());

poly << std::setprecision(20) << std::fixed;

poly << mwmName << std::endl;
size_t polygonId = 1;
for (auto const & points : polygons)
Expand Down
15 changes: 15 additions & 0 deletions poly_borders/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
project(poly_borders)

set(
SRC
borders_data.cpp
borders_data.hpp
help_structures.cpp
help_structures.hpp
)

omim_add_library(${PROJECT_NAME} ${SRC})

omim_add_test_subdirectory(poly_borders_tests)

add_subdirectory(poly_borders_tool)
Loading

0 comments on commit 0e21eff

Please sign in to comment.