~thomas-voss/location-service/add_controller_and_service_configuration

« back to all changes in this revision

Viewing changes to tests/gps_provider_test.cpp

  • Committer: thomas-voss
  • Date: 2014-06-13 16:26:43 UTC
  • Revision ID: thomas.voss@canonical.com-20140613162643-lyki2pbgmn5h0qpg
Make reference position more readable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
532
532
// HardwareAbstractionLayerFixture.time_to_first_fix_cold_start_with_supl_benchmark_requires_hardware
533
533
TEST_F(HardwareAbstractionLayerFixture, time_to_first_fix_cold_start_with_supl_benchmark_requires_hardware)
534
534
{
 
535
    using namespace core::posix;
 
536
 
535
537
    typedef boost::accumulators::accumulator_set<
536
538
        double,
537
539
        boost::accumulators::stats<
581
583
 
582
584
    location::Position ref_pos
583
585
    {
584
 
        location::wgs84::Latitude{51.444670 * location::units::Degrees},
585
 
        location::wgs84::Longitude{7.210852 * location::units::Degrees}
 
586
        location::wgs84::Latitude
 
587
        {
 
588
            std::stod(this_process::env::get(
 
589
                          "GPS_SUPL_BENCHMARK_REF_LAT", "51.444670")) * location::units::Degrees
 
590
        },
 
591
        location::wgs84::Longitude
 
592
        {
 
593
            std::stod(this_process::env::get(
 
594
                          "GPS_SUPL_BENCHMARK_REF_LON", "7.210852")) * location::units::Degrees
 
595
        }
586
596
    };
587
 
    ref_pos.accuracy.horizontal = 10 * location::units::Meters;
588
 
 
589
 
    try
590
 
    {
591
 
        auto s = core::posix::this_process::env::get_or_throw("GPS_SUPL_BENCHMARK_REF_LAT");
592
 
        ref_pos.latitude = location::wgs84::Latitude{std::stod(s) * location::units::Degrees};
593
 
    } catch(const std::exception& e)
594
 
    {
595
 
        std::cerr << e.what() << std::endl;
596
 
    }
597
 
 
598
 
    try
599
 
    {
600
 
        auto s = core::posix::this_process::env::get_or_throw("GPS_SUPL_BENCHMARK_REF_LON");
601
 
        ref_pos.longitude = location::wgs84::Longitude{std::stod(s) * location::units::Degrees};
602
 
    } catch(const std::exception& e)
603
 
    {
604
 
        std::cerr << e.what() << std::endl;
605
 
    }
606
 
 
607
 
    try
608
 
    {
609
 
        auto s = core::posix::this_process::env::get_or_throw("GPS_SUPL_BENCHMARK_REF_ACCURACY");
610
 
        ref_pos.accuracy.horizontal = std::stod(s) * location::units::Meters;
611
 
    } catch(const std::exception& e)
612
 
    {
613
 
        std::cerr << e.what() << std::endl;
614
 
    }
 
597
 
 
598
    ref_pos.accuracy.horizontal
 
599
            = std::stod(this_process::env::get(
 
600
                            "GPS_SUPL_BENCHMARK_REF_ACCURACY", "10")) * location::units::Meters;
615
601
 
616
602
    // We wire up our state to position updates from the hal.
617
603
    hal->position_updates().connect([&state](const location::Position& pos)
619
605
        try
620
606
        {
621
607
            // This will throw if the env variable is not set.
622
 
            core::posix::this_process::env::get(enable_harvesting_key);
 
608
            core::posix::this_process::env::get_or_throw(enable_harvesting_key);
623
609
 
624
 
            the_harvester().report_position_update(location::Update<location::Position>
625
 
            {
626
 
                pos, location::Clock::now()
627
 
            });
 
610
            the_harvester().report_position_update(
 
611
                        location::Update<location::Position>
 
612
                        {
 
613
                            pos, location::Clock::now()
 
614
                        });
628
615
        } catch(...)
629
616
        {
630
617
        }