Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. I need help getting Placemarks to show on my MarbleWidget with addGeoDataString
Forum Updated to NodeBB v4.3 + New Features

I need help getting Placemarks to show on my MarbleWidget with addGeoDataString

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    solareclectic
    wrote on last edited by
    #1

    I believe I've got the correct function to put Placemarks on my MarbleWidget:

    @void addGeoDataString (const QString &data, const QString &key="data")@

    to put the Point indicated in this kml string onto my MarbleWidget

    @<?xml version="1.0" encoding="UTF-8"?>
    <kml>
    <Document>
    <Placemark>
    <name>Houlton International Airport</name>
    <description>Weather Station</description>
    <Point>
    <coordinates>-67.8,46.12,150</coordinates>
    </Point>
    </Placemark>
    </Document>
    </kml>@

    but I'm getting nothing to appear.
    ( "xmlns="http://www.opengis.net/kml/2.2"" keeps getting cropped out of my kml open tag )

    Is my kml correct?

    Do I need to call another function on MarbleWidget to display the newly added Points in the model?

    I've left the second parameter empty, as it has a default, and frankly (from the "documentation":http://api.kde.org/4.6-api/kdeedu-apidocs/marble/html/classMarble_1_1MarbleWidget.html#a429644198835fbfc15982e552c41cc62)
    @Parameters:
    data- the string containing the Placemarks.
    key- the string needed to identify the data@

    I don't know what "data" is supposed to indicate.
    I've gone back in MarbleWidget source code, where the parameters flip-flopped places enough times to tangle me up.

    Mostly, I think this is probably a simple thing, and that I'm overlooking something obvious.
    Anyone have a clue for me?

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andre
      wrote on last edited by
      #2

      I think you will get more and better replies on a question on Marble in a "mailinglist":https://mail.kde.org/mailman/listinfo/marble-devel dedicated to it.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        solareclectic
        wrote on last edited by
        #3

        Andre, Thanks, you are correct. I also asked there, and got this reply...
        (I'll include for anyone else looking for this response)
        [quote]
        Hi,

        I think that you need to update the data model so that the new placemark
        appears on the mapwidget. A call to
        @
        marblewidget->model()->treeModel()->update()
        @
        (working with the latest code on git) should do it, but it maybe slow if you need to add many placemarks.

        I am working on adding a function "addFeature" to GeoDataTreeModel which will work the same way as addDocument, updating only the data you replaced, which should work better if you have a large number of placemarks to add. It works fine in single-threaded mode (see attached file for a patch).

        If you want to give it a try, you will have to create your kml tree, something like:
        @
        Marble::GeoDataDocument *mydoc=new Marble::GeoDataDocument();
        mydoc->setFileName("mydocument.kml"); //Will identify the document internally, must be unique
        mydoc->setName("My_GeoDataDocument"); //Name for visualisation in MarbleWidget

        Marble::GeoDataFolder *myfolder=new Marble::GeoDataFolder;
        myfolder->setName("My first folder"); //(setName from base class GeoDataFeature, inherited from GeoDataContainer)
        
        Marble::GeoDataPlacemark *myplacemark=new Marble::GeoDataPlacemark;
        myplacemark->setName("A placemark in a folder");
        
        marblewidget->model()->treeModel()->addDocument(mydoc);
        marblewidget->model()->treeModel()->addFeature(mydoc, myfolder);
        marblewidget->model()->treeModel()->addFeature(myfolder, myplacemark);
        

        @
        You can also retrieve an existing element GeoData... structure from its QModelIndex (for instance, if you loaded an existing document with a
        call to MarbleWidget::addDocument(QString) ):
        @
        GeoDataObject* geoobject = static_cast<GeoDataObject*>( modelindex.internalPointer()
        @

        I have added GeoDataTreeModel::index(GeoDataFeature*) function to recover the QModelIndex of a feature already present in the treemodel, I am not sure if there is an easier way to get the model (I go through up the tree upto top-level node m_rootDocument, and then build the index downwards, any ideas?).

        The attached code is work in progress. My plan is to include:

        • Implement a removeFeature function
        • Reimplement calls to addDocument and removeDocument with calls to new functions addFeature and removeFeature (so that all the code to do the update is centered in a single function).
        • Add protection for multithreaded operation. With code on svn (and my patch as it is) a single call to addDocument from a thread different of the main thread causes the application to crash.

        I am having some trouble with multithreading, I will send a message to the list asking for help on this later.

        I will be glad to hear any feedback you may have on the patch, I will submit it to reviewboard when it is complete.

        Hth
        Javier[/quote]

        Edit: added a bit of markup. Especially on code sections, could you please use @ tags to properly format them?; Andre

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved