Permalink
Browse files

Revert "Added RawLocationParser: A utility class to parse the raw rep…

…ly of low level location module of the OS. This allows for retrieving information that cannot be retrieved via the standard Qt Location API."

This reverts commit 521069e.
  • Loading branch information...
1 parent 7574203 commit 1a8bd271c35c1ccd8bbcd500b07491f3a3f92a1b @shaque committed Aug 17, 2012
@@ -0,0 +1,3 @@
+/.settings
+/arm
+/x86
@@ -1,5 +0,0 @@
-/o.le-v7
-/o.le-v7-g
-/Makefile
-/Makefile.Debug
-/Makefile.Release
@@ -87,7 +87,11 @@ void LocationEngine::positionUpdated(const QGeoPositionInfo& pos) {
_locationPage->findChild<QObject*>("qllVerticalAccuracy")->setProperty("text", pos.attribute(QGeoPositionInfo::VerticalAccuracy));
_locationPage->findChild<QObject*>("qllMagneticVariation")->setProperty("text", pos.attribute(QGeoPositionInfo::MagneticVariation));
- parseRawData();
+ logQString("update");
+ QVariant replayData = _positionSource->property("replayDat");
+
+
+
}
QGeoPositionInfoSource* LocationEngine::positionSource() {
@@ -102,6 +106,14 @@ void LocationEngine::satellitesInUseUpdated(const QList<QGeoSatelliteInfo>& sate
logQString("satellitesInUseUpdated received.");
}
+bool LocationEngine::isSoundEnabled() {
+ return soundEnabled;
+}
+
+void LocationEngine::setSoundEnabled(bool enabled) {
+ soundEnabled = enabled;
+}
+
void LocationEngine::satellitesInViewUpdated(const QList<QGeoSatelliteInfo>& satellites) {
logQString("satellitesInViewUpdated received.");
}
@@ -119,65 +131,9 @@ void LocationEngine::resetEngine(QString type) {
logQString(type + " RESET.");
}
-bool LocationEngine::isSoundEnabled() {
- return soundEnabled;
-}
-
-void LocationEngine::setSoundEnabled(bool enabled) {
- soundEnabled = enabled;
-}
-
-void LocationEngine::parseRawData() {
- // Parsing the raw data from the low level Location Manager. Use this only if a field is not accessible via QGeoPositionInfo above.
- QVariant replyData = _positionSource->property("replyDat");
- if(!replyData.isValid()){
- logQString("!!! Invalid replyDat.");
- //return;
- }
-
- RawLocationParser parser(replyData);
-
- double latitude = parser.latitude();
- double longitude = parser.longitude();
- double altitude = parser.altitude();
- double hAccuracy = parser.horizontalAccuracy();
- double vAccuracy = parser.verticalAccuracy();
- double heading = parser.heading();
- double speed = parser.speed();
- double ttff = parser.ttff();
- double gpsWeek = parser.gpsWeek();
- double gpsTow = parser.gpsTow();
- double utc = parser.utc();
- double hdop = parser.hdop();
- double vdop = parser.vdop();
- double pdop = parser.pdop();
- bool propagated = parser.propagated();
-
- QString method = parser.positionMethod();
- _locationPage->findChild<QObject*>("qllMethod")->setProperty("text", method);
-
- logQString("Method: " + method + ", Latitude: " + QString().setNum(latitude) + ", Longitude: " + QString().setNum(longitude) + ", Altitude: " + QString().setNum(altitude) + ", Horizontal Accuracy: " + QString().setNum(hAccuracy) + ", Vertical Accuracy: " + QString().setNum(vAccuracy) + ", Heading: " + QString().setNum(heading) + ", Speed: " + QString().setNum(speed) + ", TTFF: " + QString().setNum(ttff) + ", GPS Week: " + QString().setNum(gpsWeek) + ", GPS TOW: " + QString().setNum(gpsTow) + ", UTC: " + QString().setNum(utc) + ", Horizontal Dilution: " + QString().setNum(hdop) + ", Vertical Dilution: " + QString().setNum(vdop) + ", Positional Dilution: " + QString().setNum(pdop) + ", Propagated: " + QString().setNum(propagated));
- QString error = parser.error();
- if(error.length()>3){
- logQString("!!! [Error] " + error);
- }
-
- for (int i = 0; i < parser.numberOfSatellites(); i++) {
- double id = parser.satelliteId(i);
- double cno = parser.satelliteCarrierToNoiseRatio(i);
- bool ephemerisAvailable = parser.satelliteEphemerisAvailable(i);
- double azimuth = parser.satelliteAzimuth(i);
- double elevation = parser.satelliteElevation(i);
- bool tracked = parser.satelliteTracked(i);
- bool used = parser.satelliteUsed(i);
- logQString("\t[Satellite " + QString().setNum(i) + "]" + ", ID: " + QString().setNum(id) + ", CNO: " + QString().setNum(cno) + ", Ephemeris Available: " + ephemerisAvailable + ", Azimuth: " + QString().setNum(azimuth) + ", Elevation: " + QString().setNum(elevation) + ", Tracked: " + tracked + ", Used: " + used);
- }
-}
-
void LocationEngine::logQString(QString msg) {
- //QString text = _locationPage->findChild<QObject*>("logs")->property("text").toString();
- //_locationPage->findChild<QObject*>("logs")->setProperty("text", text + "\n" + msg);
-
- cout << "Location Diagnostics: "<< msg.toLocal8Bit().constData() << endl;
+ QString text = _locationPage->findChild<QObject*>("logs")->property("text").toString();
+ _locationPage->findChild<QObject*>("logs")->setProperty("text", text + "\n" + msg);
+ cout << "Location Diagnostics: " << msg.toLocal8Bit().constData() << endl;
}
@@ -31,8 +31,6 @@
#include <bb/multimedia/MediaPlayer.hpp>
#include <stdio.h>
-#include<ReplyParser.h>
-
using namespace std;
using namespace QtMobilitySubset;
using namespace bb::cascades;
@@ -69,7 +67,6 @@ public Q_SLOTS:
void printField( QString & key, QVariant & value );
void dumpRawPositionData( QString & label, QVariantMap & rawDat );
void logQString(QString msg);
- void parseRawData();
};
#endif /* LOCATIONENGINE_H_ */
@@ -7,202 +7,113 @@
#include "ReplyParser.h"
-RawLocationParser::RawLocationParser(const QVariant & replyData) :
- _replyData(replyData) {
-
-}
-
-double RawLocationParser::latitude() {
- return parseDouble(_replyData, "latitude");
-}
-
-double RawLocationParser::longitude() {
- return parseDouble(_replyData, "longitude");
-}
-
-double RawLocationParser::altitude() {
- return parseDouble(_replyData, "altitude");
-}
-
-double RawLocationParser::horizontalAccuracy() {
- return parseDouble(_replyData, "accuracy");
-}
-
-double RawLocationParser::verticalAccuracy() {
- return parseDouble(_replyData, "altitudeAccuracy");
-}
-
-double RawLocationParser::heading() {
- return parseDouble(_replyData, "heading");
-}
-
-double RawLocationParser::speed() {
- return parseDouble(_replyData, "speed");
+ReplyParser::ReplyParser(const QVariant & replyData) :
+ _replyData(replyData), _satIndex(0) {
}
+;
-double RawLocationParser::ttff() {
- return parseDouble(_replyData, "ttff");
+bool ReplyParser::latitude(double *lat) {
+ return parseDouble(lat, _replyData, "latitude");
}
-double RawLocationParser::gpsWeek() {
- return parseDouble(_replyData, "gpsWeek");
+bool ReplyParser::longitude(double *lon) {
+ return parseDouble(lon, _replyData, "longitude");
}
-double RawLocationParser::gpsTow() {
- return parseDouble(_replyData, "gpsTow");
+bool ReplyParser::altitude(double *alt) {
+ return parseDouble(alt, _replyData, "altitude");
}
-double RawLocationParser::utc() {
- return parseDouble(_replyData, "utc");
+bool ReplyParser::horizontalAccuracy(double *acc) {
+ return parseDouble(acc, _replyData, "accuracy");
}
-double RawLocationParser::hdop() {
- return parseDouble(_replyData, "hdop");
+bool ReplyParser::verticalAccuracy(double *acc) {
+ return parseDouble(acc, _replyData, "altitudeAccuracy");
}
-double RawLocationParser::vdop() {
- return parseDouble(_replyData, "vdop");
+bool ReplyParser::heading(double *heading) {
+ return parseDouble(heading, _replyData, "heading");
}
-double RawLocationParser::pdop() {
- return parseDouble(_replyData, "pdop");
+bool ReplyParser::speed(double *speed) {
+ return parseDouble(speed, _replyData, "speed");
}
-bool RawLocationParser::propagated() {
- return parseBool(_replyData, "propagated");
-}
-
-QString RawLocationParser::positionMethod() {
- QString fixType = parseString(_replyData, "fix_type");
- QString provider = parseString(_replyData, "provider");
- return fixType + " [" + provider + "]";
-}
-
-QString RawLocationParser::error() {
- QString err = parseString(_replyData, "err");
- QString errstr = parseString(_replyData, "errstr");
- return err + ": " + errstr;
-}
-
-int RawLocationParser::numberOfSatellites() {
+bool ReplyParser::satellitesSize(int *size) {
QVariantList satellites;
bool sizeFound = parseList(&satellites, _replyData, "satellites");
if (sizeFound == false) {
- return 0;
- }
-
- return satellites.size();
-}
-
-double RawLocationParser::satelliteId(int satIndex) {
- QVariantList satellites;
- if (parseList(&satellites, _replyData, "satellites") == false) {
- return qQNaN();
- }
- QVariant sat = satellites.at(satIndex);
- return parseDouble(sat, "id");
-}
-
-double RawLocationParser::satelliteCarrierToNoiseRatio(int satIndex) {
- QVariantList satellites;
- if (parseList(&satellites, _replyData, "satellites") == false) {
- return qQNaN();
- }
- QVariant sat = satellites.at(satIndex);
- return parseDouble(sat, "cno");
-}
-
-bool RawLocationParser::satelliteEphemerisAvailable(int satIndex) {
- QVariantList satellites;
- if (parseList(&satellites, _replyData, "satellites") == false) {
return false;
}
- QVariant sat = satellites.at(satIndex);
- return parseBool(sat, "ephemeris");
-}
-double RawLocationParser::satelliteAzimuth(int satIndex) {
- QVariantList satellites;
- if (parseList(&satellites, _replyData, "satellites") == false) {
- return qQNaN();
- }
- QVariant sat = satellites.at(satIndex);
- return parseDouble(sat, "azimuth");
+ *size = satellites.size();
+ return true;
}
-double RawLocationParser::satelliteElevation(int satIndex) {
- QVariantList satellites;
- if (parseList(&satellites, _replyData, "satellites") == false) {
- return qQNaN();
- }
- QVariant sat = satellites.at(satIndex);
- return parseDouble(sat, "elevation");
-}
-
-bool RawLocationParser::satelliteTracked(int satIndex) {
- QVariantList satellites;
- if (parseList(&satellites, _replyData, "satellites") == false) {
- return false;
- }
- QVariant sat = satellites.at(satIndex);
- return parseBool(sat, "tracked");
-}
-bool RawLocationParser::satelliteUsed(int satIndex) {
+bool ReplyParser::satelliteId(double *id) {
QVariantList satellites;
if (parseList(&satellites, _replyData, "satellites") == false) {
return false;
}
- QVariant sat = satellites.at(satIndex);
- return parseBool(sat, "used");
+ QVariant sat = satellites.at(_satIndex);
+ return parseDouble(id, sat, "id");
}
-bool RawLocationParser::satelliteAlmanac(int satIndex) {
+bool ReplyParser::satelliteCarrierToNoiseRatio(double *cno) {
QVariantList satellites;
if (parseList(&satellites, _replyData, "satellites") == false) {
return false;
}
- QVariant sat = satellites.at(satIndex);
- return parseBool(sat, "almanac");
+ QVariant sat = satellites.at(_satIndex);
+ return parseDouble(cno, sat, "cno");
}
-double RawLocationParser::parseDouble(const QVariant & replyData, const QString & key) {
+bool ReplyParser::parseDouble(double *out, const QVariant & replyData,
+ const QString & key) {
// replyData is a QVariantMap holding all of the reply parameters
QVariantMap positionData = replyData.toMap();
QVariant val = positionData.value(key);
if (val.isValid() && val.canConvert<double>()) {
- return val.toDouble();
+ *out = val.toDouble();
+ return true;
}
- return qQNaN();
+ return false;
}
-bool RawLocationParser::parseBool(const QVariant & replyData, const QString & key) {
+bool ReplyParser::parseBool(bool *out, const QVariant & replyData,
+ const QString & key) {
// replyData is a QVariantMap holding all of the reply parameters
QVariantMap positionData = replyData.toMap();
QVariant val = positionData.value(key);
if (val.isValid() && val.canConvert<bool>()) {
- return val.toBool();
+ *out = val.toBool();
+ return true;
}
return false;
}
-QString RawLocationParser::parseString(const QVariant & replyData, const QString & key) {
+bool ReplyParser::parseString(QString *out, const QVariant & replyData,
+ const QString & key) {
// replyData is a QVariantMap holding all of the reply parameters
QVariantMap positionData = replyData.toMap();
QVariant val = positionData.value(key);
if (val.isValid() && val.canConvert<QString>()) {
- return val.toString();
+ *out = val.toString();
+ return true;
}
- return "";
+ return false;
}
-bool RawLocationParser::parseList(QVariantList *out, const QVariant & replyData, const QString & key) {
+bool ReplyParser::parseList(QVariantList *out, const QVariant & replyData,
+ const QString & key) {
// replyData is a QVariantMap holding all of the reply parameters
QVariantMap positionData = replyData.toMap();
@@ -215,3 +126,5 @@ bool RawLocationParser::parseList(QVariantList *out, const QVariant & replyData,
return false;
}
+
+
Oops, something went wrong.

0 comments on commit 1a8bd27

Please sign in to comment.