diff --git a/topography_generator/generator.cpp b/topography_generator/generator.cpp index 6a997aa627..e84550c221 100644 --- a/topography_generator/generator.cpp +++ b/topography_generator/generator.cpp @@ -101,6 +101,7 @@ private: { auto const tileName = generator::SrtmTile::GetBase(ms::LatLon(lat, lon)); LOG(LINFO, ("Begin generating isolines for tile", tileName)); + ms::LatLon const leftBottom = ms::LatLon(lat, lon); ms::LatLon const rightTop = ms::LatLon(lat + 1.0, lon + 1.0); double const squaresStep = 1.0 / (kArcSecondsInDegree) * m_params.m_latLonStepFactor; @@ -126,7 +127,11 @@ private: squares.GenerateContours(contours); } + LOG(LINFO, ("Isolines for tile", tileName, "min altitude", contours.m_minValue, + "max altitude", contours.m_maxValue, "invalid values count", contours.m_invalidValuesCount)); + SaveContrours(GetIsolinesFilePath(lat, lon, m_params.m_outputDir), std::move(contours)); + LOG(LINFO, ("End generating isolines for tile", tileName)); } diff --git a/topography_generator/marching_squares/contours_builder.cpp b/topography_generator/marching_squares/contours_builder.cpp index 4c5156894e..d399f70c86 100644 --- a/topography_generator/marching_squares/contours_builder.cpp +++ b/topography_generator/marching_squares/contours_builder.cpp @@ -40,7 +40,7 @@ void ContoursBuilder::AddSegment(size_t levelInd, ms::LatLon const & beginPos, m else if (connectEnd) { contourItAfter->m_countour.push_front(beginPos); - contourItBefore->m_active = true; + contourItAfter->m_active = true; } else { diff --git a/topography_generator/marching_squares/marching_squares.hpp b/topography_generator/marching_squares/marching_squares.hpp index a57bd55856..fb204235da 100644 --- a/topography_generator/marching_squares/marching_squares.hpp +++ b/topography_generator/marching_squares/marching_squares.hpp @@ -44,16 +44,16 @@ public: ContoursBuilder contoursBuilder(levelsCount); - for (size_t i = 0; i < m_stepsCountLat - 1; ++i) + for (size_t i = 0; i < m_stepsCountLat; ++i) { contoursBuilder.BeginLine(); - for (size_t j = 0; j < m_stepsCountLon - 1; ++j) + for (size_t j = 0; j < m_stepsCountLon; ++j) { auto const pos = ms::LatLon(m_leftBottom.m_lat + m_step * i, m_leftBottom.m_lon + m_step * j); Square square(pos, m_step, result.m_minValue, m_valueStep, m_valuesProvider); square.GenerateSegments(contoursBuilder); } - auto const isLastLine = i == m_stepsCountLat - 2; + auto const isLastLine = i == m_stepsCountLat - 1; contoursBuilder.EndLine(isLastLine); } @@ -66,9 +66,9 @@ private: minValue = maxValue = m_valuesProvider.GetValue(m_leftBottom); invalidValuesCount = 0; - for (size_t i = 0; i < m_stepsCountLat; ++i) + for (size_t i = 0; i <= m_stepsCountLat; ++i) { - for (size_t j = 0; j < m_stepsCountLon; ++j) + for (size_t j = 0; j <= m_stepsCountLon; ++j) { auto const pos = ms::LatLon(m_leftBottom.m_lat + m_step * i, m_leftBottom.m_lon + m_step * j); diff --git a/topography_generator/utils/contours_serdes.hpp b/topography_generator/utils/contours_serdes.hpp index a03948b9e1..34d6993e9f 100644 --- a/topography_generator/utils/contours_serdes.hpp +++ b/topography_generator/utils/contours_serdes.hpp @@ -20,6 +20,7 @@ public: WriteToSink(sink, m_contours.m_minValue); WriteToSink(sink, m_contours.m_maxValue); WriteToSink(sink, m_contours.m_valueStep); + WriteToSink(sink, static_cast(m_contours.m_invalidValuesCount)); WriteToSink(sink, static_cast(m_contours.m_contours.size())); for (auto const & levelContours : m_contours.m_contours) @@ -35,23 +36,17 @@ private: WriteToSink(sink, value); WriteToSink(sink, static_cast(contours.size())); for (auto const & contour : contours) - { SerializeContour(sink, contour); - } } template void SerializeContour(Sink & sink, topography_generator::Contour const & contour) { - WriteToSink(sink, static_cast(contour.size())); - sink.Write(contour.data(), contour.size() * sizeof(contour[0])); - /* - serial::GeometryCodingParams codingParams(kFeatureSorterPointCoordBits, 0); + serial::GeometryCodingParams codingParams; + serial::SavePoint(sink, contour[0], codingParams); codingParams.SetBasePoint(contour[0]); - std::vector toSave; - toSave.insert(contour.begin() + 1, contour.end()); - serial::SaveInnerPath(toSave, codingParams, sink); - */ + std::vector toSave(contour.begin() + 1, contour.end()); + serial::SaveOuterPath(contour, codingParams, sink); } Contours m_contours; @@ -68,6 +63,7 @@ public: contours.m_minValue = ReadPrimitiveFromSource(source); contours.m_maxValue = ReadPrimitiveFromSource(source); contours.m_valueStep = ReadPrimitiveFromSource(source); + contours.m_invalidValuesCount = ReadPrimitiveFromSource(source); size_t const levelsCount = ReadPrimitiveFromSource(source); for (size_t i = 0; i < levelsCount; ++i) @@ -93,9 +89,12 @@ private: void DeserializeContour(NonOwningReaderSource & source, topography_generator::Contour & contour) { - size_t const pointsCount = ReadPrimitiveFromSource(source); - contour.resize(pointsCount); - source.Read(contour.data(), pointsCount * sizeof(contour[0])); + serial::GeometryCodingParams codingParams; + auto const pt = serial::LoadPoint(source, codingParams); + codingParams.SetBasePoint(pt); + std::vector points; + serial::LoadOuterPath(source, codingParams, points); + contour.swap(points); } };