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
path: root/map
diff options
context:
space:
mode:
authorvng <viktor.govako@gmail.com>2012-12-17 21:04:20 +0400
committerAlex Zolotarev <alex@maps.me>2015-09-23 01:48:02 +0300
commita4a7b15b6c64d112c2c8568145b18b9fe4461986 (patch)
treebccd9329659b80aa78f5a84e8075f042314a6263 /map
parent362a283c933a30ceb86ce090759d499bd9afebcc (diff)
Fix bug with bookmarks loading.
Diffstat (limited to 'map')
-rw-r--r--map/bookmark.cpp5
-rw-r--r--map/map_tests/bookmarks_test.cpp37
2 files changed, 40 insertions, 2 deletions
diff --git a/map/bookmark.cpp b/map/bookmark.cpp
index e64f552fc4..8761f7d69d 100644
--- a/map/bookmark.cpp
+++ b/map/bookmark.cpp
@@ -231,7 +231,7 @@ namespace bookmark_impl
else if (currTag == "description")
m_description = value;
}
- else if (count > 3 && m_tags[2] == "Placemark")
+ else if (count > 3 && m_tags[count-3] == "Placemark")
{
if (prevTag == "Point")
{
@@ -265,7 +265,8 @@ void BookmarkCategory::LoadFromKML(ReaderPtr<Reader> const & reader)
{
ReaderSource<ReaderPtr<Reader> > src(reader);
bookmark_impl::KMLParser parser(*this);
- ParseXML(src, parser, true);
+ if (!ParseXML(src, parser, true))
+ LOG(LERROR, ("XML read error. Probably, incorrect file encoding."));
}
BookmarkCategory * BookmarkCategory::CreateFromKMLFile(string const & file)
diff --git a/map/map_tests/bookmarks_test.cpp b/map/map_tests/bookmarks_test.cpp
index 26a5e42017..d1226bbdfa 100644
--- a/map/map_tests/bookmarks_test.cpp
+++ b/map/map_tests/bookmarks_test.cpp
@@ -415,3 +415,40 @@ UNIT_TEST(Bookmarks_AddingMoving)
DeleteCategoryFiles();
}
+
+namespace
+{
+char const * kmlString2 =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<kml xmlns=\"http://earth.google.com/kml/2.1\">"
+ "<Document>"
+ "<name>busparkplatz</name>"
+ "<Folder>"
+ "<name>Waypoint</name>"
+ "<Style id=\"poiIcon37\">"
+ "<IconStyle>"
+ "<scale>1</scale>"
+ "<Icon><href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png</href></Icon>"
+ "<hotSpot x=\"0.5\" y=\"0\" xunits=\"fraction\" yunits=\"fraction\"/>"
+ "</IconStyle>"
+ "</Style>"
+ "<Placemark>"
+ "<name>[P] Silvrettastrae[Bieler Hhe]</name>"
+ "<description></description>"
+ "<styleUrl>#poiIcon37</styleUrl>"
+ "<Point>"
+ "<coordinates>10.09237,46.91741,0</coordinates>"
+ "</Point>"
+ "</Placemark>"
+ "</Folder>"
+ "</Document>"
+ "</kml>";
+}
+
+UNIT_TEST(Bookmarks_InnerFolder)
+{
+ BookmarkCategory cat("Default");
+ cat.LoadFromKML(new MemReader(kmlString2, strlen(kmlString2)));
+
+ TEST_EQUAL(cat.GetBookmarksCount(), 1, ());
+}