~valhalla-routing/+junk/valhalla_2.1.9-0ubuntu1

« back to all changes in this revision

Viewing changes to libvalhalla/src/baldr/streetname_us.cc

  • Committer: valhalla
  • Date: 2017-04-24 20:20:53 UTC
  • Revision ID: valhalla@mapzen.com-20170424202053-7o69b9nwx9ee0tw3
PackagingĀ forĀ 2.1.9-0ubuntu1.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <iostream>
 
2
 
 
3
#include "baldr/streetname.h"
 
4
#include "baldr/streetname_us.h"
 
5
 
 
6
#include <boost/algorithm/string/predicate.hpp>
 
7
 
 
8
namespace valhalla {
 
9
namespace baldr {
 
10
 
 
11
const std::vector<std::string> StreetNameUs::pre_dirs_ { "North ", "East ",
 
12
    "South ", "West ", "Northeast ", "Southeast ", "Southwest ", "Northwest " };
 
13
const std::vector<std::string> StreetNameUs::post_dirs_ { " North", " East",
 
14
    " South", " West", " Northeast", " Southeast", " Southwest", " Northwest" };
 
15
const std::vector<std::string> StreetNameUs::post_cardinal_dirs_ { " North",
 
16
    " East", " South", " West" };
 
17
 
 
18
StreetNameUs::StreetNameUs(const std::string& value) : StreetName(value) {
 
19
}
 
20
 
 
21
std::string StreetNameUs::GetPreDir() const {
 
22
  for (const auto& pre_dir : StreetNameUs::pre_dirs_) {
 
23
    if (StartsWith(pre_dir))
 
24
      return pre_dir;
 
25
  }
 
26
  return "";
 
27
}
 
28
 
 
29
std::string StreetNameUs::GetPostDir() const {
 
30
  for (const auto& post_dir : StreetNameUs::post_dirs_) {
 
31
    if (EndsWith(post_dir))
 
32
      return post_dir;
 
33
  }
 
34
  return "";
 
35
}
 
36
 
 
37
std::string StreetNameUs::GetPostCardinalDir() const {
 
38
  for (const auto& post_cardinal_dir : StreetNameUs::post_cardinal_dirs_) {
 
39
    if (EndsWith(post_cardinal_dir))
 
40
      return post_cardinal_dir;
 
41
  }
 
42
  return "";
 
43
}
 
44
 
 
45
std::string StreetNameUs::GetBaseName() const {
 
46
  std::string pre_dir = GetPreDir();
 
47
  std::string post_dir = GetPostDir();
 
48
 
 
49
  return value_.substr(pre_dir.size(),
 
50
                       (value_.size() - pre_dir.size() - post_dir.size()));
 
51
}
 
52
 
 
53
bool StreetNameUs::HasSameBaseName(const StreetName& rhs) const {
 
54
  return (GetBaseName() == rhs.GetBaseName());
 
55
}
 
56
 
 
57
}
 
58
}