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

github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2012-01-30 21:55:59 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:32:41 +0300
commit187413d181b9e2de4b69867a732112ece1e908e9 (patch)
treeaf3b73428efce0766939e518e8a3325b76621723 /storage
parent9176ae505689d32958ba919c65421722583d5c5e (diff)
Calculate USA limit rect.
Diffstat (limited to 'storage')
-rw-r--r--storage/country_info.cpp19
-rw-r--r--storage/country_info.hpp2
-rw-r--r--storage/storage_tests/country_info_test.cpp30
3 files changed, 42 insertions, 9 deletions
diff --git a/storage/country_info.cpp b/storage/country_info.cpp
index b0b99d292c..db4f1588d1 100644
--- a/storage/country_info.cpp
+++ b/storage/country_info.cpp
@@ -108,9 +108,9 @@ namespace storage
if (info.m_name.empty())
info.m_name = id;
- if (id.find_first_of('_') != string::npos)
+ if (id.find('_') != string::npos)
{
- size_t const i = info.m_name.find_first_of('_');
+ size_t const i = info.m_name.find('_');
ASSERT ( i != string::npos, () );
// replace '_' with ", "
@@ -118,4 +118,19 @@ namespace storage
info.m_name.insert(i+1, " ");
}
}
+
+ m2::RectD CountryInfoGetter::CalcUSALimitRect() const
+ {
+ m2::RectD r;
+ for (size_t i = 0; i < m_countries.size(); ++i)
+ {
+ if ((m_countries[i].m_name.find("USA_") != string::npos) &&
+ (m_countries[i].m_name != "USA_Alaska") &&
+ (m_countries[i].m_name != "USA_Hawaii"))
+ {
+ r.Add(m_countries[i].m_rect);
+ }
+ }
+ return r;
+ }
}
diff --git a/storage/country_info.hpp b/storage/country_info.hpp
index 1209fe85bf..06ac1ffd93 100644
--- a/storage/country_info.hpp
+++ b/storage/country_info.hpp
@@ -45,5 +45,7 @@ namespace storage
void GetRegionInfo(m2::PointD const & pt, CountryInfo & info) const;
void GetRegionInfo(string const & id, CountryInfo & info) const;
+
+ m2::RectD CalcUSALimitRect() const;
};
}
diff --git a/storage/storage_tests/country_info_test.cpp b/storage/storage_tests/country_info_test.cpp
index 5b9a91e07a..d41070ccfe 100644
--- a/storage/storage_tests/country_info_test.cpp
+++ b/storage/storage_tests/country_info_test.cpp
@@ -7,21 +7,31 @@
#include "../../platform/platform.hpp"
+#include "../../base/logging.hpp"
+
using namespace storage;
-UNIT_TEST(CountryInfo_GetByPoint_Smoke)
+namespace
{
- Platform & pl = GetPlatform();
+ typedef storage::CountryInfoGetter CountryInfoT;
+ CountryInfoT * GetCountryInfo()
+ {
+ Platform & pl = GetPlatform();
+ return new CountryInfoT(pl.GetReader(PACKED_POLYGONS_FILE),
+ pl.GetReader(COUNTRIES_FILE));
+ }
+}
- storage::CountryInfoGetter getter(pl.GetReader(PACKED_POLYGONS_FILE),
- pl.GetReader(COUNTRIES_FILE));
+UNIT_TEST(CountryInfo_GetByPoint_Smoke)
+{
+ scoped_ptr<CountryInfoT> getter(GetCountryInfo());
// Minsk
CountryInfo info;
- getter.GetRegionInfo(m2::PointD(MercatorBounds::LonToX(27.5618818),
- MercatorBounds::LatToY(53.9022651)),
- info);
+ getter->GetRegionInfo(m2::PointD(MercatorBounds::LonToX(27.5618818),
+ MercatorBounds::LatToY(53.9022651)),
+ info);
TEST_EQUAL(info.m_name, "Belarus", ());
TEST_EQUAL(info.m_flag, "by", ());
@@ -51,3 +61,9 @@ UNIT_TEST(CountryInfo_ValidName_Smoke)
TEST(IsEmptyName(id2info, "Russia_Far Eastern"), ());
TEST(IsEmptyName(id2info, "UK_Northern Ireland"), ());
}
+
+UNIT_TEST(CountryInfo_USARect)
+{
+ scoped_ptr<CountryInfoT> getter(GetCountryInfo());
+ LOG(LINFO, (getter->CalcUSALimitRect()));
+}