Exemple #1
0
    double PureProjection::courseBetweenLatLng(PointLatLng const& p1,PointLatLng const& p2)
    {

        double lon1_R = p1.Lng() * DEG2RAD;
        double lat1_R = p1.Lat() * DEG2RAD;
        double lon2_R = p2.Lng() * DEG2RAD;
        double lat2_R = p2.Lat() * DEG2RAD;

        return TWO_PI - myfmod(atan2(sin(lon1_R - lon2_R) * cos(lat2_R),
                       cos(lat1_R) * sin(lat2_R) - sin(lat1_R) * cos(lat2_R) * cos(lon1_R - lon2_R)), TWO_PI);
    }
 double PureProjection::DistanceBetweenLatLng(PointLatLng const& p1,PointLatLng const& p2)
 {
      double R = 6371; // km
      double lat1=p1.Lat();
      double lat2=p2.Lat();
      double lon1=p1.Lng();
      double lon2=p2.Lng();
      double dLat = (lat2-lat1)* (PI / 180);
      double dLon = (lon2-lon1)* (PI / 180);
      double a = sin(dLat/2) * sin(dLat/2) + cos(lat1* (PI / 180)) * cos(lat2* (PI / 180)) * sin(dLon/2) * sin(dLon/2);
      double c = 2 * atan2(sqrt(a), sqrt(1-a));
      double d = R * c;
      return d;
 }
Exemple #3
0
 /**
  * @brief PureProjection::DistanceBetweenLatLng Returns 2D distance between two geodetic points
  * @param p1 Latitude-longitude in WGS84 coordinates, first point
  * @param p2 Latitude-longitude in WGS84 coordinates, second point
  * @return Distance in [m]
  */
 double PureProjection::DistanceBetweenLatLng(PointLatLng const& p1,PointLatLng const& p2)
 {
      double R = WGS84_RADIUS_EARTH_KM;
      double lat1_R = p1.Lat() * DEG2RAD;
      double lat2_R = p2.Lat() * DEG2RAD;
      double lon1_R = p1.Lng() * DEG2RAD;
      double lon2_R = p2.Lng() * DEG2RAD;
      double dLat_R = (lat2_R-lat1_R);
      double dLon_R = (lon2_R-lon1_R);
      double a = sin(dLat_R/2) * sin(dLat_R/2) + cos(lat1_R) * cos(lat2_R) * sin(dLon_R/2) * sin(dLon_R/2);
      double c = 2 * atan2(sqrt(a), sqrt(1-a));
      double d = R * c;
      return d;
 }
Exemple #4
0
    PointLatLng PureProjection::translate(PointLatLng  p1,double distance,double bearing)
    {
        PointLatLng ret;
        double d=distance;
        double tc=bearing;
        double lat1_R = p1.Lat() * DEG2RAD;
        double lon1_R = p1.Lng() * DEG2RAD;
        double R=6378137;
        double lat2_R = asin(sin(lat1_R) * cos(d/R) + cos(lat1_R) * sin(d/R) * cos(tc) );
        double lon2_R = lon1_R + atan2(sin(tc) * sin(d/R) * cos(lat1_R),
                             cos(d/R) - sin(lat1_R) * sin(lat2_R));

        ret.SetLat(lat2_R * RAD2DEG);
        ret.SetLng(lon2_R * RAD2DEG);
        return ret;
    }
bool operator==(PointLatLng const& lhs,PointLatLng const& rhs)
{
   return ((lhs.Lng() == rhs.Lng()) && (lhs.Lat() == rhs.Lat()));
}
Point PureProjection::FromLatLngToPixel(const PointLatLng &p,const int &zoom)
      {
         return FromLatLngToPixel(p.Lat(), p.Lng(), zoom);
      }
Exemple #7
0
SizeLatLng::SizeLatLng(PointLatLng const&  pt)
{
  this->heightLat = pt.Lat();
  this->widthLng = pt.Lng();
}