forked from organicmaps/organicmaps
Old apps can read header and skip mwm's with new data format, since now.
This commit is contained in:
parent
0b5feff580
commit
6766d52a7b
7 changed files with 43 additions and 20 deletions
|
@ -105,8 +105,16 @@ namespace feature
|
|||
LoadBytes(src, m_langs);
|
||||
|
||||
m_type = static_cast<MapType>(ReadVarInt<int32_t>(src));
|
||||
|
||||
m_ver = ver;
|
||||
|
||||
if (!IsMWMSuitable())
|
||||
{
|
||||
// Actually, old versions of the app should read mwm header correct!
|
||||
// This condition is also checked in adding mwm to the model.
|
||||
return;
|
||||
}
|
||||
|
||||
// Place all new serializable staff here.
|
||||
}
|
||||
|
||||
void DataHeader::LoadVer1(ModelReaderPtr const & r)
|
||||
|
|
|
@ -67,7 +67,9 @@ namespace feature
|
|||
v3, // March 2013 (store type index, instead of raw type in search data)
|
||||
lastVersion = v3
|
||||
};
|
||||
|
||||
inline Version GetVersion() const { return m_ver; }
|
||||
inline bool IsMWMSuitable() const { return (m_ver <= lastVersion); }
|
||||
|
||||
/// @name Serialization
|
||||
//@{
|
||||
|
@ -77,7 +79,8 @@ namespace feature
|
|||
void LoadVer1(ModelReaderPtr const & r);
|
||||
//@}
|
||||
|
||||
enum MapType {
|
||||
enum MapType
|
||||
{
|
||||
world,
|
||||
worldcoasts,
|
||||
country
|
||||
|
|
|
@ -44,18 +44,25 @@ int Index::GetInfo(string const & name, MwmInfo & info) const
|
|||
MwmValue value(name);
|
||||
|
||||
feature::DataHeader const & h = value.GetHeader();
|
||||
info.m_limitRect = h.GetBounds();
|
||||
if (h.IsMWMSuitable())
|
||||
{
|
||||
info.m_limitRect = h.GetBounds();
|
||||
|
||||
pair<int, int> const scaleR = h.GetScaleRange();
|
||||
info.m_minScale = static_cast<uint8_t>(scaleR.first);
|
||||
info.m_maxScale = static_cast<uint8_t>(scaleR.second);
|
||||
pair<int, int> const scaleR = h.GetScaleRange();
|
||||
info.m_minScale = static_cast<uint8_t>(scaleR.first);
|
||||
info.m_maxScale = static_cast<uint8_t>(scaleR.second);
|
||||
|
||||
return h.GetVersion();
|
||||
return h.GetVersion();
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
MwmValue * Index::CreateValue(string const & name) const
|
||||
{
|
||||
return new MwmValue(name);
|
||||
MwmValue * p = new MwmValue(name);
|
||||
ASSERT(p->GetHeader().IsMWMSuitable(), ());
|
||||
return p;
|
||||
}
|
||||
|
||||
Index::Index()
|
||||
|
|
|
@ -130,6 +130,8 @@ int MwmSet::AddImpl(string const & fileName, m2::RectD & rect)
|
|||
// this function can throw an exception for bad mwm file
|
||||
MwmInfo info;
|
||||
int const version = GetInfo(fileName, info);
|
||||
if (version == -1)
|
||||
return -1;
|
||||
|
||||
info.m_status = MwmInfo::STATUS_ACTIVE;
|
||||
|
||||
|
|
|
@ -35,14 +35,16 @@ void FeaturesFetcher::InitClassificator()
|
|||
int FeaturesFetcher::AddMap(string const & file)
|
||||
{
|
||||
int version = -1;
|
||||
|
||||
try
|
||||
{
|
||||
m2::RectD r;
|
||||
version = m_multiIndex.Add(file, r);
|
||||
|
||||
// For debug purposes - add rect for countries only (press 'A' in map view).
|
||||
//if (file.find("World") == string::npos)
|
||||
if (version != -1)
|
||||
m_rect.Add(r);
|
||||
else
|
||||
LOG(LWARNING, ("Can't add map", file, "Probably it's already added or has newer data version."));
|
||||
}
|
||||
catch (RootException const & e)
|
||||
{
|
||||
|
|
|
@ -70,26 +70,29 @@ void Framework::AddMap(string const & file)
|
|||
{
|
||||
LOG(LINFO, ("Loading map:", file));
|
||||
|
||||
//threads::MutexGuard lock(m_modelSyn);
|
||||
int const version = m_model.AddMap(file);
|
||||
|
||||
// Now we do force delete of old (April 2011) maps.
|
||||
if (version == feature::DataHeader::v1)
|
||||
switch (version)
|
||||
{
|
||||
case -1:
|
||||
// Error in adding map - do nothing.
|
||||
break;
|
||||
|
||||
case feature::DataHeader::v1:
|
||||
// Now we do force delete of old (April 2011) maps.
|
||||
LOG(LINFO, ("Deleting old map:", file));
|
||||
RemoveMap(file);
|
||||
VERIFY ( my::DeleteFileX(GetPlatform().WritablePathForFile(file)), () );
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
|
||||
default:
|
||||
if (m_lowestMapVersion > version)
|
||||
m_lowestMapVersion = version;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void Framework::RemoveMap(string const & file)
|
||||
{
|
||||
//threads::MutexGuard lock(m_modelSyn);
|
||||
m_model.RemoveMap(file);
|
||||
}
|
||||
|
||||
|
|
|
@ -111,8 +111,6 @@ protected:
|
|||
|
||||
void StopLocationFollow();
|
||||
|
||||
//mutable threads::Mutex m_modelSyn;
|
||||
|
||||
storage::Storage m_storage;
|
||||
scoped_ptr<gui::Controller> m_guiController;
|
||||
scoped_ptr<anim::Controller> m_animController;
|
||||
|
|
Loading…
Add table
Reference in a new issue