void GeoDialog::loadCityList() { mCityCombo->clear(); mGeoDataMap.clear(); QFile file( KStandardDirs::locate( "data", "kaddressbook/zone.tab" ) ); if ( file.open( QIODevice::ReadOnly ) ) { QTextStream s( &file ); QString line, country; QRegExp coord( "[+-]\\d+[+-]\\d+" ); QRegExp name( "[^\\s]+/[^\\s]+" ); int pos; while ( !s.atEnd() ) { line = s.readLine().trimmed(); if ( line.isEmpty() || line[ 0 ] == '#' ) continue; country = line.left( 2 ); QString c, n; pos = coord.indexIn( line, 0 ); if ( pos >= 0 ) c = line.mid( pos, coord.matchedLength() ); pos = name.indexIn(line, pos); if ( pos > 0 ) { n = line.mid( pos, name.matchedLength() ).trimmed(); n.replace( '_', " " ); } if ( !c.isEmpty() && !n.isEmpty() ) { pos = c.indexOf( "+", 1 ); if ( pos < 0 ) pos = c.indexOf( "-", 1 ); if ( pos > 0 ) { GeoData data; data.latitude = calculateCoordinate( c.left( pos ) ); data.longitude = calculateCoordinate( c.mid( pos ) ); data.country = country; mGeoDataMap.insert( n, data ); } } } QStringList items( mGeoDataMap.keys() ); items.prepend( i18nc( "@item:inlistbox Undefined location", "Undefined" ) ); mCityCombo->addItems( items ); file.close(); } }
AU_UAV_ROS::GoToWaypoint updatePath(const AU_UAV_ROS::TelemetryUpdate::ConstPtr &msg, AU_UAV_ROS::mathVector forceVector){ AU_UAV_ROS::GoToWaypoint goToWaypointSrv; /* destination to go to */ double forceTheta = forceVector.getDirection(); /* angle of the force vector with respect to North bearing */ double d = MPS_SPEED/EARTH_RADIUS; /* angular distance traveled in one second */ AU_UAV_ROS::waypoint currentPosition, newPosition; currentPosition.latitude = msg->currentLatitude; currentPosition.longitude = msg->currentLongitude; currentPosition.altitude = msg->currentAltitude; newPosition = calculateCoordinate(currentPosition, forceTheta, d); /* find new position one second away based on direction of force */ /* set up new goToWaypoint service */ goToWaypointSrv.request.planeID = msg->planeID; goToWaypointSrv.request.latitude = newPosition.latitude; goToWaypointSrv.request.longitude = newPosition.longitude; goToWaypointSrv.request.altitude = newPosition.altitude; return goToWaypointSrv; }