Example #1
0
void RoadGraphMockSource::FindClosestEdges(m2::PointD const & point, uint32_t count,
                                           vector<pair<Edge, Junction>> & vicinities) const
{
  UNUSED_VALUE(point);
  UNUSED_VALUE(count);
  UNUSED_VALUE(vicinities);
}
Example #2
0
void Platform::RunAsync(TFunctor const & fn, Priority p)
{
  UNUSED_VALUE(p);

  // We don't need to store thread handler in POSIX, just create and
  // run.  Unfortunately we can't use std::async() here since it
  // doesn't attach to JVM threads.
  threads::Thread().Create(make_unique<FunctorWrapper>(fn));
}
Example #3
0
void LayerRenderer::OnTouchCancel(m2::RectD const & touchArea)
{
  UNUSED_VALUE(touchArea);
  if (m_activeOverlay != nullptr)
  {
    m_activeOverlay->OnTapEnd();
    m_activeOverlay = nullptr;
    m_activeOverlayId = FeatureID();
  }
}
Example #4
0
double RulerHelper::CalcMetresDiff(double value)
{
  UnitValue * arrU = g_arrMetres;
  int count = ARRAY_SIZE(g_arrMetres);

  typedef double (*ConversionFn)(double);
  ConversionFn conversionFn = &identity;

  auto units = measurement_utils::Units::Metric;
  UNUSED_VALUE(settings::Get(settings::kMeasurementUnits, units));

  if (units == measurement_utils::Units::Imperial)
  {
    arrU = g_arrFeets;
    count = ARRAY_SIZE(g_arrFeets);
    conversionFn = &measurement_utils::MetersToFeet;
  }

  int prevUnitRange = m_rangeIndex;
  double result = 0.0;
  double v = conversionFn(value);
  if (arrU[0].m_i > v)
  {
    m_rangeIndex = MinUnitValue;
    m_rulerText = string("< ") + arrU[0].m_s;
    result = MinMetersWidth - 1.0;
  }
  else if (arrU[count-1].m_i <= v)
  {
    m_rangeIndex = MaxUnitValue;
    m_rulerText = string("> ") + arrU[count-1].m_s;
    result = MaxMetersWidth + 1.0;
  }
  else
    for (int i = 0; i < count; ++i)
    {
      if (arrU[i].m_i > v)
      {
        m_rangeIndex = i;
        result = arrU[i].m_i / conversionFn(1.0);
        m_rulerText = arrU[i].m_s;
        break;
      }
    }

  if (m_rangeIndex != prevUnitRange)
    SetTextDirty();

  return result;
}
Example #5
0
int main(int argc, char * argv[])
{
  // Our double parsing code (base/string_utils.hpp) needs dots as a floating point delimiters, not commas.
  // TODO: Refactor our doubles parsing code to use locale-independent delimiters.
  // For example, https://github.com/google/double-conversion can be used.
  // See http://dbaron.org/log/20121222-locale for more details.
  (void)::setenv("LC_NUMERIC", "C", 1);

  InitializeFinalize mainGuard;
  UNUSED_VALUE(mainGuard);

  QApplication a(argc, argv);

#ifdef DEBUG
  alohalytics::Stats::Instance().SetDebugMode(true);
#endif

  GetPlatform().SetupMeasurementSystem();

  // display EULA if needed
  char const * settingsEULA = "EulaAccepted";
  bool eulaAccepted = false;
  if (!Settings::Get(settingsEULA, eulaAccepted) || !eulaAccepted)
  {
    QStringList buttons;
    buttons << "Accept" << "Decline";

    string buffer;
    {
      ReaderPtr<Reader> reader = GetPlatform().GetReader("eula.html");
      reader.ReadAsString(buffer);
    }
    qt::InfoDialog eulaDialog("MAPS.ME End User Licensing Agreement", buffer.c_str(), NULL, buttons);
    eulaAccepted = (eulaDialog.exec() == 1);
    Settings::Set(settingsEULA, eulaAccepted);
  }

  int returnCode = -1;
  if (eulaAccepted)   // User has accepted EULA
  {
    qt::MainWindow w;
    w.show();
    returnCode = a.exec();
  }

  dbg::ObjectTracker::PrintLeaks();

  LOG_SHORT(LINFO, ("MapsWithMe finished with code", returnCode));
  return returnCode;
}
Example #6
0
    void EmitFeature(borders::CountryPolygons const * country, FeatureBuilder1 const & fb)
    {
#if PARALLEL_POLYGONIZER
      QMutexLocker mutexLocker(&m_EmitFeatureMutex);
      UNUSED_VALUE(mutexLocker);
#endif
      if (country->m_index == -1)
      {
        m_Names.push_back(country->m_name);
        m_Buckets.push_back(new FeatureOutT(m_info.GetTmpFileName(country->m_name)));
        country->m_index = static_cast<int>(m_Buckets.size())-1;
      }

      (*(m_Buckets[country->m_index]))(fb);
    }
Example #7
0
void SelectionShape::Render(ScreenBase const & screen, ref_ptr<dp::GpuProgramManager> mng,
                            dp::UniformValuesStorage const & commonUniforms)
{
    UNUSED_VALUE(screen);
    ShowHideAnimation::EState state = m_animation.GetState();
    if (state == ShowHideAnimation::STATE_VISIBLE ||
            state == ShowHideAnimation::STATE_SHOW_DIRECTION)
    {
        dp::UniformValuesStorage uniforms = commonUniforms;
        uniforms.SetFloatValue("u_position", m_position.x, m_position.y, 0.0);
        uniforms.SetFloatValue("u_accuracy", m_mapping.GetValue(m_animation.GetT()));
        uniforms.SetFloatValue("u_opacity", 1.0f);
        m_renderNode->Render(mng, uniforms);
    }
}
Example #8
0
string MapObject::GetDefaultName() const
{
  string name;
  UNUSED_VALUE(m_name.GetString(StringUtf8Multilang::kDefaultCode, name));
  return name;
}
Example #9
0
int main(int argc, char * argv[])
{
#ifdef OMIM_UNIT_TEST_WITH_QT_EVENT_LOOP
  QAPP theApp(argc, argv);
  UNUSED_VALUE(theApp);
#else
  UNUSED_VALUE(argc);
  UNUSED_VALUE(argv);
#endif

  my::g_LogLevel = LINFO;
#if defined(OMIM_OS_MAC) || defined(OMIM_OS_LINUX)
  my::SetLogMessageFn(my::LogMessageTests);
#endif

  vector<string> testNames;
  vector<bool> testResults;
  int numFailedTests = 0;

  ParseOptions(argc, argv, g_testingOptions);
  if (g_testingOptions.m_help)
  {
    Usage(argv[0]);
    return STATUS_SUCCESS;
  }

  regex filterRegExp;
  if (g_testingOptions.m_filterRegExp)
    filterRegExp.assign(g_testingOptions.m_filterRegExp);

  regex suppressRegExp;
  if (g_testingOptions.m_suppressRegExp)
    suppressRegExp.assign(g_testingOptions.m_suppressRegExp);

  for (TestRegister * pTest = TestRegister::FirstRegister(); pTest; pTest = pTest->m_pNext)
  {
    string fileName(pTest->m_FileName);
    string testName(pTest->m_TestName);

    // Retrieve fine file name
    auto const lastSlash = fileName.find_last_of("\\/");
    if (lastSlash != string::npos)
      fileName.erase(0, lastSlash + 1);

    testNames.push_back(fileName + "::" + testName);
    testResults.push_back(true);
  }

  if (GetTestingOptions().m_listTests)
  {
    for (auto const & name : testNames)
      cout << name << endl;
    return 0;
  }

  int iTest = 0;
  for (TestRegister * pTest = TestRegister::FirstRegister(); pTest; ++iTest, pTest = pTest->m_pNext)
  {
    auto const & testName = testNames[iTest];
    if (g_testingOptions.m_filterRegExp &&
        !regex_match(testName.begin(), testName.end(), filterRegExp))
    {
      continue;
    }
    if (g_testingOptions.m_suppressRegExp &&
        regex_match(testName.begin(), testName.end(), suppressRegExp))
    {
      continue;
    }

    LOG(LINFO, ("Running", testName));
    if (!g_bLastTestOK)
    {
      // Somewhere else global variables have been reset.
      LOG(LERROR, ("\n\nSOMETHING IS REALLY WRONG IN THE UNIT TEST FRAMEWORK!!!"));
      return STATUS_BROKEN_FRAMEWORK;
    }

    my::HighResTimer timer(true);

    try
    {
      // Run the test.
      pTest->m_Fn();

      if (g_bLastTestOK)
      {
        LOG(LINFO, ("OK"));
      }
      else
      {
        // You can set Break here if test failed,
        // but it is already set in OnTestFail - to fail immediately.
        testResults[iTest] = false;
        ++numFailedTests;
      }

    }
    catch (TestFailureException const & )
    {
      testResults[iTest] = false;
      ++numFailedTests;
    }
    catch (std::exception const & ex)
    {
      LOG(LERROR, ("FAILED", "<<<Exception thrown [", ex.what(), "].>>>"));
      testResults[iTest] = false;
      ++numFailedTests;
    }
    catch (...)
    {
      LOG(LERROR, ("FAILED<<<Unknown exception thrown.>>>"));
      testResults[iTest] = false;
      ++numFailedTests;
    }
    g_bLastTestOK = true;

    uint64_t const elapsed = timer.ElapsedNano();
    LOG(LINFO, ("Test took", elapsed / 1000000, "ms\n"));
  }

  if (numFailedTests != 0)
  {
    LOG(LINFO, (numFailedTests, " tests failed:"));
    for (size_t i = 0; i < testNames.size(); ++i)
    {
      if (!testResults[i])
        LOG(LINFO, (testNames[i]));
    }
    LOG(LINFO, ("Some tests FAILED."));
    return STATUS_FAILED;
  }

  LOG(LINFO, ("All tests passed."));
  return STATUS_SUCCESS;
}
Example #10
0
 template <typename T> inline void ForceUseValue(T const & t)
 {
    volatile T dummy = t;
    UNUSED_VALUE(dummy);
 }
Example #11
0
void RoadGraphMockSource::GetJunctionTypes(Junction const & junction, feature::TypesHolder & types) const
{
  UNUSED_VALUE(junction);
  UNUSED_VALUE(types);
}
Example #12
0
void RoadGraphMockSource::GetFeatureTypes(FeatureID const & featureId, feature::TypesHolder & types) const
{
  UNUSED_VALUE(featureId);
  UNUSED_VALUE(types);
}
Example #13
0
 void GetTexturingInfo(float const globalLength, int & steps, float & maskSize)
 {
     UNUSED_VALUE(globalLength);
     UNUSED_VALUE(steps);
     UNUSED_VALUE(maskSize);
 }
Example #14
0
OsrmRouter::ResultCode OsrmRouter::CalculateRoute(m2::PointD const & startPoint,
        m2::PointD const & startDirection,
        m2::PointD const & finalPoint,
        RouterDelegate const & delegate, Route & route)
{
    my::HighResTimer timer(true);
    m_indexManager.Clear();  // TODO (Dragunov) make proper index manager cleaning

    TRoutingMappingPtr startMapping = m_indexManager.GetMappingByPoint(startPoint);
    TRoutingMappingPtr targetMapping = m_indexManager.GetMappingByPoint(finalPoint);

    if (!startMapping->IsValid())
    {
        ResultCode const code = startMapping->GetError();
        if (code != NoError)
        {
            route.AddAbsentCountry(startMapping->GetCountryName());
            return code;
        }
        return IRouter::StartPointNotFound;
    }
    if (!targetMapping->IsValid())
    {
        ResultCode const code = targetMapping->GetError();
        if (code != NoError)
        {
            route.AddAbsentCountry(targetMapping->GetCountryName());
            return code;
        }
        return IRouter::EndPointNotFound;
    }

    MappingGuard startMappingGuard(startMapping);
    MappingGuard finalMappingGuard(targetMapping);
    UNUSED_VALUE(startMappingGuard);
    UNUSED_VALUE(finalMappingGuard);
    LOG(LINFO, ("Duration of the MWM loading", timer.ElapsedNano()));
    timer.Reset();

    delegate.OnProgress(kMwmLoadedProgress);

    // 3. Find start/end nodes.
    TFeatureGraphNodeVec startTask;

    {
        ResultCode const code = FindPhantomNodes(startPoint, startDirection,
                                startTask, kMaxNodeCandidatesCount, startMapping);
        if (code != NoError)
            return code;
    }
    {
        if (finalPoint != m_cachedTargetPoint)
        {
            ResultCode const code =
                FindPhantomNodes(finalPoint, m2::PointD::Zero(),
                                 m_cachedTargets, kMaxNodeCandidatesCount, targetMapping);
            if (code != NoError)
                return code;
            m_cachedTargetPoint = finalPoint;
        }
    }
    INTERRUPT_WHEN_CANCELLED(delegate);

    LOG(LINFO, ("Duration of the start/stop points lookup", timer.ElapsedNano()));
    timer.Reset();
    delegate.OnProgress(kPointsFoundProgress);

    // 4. Find route.
    RawRoutingResult routingResult;

    // 4.1 Single mwm case
    if (startMapping->GetMwmId() == targetMapping->GetMwmId())
    {
        LOG(LINFO, ("Single mwm routing case"));
        m_indexManager.ForEachMapping([](pair<string, TRoutingMappingPtr> const & indexPair)
        {
            indexPair.second->FreeCrossContext();
        });
        if (!FindRouteFromCases(startTask, m_cachedTargets, startMapping->m_dataFacade,
                                routingResult))
        {
            return RouteNotFound;
        }
        INTERRUPT_WHEN_CANCELLED(delegate);
        delegate.OnProgress(kPathFoundProgress);

        // 5. Restore route.

        Route::TTurns turnsDir;
        Route::TTimes times;
        vector<m2::PointD> points;

        MakeTurnAnnotation(routingResult, startMapping, delegate, points, turnsDir, times);

        route.SetGeometry(points.begin(), points.end());
        route.SetTurnInstructions(turnsDir);
        route.SetSectionTimes(times);

        return NoError;
    }
    else //4.2 Multiple mwm case
    {
        LOG(LINFO, ("Multiple mwm routing case"));
        TCheckedPath finalPath;
        ResultCode code = CalculateCrossMwmPath(startTask, m_cachedTargets, m_indexManager, delegate,
                                                finalPath);
        timer.Reset();
        INTERRUPT_WHEN_CANCELLED(delegate);
        delegate.OnProgress(kCrossPathFoundProgress);

        // 5. Make generate answer
        if (code == NoError)
        {
            auto code = MakeRouteFromCrossesPath(finalPath, delegate, route);
            // Manually free all cross context allocations before geometry unpacking.
            m_indexManager.ForEachMapping([](pair<string, TRoutingMappingPtr> const & indexPair)
            {
                indexPair.second->FreeCrossContext();
            });
            LOG(LINFO, ("Make final route", timer.ElapsedNano()));
            timer.Reset();
            return code;
        }
        return OsrmRouter::RouteNotFound;
    }
}
Example #15
0
// TODO (ldragunov) move this function to cross mwm router
// TODO (ldragunov) process case when the start and the finish points are placed on the same edge.
OsrmRouter::ResultCode OsrmRouter::MakeRouteFromCrossesPath(TCheckedPath const & path,
        RouterDelegate const & delegate,
        Route & route)
{
    Route::TTurns TurnsDir;
    Route::TTimes Times;
    vector<m2::PointD> Points;
    for (RoutePathCross cross : path)
    {
        ASSERT_EQUAL(cross.startNode.mwmId, cross.finalNode.mwmId, ());
        RawRoutingResult routingResult;
        TRoutingMappingPtr mwmMapping = m_indexManager.GetMappingById(cross.startNode.mwmId);
        ASSERT(mwmMapping->IsValid(), ());
        MappingGuard mwmMappingGuard(mwmMapping);
        UNUSED_VALUE(mwmMappingGuard);
        CalculatePhantomNodeForCross(mwmMapping, cross.startNode, m_pIndex, true /* forward */);
        CalculatePhantomNodeForCross(mwmMapping, cross.finalNode, m_pIndex, false /* forward */);
        if (!FindSingleRoute(cross.startNode, cross.finalNode, mwmMapping->m_dataFacade, routingResult))
            return OsrmRouter::RouteNotFound;

        if (!Points.empty())
        {
            // Remove road end point and turn instruction.
            Points.pop_back();
            TurnsDir.pop_back();
            Times.pop_back();
        }

        // Get annotated route.
        Route::TTurns mwmTurnsDir;
        Route::TTimes mwmTimes;
        vector<m2::PointD> mwmPoints;
        MakeTurnAnnotation(routingResult, mwmMapping, delegate, mwmPoints, mwmTurnsDir, mwmTimes);
        // Connect annotated route.
        auto const pSize = static_cast<uint32_t>(Points.size());
        for (auto turn : mwmTurnsDir)
        {
            if (turn.m_index == 0)
                continue;
            turn.m_index += pSize;
            TurnsDir.push_back(turn);
        }

        double const estimationTime = Times.size() ? Times.back().second : 0.0;
        for (auto time : mwmTimes)
        {
            if (time.first == 0)
                continue;
            time.first += pSize;
            time.second += estimationTime;
            Times.push_back(time);
        }

        Points.insert(Points.end(), mwmPoints.begin(), mwmPoints.end());
    }

    route.SetGeometry(Points.begin(), Points.end());
    route.SetTurnInstructions(TurnsDir);
    route.SetSectionTimes(Times);
    return OsrmRouter::NoError;
}