<commit_before>//
// This file is part of the Marble Desktop Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2007   <NAME>   <<EMAIL>>
// Copyright 2009   <NAME>  <<EMAIL>>
//

#include "PositionTracking.h"

#include "AbstractLayer.h"
#include "ClipPainter.h"
#include "GmlSax.h"
#include "GpxFile.h"
#include "Track.h"
#include "TrackPoint.h"
#include "TrackSegment.h"
#include "PluginManager.h"
#include "PositionProviderPlugin.h"

#include <QtXml/QXmlInputSource>
#include <QtXml/QXmlSimpleReader>

#include <QtCore/QDebug>



using namespace Marble;

PositionTracking::PositionTracking( GpxFile *currentGpx,
                          QObject *parent ) 
     : QObject( parent )
{
    m_gpsCurrentPosition  = new TrackPoint( 0,0 );
    m_gpsPreviousPosition = new TrackPoint( 0,0 );
    m_gpsTracking         = new TrackPoint( 0,0 );

    m_gpsTrack    = new Track();
    currentGpx->addTrack( m_gpsTrack );
    m_gpsTrackSeg = 0;
    m_updateDelay = 0;

    PluginManager pluginManager;
    QList<PositionProviderPlugin *> plugins = pluginManager.createPositionProviderPlugins();
    if ( !plugins.isEmpty() ) {
        // FIXME: not just take the first plugin, but use some configuration setting
        // take the first plugin and delete the rest
        m_positionProvider = plugins.takeFirst();
        qDeleteAll( plugins );
        m_positionProvider->setParent( this );
        m_positionProvider->initialize();
    }
}


PositionTracking::~PositionTracking()
{
    delete m_gpsCurrentPosition;
    delete m_gpsPreviousPosition;
    delete m_gpsTracking;

    delete m_gpsTrack;
}


void PositionTracking::construct( const QSize &canvasSize,
                             ViewParams *viewParams )
{
    //qreal const radius = viewParams->m_radius;

    // FIXME: Review
//#ifdef HAVE_LIBGPS<commit_msg>initialize it properly if there are no plugins available<commit_after>//
// This file is part of the Marble Desktop Globe.
//
// This program is free software licensed under the GNU LGPL. You can
// find a copy of this license in LICENSE.txt in the top directory of
// the source code.
//
// Copyright 2007   <NAME>   <<EMAIL>>
// Copyright 2009   <NAME>  <<EMAIL>>
//

#include "PositionTracking.h"

#include "AbstractLayer.h"
#include "ClipPainter.h"
#include "GmlSax.h"
#include "GpxFile.h"
#include "Track.h"
#include "TrackPoint.h"
#include "TrackSegment.h"
#include "PluginManager.h"
#include "PositionProviderPlugin.h"

#include <QtXml/QXmlInputSource>
#include <QtXml/QXmlSimpleReader>

#include <QtCore/QDebug>



using namespace Marble;

PositionTracking::PositionTracking( GpxFile *currentGpx,
                          QObject *parent ) 
     : QObject( parent )
{
    m_gpsCurrentPosition  = new TrackPoint( 0,0 );
    m_gpsPreviousPosition = new TrackPoint( 0,0 );
    m_gpsTracking         = new TrackPoint( 0,0 );

    m_gpsTrack    = new Track();
    currentGpx->addTrack( m_gpsTrack );
    m_gpsTrackSeg = 0;
    m_updateDelay = 0;

    PluginManager pluginManager;
    QList<PositionProviderPlugin *> plugins = pluginManager.createPositionProviderPlugins();
    if ( !plugins.isEmpty() ) {
        // FIXME: not just take the first plugin, but use some configuration setting
        // take the first plugin and delete the rest
        m_positionProvider = plugins.takeFirst();
        qDeleteAll( plugins );
        m_positionProvider->setParent( this );
        m_positionProvider->initialize();
    } else {
        // usefull under Windows, where there is no plugin available yet.
        m_positionProvider = 0;
    }
}


PositionTracking::~PositionTracking()
{
    delete m_gpsCurrentPosition;
    delete m_gpsPreviousPosition;
    delete m_gpsTracking;

    delete m_gpsTrack;
}


void PositionTracking::construct( const QSize &canvasSize,
                             ViewParams *viewParams )
{
    //qreal const radius = viewParams->m_radius;

    // FIXME: Review
//#ifdef HAVE_LIBGPS
{'fraction_non_alphanumeric': 0.10236220472440945, 'fraction_numerical': 0.00812007874015748, 'mean_word_length': 3.1353001017294, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3289110', 'n_tokens_mistral': 1276, 'n_tokens_neox': 1229, 'n_words': 342}