LCOV - code coverage report
Current view: top level - tests/point - RandomGeometry.hpp (source / functions) Hit Total Coverage
Test: ad_map_access Lines: 21 21 100.0 %
Date: 2022-10-04 09:48:07 Functions: 3 3 100.0 %
Branches: 8 14 57.1 %

           Branch data     Line data    Source code
       1                 :            : // ----------------- BEGIN LICENSE BLOCK ---------------------------------
       2                 :            : //
       3                 :            : // Copyright (C) 2018-2021 Intel Corporation
       4                 :            : //
       5                 :            : // SPDX-License-Identifier: MIT
       6                 :            : //
       7                 :            : // ----------------- END LICENSE BLOCK -----------------------------------
       8                 :            : 
       9                 :            : #pragma once
      10                 :            : 
      11                 :            : #include <ad/map/point/Operation.hpp>
      12                 :            : #include <cstdlib>
      13                 :            : 
      14                 :            : using namespace ad;
      15                 :            : using namespace ad::map;
      16                 :            : 
      17                 :         13 : inline point::ECEFPoint randECEFPoint()
      18                 :            : {
      19                 :         13 :   double rndLat = std::rand() / static_cast<double>(RAND_MAX);
      20                 :         13 :   double rndLon = std::rand() / static_cast<double>(RAND_MAX);
      21                 :         13 :   double rndAlt = std::rand() / static_cast<double>(RAND_MAX);
      22                 :            : 
      23                 :         13 :   auto lat = point::Latitude(-90.0 + 180.0 * rndLat);
      24                 :         13 :   auto lon = point::Longitude(-180.0 + 360.0 * rndLon);
      25                 :         13 :   auto alt = point::Altitude(-100.0 + 3100.0 * rndAlt);
      26         [ +  - ]:         26 :   return point::toECEF(point::createGeoPoint(lon, lat, alt));
      27                 :            : }
      28                 :            : 
      29                 :         44 : inline point::Geometry randGeometry(const point::ECEFPoint &pt0, size_t points, uint32_t seed)
      30                 :            : {
      31                 :         88 :   point::ECEFEdge pts;
      32                 :         44 :   std::srand(seed);
      33                 :         44 :   point::ECEFPoint pt = pt0;
      34         [ +  - ]:         44 :   pts.push_back(pt);
      35         [ +  + ]:       2697 :   for (size_t i = 1; i < points; i++)
      36                 :            :   {
      37                 :       2653 :     auto offsetPt = point::createECEFPoint(std::rand() % 10, std::rand() % 10, std::rand() % 10);
      38         [ +  - ]:       2653 :     pt = pt + offsetPt;
      39         [ +  - ]:       2653 :     pts.push_back(pt);
      40                 :            :   }
      41         [ +  - ]:         88 :   return point::createGeometry(pts, false);
      42                 :            : }
      43                 :            : 
      44                 :          7 : inline point::Geometry randGeometry(size_t points, uint32_t seed)
      45                 :            : {
      46                 :          7 :   std::srand(seed ^ 0x12345678);
      47         [ +  - ]:         14 :   return randGeometry(randECEFPoint(), points, seed);
      48                 :            : }

Generated by: LCOV version 1.14