#include <math.h>
#include <algorithm>
+#include <iostream>
#include <simgear/compiler.h>
#include "awynet.hxx"
-SG_USING_STD(sort);
+using std::sort;
+
+using std::cerr;
+using std::endl;
/**************************************************************************
* FGNode
{
}
+FGNode::FGNode(double lt, double ln, int idx, std::string id) :
+ ident(id),
+ geod(SGGeod::fromDeg(ln, lt)),
+ index(idx)
+{
+}
+
bool FGNode::matches(string id, double lt, double ln)
{
if ((ident == id) &&
- (fabs(lt - lat) < 1.0) &&
- (fabs(ln - lon) < 1.0))
+ (fabs(lt - geod.getLatitudeDeg()) < 1.0) &&
+ (fabs(ln - geod.getLongitudeDeg()) < 1.0))
return true;
else
return false;
// doing this.
void FGAirway::setTrackDistance()
{
- double course;
- SGWayPoint first (start->getLongitude(),
- start->getLatitude(),
- 0);
- SGWayPoint second (end->getLongitude(),
- end->getLatitude(),
- 0);
- first.CourseAndDistance(second, &course, &length);
-
+ length = SGGeodesy::distanceM(start->getPosition(), end->getPosition());
}
/***************************************************************************
in >> skipeol;
// read in each remaining line of the file
-
-#ifdef __MWERKS__
- char c = 0;
- while ( in.get(c) && c != '\0' ) {
- in.putback(c);
-#else
while ( ! in.eof() ) {
-#endif
string token;
in >> token;
// Read each line from the database
identStart = token;
in >> latStart >> lonStart >> identEnd >> latEnd >> lonEnd >> type >> base >> top >> name;
+ in >> skipeol;
/*out << identStart << " "
<< latStart << " "
<< lonStart << " "
double minDist = HUGE_VAL;
double distsqrt, lat2, lon2;
int index;
- SGWayPoint first (lon,
- lat,
- 0);
//cerr << "Lat " << lat << " lon " << lon << endl;
for (FGNodeVectorIterator
itr = nodes.begin();
itr != nodes.end(); itr++)
{
- //double course;
- //if ((fabs(lat - ((*itr)->getLatitude())) < 0.001) &&
- // (fabs(lon - ((*itr)->getLongitude()) < 0.001)))
- //cerr << "Warning: nodes are near" << endl;
- //SGWayPoint second ((*itr)->getLongitude(),
- // (*itr)->getLatitude(),
- // 0);
- //first.CourseAndDistance(second, &course, &dist);
lat2 = (*itr)->getLatitude();
lon2 = (*itr)->getLongitude();
// Note: This equation should adjust for decreasing distance per longitude