Bug 299527 - Red line does not shown
Summary: Red line does not shown
Status: RESOLVED NOT A BUG
Alias: None
Product: marble
Classification: Applications
Component: data (show other bugs)
Version: unspecified
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: 1.4 (KDE 4.9)
Assignee: marble-bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-05-06 20:35 UTC by marbledeveloper
Modified: 2012-07-02 14:17 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description marbledeveloper 2012-05-06 20:35:02 UTC
If I use this code (from 0º to 360º): http://pastebin.com/RUkdh1qZ the line that joins the points does not shown.

But If use this another code (from 0º to 359º): http://pastebin.com/5De6wFsX the line that joins the points is shown properly.

m_track is a pointer to GeoDataTrack object.

Reproducible: Always
Comment 1 Bernhard Beschow 2012-05-11 11:50:42 UTC
Can you reproduce the error if you reduce your test case, e.g. to just two coordinates?

In addition, it would greately help us if you could provide a small demo app (not more than a few lines, please! ;) which gives us a bit more context of what your're trying to do. Thanks!
Comment 2 marbledeveloper 2012-05-16 18:30:37 UTC
Hi,

I have implemented a small demo that I have attached:

marblemanager.h: http://pastebin.com/XXR8cdiv
marblemanager.cpp: http://pastebin.com/fsfmGvtG
satitem.h: http://pastebin.com/G2wwdkvs
satitem.cpp: http://pastebin.com/NyTWVMC9

If you run the demo without changes, you can check that the red line disappear when the point with longitude == 360 is drawn.

If you run the demo using GeoDataTrack instead of GeoDataLineString, you can check that the red line does not appear directly. I have special interest in this last case because I need add points in each update of marble clock.

Best regards.
Comment 3 Dennis Nienhüser 2012-05-19 09:55:17 UTC
Git commit f50a2c7bb70ff863d943e58d8ed90fedba664fb0 by Dennis Nienhüser.
Committed on 19/05/2012 at 11:52.
Pushed by nienhueser into branch 'master'.

Handle corner case correctly. Thanks to Torsten helping track it down.

M  +1    -1    src/lib/geodata/data/GeoDataLatLonBox.cpp
M  +17   -0    tests/TestGeoDataLatLonAltBox.cpp

http://commits.kde.org/marble/f50a2c7bb70ff863d943e58d8ed90fedba664fb0
Comment 4 marbledeveloper 2012-05-22 22:15:23 UTC
The bug is partially solved.

The second part of the bug is not solved:

If you run the demo using GeoDataTrack instead of GeoDataLineString, you can check that the red line does not appear directly.

Have you checked this behaviour?

Best regards.
Comment 5 Dennis Nienhüser 2012-05-23 19:26:51 UTC
I used the code pasted below and get two lines as expected. One is a placemark with a line string geometry, the other one with a track geometry.


#include <QtGui/QApplication>
#include <marble/MarbleWidget.h>
#include <marble/MarbleModel.h>
#include <marble/MarbleClock.h>
#include <marble/GeoDataPlacemark.h>
#include <marble/GeoDataLineString.h>
#include <marble/GeoDataStyle.h>
#include <marble/GeoDataDocument.h>
#include <marble/GeoDataTrack.h>
#include <marble/GeoDataTreeModel.h>
#include <marble/RenderPlugin.h>

using namespace Marble;

int main(int argc, char** argv)
{
    QApplication app(argc,argv);

    // Create a Marble QWidget without a parent
    MarbleWidget *mapWidget = new MarbleWidget();

    // Load the OpenStreetMap map
    mapWidget->setMapThemeId("earth/openstreetmap/openstreetmap.dgml");

    GeoDataLineString* track_line_string = new GeoDataLineString();
    GeoDataTrack* track = new GeoDataTrack();
    for (int i=0; i<=360; ++i) {
        track_line_string->append(GeoDataCoordinates( i, 0, 20000.0 * 1000, GeoDataCoordinates::Degree ));
        track->addPoint(mapWidget->model()->clock()->dateTime(), GeoDataCoordinates( i, 0, 22000.0 * 1000, GeoDataCoordinates::Degree ));
    }

    QString satelliteName("test");
    GeoDataPlacemark* geoDataPlacemark = new GeoDataPlacemark("LineString Geometry");
    geoDataPlacemark->setVisualCategory( GeoDataFeature::Satellite );
    geoDataPlacemark->setGeometry( track_line_string );
    GeoDataStyle *style = new GeoDataStyle( *geoDataPlacemark->style() );
    geoDataPlacemark->setStyle( style );
    geoDataPlacemark->style()->lineStyle().setColor( oxygenBrickRed4 );
    geoDataPlacemark->style()->lineStyle().setPenStyle( Qt::SolidLine );
    geoDataPlacemark->style()->labelStyle().setGlow( true );

    GeoDataPlacemark* geoDataPlacemarkTrack = new GeoDataPlacemark("Track Geometry");
    geoDataPlacemarkTrack->setVisualCategory( GeoDataFeature::Satellite );
    geoDataPlacemarkTrack->setGeometry( track );
    GeoDataStyle *trackStyle = new GeoDataStyle( *geoDataPlacemarkTrack->style() );
    geoDataPlacemarkTrack->setStyle( trackStyle );
    geoDataPlacemarkTrack->style()->lineStyle().setColor( oxygenSkyBlue4 );
    geoDataPlacemarkTrack->style()->lineStyle().setPenStyle( Qt::SolidLine );
    geoDataPlacemarkTrack->style()->labelStyle().setGlow( true );

    GeoDataDocument *geoDataContainer = new GeoDataDocument();
    geoDataContainer->setFileName("container_" + satelliteName);
    geoDataContainer->append( geoDataPlacemark );
    geoDataContainer->append( geoDataPlacemarkTrack );
    mapWidget->model()->treeModel()->addDocument(geoDataContainer);

    foreach( RenderPlugin* plugin, mapWidget->renderPlugins() ) {
        plugin->setEnabled(false);
        plugin->setVisible(false);
    }

    mapWidget->setRadius(120);
    mapWidget->centerOn(0,30);
    mapWidget->show();

    return app.exec();
}
Comment 6 marbledeveloper 2012-05-23 21:10:09 UTC
Hi Dennis,

Yes, your code works properly because you are adding the points in one time.

Have you tried to add the points in each update of Marble clock? If you try it, you will get the bug.

For example:

#include <QtGui/QApplication>
#include "marblemanager.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    MarbleManager w;
    w.show();
    return a.exec();
}

#ifndef MARBLEMANAGER_H
#define MARBLEMANAGER_H

#include <MarbleWidget.h>

#include <GeoDataTreeModel.h>
#include <GeoDataLineString.h>
#include <GeoDataTrack.h>

using namespace Marble;

class MarbleManager: public MarbleWidget
{
    Q_OBJECT

public:
    MarbleManager(QWidget* parent = 0);

private slots:
    void update();

private:
    int lon;
    GeoDataTrack*           m_track;
};

#endif // MARBLEMANAGER_H

#include "marblemanager.h"

#include <MarbleModel.h>
#include <MarbleClock.h>
#include <RenderPlugin.h>
#include <QtGui/QTreeView>

#include <GeoDataStyle.h>
#include <GeoDataDocument.h>
#include <GeoDataPlacemark.h>

#include <QDebug>

MarbleManager::MarbleManager(QWidget* parent) :
    MarbleWidget(parent),
    lon(0)
{
    // Load the OpenStreetMap map
    setMapThemeId("earth/bluemarble/bluemarble.dgml");
    // Sets the camera fixed by default
    setShowSunInZenith(true);
    // Sets default distance
    setDistance(12000);
    // Sets default zoom
    zoomView(800);
    // Sets default simulation speed
    int speed(1000);
    model()->clock()->setSpeed(speed);
    // Sets initial time
    Qt::DateFormat format = Qt::ISODate;
    QString dateString("2000-01-01T00:00:00");
    QDateTime dateTime = QDateTime::fromString(dateString, format);
    model()->clock()->setDateTime(dateTime);
    // Sets update interval
    int updateInterval(20);
    model()->clock()->setUpdateInterval(updateInterval);
    // Filters the default plugins: satellites, stars and sun
    for (int i = 0; i < renderPlugins().count(); i++){
        if ("stars" == renderPlugins().at(i)->nameId().toAscii() ||
            "sun" == renderPlugins().at(i)->nameId().toAscii() ) {
            renderPlugins().at(i)->setVisible(true);
            renderPlugins().at(i)->setEnabled(true);
        }
        else {
            renderPlugins().at(i)->setVisible(false);
            renderPlugins().at(i)->setEnabled(false);
        }
    }
    show();
    connect(model()->clock(), SIGNAL(timeChanged()), this, SLOT(update()));

    m_track = new GeoDataTrack();
    QString satelliteName("test");
    GeoDataPlacemark* geoDataPlacemark = new GeoDataPlacemark(satelliteName);

    geoDataPlacemark->setVisualCategory( GeoDataFeature::Satellite );
    geoDataPlacemark->setGeometry( m_track );
    GeoDataStyle *style = new GeoDataStyle( *geoDataPlacemark->style() );
    geoDataPlacemark->setStyle( style );
    geoDataPlacemark->style()->lineStyle().setColor( oxygenBrickRed4 );
    geoDataPlacemark->style()->lineStyle().setPenStyle( Qt::SolidLine );
    geoDataPlacemark->style()->labelStyle().setGlow( true );


    GeoDataDocument *geoDataContainer = new GeoDataDocument();
    geoDataContainer->setFileName("container_" + satelliteName);
    geoDataContainer->append( geoDataPlacemark );
    model()->treeModel()->addDocument(geoDataContainer);
}

void MarbleManager::update()
{
    if (360 < lon)
        return;
    GeoDataCoordinates coordinates = GeoDataCoordinates( lon, 0, 20000.0 * 1000, GeoDataCoordinates::Degree );
    m_track->addPoint(model()->clock()->dateTime(), coordinates);
    lon++;
}

Try it please.

Regards!
Comment 7 marbledeveloper 2012-05-23 21:19:29 UTC
When I run your code, I can see the next: http://i48.tinypic.com/rli6tf.jpg

I thought that only a red line should be appear...

Anyway test my code, please.

I use MS Windows.
Comment 8 marbledeveloper 2012-05-23 22:20:48 UTC
If I change the line:

track->addPoint(mapWidget->model()->clock()->dateTime(), GeoDataCoordinates( i, 0, 22000.0 * 1000, GeoDataCoordinates::Degree ));

by the line:

track->addPoint(mapWidget->model()->clock()->dateTime().addSecs(i), GeoDataCoordinates( i, 0, 22000.0 * 1000, GeoDataCoordinates::Degree ));

I can see the two lines: http://i46.tinypic.com/35bcr2q.jpg But I think that isn't a solution.

I have tracked down it with Earthwings in the IRC chat and he has viewed a strange behaviour when he has tested my code.

Those are his exact words:

"there seems to be some inconsistency, noticed this in the other example as well"
"sometimes it's shown, sometimes not, sometimes at the wrong place"

He has made a screenshot: http://nienhueser.de/marble/marble-saturn1.png and in there the satellite is not shown it should be appear.

Regards.
Comment 9 Dennis Nienhüser 2012-05-24 06:24:55 UTC
So the remaining issues should be 

1) on Windows the GeoDataTrack as a placemark geometry is not shown in all cases
and
2) the placemark label appears at sometimes strange places
Comment 10 marbledeveloper 2012-05-24 08:31:51 UTC
I think that Marble must work properly in Linux and Windows systems.

Will you prepare a patch to fix it?

Regards!
Comment 11 Thibaut Gridel 2012-06-30 12:54:54 UTC
Hi, the issue is you have to call treeModel()->updateFeature(GeoDataFeature*) in order to trigger a repaint.
Comment 12 marbledeveloper 2012-07-02 14:17:27 UTC
I have tried using the line: treeModel()->updateFeature(GeoDataFeature*) in my code but the method 'updateFeature' is not declared in GeoDataTreeModel: http://api.kde.org/4.8-api/kdeedu-apidocs/marble/html/classMarble_1_1GeoDataTreeModel.html#a0391a7f16744e248e0d5d669e5fe2332

I have using Marble 4.8.

Which version of Marble have you using?

Regards.