[generator] nullbuilding fix

This commit is contained in:
LaGrunge 2019-08-07 17:40:55 +03:00 committed by cc-engineering
parent 29769938f1
commit 7274c8b24d
2 changed files with 45 additions and 17 deletions

View file

@ -107,7 +107,8 @@ GeoObjectsGenerator TearUp(std::vector<OsmElementData> const & osmElements,
1 /* threadsCount */};
}
void TestFindReverse(std::vector<OsmElementData> const & osmElements)
void TestFindReverse(std::vector<OsmElementData> const & osmElements,
std::vector<m2::PointD> const & where)
{
classificator::Load();
ScopedFile const geoObjectsFeatures{"geo_objects_features.mwm", ScopedFile::Mode::DoNotCreate};
@ -126,9 +127,10 @@ void TestFindReverse(std::vector<OsmElementData> const & osmElements)
TEST(geoObjectsIndex.has_value(), ("Temporary index build failed"));
TEST(CheckWeGotExpectedIdsByPoint({1.5, 1.5}, expectedIds, *geoObjectsIndex), ());
TEST(CheckWeGotExpectedIdsByPoint({2, 2}, expectedIds, *geoObjectsIndex), ());
TEST(CheckWeGotExpectedIdsByPoint({4, 4}, expectedIds, *geoObjectsIndex), ());
for (auto const & point : where)
{
TEST(CheckWeGotExpectedIdsByPoint(point, expectedIds, *geoObjectsIndex), ());
}
}
UNIT_TEST(GenerateGeoObjects_AddNullBuildingGeometryForPointsWithAddressesInside)
@ -150,7 +152,8 @@ UNIT_TEST(GenerateGeoObjects_AddNullBuildingGeometryForPointsWithAddressesInside
{{1.6, 1.6}},
{}}
};
TestFindReverse(osmElements);
TestFindReverse(osmElements, {{1.5, 1.5}, {2, 2}, {4, 4}});
}
UNIT_TEST(GenerateGeoObjects_AddNullBuildingGeometryForPointsWithAddressesInside2)
@ -174,7 +177,24 @@ UNIT_TEST(GenerateGeoObjects_AddNullBuildingGeometryForPointsWithAddressesInside
{}},
};
TestFindReverse(osmElements);
TestFindReverse(osmElements, {{1.5, 1.5}, {2, 2}, {4, 4}});
}
UNIT_TEST(GenerateGeoObjects_AddNullBuildingPointToPoint)
{
std::vector<OsmElementData> const osmElements{
{1,
{{"addr:housenumber", "39 с79"},
{"addr:street", "Ленинградский проспект"},
{"building", "yes"}},
{{1.5, 1.5}},
{}},
{3,
{{"building", "commercial"}, {"type", "multipolygon"}, {"name", "superbuilding"}},
{{1.5, 1.5}},
{}},
};
TestFindReverse(osmElements, {});
}
void TestPoiHasAddress(std::vector<OsmElementData> const & osmElements)

View file

@ -188,20 +188,28 @@ size_t AddBuildingGeometriesToAddressPoints(std::string const & pathInGeoObjects
auto point2BuildingIt = buildingsInfo.m_addressPoints2Buildings.find(id);
if (point2BuildingIt != buildingsInfo.m_addressPoints2Buildings.end())
{
auto const & geometry = geometries.at(point2BuildingIt->second);
auto geometryIt = geometries.find(point2BuildingIt->second);
if (geometryIt != geometries.end())
{
auto const & geometry = geometryIt->second;
// ResetGeometry does not reset center but SetCenter changes geometry type to Point and
// adds center to bounding rect
fb.SetCenter({});
// ResetGeometry clears bounding rect
fb.ResetGeometry();
fb.GetParams().SetGeomType(feature::GeomType::Area);
// ResetGeometry does not reset center but SetCenter changes geometry type to Point and
// adds center to bounding rect
fb.SetCenter({});
// ResetGeometry clears bounding rect
fb.ResetGeometry();
fb.GetParams().SetGeomType(feature::GeomType::Area);
for (std::vector<m2::PointD> poly : geometry)
fb.AddPolygon(poly);
for (std::vector<m2::PointD> poly : geometry)
fb.AddPolygon(poly);
fb.PreSerialize();
++pointsEnriched;
fb.PreSerialize();
++pointsEnriched;
}
else
{
LOG(LINFO, (point2BuildingIt->second, "is a null building with strange geometry"));
}
}
std::lock_guard<std::mutex> lock(collectorMutex);
collector.Collect(fb);