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:
-rw-r--r--defines.hpp1
-rw-r--r--platform/country_defines.cpp2
-rw-r--r--platform/country_defines.hpp3
-rw-r--r--platform/country_file.cpp9
-rw-r--r--platform/country_file.hpp4
-rw-r--r--platform/local_country_file.cpp8
-rw-r--r--platform/local_country_file.hpp13
-rw-r--r--storage/queued_country.cpp7
-rw-r--r--storage/queued_country.hpp2
9 files changed, 36 insertions, 13 deletions
diff --git a/defines.hpp b/defines.hpp
index 72993aca54..fcaa00f1d4 100644
--- a/defines.hpp
+++ b/defines.hpp
@@ -2,6 +2,7 @@
#define DATA_FILE_EXTENSION ".mwm"
#define DATA_FILE_EXTENSION_TMP ".mwm.tmp"
+#define DIFF_FILE_EXTENSION ".mwmdiff"
#define FONT_FILE_EXTENSION ".ttf"
#define OSM2FEATURE_FILE_EXTENSION ".osm2ft"
#define EXTENSION_TMP ".tmp"
diff --git a/platform/country_defines.cpp b/platform/country_defines.cpp
index bbbf933a2a..4f1072a466 100644
--- a/platform/country_defines.cpp
+++ b/platform/country_defines.cpp
@@ -40,5 +40,7 @@ string DebugPrint(MapOptions options)
return "CarRouting";
case MapOptions::MapWithCarRouting:
return "MapWithCarRouting";
+ case MapOptions::Diff:
+ return "Diff";
}
}
diff --git a/platform/country_defines.hpp b/platform/country_defines.hpp
index c59d63759b..e9a123bc8a 100644
--- a/platform/country_defines.hpp
+++ b/platform/country_defines.hpp
@@ -8,7 +8,8 @@ enum class MapOptions : uint8_t
Nothing = 0x0,
Map = 0x1,
CarRouting = 0x2,
- MapWithCarRouting = 0x3
+ MapWithCarRouting = 0x3,
+ Diff = 0x4
};
using TMwmCounter = uint32_t;
diff --git a/platform/country_file.cpp b/platform/country_file.cpp
index f013ba92b8..2910e68d2b 100644
--- a/platform/country_file.cpp
+++ b/platform/country_file.cpp
@@ -20,6 +20,8 @@ string GetNameWithExt(string const & countryFile, MapOptions file)
return countryFile + DATA_FILE_EXTENSION;
case MapOptions::CarRouting:
return countryFile + DATA_FILE_EXTENSION + ROUTING_FILE_EXTENSION;
+ case MapOptions::Diff:
+ return countryFile + DIFF_FILE_EXTENSION;
default:
ASSERT(false, ("Can't get name for:", file));
return string();
@@ -51,11 +53,12 @@ TMwmSize CountryFile::GetRemoteSize(MapOptions filesMask) const
return size;
}
-
string GetFileName(string const & countryFile, MapOptions opt, int64_t version)
{
- return version::IsSingleMwm(version) ? GetNameWithExt(countryFile, MapOptions::Map)
- : GetNameWithExt(countryFile, opt);
+ if (version::IsSingleMwm(version))
+ opt = opt == MapOptions::Diff ? MapOptions::Diff : MapOptions::Map;
+
+ return GetNameWithExt(countryFile, opt);
}
string DebugPrint(CountryFile const & file)
diff --git a/platform/country_file.hpp b/platform/country_file.hpp
index 06a3286155..c7f253ce5d 100644
--- a/platform/country_file.hpp
+++ b/platform/country_file.hpp
@@ -32,8 +32,8 @@ private:
/// Base name (without any extensions) of the file. Same as id of country/region.
string m_name;
- TMwmSize m_mapSize;
- TMwmSize m_routingSize;
+ TMwmSize m_mapSize = 0;
+ TMwmSize m_routingSize = 0;
};
/// \returns This method returns file name with extension. For example Abkhazia.mwm or
diff --git a/platform/local_country_file.cpp b/platform/local_country_file.cpp
index a69c7439e0..40a63fe105 100644
--- a/platform/local_country_file.cpp
+++ b/platform/local_country_file.cpp
@@ -35,6 +35,12 @@ void LocalCountryFile::SyncWithDisk()
m_routingSize = 0;
Platform & platform = GetPlatform();
+ if (platform.GetFileSizeByFullPath(GetPath(MapOptions::Diff), m_mapSize))
+ {
+ m_files = SetOptions(m_files, MapOptions::Diff);
+ return;
+ }
+
if (platform.GetFileSizeByFullPath(GetPath(MapOptions::Map), m_mapSize))
m_files = SetOptions(m_files, MapOptions::Map);
@@ -53,7 +59,7 @@ void LocalCountryFile::SyncWithDisk()
void LocalCountryFile::DeleteFromDisk(MapOptions files) const
{
vector<MapOptions> const mapOptions =
- version::IsSingleMwm(GetVersion()) ? vector<MapOptions>({MapOptions::Map})
+ version::IsSingleMwm(GetVersion()) ? vector<MapOptions>({MapOptions::Map, MapOptions::Diff})
: vector<MapOptions>({MapOptions::Map, MapOptions::CarRouting});
for (MapOptions file : mapOptions)
{
diff --git a/platform/local_country_file.hpp b/platform/local_country_file.hpp
index e506a72f0e..cebf6b55cd 100644
--- a/platform/local_country_file.hpp
+++ b/platform/local_country_file.hpp
@@ -55,20 +55,21 @@ public:
// Returns a mask of all known country files. Return value may be
// empty until SyncWithDisk() is called.
- inline MapOptions GetFiles() const { return m_files; }
+ MapOptions GetFiles() const { return m_files; }
// Checks whether files specified in filesMask are on disk. Return
// value will be false until SyncWithDisk() is called.
- inline bool OnDisk(MapOptions filesMask) const
+ bool OnDisk(MapOptions filesMask) const
{
return (static_cast<unsigned>(m_files) & static_cast<unsigned>(filesMask)) ==
static_cast<unsigned>(filesMask);
}
- inline string const & GetDirectory() const { return m_directory; }
- inline string const & GetCountryName() const { return m_countryFile.GetName(); }
- inline int64_t GetVersion() const { return m_version; }
- inline CountryFile const & GetCountryFile() const { return m_countryFile; }
+ string const & GetDirectory() const { return m_directory; }
+ string const & GetCountryName() const { return m_countryFile.GetName(); }
+ int64_t GetVersion() const { return m_version; }
+ CountryFile const & GetCountryFile() const { return m_countryFile; }
+ CountryFile & GetCountryFile() { return m_countryFile; }
bool operator<(LocalCountryFile const & rhs) const;
bool operator==(LocalCountryFile const & rhs) const;
diff --git a/storage/queued_country.cpp b/storage/queued_country.cpp
index d1e73015ab..22a3aa0fb3 100644
--- a/storage/queued_country.cpp
+++ b/storage/queued_country.cpp
@@ -39,6 +39,13 @@ void QueuedCountry::RemoveOptions(MapOptions opt)
m_current = LeastSignificantOption(m_left);
}
+void QueuedCountry::ResetToDefaultOptions()
+{
+ m_init = MapOptions::MapWithCarRouting;
+ m_left = MapOptions::MapWithCarRouting;
+ m_current = LeastSignificantOption(m_left);
+}
+
bool QueuedCountry::SwitchToNextFile()
{
ASSERT(HasOptions(m_left, m_current),
diff --git a/storage/queued_country.hpp b/storage/queued_country.hpp
index 9597723de1..0747fe018d 100644
--- a/storage/queued_country.hpp
+++ b/storage/queued_country.hpp
@@ -16,6 +16,8 @@ public:
void AddOptions(MapOptions opt);
void RemoveOptions(MapOptions opt);
+ /// In case we can't update file using diff scheme.
+ void ResetToDefaultOptions();
bool SwitchToNextFile();
inline TCountryId const & GetCountryId() const { return m_countryId; }