Distance ReachableList::getDistance( const QPoint& position ) { // qDebug("name: %s: %d", (const char *)name, arrivalAltMap[name] ); if ( distanceMap.contains( coordinateString ( position ) ) ) { return( distanceMap[ coordinateString ( position ) ] ); } return Distance(); //return an invalid distance }
Altitude ReachableList::getArrivalAltitude( const QPoint& position ) { // qDebug("name: %s: %d", (const char *)name, arrivalAltMap[name] ); if ( arrivalAltMap.contains( coordinateString ( position ) ) ) { return (Altitude( arrivalAltMap[ coordinateString ( position ) ]) - safetyAlt) ; } return Altitude(); //return an invalid altitude }
int ReachableList::getArrivalAlt( const QPoint& position ) { // qDebug("name: %s: %d", (const char *)name, arrivalAltMap[name] ); if ( arrivalAltMap.contains( coordinateString ( position ) ) ) { return( arrivalAltMap[ coordinateString ( position ) ] - safetyAlt ); } return( -9999 ); }
ReachablePoint::reachable ReachableList::getReachable( const QPoint& position ) { // qDebug("name: %s: %d", (const char *)name, arrivalAltMap[name] ); if ( arrivalAltMap.contains( coordinateString ( position ) ) ) { if ( arrivalAltMap[ coordinateString ( position ) ] > safetyAlt ) return ReachablePoint::yes; else if ( arrivalAltMap[ coordinateString ( position ) ] > 0 ) return ReachablePoint::belowSafety; else return ReachablePoint::no; } return ReachablePoint::no; }
//------------------------------------------------------------------------------------------------------------------------------------------------------------------- string ChessGame::formatCoordString(char xCoordSource, char yCoordSource, char xCoordDest, char yCoordDest) { int index = 1; //'( a , 1 ) -> ( a , 2 )' char coordinateCharArray[18]; coordinateCharArray[0] = 0x28; if(xCoordSource != '\0') { coordinateCharArray[index] = xCoordSource; index ++; coordinateCharArray[index] = ' '; index++; coordinateCharArray[index] = ','; index ++; coordinateCharArray[index] = ' '; index++; coordinateCharArray[index] = yCoordSource+ 0x30; index++; coordinateCharArray[index] = ')'; } //( a , b ) index++; coordinateCharArray[index] = ' '; index++; coordinateCharArray[index] = '-'; index++; coordinateCharArray[index] = '>'; index++; coordinateCharArray[index] = ' '; index++; coordinateCharArray[index] = '('; index++; //( a , b ) - > ( if(xCoordDest != '\0') { coordinateCharArray[index] = xCoordDest; index ++; coordinateCharArray[index] = ','; index ++; coordinateCharArray[index] = ' '; index++; coordinateCharArray[index] = yCoordDest+ 0x30; index++; coordinateCharArray[index] = ')'; } index++; coordinateCharArray[index] = '\0'; string coordinateString(coordinateCharArray); return coordinateString; }
/** * Calculate course, distance and reachability from the current position * to the elements contained in the limited list. If a glider is defined * the glide path is taken into account and the arrival altitude is * calculated too. */ void ReachableList::calculateDataInList() { // QTime t; // t.start(); int counter = 0; setInitValues(); arrivalAltMap.clear(); distanceMap.clear(); for (int i = 0; i < count(); i++) { // recalculate Distance ReachablePoint& p = (*this)[i]; WGSPoint pt = p.getWaypoint()->wgsPoint; Altitude arrivalAlt; Distance distance; Speed bestSpeed; distance.setKilometers( MapCalc::dist(&lastPosition, &pt) ); if ( lastPosition == pt || distance.getMeters() <= 100.0 ) { // @AP: there is nearly no difference between the two points, // therefore we have no distance and no bearing distance.setMeters(0.0); p.setDistance( distance ); p.setBearing( 0 ); p.setArrivalAlt( calculator->getAltitudeCollection().gpsAltitude ); } else { p.setDistance( distance ); // recalculate Bearing p.setBearing( short (rint(MapCalc::getBearingWgs(lastPosition, pt) * 180/M_PI)) ); // Calculate glide path. Returns false, if no glider is known. calculator->glidePath( p.getBearing(), p.getDistance(), Altitude(p.getElevation()), arrivalAlt, bestSpeed ); // Save arrival altitude. Is set to invalid, if no glider is defined in calculator. p.setArrivalAlt( arrivalAlt ); } if ( arrivalAlt.isValid() ) { // add only valid altitudes to the map arrivalAltMap[ coordinateString ( pt ) ] = (int) arrivalAlt.getMeters() + safetyAlt; } distanceMap[ coordinateString ( pt ) ] = distance; if ( arrivalAlt.getMeters() > 0 ) { counter++; } } // sorting of items depends on the glider selection if ( calculator->glider() ) { modeAltitude = true; // glider is known, sort by arrival altitudes } else { modeAltitude = false; // glider is unknown, sort by distances } qSort( begin(), end() ); // qDebug("Number of reachable sites (arriv >0): %d", counter ); // qDebug("Time for glide path calculation: %d msec", t.restart() ); emit newReachList(); }