PedestrianDirectionsEngine::PedestrianDirectionsEngine()
    : m_typeSteps(classif().GetTypeByPath( {
    "highway", "steps"
}))
, m_typeLiftGate(classif().GetTypeByPath({"barrier", "lift_gate"}))
, m_typeGate(classif().GetTypeByPath({"barrier", "gate"}))
{
}
Exemple #2
0
CarModel::CarModel()
  : VehicleModel(classif(), s_carLimits)
{
  vector<AdditionalRoadTags> const additionalTags = {
      {{"route", "ferry", "motorcar"}, kSpeedFerryMotorcarKMpH},
      {{"route", "ferry", "motor_vehicle"}, kSpeedFerryMotorcarVehicleKMpH},
      {{"railway", "rail", "motor_vehicle"}, kSpeedRailMotorcarVehicleKMpH},
      {{"route", "shuttle_train"}, kSpeedShuttleTrainKMpH},
  };

  SetAdditionalRoadTypes(classif(), additionalTags);
}
Exemple #3
0
void PedestrianModel::Init()
{
  initializer_list<char const *> hwtagYesFoot = {"hwtag", "yesfoot"};

  m_noFootType = classif().GetTypeByPath({ "hwtag", "nofoot" });
  m_yesFootType = classif().GetTypeByPath(hwtagYesFoot);

  initializer_list<char const *> arr[] = {
      hwtagYesFoot, {"route", "ferry"}, {"man_made", "pier"},
  };

  SetAdditionalRoadTypes(classif(), arr, ARRAY_SIZE(arr));
}
Exemple #4
0
void PedestrianModel::Init()
{
  initializer_list<char const *> hwtagYesFoot = {"hwtag", "yesfoot"};

  m_noFootType = classif().GetTypeByPath({ "hwtag", "nofoot" });
  m_yesFootType = classif().GetTypeByPath(hwtagYesFoot);

  vector<AdditionalRoadTags> const additionalTags = {
      {hwtagYesFoot, m_maxModelSpeed},
      {{"route", "ferry"}, kDefaultSpeeds.at(HighwayType::RouteFerry)},
      {{"man_made", "pier"}, kDefaultSpeeds.at(HighwayType::ManMadePier)}};

  SetAdditionalRoadTypes(classif(), additionalTags);
}
Exemple #5
0
HighwayClass GetHighwayClass(feature::TypesHolder const & types)
{
  Classificator const & c = classif();
  static pair<HighwayClass, uint32_t> const kHighwayClasses[] = {
      {HighwayClass::Trunk, c.GetTypeByPath({"highway", "motorway"})},
      {HighwayClass::Trunk, c.GetTypeByPath({"highway", "motorway_link"})},
      {HighwayClass::Trunk, c.GetTypeByPath({"highway", "trunk"})},
      {HighwayClass::Trunk, c.GetTypeByPath({"highway", "trunk_link"})},
      {HighwayClass::Trunk, c.GetTypeByPath({"route", "ferry"})},
      {HighwayClass::Primary, c.GetTypeByPath({"highway", "primary"})},
      {HighwayClass::Primary, c.GetTypeByPath({"highway", "primary_link"})},
      {HighwayClass::Secondary, c.GetTypeByPath({"highway", "secondary"})},
      {HighwayClass::Secondary, c.GetTypeByPath({"highway", "secondary_link"})},
      {HighwayClass::Tertiary, c.GetTypeByPath({"highway", "tertiary"})},
      {HighwayClass::Tertiary, c.GetTypeByPath({"highway", "tertiary_link"})},
      {HighwayClass::LivingStreet, c.GetTypeByPath({"highway", "unclassified"})},
      {HighwayClass::LivingStreet, c.GetTypeByPath({"highway", "residential"})},
      {HighwayClass::LivingStreet, c.GetTypeByPath({"highway", "living_street"})},
      {HighwayClass::Service, c.GetTypeByPath({"highway", "service"})},
      {HighwayClass::Service, c.GetTypeByPath({"highway", "track"})}};
  uint8_t const kTruncLevel = 2;

  for (auto t : types)
  {
    ftype::TruncValue(t, kTruncLevel);
    for (auto const & cls : kHighwayClasses)
    {
      if (cls.second == t)
        return cls.first;
    }
  }

  return HighwayClass::Error;
}
Exemple #6
0
IsBuildingChecker::IsBuildingChecker()
{
  Classificator const & c = classif();

  m_types.push_back(c.GetTypeByPath({ "building" }));
  m_types.push_back(c.GetTypeByPath({ "building", "address" }));
}
Exemple #7
0
IsStreetChecker::IsStreetChecker()
{
  // TODO (@y, @m, @vng): this list must be up-to-date with
  // data/categories.txt, so, it's worth it to generate or parse it
  // from that file.
  Classificator const & c = classif();
  char const * arr[][2] = {{"highway", "living_street"},
                           {"highway", "footway"},
                           {"highway", "motorway"},
                           {"highway", "motorway_link"},
                           {"highway", "path"},
                           {"highway", "pedestrian"},
                           {"highway", "primary"},
                           {"highway", "primary_link"},
                           {"highway", "residential"},
                           {"highway", "road"},
                           {"highway", "secondary"},
                           {"highway", "secondary_link"},
                           {"highway", "service"},
                           {"highway", "tertiary"},
                           {"highway", "tertiary_link"},
                           {"highway", "track"},
                           {"highway", "trunk"},
                           {"highway", "trunk_link"},
                           {"highway", "unclassified"}};
  for (auto const & p : arr)
    m_types.push_back(c.GetTypeByPath({p[0], p[1]}));
}
Exemple #8
0
void BicycleModel::Init()
{
  initializer_list<char const *> hwtagYesBicycle = {"hwtag", "yesbicycle"};

  m_yesBicycleType = classif().GetTypeByPath(hwtagYesBicycle);
  m_noBicycleType = classif().GetTypeByPath({"hwtag", "nobicycle"});
  m_bidirBicycleType = classif().GetTypeByPath({"hwtag", "bidir_bicycle"});

  vector<AdditionalRoadTags> const additionalTags = {
      {hwtagYesBicycle, m_maxSpeedKMpH},
      {{"route", "ferry"}, m_maxSpeedKMpH},
      {{"man_made", "pier"}, kSpeedPierKMpH},
  };

  SetAdditionalRoadTypes(classif(), additionalTags);
}
Exemple #9
0
void BookingDataset::PreprocessMatchedOsmObject(ObjectId, FeatureBuilder1 & fb,
                                                std::function<void(FeatureBuilder1 &)> const fn) const
{
  // Turn a hotel into a simple building.
  if (fb.GetGeomType() == feature::GEOM_AREA)
  {
    // Remove all information about the hotel.
    auto & meta = fb.GetMetadata();
    meta.Drop(feature::Metadata::EType::FMD_STARS);
    meta.Drop(feature::Metadata::EType::FMD_WEBSITE);
    meta.Drop(feature::Metadata::EType::FMD_PHONE_NUMBER);

    auto & params = fb.GetParams();
    params.ClearName();

    auto const tourism = classif().GetTypeByPath({"tourism"});
    base::EraseIf(params.m_types, [tourism](uint32_t type)
    {
      ftype::TruncValue(type, 1);
      return type == tourism;
    });
  }

  fn(fb);
}
Exemple #10
0
IsAddressObjectChecker::IsAddressObjectChecker() : BaseChecker(1 /* level */)
{
  auto const paths = {"building", "amenity", "shop", "tourism", "historic", "office", "craft"};

  Classificator const & c = classif();
  for (auto const & p : paths)
    m_types.push_back(c.GetTypeByPath({p}));
}
Exemple #11
0
IsHatchingTerritoryChecker::IsHatchingTerritoryChecker()
{
  Classificator const & c = classif();
  char const * arr[][2] = {{"leisure", "nature_reserve"},
                           {"boundary", "national_park"},
                           {"landuse", "military"}};
  for (auto const & p : arr)
    m_types.push_back(c.GetTypeByPath({p[0], p[1]}));
}
 ~EmitterImpl() override
 {
   Classificator const & c = classif();
   
   stringstream ss;
   ss << endl;
   for (auto const & p : m_mapTypes)
     ss << c.GetReadableObjectName(p.first) << " : " <<  p.second << endl;
   LOG_SHORT(LINFO, ("World types:", ss.str()));
 }
Exemple #13
0
string DebugPrint(TypesHolder const & holder)
{
  Classificator const & c = classif();
  string s;
  for (uint32_t type : holder)
    s += c.GetReadableObjectName(type) + " ";
  if (!s.empty())
    s.pop_back();
  return s;
}
Exemple #14
0
IsVillageChecker::IsVillageChecker()
{
  // TODO (@y, @m, @vng): this list must be up-to-date with
  // data/categories.txt, so, it's worth it to generate or parse it
  // from that file.
  Classificator const & c = classif();
  char const * arr[][2] = {{"place", "village"}, {"place", "hamlet"}};

  for (auto const & p : arr)
    m_types.push_back(c.GetTypeByPath({p[0], p[1]}));
}
Exemple #15
0
 StreetCategories()
 {
   auto const & classificator = classif();
   auto addCategory = [&](uint32_t type)
   {
     uint32_t const index = classificator.GetIndexForType(type);
     m_categories.push_back(FeatureTypeToString(index));
   };
   ftypes::IsStreetChecker::Instance().ForEachType(addCategory);
   sort(m_categories.begin(), m_categories.end());
 }
Exemple #16
0
void LoaderCurrent::ParseTypes()
{
  Classificator & c = classif();

  ArrayByteSource source(DataPtr() + m_TypesOffset);

  size_t const count = m_pF->GetTypesCount();
  for (size_t i = 0; i < count; ++i)
    m_pF->m_types[i] = c.GetTypeForIndex(ReadVarUint<uint32_t>(source));

  m_CommonOffset = CalcOffset(source);
}
Exemple #17
0
IsLinkChecker::IsLinkChecker()
{
  Classificator const & c = classif();
  char const * arr[][2] = {{"highway", "motorway_link"},
                           {"highway", "trunk_link"},
                           {"highway", "primary_link"},
                           {"highway", "secondary_link"},
                           {"highway", "tertiary_link"}};

  for (size_t i = 0; i < ARRAY_SIZE(arr); ++i)
    m_types.push_back(c.GetTypeByPath(vector<string>(arr[i], arr[i] + 2)));
}
Exemple #18
0
TwoLevelPOIChecker::TwoLevelPOIChecker() : ftypes::BaseChecker(2 /* level */)
{
  Classificator const & c = classif();
  StringIL arr[] = {{"highway", "bus_stop"},
                    {"highway", "speed_camera"},
                    {"waterway", "waterfall"},
                    {"natural", "volcano"},
                    {"natural", "cave_entrance"},
                    {"natural", "beach"}};

  for (size_t i = 0; i < ARRAY_SIZE(arr); ++i)
    m_types.push_back(c.GetTypeByPath(arr[i]));
}
Exemple #19
0
void BicycleModel::Init()
{
  // @TODO(bykoianko) Uncomment line below what tags hwtag=nobicycle and hwtag=yesbicycle
  // will be added to classificator.txt. (https://jira.mail.ru/browse/MAPSME-858)
//  m_noBicycleType = classif().GetTypeByPath({ "hwtag", "nobicycle" });
//  m_yesBicycleType = classif().GetTypeByPath({ "hwtag", "yesbicycle" });

  initializer_list<char const *> arr[] =
  {
    { "route", "ferry" },
    { "man_made", "pier" },
  };

  SetAdditionalRoadTypes(classif(), arr, ARRAY_SIZE(arr));
}
Exemple #20
0
void BannerSet::Add(Banner const & banner, string const & type)
{
  vector<string> v;
  strings::Tokenize(type, "-", MakeBackInsertFunctor(v));
  uint32_t const ctype = classif().GetTypeByPathSafe(v);
  if (ctype == 0)
  {
    LOG(LWARNING, ("Missing type", type, "for a banner"));
  }
  else
  {
    CHECK(m_banners.find(ctype) == m_banners.end(), ("Duplicate banner type", type));
    m_banners.emplace(make_pair(ctype, banner));
  }
}
Exemple #21
0
IsLocalityChecker::IsLocalityChecker()
{
  Classificator const & c = classif();

  // Note! The order should be equal with constants in Type enum (add other villages to the end).
  char const * arr[][2] = {
    { "place", "country" },
    { "place", "state" },
    { "place", "city" },
    { "place", "town" },
    { "place", "village" },
    { "place", "hamlet" }
  };

  for (size_t i = 0; i < ARRAY_SIZE(arr); ++i)
    m_types.push_back(c.GetTypeByPath(vector<string>(arr[i], arr[i] + 2)));
}
Exemple #22
0
IsStreetChecker::IsStreetChecker()
{
  Classificator const & c = classif();
  char const * arr[][2] = {
    { "highway", "trunk" },
    { "highway", "primary" },
    { "highway", "secondary" },
    { "highway", "residential" },
    { "highway", "pedestrian" },
    { "highway", "tertiary" },
    { "highway", "construction" },
    { "highway", "living_street" },
    { "highway", "service" },
    { "highway", "unclassified" }
  };

  for (size_t i = 0; i < ARRAY_SIZE(arr); ++i)
    m_types.push_back(c.GetTypeByPath(vector<string>(arr[i], arr[i] + 2)));
}
Exemple #23
0
void OpentableDataset::PreprocessMatchedOsmObject(ObjectId const matchedObjId, FeatureBuilder1 & fb,
                                                  function<void(FeatureBuilder1 &)> const fn) const
{
  auto const & restaurant = m_storage.GetObjectById(matchedObjId);
  auto & metadata = fb.GetMetadata();
  metadata.Set(feature::Metadata::FMD_SPONSORED_ID, strings::to_string(restaurant.m_id.Get()));

  FeatureParams & params = fb.GetParams();
  // params.AddAddress(restaurant.address);
  // TODO(mgsergio): addr:full ???

  params.AddName(StringUtf8Multilang::GetLangByCode(StringUtf8Multilang::kDefaultCode),
                 restaurant.m_name);

  auto const & clf = classif();
  params.AddType(clf.GetTypeByPath({"sponsored", "opentable"}));

  fn(fb);
}
Exemple #24
0
void DumpTypes(string const & fPath)
{
    TypesCollector doClass;
    feature::ForEachFromDat(fPath, doClass);

    typedef pair<vector<uint32_t>, size_t> stats_elem_type;
    typedef vector<stats_elem_type> vec_to_sort;
    vec_to_sort vecToSort(doClass.m_stats.begin(), doClass.m_stats.end());
    sort(vecToSort.begin(), vecToSort.end(), &SortFunc<stats_elem_type>);

    for (vec_to_sort::iterator it = vecToSort.begin(); it != vecToSort.end(); ++it)
    {
        cout << it->second << " ";
        for (size_t i = 0; i < it->first.size(); ++i)
            cout << classif().GetFullObjectName(it->first[i]) << " ";
        cout << endl;
    }
    cout << "Total features: " << doClass.m_totalCount << endl;
    cout << "Features with names: " << doClass.m_namesCount << endl;
}
Exemple #25
0
bool IsTypeConformed(uint32_t type, vector<string> const & path)
{
  Classificator const & c = classif();
  ClassifObject const * p = c.GetRoot();
  ASSERT(p, ());

  uint8_t val = 0, i = 0;
  for (auto const n : path)
  {
    if (!ftype::GetValue(type, i, val))
      return false;
    p = p->GetObject(val);
    if (p == 0)
      return false;
    string const name = p->GetName();
    if (n != name && n != "*")
      return false;
    ++i;
  }
  return true;
}
Exemple #26
0
bool IsTypeConformed(uint32_t type, StringIL const & path)
{
  ClassifObject const * p = classif().GetRoot();
  ASSERT(p, ());

  uint8_t val = 0, i = 0;
  for (char const * s : path)
  {
    if (!ftype::GetValue(type, i, val))
      return false;

    p = p->GetObject(val);
    if (p == 0)
      return false;

    if (p->GetName() != s && strcmp(s, "*") != 0)
      return false;

    ++i;
  }
  return true;
}
Exemple #27
0
int main(int argc, char ** argv)
{
  google::SetUsageMessage(
      "Takes OSM XML data from stdin and creates data and index files in several passes.");

  google::ParseCommandLineFlags(&argc, &argv, true);

  Platform & pl = GetPlatform();

  if (!FLAGS_user_resource_path.empty())
    pl.SetResourceDir(FLAGS_user_resource_path);

  string const path =
      FLAGS_data_path.empty() ? pl.WritableDir() : my::AddSlashIfNeeded(FLAGS_data_path);

  feature::GenerateInfo genInfo;
  genInfo.m_intermediateDir = FLAGS_intermediate_data_path.empty() ? path
                            : my::AddSlashIfNeeded(FLAGS_intermediate_data_path);
  genInfo.m_targetDir = genInfo.m_tmpDir = path;

  /// @todo Probably, it's better to add separate option for .mwm.tmp files.
  if (!FLAGS_intermediate_data_path.empty())
  {
    string const tmpPath = genInfo.m_intermediateDir + "tmp" + my::GetNativeSeparator();
    if (pl.MkDir(tmpPath) != Platform::ERR_UNKNOWN)
      genInfo.m_tmpDir = tmpPath;
  }

  genInfo.m_osmFileName = FLAGS_osm_file_name;
  genInfo.m_failOnCoasts = FLAGS_fail_on_coasts;
  genInfo.m_preloadCache = FLAGS_preload_cache;

  genInfo.m_versionDate = static_cast<uint32_t>(FLAGS_planet_version);

  if (!FLAGS_node_storage.empty())
    genInfo.SetNodeStorageType(FLAGS_node_storage);
  if (!FLAGS_osm_file_type.empty())
    genInfo.SetOsmFileType(FLAGS_osm_file_type);

  // Generating intermediate files
  if (FLAGS_preprocess)
  {
    LOG(LINFO, ("Generating intermediate data ...."));
    if (!GenerateIntermediateData(genInfo))
    {
      return -1;
    }
  }

  // load classificator only if necessary
  if (FLAGS_make_coasts || FLAGS_generate_features || FLAGS_generate_geometry ||
      FLAGS_generate_index || FLAGS_generate_search_index ||
      FLAGS_calc_statistics || FLAGS_type_statistics || FLAGS_dump_types || FLAGS_dump_prefixes ||
      FLAGS_check_mwm)
  {
    classificator::Load();
    classif().SortClassificator();
  }

  // Generate dat file
  if (FLAGS_generate_features || FLAGS_make_coasts)
  {
    LOG(LINFO, ("Generating final data ..."));

    genInfo.m_splitByPolygons = FLAGS_split_by_polygons;
    genInfo.m_createWorld = FLAGS_generate_world;
    genInfo.m_makeCoasts = FLAGS_make_coasts;
    genInfo.m_emitCoasts = FLAGS_emit_coasts;
    genInfo.m_fileName = FLAGS_output;
    genInfo.m_genAddresses = FLAGS_generate_addresses_file;

    if (!GenerateFeatures(genInfo))
      return -1;

    if (FLAGS_generate_world)
    {
      genInfo.m_bucketNames.push_back(WORLD_FILE_NAME);
      genInfo.m_bucketNames.push_back(WORLD_COASTS_FILE_NAME);
    }
  }
  else
  {
    if (!FLAGS_output.empty())
      genInfo.m_bucketNames.push_back(FLAGS_output);
  }

  // Enumerate over all dat files that were created.
  size_t const count = genInfo.m_bucketNames.size();
  for (size_t i = 0; i < count; ++i)
  {
    string const & country = genInfo.m_bucketNames[i];
    string const datFile = my::JoinFoldersToPath(path, country + DATA_FILE_EXTENSION);

    if (FLAGS_generate_geometry)
    {
      int mapType = feature::DataHeader::country;
      if (country == WORLD_FILE_NAME)
        mapType = feature::DataHeader::world;
      if (country == WORLD_COASTS_FILE_NAME)
        mapType = feature::DataHeader::worldcoasts;

      // If error - move to next bucket without index generation.

      LOG(LINFO, ("Generating result features for", country));
      if (!feature::GenerateFinalFeatures(genInfo, country, mapType))
        continue;

      LOG(LINFO, ("Generating offsets table for", datFile));
      if (!feature::BuildOffsetsTable(datFile))
        continue;
    }

    if (FLAGS_generate_index)
    {
      LOG(LINFO, ("Generating index for", datFile));

      if (!indexer::BuildIndexFromDatFile(datFile, FLAGS_intermediate_data_path + country))
        LOG(LCRITICAL, ("Error generating index."));
    }

    if (FLAGS_generate_search_index)
    {
      LOG(LINFO, ("Generating search index for ", datFile));

      if (!indexer::BuildSearchIndexFromDatFile(datFile, true))
        LOG(LCRITICAL, ("Error generating search index."));
    }
  }

  // Create http update list for countries and corresponding files
  if (FLAGS_generate_update)
  {
    LOG(LINFO, ("Updating countries file..."));
    update::UpdateCountries(path);
  }

  string const datFile = path + FLAGS_output + DATA_FILE_EXTENSION;

  if (FLAGS_calc_statistics)
  {
    LOG(LINFO, ("Calculating statistics for ", datFile));

    stats::FileContainerStatistic(datFile);
    stats::FileContainerStatistic(datFile + ROUTING_FILE_EXTENSION);

    stats::MapInfo info;
    stats::CalcStatistic(datFile, info);
    stats::PrintStatistic(info);
  }

  if (FLAGS_type_statistics)
  {
    LOG(LINFO, ("Calculating type statistics for ", datFile));

    stats::MapInfo info;
    stats::CalcStatistic(datFile, info);
    stats::PrintTypeStatistic(info);
  }

  if (FLAGS_dump_types)
    feature::DumpTypes(datFile);

  if (FLAGS_dump_prefixes)
    feature::DumpPrefixes(datFile);

  if (FLAGS_dump_search_tokens)
    feature::DumpSearchTokens(datFile);

  if (FLAGS_unpack_mwm)
    UnpackMwm(datFile);

  if (!FLAGS_delete_section.empty())
    DeleteSection(datFile, FLAGS_delete_section);

  if (FLAGS_generate_packed_borders)
    borders::GeneratePackedBorders(path);

  if (FLAGS_check_mwm)
    check_model::ReadFeatures(datFile);

  if (!FLAGS_osrm_file_name.empty() && FLAGS_make_routing)
    routing::BuildRoutingIndex(path, FLAGS_output, FLAGS_osrm_file_name);

  if (!FLAGS_osrm_file_name.empty() && FLAGS_make_cross_section)
    routing::BuildCrossRoutingIndex(path, FLAGS_output, FLAGS_osrm_file_name);

  return 0;
}
Exemple #28
0
IsHotelChecker::IsHotelChecker()
{
  Classificator const & c = classif();
  for (auto const & tag : GetHotelTags())
    m_types.push_back(c.GetTypeByPath({"tourism", tag}));
}
Exemple #29
0
IsBookingChecker::IsBookingChecker()
{
  Classificator const & c = classif();
  m_types.push_back(c.GetTypeByPath({"sponsored", "booking"}));
}
Exemple #30
0
IsBuildingPartChecker::IsBuildingPartChecker() : BaseChecker(1 /* level */)
{
  m_types.push_back(classif().GetTypeByPath({"building:part"}));
}