This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Placemarks

Tags: None
(comma "," separated)
diavo
Registered Member
Posts
5
Karma
0

Placemarks

Wed Apr 18, 2012 1:53 pm
Hi,
I want to show the content of a .nmea file in a MarbleWidget. For this purpose I wanted to use placemarks. But it seems that the MarbleWidget does not show them.
Code: Select all
GeoDataPlacemark *geoPlacemark = new GeoDataPlacemark;
          GeoDataLineStyle style;
          GeoDataStyle *geoStyle = new GeoDataStyle;
          style.setColor(Qt::green);
          geoStyle->setLineStyle(style);
          GeoDataLineString *line = new GeoDataLineString;
          geoPlacemark->setGeometry(line);
          geoPlacemark->setStyle(geoStyle);
          while (!file.atEnd())
          {
            QByteArray temp = file.readLine();
            if (temp.contains("$GPGGA"))
            {
              line->append(GeoDataCoordinates(lon, lat, 0, GeoDataCoordinates::Degree));
            }
          }
          m_mapWidget->addBookmark(*geoPlacemark, "Default");
          m_mapWidget->centerOn(line->latLonAltBox());
          m_mapWidget->map()->setShowPlaces(true);
What might be wrong?
I also ttried to load sample .kml file in the Marble application. And also there is no placemark visible.
User avatar
Earthwings
KDE Developer
Posts
172
Karma
1
OS

Re: Placemarks

Wed Apr 18, 2012 2:19 pm
In the code snippet, where is lon, lat defined? And when is the line containing $GPGGA parsed? Doesn't seem to happen anywhere.

The easiest way to visualize a .nmea file is to transform it to .gpx before:
Code: Select all
wget http://nienhueser.de/marble/stuttgart.nmea -O /tmp/stuttgart.nmea
gpsbabel -i nmea -f /tmp/stuttgart.nmea -o gpx -F /tmp/stuttgart.gpx
marble --enableFileView /tmp/stuttgart.gpx

The --enableFileView parameter is not strictly needed, but it creates a new tab on the left of Marble where you can examine the contents of the loaded file. You can also use File -> Open inside marble to load a .gpx file.
User avatar
tackat
KDE Developer
Posts
131
Karma
0
OS

Re: Placemarks

Wed Apr 18, 2012 2:26 pm
Of course Dennis' suggestion might be the more convenient way. Still your code looks mostly alright on first glimpse. So I'm still a bit curious why it doesn't work. If it's just due to the missing lon/lat definition do your placemarks appear at 0°N 0°E by chance?
diavo
Registered Member
Posts
5
Karma
0

Re: Placemarks

Wed Apr 18, 2012 2:26 pm
Hi,
the code snipped is only part of the code. And the placemark seems to be at the correct position, because
Code: Select all
m_mapWidget->centerOn(line->latLonAltBox());

goes to the right position. But the green line is not visible there.
tgridel
KDE Developer
Posts
1
Karma
0

Re: Placemarks

Wed Apr 18, 2012 6:14 pm
Hello,

if you are using MarbleWidget::addPlacemark, then you must be using a 4.5 or 4.6 release of marble, which is at best one year old.
For now a stable version of KDE is 4.8

Unless you have a pressing need to stick to such environment, I would first recommend to use a more recent release, because we keep improving on the geodata rendering department from release to release.

Now even considering a 4.6, you are basically using the Bookmark management, which is slightly different from the generic Placemark rendering. (Bookmark is a special case of point placemarks which are stored in a marble specific file, whereas you are looking for a generic geometry Placemark).

The api alternatives would be to either:
- do your file parsing, generate a kml string for your placemark, and use widget->model()->addGeoDataString (convoluted but the historical api)
- use the FileManager, but i'm not sure if it ever was part of the public api
- in 4.8+ use the widget()->model()->treeModel() (now a GeoDataTreeModel) which is the recommended way to interact with geodata now. You can find usecases how geodata documents are handled in PositionTracking (internal code though), of in the recent Satellite plugin (which reads data from file and manipulates the treeModel to insert its satellites tracks)

Hth, if you have more questions feel free to ask.
diavo
Registered Member
Posts
5
Karma
0

Re: Placemarks

Thu Apr 19, 2012 6:47 am
Hi,
I think there is another problem. Even if I use
Code: Select all
m_mapWidget->addGeoDataFile(s);

I cannot see any overlays in the map. Also if I start the normal marble application (PRE 0.12.0 SVN) and load a .kml file (https://developers.google.com/kml/docum ... amples.kml) I cannot see it in the map.
User avatar
tackat
KDE Developer
Posts
131
Karma
0
OS

Re: Placemarks

Fri Apr 20, 2012 9:34 am
The "PRE" indicates that you are not running a stable release of Marble but instead a development snapshot that might have bugs. Therefore PRE 0.12.0 SVN is likely more than a year old (and lacks a vast amount of bugfixes and features).

However even with the current version of Marble we lack support for certain features. When loading the KML Samples file I can at least spot the "Simple Placemark" on the map.

If you load

https://developers.google.com/kml/docum ... states.kml

does it show the us states like this:

http://edu.kde.org/marble/screenshots/g ... le-kml.png

It should.
diavo
Registered Member
Posts
5
Karma
0

Re: Placemarks

Fri Apr 20, 2012 10:19 am
Hi,
this .kml example works fine. But why are my placemarks not drawn?
From where do I get the current stable release sources?
Maybe this fixes the problem.
User avatar
tackat
KDE Developer
Posts
131
Karma
0
OS

Re: Placemarks

Fri Apr 20, 2012 10:31 am
Building Marble is easy: you just need Qt:

http://edu.kde.org/marble/obtain.php


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, Google [Bot], rblackwell