Skip to content
Permalink
Browse files

android goodies (pull request #94):

[Marco Bernasocchi]
- adding needed files to support internal GPS via QtMobility, implementation of QgsQtLocationConnection is only a stub
- cleaning up methods names
- adding mobility to CMakeLists
- testing
- added hack to test parseData()
- adding more parsing stuff
- Adding debugging info and making connection fail if no QtSatellite datasource available
- Initial working GPS with coordinates bug (values shifted)
- Adding Initial GPS support to android using QtLocation
- Adding Ground speed and direction
- put ok button on top of widget to make it usable until scroll area is added (HACK to be Reverted later)
- added vertical and horizontal accurancy
- Removing test values qtlocationconnection
- refactor debug messages
- adding compass plugin
- trying NathanW suggestion
- adding new compass plugin
- Fixed satellitesUpdated signals
- removing setDataRate
- temporarely removed calibrationLevel display to be reverted when https://sourceforge.net/p/necessitas/tickets/153/ is fixed
- addin comment
- making QLineEdits readonly
- added calibration level support
[Jürgen E. Fischer]
- squashed, reindented and skipped some already addressed changes to qgisapp and vector layer provider
  • Loading branch information
mbernasocchi authored and jef-n committed Feb 8, 2012
1 parent d2b5ed9 commit 6055c11fe4e04b4e719a9d58a80c20677ffb488b
@@ -80,6 +80,17 @@ IF (WITH_BINDINGS)
SET (BINDINGS_GLOBAL_INSTALL FALSE CACHE BOOL "Install bindings to global python directory? (might need root)")
ENDIF (WITH_BINDINGS)

#BUILD WITH QtMobility by default on android only. Other platform can force it
IF (ANDROID)
SET (DEFAULT_WITH_QTMOBILITY TRUE)
ELSE (ANDROID)
SET (DEFAULT_WITH_QTMOBILITY FALSE)
ENDIF (ANDROID)
SET (WITH_QTMOBILITY ${DEFAULT_WITH_QTMOBILITY} CACHE BOOL "Determines QtMobility related code should be build (for example internal GPS)")
IF (WITH_QTMOBILITY)
FIND_PACKAGE(QtMobility 1.1.0)
ENDIF (WITH_QTMOBILITY)

SET (WITH_GLOBE FALSE CACHE BOOL "Determines whether Globe plugin should be built")
IF (WITH_GLOBE)
SET(QT_USE_QTOPENGL 1)
@@ -0,0 +1,163 @@
INCLUDE(FindQt4)

set(MOBILITY_CONFIG_MKSPECS_FILE "")
IF(EXISTS "${QT_MKSPECS_DIR}/features/mobilityconfig.prf")
set(MOBILITY_CONFIG_MKSPECS_FILE "${QT_MKSPECS_DIR}/features/mobilityconfig.prf")
ELSEIF(EXISTS "${QT_MKSPECS_DIR}/features/mobility.prf")
set(MOBILITY_CONFIG_MKSPECS_FILE "${CMAKE_CURRENT_SOURCE_DIR}/cmakes/mobilityconfig.prf")
ENDIF()

macro(export_component component)
IF(NOT ${MOBILITY_CONFIG_MKSPECS_FILE} STREQUAL "")
FILE(READ ${MOBILITY_CONFIG_MKSPECS_FILE} MOBILITY_FILE_CONTENTS)
STRING(TOLOWER ${component} _COMPONENT)
IF(${MOBILITY_FILE_CONTENTS} MATCHES "MOBILITY_CONFIG=.*${_COMPONENT}.*")
STRING(TOUPPER ${component} _COMPONENT)
SET(QT_MOBILITY_${_COMPONENT}_FOUND 1)
SET(QT_MOBILITY_${_COMPONENT}_INCLUDE_DIR ${QT_MOBILITY_PARENT_INCLUDE_DIR}/Qt${component})
SET(QT_MOBILITY_${_COMPONENT}_LIBRARY Qt${component})
ADD_DEFINITIONS(-DHAVE_QT_MOBILITY_${_COMPONENT})
ENDIF()
ENDIF()
endmacro()

set(VERSION_INFO "")
set(FEATURE_FILE_PREFIX "${QT_MKSPECS_DIR}/features/mobility")

if(DEFINED MOBILITY_VERSION)
if(MOBILITY_VERSION STREQUAL "1.1" AND EXISTS "${FEATURE_FILE_PREFIX}11.prf")
set(MOBILITY_PRF_FILE "${FEATURE_FILE_PREFIX}11.prf")
set(VERSION_INFO "1.1")
elseif(MOBILITY_VERSION STREQUAL "1.2" AND EXISTS "${FEATURE_FILE_PREFIX}12.prf")
set(MOBILITY_PRF_FILE "${FEATURE_FILE_PREFIX}12.prf")
set(VERSION_INFO "1.2")
elseif(MOBILITY_VERSION STREQUAL "default" AND EXISTS "${FEATURE_FILE_PREFIX}.prf")
set(MOBILITY_PRF_FILE "${FEATURE_FILE_PREFIX}.prf")
set(VERSION_INFO "system's default")
else()
message(STATUS "Couldn't find QtMobility version: ${MOBILITY_VERSION}")
endif()
endif()

if(NOT DEFINED MOBILITY_PRF_FILE)
if(EXISTS "${FEATURE_FILE_PREFIX}.prf")
set(MOBILITY_PRF_FILE "${FEATURE_FILE_PREFIX}.prf")
set(VERSION_INFO "system's default")
elseif(EXISTS "${FEATURE_FILE_PREFIX}12.prf")
set(MOBILITY_PRF_FILE "${FEATURE_FILE_PREFIX}12.prf")
set(VERSION_INFO "1.2")
elseif(EXISTS "${FEATURE_FILE_PREFIX}11.prf")
set(MOBILITY_PRF_FILE "${FEATURE_FILE_PREFIX}11.prf")
set(VERSION_INFO "1.1")
else()
message(FATAL_ERROR "Couldn't find any version of QtMobility.")
endif()
endif()

message(STATUS "Using QtMobility version: ${VERSION_INFO}")

IF(DEFINED MOBILITY_PRF_FILE)
FILE(READ ${MOBILITY_PRF_FILE} MOBILITY_FILE_CONTENTS)

STRING(REGEX MATCH "MOBILITY_PREFIX=([^\n]+)" QT_MOBILITY_PREFIX "${MOBILITY_FILE_CONTENTS}")
SET(QT_MOBILITY_PREFIX ${CMAKE_MATCH_1})

STRING(REGEX MATCH "MOBILITY_INCLUDE=([^\n]+)" QT_MOBILITY_INCLUDE_DIR "${MOBILITY_FILE_CONTENTS}")
SET(QT_MOBILITY_INCLUDE_DIR ${CMAKE_MATCH_1})

STRING(REGEX MATCH "MOBILITY_LIB=([^\n]+)" "\\1" QT_MOBILITY_LIBRARY "${MOBILITY_FILE_CONTENTS}")
SET(QT_MOBILITY_LIBRARY_DIR ${CMAKE_MATCH_1})

#VERSION
IF(NOT ${MOBILITY_CONFIG_MKSPECS_FILE} STREQUAL "")
FILE(READ ${MOBILITY_CONFIG_MKSPECS_FILE} MOBILITY_CONFIG_FILE_CONTENTS)
STRING(REGEX MATCH "MOBILITY_VERSION = ([^\n]+)" QT_MOBILITY_VERSION "${MOBILITY_CONFIG_FILE_CONTENTS}")
SET(QT_MOBILITY_VERSION ${CMAKE_MATCH_1})

STRING(REGEX MATCH "MOBILITY_MAJOR_VERSION = ([^\n]+)" QT_MOBILITY_MAJOR_VERSION "${MOBILITY_CONFIG_FILE_CONTENTS}")
SET(QT_MOBILITY_MAJOR_VERSION ${CMAKE_MATCH_1})

STRING(REGEX MATCH "MOBILITY_MINOR_VERSION = ([^\n]+)" QT_MOBILITY_MINOR_VERSION "${MOBILITY_CONFIG_FILE_CONTENTS}")
SET(QT_MOBILITY_MINOR_VERSION ${CMAKE_MATCH_1})

STRING(REGEX MATCH "MOBILITY_PATCH_VERSION = ([^\n]+)" QT_MOBILITY_PATCH_VERSION "${MOBILITY_CONFIG_FILE_CONTENTS}")
SET(QT_MOBILITY_PATCH_VERSION ${CMAKE_MATCH_1})

message(STATUS "QtMobility version: ${QT_MOBILITY_VERSION}")
ELSE()
SET(QT_MOBILITY_VERSION 1.0.0)
SET(QT_MOBILITY_MAJOR_VERSION 1)
SET(QT_MOBILITY_MINOR_VERSION 0)
SET(QT_MOBILITY_PATCH_VERSION 0)
ENDIF()

SET(QT_MOBILITY_PARENT_INCLUDE_DIR ${QT_MOBILITY_INCLUDE_DIR})
SET(QT_MOBILITY_INCLUDE_DIR ${QT_MOBILITY_INCLUDE_DIR}/QtMobility)

IF(QtMobility_FIND_VERSION_EXACT)
IF(QT_MOBILITY_VERSION VERSION_EQUAL QtMobility_FIND_VERSION)
SET(QT_MOBILITY_FOUND TRUE)
ELSE()
SET(QT_MOBILITY_FOUND FALSE)
IF(QT_MOBILITY_VERSION VERSION_LESS QtMobility_FIND_VERSION)
SET(QT_MOBILITY_TOO_OLD TRUE)
ELSE()
SET(QT_MOBILITY_TOO_NEW TRUE)
ENDIF()
ENDIF()
ELSE()
IF(QT_MOBILITY_VERSION VERSION_LESS QtMobility_FIND_VERSION)
SET(QT_MOBILITY_FOUND FALSE)
SET(QT_MOBILITY_TOO_OLD TRUE)
ELSE()
SET(QT_MOBILITY_FOUND TRUE)
ENDIF()
ENDIF()
ELSE()
SET(QT_MOBILITY_FOUND NOTFOUND)
SET(QT_MOBILITY_PREFIX NOTFOUND)
SET(QT_MOBILITY_INCLUDE NOTFOUND)
SET(QT_MOBILITY_LIB NOTFOUND)
ENDIF()

IF(NOT QT_MOBILITY_FOUND)
if(QT_MOBILITY_TOO_OLD)
MESSAGE(FATAL_ERROR "The installed QtMobility version ${QT_MOBILITY_VERSION} it too old, version ${QtMobility_FIND_VERSION} is required.")
ELSEIF(QT_MOBILITY_TOO_NEW)
MESSAGE(FATAL_ERROR "The installed QtMobility version ${QT_MOBILITY_VERSION} it too new, version ${QtMobility_FIND_VERSION} is required.")
ELSE()
MESSAGE(FATAL_ERROR "QtMobility not found.")
ENDIF()
ELSE()
INCLUDE_DIRECTORIES(${QT_MOBILITY_INCLUDE_DIR})
export_component(Bearer)
export_component(Feedback)
export_component(Gallery)
export_component(PublishSubscribe)
export_component(Location)
export_component(Organizer)
export_component(ServiceFramework)
export_component(SystemInfo)
export_component(Contacts)
export_component(Connectivity)
export_component(Messaging)
export_component(Versit)
export_component(Sensors)
# VersitOrganizer
if(QT_MOBILITY_VERSIT_FOUND AND QT_MOBILITY_ORGANIZER_FOUND)
SET(QT_MOBILITY_VERSITORGANIZER_FOUND 1)
SET(QT_MOBILITY_VERSITORGANIZER_INCLUDE_DIR ${QT_MOBILITY_PARENT_INCLUDE_DIR}/QtVersitOrganizer)
SET(QT_MOBILITY_VERSITORGANIZER_LIBRARY QtVersitOrganizer)
endif()

# MultimediaKit - it's just 'multimedia' in the .prf file.
IF(NOT ${MOBILITY_CONFIG_MKSPECS_FILE} STREQUAL "")
FILE(READ ${MOBILITY_CONFIG_MKSPECS_FILE} MOBILITY_FILE_CONTENTS)
IF(${MOBILITY_FILE_CONTENTS} MATCHES "MOBILITY_CONFIG=.*multimedia.*")
SET(QT_MOBILITY_MULTIMEDIAKIT_FOUND 1)
SET(QT_MOBILITY_MULTIMEDIAKIT_INCLUDE_DIR ${QT_MOBILITY_PARENT_INCLUDE_DIR}/QtMultimediaKit)
SET(QT_MOBILITY_MULTIMEDIAKIT_LIBRARY QtMultimediaKit)
ENDIF()
ENDIF()

ENDIF()
@@ -1,5 +1,5 @@
/***************************************************************************
qgsgpsinformationwidget.h - description
qgsgpsinformationwidget.cpp - description
-------------------
begin : Sat Jan 01 2010
copyright : (C) 2010 by Tim Sutton and Marco Hugentobler
@@ -184,6 +184,10 @@ QgsGPSInformationWidget::QgsGPSInformationWidget( QgsMapCanvas * thepCanvas, QWi
{
mRadAutodetect->setChecked( true );
}
else if ( myPortMode == "internalGPS" )
{
mRadInternal->setChecked( true );
}
else if ( myPortMode == "explicitPort" )
{
mRadUserPath->setChecked( true );
@@ -192,6 +196,11 @@ QgsGPSInformationWidget::QgsGPSInformationWidget( QgsMapCanvas * thepCanvas, QWi
{
mRadGpsd->setChecked( true );
}
//disable the internal port method if build is without QtLocation
#ifndef HAVE_QT_MOBILITY_LOCATION
mRadInternal->setDisabled( true );
mRadAutodetect->setChecked( true );
#endif

//auto digitising behaviour
mCbxAutoAddVertices->setChecked( mySettings.value( "/gps/autoAddVertices", "false" ).toBool() );
@@ -256,6 +265,10 @@ QgsGPSInformationWidget::~QgsGPSInformationWidget()
{
mySettings.setValue( "/gps/portMode", "scanPorts" );
}
else if ( mRadInternal->isChecked() )
{
mySettings.setValue( "/gps/portMode", "internalGPS" );
}
else if ( mRadUserPath->isChecked() )
{
mySettings.setValue( "/gps/portMode", "explicitPort" );
@@ -406,6 +419,10 @@ void QgsGPSInformationWidget::connectGps()
{
port = QString( "%1:%2:%3" ).arg( mGpsdHost->text() ).arg( mGpsdPort->text() ).arg( mGpsdDevice->text() );
}
else if ( mRadInternal->isChecked() )
{
port = QString( "internalGPS" );
}

mGPSPlainTextEdit->appendPlainText( tr( "Connecting..." ) );
showStatusBarMessage( tr( "Connecting to GPS device..." ) );
@@ -678,10 +695,12 @@ void QgsGPSInformationWidget::displayGPSInformation( const QgsGPSInformation& in
mTxtDateTime->setText( info.utcDateTime.toString( mDateTimeFormat ) ); //user specified format string for testing the millisecond part of time
}
mTxtSpeed->setText( tr( "%1 km/h" ).arg( info.speed, 0, 'f', 1 ) );
mTxtDirection->setText( QString::number( info.direction, 'f', 1 ) );
mTxtDirection->setText( QString::number( info.direction, 'f', 1 ) + QString::fromUtf8( "°" ) );
mTxtHdop->setText( QString::number( info.hdop, 'f', 1 ) );
mTxtVdop->setText( QString::number( info.vdop, 'f', 1 ) );
mTxtPdop->setText( QString::number( info.pdop, 'f', 1 ) );
mTxtHacc->setText( QString::number( info.hacc, 'f', 1 ) + "m" );
mTxtVacc->setText( QString::number( info.vacc, 'f', 1 ) + "m" );
mTxtFixMode->setText( info.fixMode == 'A' ? tr( "Automatic" ) : info.fixMode == 'M' ? tr( "Manual" ) : "" ); // A=automatic 2d/3d, M=manual; allowing for anything else
mTxtFixType->setText( info.fixType == 3 ? tr( "3D" ) : info.fixType == 2 ? tr( "2D" ) : info.fixType == 1 ? tr( "No fix" ) : QString::number( info.fixType ) ); // 1=no fix, 2=2D, 3=3D; allowing for anything else
mTxtQuality->setText( info.quality == 2 ? tr( "Differential" ) : info.quality == 1 ? tr( "Non-differential" ) : info.quality == 0 ? tr( "No position" ) : info.quality > 2 ? QString::number( info.quality ) : "" ); // allowing for anything else
@@ -794,7 +813,7 @@ void QgsGPSInformationWidget::on_mBtnAddVertex_clicked( )

void QgsGPSInformationWidget::addVertex( )
{

QgsDebugMsg( "Adding Vertex" );
if ( !mpRubberBand )
{
createRubberBand( );
@@ -191,6 +191,13 @@ ELSE(WIN32)
ADD_DEFINITIONS(-D_TTY_POSIX_)
ENDIF(WIN32)

IF (QT_MOBILITY_LOCATION_FOUND)
SET(QGIS_CORE_SRCS
${QGIS_CORE_SRCS}
gps/qgsqtlocationconnection.cpp
)
ENDIF (QT_MOBILITY_LOCATION_FOUND)

IF (WITH_INTERNAL_SPATIALITE)
IF (WIN32 OR APPLE OR ANDROID)
INCLUDE_DIRECTORIES(${ICONV_INCLUDE_DIR})
@@ -274,6 +281,13 @@ SET(QGIS_CORE_MOC_HDRS
gps/qextserialport/qextserialenumerator.h
)

IF (QT_MOBILITY_LOCATION_FOUND)
SET(QGIS_CORE_MOC_HDRS
${QGIS_CORE_MOC_HDRS}
gps/qgsqtlocationconnection.h
)
ENDIF (QT_MOBILITY_LOCATION_FOUND)

QT4_WRAP_CPP(QGIS_CORE_MOC_SRCS ${QGIS_CORE_MOC_HDRS})

# install headers
@@ -394,6 +408,13 @@ SET(QGIS_CORE_HDRS
qgsspatialindex.h
)

IF (QT_MOBILITY_LOCATION_FOUND)
SET(QGIS_CORE_HDRS
${QGIS_CORE_HDRS}
gps/qgsqtlocationconnection.h
)
ENDIF (QT_MOBILITY_LOCATION_FOUND)

INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}
composer
@@ -494,6 +515,10 @@ IF(APPLE)
TARGET_LINK_LIBRARIES(qgis_core "-framework CoreFoundation -framework IOKit")
ENDIF(APPLE)

IF (QT_MOBILITY_LOCATION_FOUND)
TARGET_LINK_LIBRARIES(qgis_core ${QT_MOBILITY_LOCATION_LIBRARY})
ENDIF (QT_MOBILITY_LOCATION_FOUND)

TARGET_LINK_LIBRARIES(qgis_core
${QT_QTMAIN_LIBRARY}
${QT_QTXML_LIBRARY}
@@ -94,6 +94,8 @@ void QgsGPSConnection::clearLastGPSInformation()
mLastGPSInformation.satellitesInView.clear();
mLastGPSInformation.speed = 0;
mLastGPSInformation.vdop = 0;
mLastGPSInformation.hacc = -1;
mLastGPSInformation.vacc = -1;
mLastGPSInformation.quality = -1; // valid values: 0,1,2, maybe others
mLastGPSInformation.satellitesUsed = 0;
mLastGPSInformation.fixMode = ' ';
@@ -44,6 +44,8 @@ struct CORE_EXPORT QgsGPSInformation
double pdop;
double hdop;
double vdop;
double hacc; //horizontal accurancy in meters
double vacc; //vertical accurancy in meters
QDateTime utcDateTime;
QChar fixMode;
int fixType;
@@ -22,6 +22,10 @@
#include "qgsnmeaconnection.h"
#include "qgsgpsdconnection.h"

#ifdef HAVE_QT_MOBILITY_LOCATION
#include "qgsqtlocationconnection.h"
#endif

#include <QStringList>
#include <QFileInfo>
#include <QTimer>
@@ -30,6 +34,10 @@ QList< QPair<QString, QString> > QgsGPSDetector::availablePorts()
{
QList< QPair<QString, QString> > devs;

// try local QtLocation first
#ifdef HAVE_QT_MOBILITY_LOCATION
devs << QPair<QString, QString>( "internalGPS", tr( "internal GPS" ) );
#endif
// try local gpsd first
devs << QPair<QString, QString>( "localhost:2947:", tr( "local gpsd" ) );

@@ -145,6 +153,15 @@ void QgsGPSDetector::advance()

mConn = new QgsGpsdConnection( gpsParams[0], gpsParams[1].toShort(), gpsParams[2] );
}
else if ( mPortList[ mPortIndex ].first.contains( "internalGPS" ) )
{
#ifdef HAVE_QT_MOBILITY_LOCATION
mConn = new QgsQtLocationConnection();
#else
qWarning( "QT_MOBILITY_LOCATION not found and mPortList matches internalGPS, this should never happen" );
#endif
}

else
{
QextSerialPort *serial = new QextSerialPort( mPortList[ mPortIndex ].first, QextSerialPort::EventDriven );

0 comments on commit 6055c11

Please sign in to comment.
You can’t perform that action at this time.