[Marble-devel] Performance issues adding placemarks to MarbleWidget

Dennis Nienhüser earthwings at gentoo.org
Thu Nov 22 07:53:41 UTC 2012


Hi Martin,

Am 20.11.2012 20:40, schrieb Martin Engelmann:
> Hello,
>
> I'm developing an application for managing geocaches and I'm using marble to
> display the locations on a map. I'm using a GeoDataDocument to colect all the
> placemarks for the caches. For each cache I use the following code to add a
> placemark to the map:
>
>      Marble::GeoDataPlacemark* placemark = new Marble::GeoDataPlacemark();
>      placemark->setName(geocache->waypoint());
>      placemark->setCoordinate(Marble::GeoDataPoint(geocache->position()));
>      // Set style, description and visual category ...
>
>      marbleWidget->model()->treeModel()->addFeature(geoDataDoc, placemark);
>
> The code works fine and fast when the application starts and the widget is not
> yet shown on the screen. The placemarks are created based on information from
> a database in a function called from the constructor of the applications main
> window.
>
> When I change the path to the database file however I need to remove all
> geocache placemarks and repopulate the map with the placemarks read from the
> database. The map is shown as it is part of the main window. This is much
> slower on my machine.
>
> I measured the follwing times for the addFeature call on my machine (Intel
> Core i7 CPU  860 @ 2.80GHz, 6GB RAM):
> Startup of the application: 1.1ms
> Repopulate the map: 28ms - 29ms
I guess seconds, not milliseconds? 30 ms would still be pretty fast.

> I assume it's slower because after each call to addFeature the map is updated
> to show the new placemark. Is there a possibility to disable updating the map
> when I add placemarks?

For testing (I wouldn't recommend this as a general solution) you can 
call something like (see also [1])

marbleWidget->model()->treeModel()->blockSignals(true);
// repopulate map
marbleWidget->model()->treeModel()->blockSignals(false);
marbleWidget->model()->treeModel()->update();

If that speeds things up, I'd try wrapping the placemarks in a GeoDataDocument and add/remove that to the model like so:


Marble::GeoDataDocument* document = new Marble::GeoDataDocument;
Marble::GeoDataPlacemark* placemark = new Marble::GeoDataPlacemark();
placemark->setName(geocache->waypoint());
placemark->setCoordinate(Marble::GeoDataPoint(geocache->position()));
// Set style, description and visual category ...
document->add(placemark);

marbleWidget->model()->treeModel()->addFeature(geoDataDoc, document);

The benefit is that you have just one addFeature/removeFeature call for all placemarks.

Regards,
Dennis


[1] http://doc.qt.digia.com/qt/qobject.html#blockSignals

> This way I could disable updating before I start adding the placemarks and re-
> enable it when I'm finished.
>
>
> I'm using marble 1.4.1 and KDE 4.9.3 on ArchLinux x86_64.
>
>
> Kind regards,
> Martin Engelmann
> murphi.oss at googlemail.com
> _______________________________________________
> Marble-devel mailing list
> Marble-devel at kde.org
> https://mail.kde.org/mailman/listinfo/marble-devel
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/marble-devel/attachments/20121122/bc05a896/attachment.html>


More information about the Marble-devel mailing list