Welcome to mirror list, hosted at ThFree Co, Russian Federation.

road_graph_tests.cpp « routing_integration_tests « routing - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 5d45015e8805a1f24ad5536b9794fb0a48f06729 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "testing/testing.hpp"

#include "platform/local_country_file.hpp"

#include "geometry/point2d.hpp"

#include "indexer/classificator_loader.hpp"
#include "indexer/data_source.hpp"
#include "indexer/feature_altitude.hpp"
#include "indexer/mwm_set.hpp"

#include "routing_common/car_model.hpp"
#include "routing/features_road_graph.hpp"
#include "routing/road_graph.hpp"

#include "routing/routing_integration_tests/routing_test_tools.hpp"

#include <vector>

using namespace routing;
using namespace integration;

// The test on combinatorial explosion of number of fake edges at FeaturesRoadGraph.
// It might happen when a lot of roads intersect at one point. For example,
// https://www.openstreetmap.org/#map=19/50.73197/-1.21295
UNIT_TEST(FakeEdgesCombinatorialExplosion)
{
  classificator::Load();

  std::vector<LocalCountryFile> localFiles;
  GetAllLocalFiles(localFiles);
  TEST(!localFiles.empty(), ());

  DataSource dataSource(make_unique<FeatureSourceFactory>());
  for (auto const & file : localFiles)
  {
    auto const result = dataSource.Register(file);
    TEST_EQUAL(result.second, MwmSet::RegResult::Success, ());
  }

  FeaturesRoadGraph graph(dataSource, IRoadGraph::Mode::ObeyOnewayTag,
                          make_shared<CarModelFactory>(CountryParentNameGetterFn()));
  Junction const j(m2::PointD(MercatorBounds::FromLatLon(50.73208, -1.21279)), feature::kDefaultAltitudeMeters);
  std::vector<std::pair<routing::Edge, routing::Junction>> sourceVicinity;
  graph.FindClosestEdges(j.GetPoint(), 20 /* count */, sourceVicinity);
  // In case of the combinatorial explosion mentioned above all the memory was consumed for
  // FeaturesRoadGraph::m_fakeIngoingEdges and FeaturesRoadGraph::m_fakeOutgoingEdges fields.
  graph.AddFakeEdges(j, sourceVicinity);
}