From 193723415201500c325b6116b39cbbffdec4947f Mon Sep 17 00:00:00 2001 From: Anatoly Serdtcev Date: Mon, 8 Jul 2019 11:28:30 +0300 Subject: [PATCH] [generator:regions] Fix around place insertion --- .../regions/locality_point_integrator.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/generator/regions/locality_point_integrator.cpp b/generator/regions/locality_point_integrator.cpp index 718ab92ca6..caad2db103 100644 --- a/generator/regions/locality_point_integrator.cpp +++ b/generator/regions/locality_point_integrator.cpp @@ -148,14 +148,16 @@ void LocalityPointIntegrator::EmboundBy(LevelRegion const & region) continue; // Skip error in boost::geometry::intersection(): there are A and B when - // intersection(A, B) != null and intersection(A, intersection(A, B)) == null. - auto checkPolygon = boost::geometry::model::multi_polygon{}; - boost::geometry::intersection(regionPolygon, polygon, checkPolygon); - if (checkPolygon.empty()) - continue; - - m_localityRegion.SetPolygon(std::make_shared(std::move(polygon))); - return; + // intersection(A, B) != null but intersection(A, B) != intersection(A, intersection(A, B)) + // or !covered_by(intersection(A, B), A). + auto checkLocalityRegion = m_localityRegion; + checkLocalityRegion.SetPolygon(std::make_shared(std::move(polygon))); + if (0 < RegionsBuilder::CompareAffiliation(region, checkLocalityRegion, + m_countrySpecifier)) + { + m_localityRegion = checkLocalityRegion; + return; + } } LOG(LWARNING, ("Failed to embound",