示例#1
0
static int GeodSolve33() {
  /* Check max(-0.0,+0.0) issues 2015-08-22 (triggered by bugs in Octave --
   * sind(-0.0) = +0.0 -- and in some version of Visual Studio --
   * fmod(-0.0, 360.0) = +0.0. */
  double azi1, azi2, s12;
  struct geod_geodesic g;
  int result = 0;
  geod_init(&g, wgs84_a, wgs84_f);
  geod_inverse(&g, 0, 0, 0, 179, &s12, &azi1, &azi2);
  result += checkEquals(azi1, 90.00000, 0.5e-5);
  result += checkEquals(azi2, 90.00000, 0.5e-5);
  result += checkEquals(s12, 19926189, 0.5);
  geod_inverse(&g, 0, 0, 0, 179.5, &s12, &azi1, &azi2);
  result += checkEquals(azi1, 55.96650, 0.5e-5);
  result += checkEquals(azi2, 124.03350, 0.5e-5);
  result += checkEquals(s12, 19980862, 0.5);
  geod_inverse(&g, 0, 0, 0, 180, &s12, &azi1, &azi2);
  result += checkEquals(azi1, 0.00000, 0.5e-5);
  result += checkEquals(fabs(azi2), 180.00000, 0.5e-5);
  result += checkEquals(s12, 20003931, 0.5);
  geod_inverse(&g, 0, 0, 1, 180, &s12, &azi1, &azi2);
  result += checkEquals(azi1, 0.00000, 0.5e-5);
  result += checkEquals(fabs(azi2), 180.00000, 0.5e-5);
  result += checkEquals(s12, 19893357, 0.5);
  geod_init(&g, 6.4e6, 0);
  geod_inverse(&g, 0, 0, 0, 179, &s12, &azi1, &azi2);
  result += checkEquals(azi1, 90.00000, 0.5e-5);
  result += checkEquals(azi2, 90.00000, 0.5e-5);
  result += checkEquals(s12, 19994492, 0.5);
  geod_inverse(&g, 0, 0, 0, 180, &s12, &azi1, &azi2);
  result += checkEquals(azi1, 0.00000, 0.5e-5);
  result += checkEquals(fabs(azi2), 180.00000, 0.5e-5);
  result += checkEquals(s12, 20106193, 0.5);
  geod_inverse(&g, 0, 0, 1, 180, &s12, &azi1, &azi2);
  result += checkEquals(azi1, 0.00000, 0.5e-5);
  result += checkEquals(fabs(azi2), 180.00000, 0.5e-5);
  result += checkEquals(s12, 19994492, 0.5);
  geod_init(&g, 6.4e6, -1/300.0);
  geod_inverse(&g, 0, 0, 0, 179, &s12, &azi1, &azi2);
  result += checkEquals(azi1, 90.00000, 0.5e-5);
  result += checkEquals(azi2, 90.00000, 0.5e-5);
  result += checkEquals(s12, 19994492, 0.5);
  geod_inverse(&g, 0, 0, 0, 180, &s12, &azi1, &azi2);
  result += checkEquals(azi1, 90.00000, 0.5e-5);
  result += checkEquals(azi2, 90.00000, 0.5e-5);
  result += checkEquals(s12, 20106193, 0.5);
  geod_inverse(&g, 0, 0, 0.5, 180, &s12, &azi1, &azi2);
  result += checkEquals(azi1, 33.02493, 0.5e-5);
  result += checkEquals(azi2, 146.97364, 0.5e-5);
  result += checkEquals(s12, 20082617, 0.5);
  geod_inverse(&g, 0, 0, 1, 180, &s12, &azi1, &azi2);
  result += checkEquals(azi1, 0.00000, 0.5e-5);
  result += checkEquals(fabs(azi2), 180.00000, 0.5e-5);
  result += checkEquals(s12, 20027270, 0.5);

  return result;
}
示例#2
0
static int testarcdirect() {
  double lat1, lon1, azi1, lat2, lon2, azi2, s12, a12, m12, M12, M21, S12;
  double lat2a, lon2a, azi2a, s12a, m12a, M12a, M21a, S12a;
  struct geod_geodesic g;
  int i, result = 0;
  unsigned flags = GEOD_ARCMODE | GEOD_LONG_UNROLL;
  geod_init(&g, wgs84_a, wgs84_f);
  for (i = 0; i < ncases; ++i) {
    lat1 = testcases[i][0]; lon1 = testcases[i][1]; azi1 = testcases[i][2];
    lat2 = testcases[i][3]; lon2 = testcases[i][4]; azi2 = testcases[i][5];
    s12 = testcases[i][6]; a12 = testcases[i][7]; m12 = testcases[i][8];
    M12 = testcases[i][9]; M21 = testcases[i][10]; S12 = testcases[i][11];
    geod_gendirect(&g, lat1, lon1, azi1, flags, a12,
                   &lat2a, &lon2a, &azi2a, &s12a, &m12a, &M12a, &M21a, &S12a);
    result += checkEquals(lat2, lat2a, 1e-13);
    result += checkEquals(lon2, lon2a, 1e-13);
    result += checkEquals(azi2, azi2a, 1e-13);
    result += checkEquals(s12, s12a, 1e-8);
    result += checkEquals(m12, m12a, 1e-8);
    result += checkEquals(M12, M12a, 1e-15);
    result += checkEquals(M21, M21a, 1e-15);
    result += checkEquals(S12, S12a, 0.1);
  }
  return result;
}
示例#3
0
static int EmptyPoly() {
  struct geod_geodesic g;
  struct geod_polygon p;
  double perim, area;
  int result = 0;
  geod_init(&g, wgs84_a, wgs84_f);
  geod_polygon_init(&p, 0);
  geod_polygon_testpoint(&g, &p, 1, 1, 0, 1, &area, &perim);
  result += area == 0 ? 0 : 1;
  result += perim == 0 ? 0 : 1;
  geod_polygon_testedge(&g, &p, 90, 1000, 0, 1, &area, &perim);
  result += checkNaN(area);
  result += checkNaN(perim);
  geod_polygon_compute(&g, &p, 0, 1, &area, &perim);
  result += area == 0 ? 0 : 1;
  result += perim == 0 ? 0 : 1;
  geod_polygon_init(&p, 1);
  geod_polygon_testpoint(&g, &p, 1, 1, 0, 1, nullptr, &perim);
  result += perim == 0 ? 0 : 1;
  geod_polygon_testedge(&g, &p, 90, 1000, 0, 1, nullptr, &perim);
  result += checkNaN(perim);
  geod_polygon_compute(&g, &p, 0, 1, nullptr, &perim);
  result += perim == 0 ? 0 : 1;
  geod_polygon_addpoint(&g, &p, 1, 1);
  geod_polygon_testedge(&g, &p, 90, 1000, 0, 1, nullptr, &perim);
  result += checkEquals(perim, 1000, 1e-10);
  geod_polygon_testpoint(&g, &p, 2, 2, 0, 1, nullptr, &perim);
  result += checkEquals(perim, 156876.149, 0.5e-3);
  return result;
}
示例#4
0
SEXP polygonarea(SEXP longitude, SEXP latitude, SEXP pa, SEXP pf) {

  PROTECT(latitude = coerceVector(latitude, REALSXP));
  PROTECT(longitude = coerceVector(longitude, REALSXP));
  double *lat, *lon, *xr;
  lat = REAL(latitude);
  lon = REAL(longitude);

  double a = REAL(pa)[0];
  double f = REAL(pf)[0];
  
  double A, P;
  int  i;
  struct geod_geodesic g;
  struct geod_polygon p;
  
  geod_init(&g, a, f);
  geod_polygon_init(&p, 0);

  for (i=0; i<length(latitude); i++) {
    geod_polygon_addpoint(&g, &p, lat[i], lon[i]);
  }
  
  geod_polygon_compute(&g, &p, 0, 1, &A, &P);
  
  SEXP r;
  PROTECT( r = allocVector(REALSXP, 1) );
  xr = REAL(r);
  xr[0] = A;

  UNPROTECT(3);
  return(r);  
}
示例#5
0
static int Planimeter0() {
  /* Check fix for pole-encircling bug found 2011-03-16 */
  double pa[4][2] = {{89, 0}, {89, 90}, {89, 180}, {89, 270}};
  double pb[4][2] = {{-89, 0}, {-89, 90}, {-89, 180}, {-89, 270}};
  double pc[4][2] = {{0, -1}, {-1, 0}, {0, 1}, {1, 0}};
  double pd[3][2] = {{90, 0}, {0, 0}, {0, 90}};
  struct geod_geodesic g;
  double perimeter, area;
  int result = 0;
  geod_init(&g, wgs84_a, wgs84_f);

  planimeter(&g, pa, 4, &perimeter, &area);
  result += checkEquals(perimeter, 631819.8745, 1e-4);
  result += checkEquals(area, 24952305678.0, 1);

  planimeter(&g, pb, 4, &perimeter, &area);
  result += checkEquals(perimeter, 631819.8745, 1e-4);
  result += checkEquals(area, -24952305678.0, 1);

  planimeter(&g, pc, 4, &perimeter, &area);
  result += checkEquals(perimeter, 627598.2731, 1e-4);
  result += checkEquals(area, 24619419146.0, 1);

  planimeter(&g, pd, 3, &perimeter, &area);
  result += checkEquals(perimeter, 30022685, 1);
  result += checkEquals(area, 63758202715511.0, 1);

  polylength(&g, pd, 3, &perimeter);
  result += checkEquals(perimeter, 20020719, 1);

  return result;
}
示例#6
0
SEXP inversegeodesic(SEXP longitude1, SEXP latitude1, SEXP longitude2, SEXP latitude2, SEXP pa, SEXP pf) {

  PROTECT(latitude1 = coerceVector(latitude1, REALSXP));
  PROTECT(longitude1 = coerceVector(longitude1, REALSXP));
  PROTECT(latitude2 = coerceVector(latitude2, REALSXP));
  PROTECT(longitude2 = coerceVector(longitude2, REALSXP));
  double a = REAL(pa)[0];
  double f = REAL(pf)[0];

  double *lat1, *lon1, *lat2, *lon2, *xr;
  lat1 = REAL(latitude1);
  lon1 = REAL(longitude1);
  lat2 = REAL(latitude2);
  lon2 = REAL(longitude2);

  SEXP r;
  PROTECT( r = allocVector(REALSXP, length(latitude1) ));
  xr = REAL(r);  
   
  double azi1, azi2, s12;
  struct geod_geodesic g;

  geod_init(&g, a, f);
  
  for (int i=0; i < length(latitude1); i++) {
    geod_inverse(&g, lat1[i], lon1[i], lat2[i], lon2[i], &s12, &azi1, &azi2);
    xr[i] = s12;
  }
  
  UNPROTECT(5);
  return r;
}
示例#7
0
static int Planimeter6() {
  /* Check fix for Planimeter lon12 rounding bug found 2012-12-03 */
  double pa[3][2] = {{9, -0.00000000000001}, {9, 180}, {9, 0}};
  double pb[3][2] = {{9, 0.00000000000001}, {9, 0}, {9, 180}};
  double pc[3][2] = {{9, 0.00000000000001}, {9, 180}, {9, 0}};
  double pd[3][2] = {{9, -0.00000000000001}, {9, 0}, {9, 180}};
  struct geod_geodesic g;
  double perimeter, area;
  int result = 0;
  geod_init(&g, wgs84_a, wgs84_f);

  planimeter(&g, pa, 3, &perimeter, &area);
  result += checkEquals(perimeter, 36026861, 1);
  result += checkEquals(area, 0, 1);
  planimeter(&g, pb, 3, &perimeter, &area);
  result += checkEquals(perimeter, 36026861, 1);
  result += checkEquals(area, 0, 1);
  planimeter(&g, pc, 3, &perimeter, &area);
  result += checkEquals(perimeter, 36026861, 1);
  result += checkEquals(area, 0, 1);
  planimeter(&g, pd, 3, &perimeter, &area);
  result += checkEquals(perimeter, 36026861, 1);
  result += checkEquals(area, 0, 1);
  return result;
}
示例#8
0
static int GeodSolve65() {
  /* Check for bug in east-going check in GeodesicLine (needed to check for
   * sign of 0) and sign error in area calculation due to a bogus override of
   * the code for alp12.  Found/fixed on 2015-12-19. */
  double lat2, lon2, azi2, s12, a12, m12, M12, M21, S12;
  struct geod_geodesic g;
  struct geod_geodesicline l;
  int result = 0;
  unsigned flags = GEOD_LONG_UNROLL, caps = GEOD_ALL;
  geod_init(&g, wgs84_a, wgs84_f);
  geod_inverseline(&l, &g, 30, -0.000000000000000001, -31, 180, caps);
  a12 = geod_genposition(&l, flags, 1e7,
                         &lat2, &lon2, &azi2, &s12, &m12, &M12, &M21, &S12);
  result += checkEquals(lat2, -60.23169, 0.5e-5);
  result += checkEquals(lon2, -0.00000, 0.5e-5);
  result += checkEquals(fabs(azi2), 180.00000, 0.5e-5);
  result += checkEquals(s12, 10000000, 0.5);
  result += checkEquals(a12, 90.06544, 0.5e-5);
  result += checkEquals(m12, 6363636, 0.5);
  result += checkEquals(M12, -0.0012834, 0.5e-7);
  result += checkEquals(M21, 0.0013749, 0.5e-7);
  result += checkEquals(S12, 0, 0.5);
  a12 = geod_genposition(&l, flags, 2e7,
                         &lat2, &lon2, &azi2, &s12, &m12, &M12, &M21, &S12);
  result += checkEquals(lat2, -30.03547, 0.5e-5);
  result += checkEquals(lon2, -180.00000, 0.5e-5);
  result += checkEquals(azi2, -0.00000, 0.5e-5);
  result += checkEquals(s12, 20000000, 0.5);
  result += checkEquals(a12, 179.96459, 0.5e-5);
  result += checkEquals(m12, 54342, 0.5);
  result += checkEquals(M12, -1.0045592, 0.5e-7);
  result += checkEquals(M21, -0.9954339, 0.5e-7);
  result += checkEquals(S12, 127516405431022.0, 0.5);
  return result;
}
示例#9
0
static int GeodSolve17() {
  /* Check fix for LONG_UNROLL bug found on 2015-05-07 */
  double lat2, lon2, azi2;
  struct geod_geodesic g;
  struct geod_geodesicline l;
  int result = 0;
  unsigned flags = GEOD_LONG_UNROLL;
  geod_init(&g, wgs84_a, wgs84_f);
  geod_gendirect(&g, 40, -75, -10, flags, 2e7,
                 &lat2, &lon2, &azi2, nullptr, nullptr, nullptr, nullptr, nullptr);
  result += checkEquals(lat2, -39, 1);
  result += checkEquals(lon2, -254, 1);
  result += checkEquals(azi2, -170, 1);
  geod_lineinit(&l, &g, 40, -75, -10, 0);
  geod_genposition(&l, flags, 2e7, &lat2, &lon2, &azi2, nullptr, nullptr, nullptr, nullptr, nullptr);
  result += checkEquals(lat2, -39, 1);
  result += checkEquals(lon2, -254, 1);
  result += checkEquals(azi2, -170, 1);
  geod_direct(&g, 40, -75, -10, 2e7, &lat2, &lon2, &azi2);
  result += checkEquals(lat2, -39, 1);
  result += checkEquals(lon2, 105, 1);
  result += checkEquals(azi2, -170, 1);
  geod_position(&l, 2e7, &lat2, &lon2, &azi2);
  result += checkEquals(lat2, -39, 1);
  result += checkEquals(lon2, 105, 1);
  result += checkEquals(azi2, -170, 1);
  return result;
}
示例#10
0
static int Planimeter19() {
  /* Coverage tests, includes Planimeter19 - Planimeter20 (degenerate
     polygons) + extra cases.  */
  struct geod_geodesic g;
  struct geod_polygon p;
  double area, perim;
  int result = 0;
  geod_init(&g, wgs84_a, wgs84_f);
  geod_polygon_init(&p, 0);
  geod_polygon_compute(&g, &p, 0, 1, &area, &perim);
  result += area == 0 ? 0 : 1;
  result += perim == 0 ? 0 : 1;
  geod_polygon_testpoint(&g, &p, 1, 1, 0, 1, &area, &perim);
  result += area == 0 ? 0 : 1;
  result += perim == 0 ? 0 : 1;
  geod_polygon_testedge(&g, &p, 90, 1000, 0, 1, &area, &perim);
  result += checkNaN(area);
  result += checkNaN(perim);
  geod_polygon_addpoint(&g, &p, 1, 1);
  geod_polygon_compute(&g, &p, 0, 1, &area, &perim);
  result += area == 0 ? 0 : 1;
  result += perim == 0 ? 0 : 1;
  geod_polygon_init(&p, 1);
  geod_polygon_compute(&g, &p, 0, 1, nullptr, &perim);
  result += perim == 0 ? 0 : 1;
  geod_polygon_testpoint(&g, &p, 1, 1, 0, 1, nullptr, &perim);
  result += perim == 0 ? 0 : 1;
  geod_polygon_testedge(&g, &p, 90, 1000, 0, 1, nullptr, &perim);
  result += checkNaN(perim);
  geod_polygon_addpoint(&g, &p, 1, 1);
  geod_polygon_compute(&g, &p, 0, 1, nullptr, &perim);
  result += perim == 0 ? 0 : 1;
  return result;
}
示例#11
0
static int GeodSolve26() {
  /* Check 0/0 problem with area calculation on sphere 2015-09-08 */
  double S12;
  struct geod_geodesic g;
  int result = 0;
  geod_init(&g, 6.4e6, 0);
  geod_geninverse(&g, 1, 2, 3, 4, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, &S12);
  result += checkEquals(S12, 49911046115.0, 0.5);
  return result;
}
示例#12
0
static int GeodSolve4() {
  /* Check fix for short line bug found 2010-05-21 */
  double s12;
  struct geod_geodesic g;
  int result = 0;
  geod_init(&g, wgs84_a, wgs84_f);
  geod_inverse(&g, 36.493349428792, 0, 36.49334942879201, .0000008,
               &s12, nullptr, nullptr);
  result += checkEquals(s12, 0.072, 0.5e-3);
  return result;
}
示例#13
0
static int GeodSolve0() {
  double azi1, azi2, s12;
  struct geod_geodesic g;
  int result = 0;
  geod_init(&g, wgs84_a, wgs84_f);
  geod_inverse(&g, 40.6, -73.8, 49.01666667, 2.55, &s12, &azi1, &azi2);
  result += checkEquals(azi1, 53.47022, 0.5e-5);
  result += checkEquals(azi2, 111.59367, 0.5e-5);
  result += checkEquals(s12, 5853226, 0.5);
  return result;
}
示例#14
0
static int GeodSolve28() {
  /* Check for bad placement of assignment of r.a12 with |f| > 0.01 (bug in
   * Java implementation fixed on 2015-05-19). */
  double a12;
  struct geod_geodesic g;
  int result = 0;
  geod_init(&g, 6.4e6, 0.1);
  a12 = geod_gendirect(&g, 1, 2, 10, 0, 5e6, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr);
  result += checkEquals(a12, 48.55570690, 0.5e-8);
  return result;
}
示例#15
0
static int GeodSolve9() {
  /* Check fix for volatile x bug found 2011-06-25 (gcc 4.4.4 x86 -O3) */
  double s12;
  struct geod_geodesic g;
  int result = 0;
  geod_init(&g, wgs84_a, wgs84_f);
  geod_inverse(&g, 56.320923501171, 0,
               -56.320923501171, 179.664747671772880215, &s12, nullptr, nullptr);
  result += checkEquals(s12, 19993558.287, 0.5e-3);
  return result;
}
示例#16
0
static int GeodSolve15() {
  /* Initial implementation of Math::eatanhe was wrong for e^2 < 0.  This
   * checks that this is fixed. */
  double S12;
  struct geod_geodesic g;
  int result = 0;
  geod_init(&g, 6.4e6, -1/150.0);
  geod_gendirect(&g, 1, 2, 3, 0, 4,
                 nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, &S12);
  result += checkEquals(S12, 23700, 0.5);
  return result;
}
示例#17
0
static int GeodSolve11() {
  /* Check fix for bet2 = -bet1 bug found 2011-06-25 (Visual Studio
   * 10 rel + debug) */
  double s12;
  struct geod_geodesic g;
  int result = 0;
  geod_init(&g, wgs84_a, wgs84_f);
  geod_inverse(&g, 48.522876735459, 0,
               -48.52287673545898293, 179.599720456223079643, &s12, nullptr, nullptr);
  result += checkEquals(s12, 19989144.774, 0.5e-3);
  return result;
}
示例#18
0
static int GeodSolve10() {
  /* Check fix for adjust tol1_ bug found 2011-06-25 (Visual Studio
   * 10 rel + debug) */
  double s12;
  struct geod_geodesic g;
  int result = 0;
  geod_init(&g, wgs84_a, wgs84_f);
  geod_inverse(&g, 52.784459512564, 0,
               -52.784459512563990912, 179.634407464943777557, &s12, nullptr, nullptr);
  result += checkEquals(s12, 19991596.095, 0.5e-3);
  return result;
}
示例#19
0
static int GeodSolve78() {
  /* An example where the NGS calculator fails to converge */
  double azi1, azi2, s12;
  struct geod_geodesic g;
  int result = 0;
  geod_init(&g, wgs84_a, wgs84_f);
  geod_inverse(&g, 27.2, 0.0, -27.1, 179.5, &s12, &azi1, &azi2);
  result += checkEquals(azi1,  45.82468716758, 0.5e-11);
  result += checkEquals(azi2, 134.22776532670, 0.5e-11);
  result += checkEquals(s12,  19974354.765767, 0.5e-6);
  return result;
}
示例#20
0
static int GeodSolve59() {
  /* Check for points close with longitudes close to 180 deg apart. */
  double azi1, azi2, s12;
  struct geod_geodesic g;
  int result = 0;
  geod_init(&g, wgs84_a, wgs84_f);
  geod_inverse(&g, 5, 0.00000000000001, 10, 180, &s12, &azi1, &azi2);
  result += checkEquals(azi1, 0.000000000000035, 1.5e-14);
  result += checkEquals(azi2, 179.99999999999996, 1.5e-14);
  result += checkEquals(s12, 18345191.174332713, 5e-9);
  return result;
}
示例#21
0
static int GeodSolve1() {
  double lat2, lon2, azi2;
  struct geod_geodesic g;
  int result = 0;
  geod_init(&g, wgs84_a, wgs84_f);
  geod_direct(&g, 40.63972222, -73.77888889, 53.5, 5850e3,
              &lat2, &lon2, &azi2);
  result += checkEquals(lat2, 49.01467, 0.5e-5);
  result += checkEquals(lon2, 2.56106, 0.5e-5);
  result += checkEquals(azi2, 111.62947, 0.5e-5);
  return result;
}
示例#22
0
static int Planimeter12() {
  /* Area of arctic circle (not really -- adjunct to rhumb-area test) */
  double points[2][2] = {{66.562222222, 0}, {66.562222222, 180}};
  struct geod_geodesic g;
  double perimeter, area;
  int result = 0;
  geod_init(&g, wgs84_a, wgs84_f);
  planimeter(&g, points, 2, &perimeter, &area);
  result += checkEquals(perimeter, 10465729, 1);
  result += checkEquals(area, 0, 1);
  return result;
}
示例#23
0
static int Planimeter21() {
  /* Some test to add code coverage: multiple circlings of pole (includes
     Planimeter21 - Planimeter28) + invocations via testpoint and testedge.
     Some of the results for i = 4 in the loop are wrong because we don't
     reduce the area to the allowed range correctly.  However these cases are
     not "simple" polygons, so we'll defer fixing the problem for now.
   */
  struct geod_geodesic g;
  struct geod_polygon p;
  double area, lat = 45,
    a = 39.2144607176828184218, s = 8420705.40957178156285,
    r = 39433884866571.4277,    /* Area for one circuit */
    a0 = 510065621724088.5093;  /* Ellipsoid area */
  int result = 0, i;
  geod_init(&g, wgs84_a, wgs84_f);
  geod_polygon_init(&p, 0);
  geod_polygon_addpoint(&g, &p, lat,  60);
  geod_polygon_addpoint(&g, &p, lat, 180);
  geod_polygon_addpoint(&g, &p, lat, -60);
  geod_polygon_addpoint(&g, &p, lat,  60);
  geod_polygon_addpoint(&g, &p, lat, 180);
  geod_polygon_addpoint(&g, &p, lat, -60);
  for (i = 3; i <= 4; ++i) {
    geod_polygon_addpoint(&g, &p, lat,  60);
    geod_polygon_addpoint(&g, &p, lat, 180);
    geod_polygon_testpoint(&g, &p, lat, -60, 0, 1, &area, nullptr);
    if (i != 4) result += checkEquals(area,  i*r, 0.5);
    geod_polygon_testpoint(&g, &p, lat, -60, 0, 0, &area, nullptr);
    if (i != 4) result += checkEquals(area,  i*r, 0.5);
    geod_polygon_testpoint(&g, &p, lat, -60, 1, 1, &area, nullptr);
    if (i != 4) result += checkEquals(area, -i*r, 0.5);
    geod_polygon_testpoint(&g, &p, lat, -60, 1, 0, &area, nullptr);
    result += checkEquals(area, -i*r + a0, 0.5);
    geod_polygon_testedge(&g, &p, a, s, 0, 1, &area, nullptr);
    if (i != 4) result += checkEquals(area,  i*r, 0.5);
    geod_polygon_testedge(&g, &p, a, s, 0, 0, &area, nullptr);
    if (i != 4) result += checkEquals(area,  i*r, 0.5);
    geod_polygon_testedge(&g, &p, a, s, 1, 1, &area, nullptr);
    if (i != 4) result += checkEquals(area, -i*r, 0.5);
    geod_polygon_testedge(&g, &p, a, s, 1, 0, &area, nullptr);
    result += checkEquals(area, -i*r + a0, 0.5);
    geod_polygon_addpoint(&g, &p, lat, -60);
    geod_polygon_compute(&g, &p, 0, 1, &area, nullptr);
    if (i != 4) result += checkEquals(area,  i*r, 0.5);
    geod_polygon_compute(&g, &p, 0, 0, &area, nullptr);
    if (i != 4) result += checkEquals(area,  i*r, 0.5);
    geod_polygon_compute(&g, &p, 1, 1, &area, nullptr);
    if (i != 4) result += checkEquals(area, -i*r, 0.5);
    geod_polygon_compute(&g, &p, 1, 0, &area, nullptr);
    result += checkEquals(area, -i*r + a0, 0.5);
  }
  return result;
}
示例#24
0
static int Planimeter5() {
  /* Check fix for Planimeter pole crossing bug found 2011-06-24 */
  double points[3][2] = {{89, 0.1}, {89, 90.1}, {89, -179.9}};
  struct geod_geodesic g;
  double perimeter, area;
  int result = 0;
  geod_init(&g, wgs84_a, wgs84_f);
  planimeter(&g, points, 3, &perimeter, &area);
  result += checkEquals(perimeter, 539297, 1);
  result += checkEquals(area, 12476152838.5, 1);
  return result;
}
示例#25
0
static int Planimeter13() {
  /* Check encircling pole twice */
  double points[6][2] = {{89,-360}, {89,-240}, {89,-120},
                         {89,0}, {89,120}, {89,240}};
  struct geod_geodesic g;
  double perimeter, area;
  int result = 0;
  geod_init(&g, wgs84_a, wgs84_f);
  planimeter(&g, points, 6, &perimeter, &area);
  result += checkEquals(perimeter, 1160741, 1);
  result += checkEquals(area, 32415230256.0, 1);
  return result;
}
示例#26
0
static int GeodSolve71() {
  /* Check that DirectLine sets s13. */
  double lat2, lon2, azi2;
  struct geod_geodesic g;
  struct geod_geodesicline l;
  int result = 0;
  geod_init(&g, wgs84_a, wgs84_f);
  geod_directline(&l, &g, 1, 2, 45, 1e7, 0);
  geod_position(&l, 0.5 * l.s13, &lat2, &lon2, &azi2);
  result += checkEquals(lat2, 30.92625, 0.5e-5);
  result += checkEquals(lon2, 37.54640, 0.5e-5);
  result += checkEquals(azi2, 55.43104, 0.5e-5);
  return result;
}
示例#27
0
static int GeodSolve12() {
  /* Check fix for inverse geodesics on extreme prolate/oblate
   * ellipsoids Reported 2012-08-29 Stefan Guenther
   * <*****@*****.**>; fixed 2012-10-07 */
  double azi1, azi2, s12;
  struct geod_geodesic g;
  int result = 0;
  geod_init(&g, 89.8, -1.83);
  geod_inverse(&g, 0, 0, -10, 160, &s12, &azi1, &azi2);
  result += checkEquals(azi1, 120.27, 1e-2);
  result += checkEquals(azi2, 105.15, 1e-2);
  result += checkEquals(s12, 266.7, 1e-1);
  return result;
}
示例#28
0
static int GeodSolve76() {
  /* The distance from Wellington and Salamanca (a classic failure of
     Vincenty) */
  double azi1, azi2, s12;
  struct geod_geodesic g;
  int result = 0;
  geod_init(&g, wgs84_a, wgs84_f);
  geod_inverse(&g, -(41+19/60.0), 174+49/60.0, 40+58/60.0, -(5+30/60.0),
               &s12, &azi1, &azi2);
  result += checkEquals(azi1, 160.39137649664, 0.5e-11);
  result += checkEquals(azi2,  19.50042925176, 0.5e-11);
  result += checkEquals(s12,  19960543.857179, 0.5e-6);
  return result;
}
示例#29
0
static int AddEdge1() {
  /* Check fix to transitdirect vs transit zero handling inconsistency */
  struct geod_geodesic g;
  struct geod_polygon p;
  double area;
  int result = 0;
  geod_init(&g, wgs84_a, wgs84_f);
  geod_polygon_init(&p, 0);
  geod_polygon_addpoint(&g, &p, 0, 0);
  geod_polygon_addedge(&g, &p,  90, 1000);
  geod_polygon_addedge(&g, &p,   0, 1000);
  geod_polygon_addedge(&g, &p, -90, 1000);
  geod_polygon_compute(&g, &p, 0, 1, &area, nullptr);
  result += checkEquals(area, 1000000.0, 0.01);
  return result;
}
示例#30
0
static int GeodSolve73() {
  /* Check for backwards from the pole bug reported by Anon on 2016-02-13.
   * This only affected the Java implementation.  It was introduced in Java
   * version 1.44 and fixed in 1.46-SNAPSHOT on 2016-01-17. */
  double lat2, lon2, azi2;
  struct geod_geodesic g;
  int result = 0;
  geod_init(&g, wgs84_a, wgs84_f);
  geod_direct(&g, 90, 10, 180, -1e6,
              &lat2, &lon2, &azi2);
  result += checkEquals(lat2, 81.04623, 0.5e-5);
  result += checkEquals(lon2, -170, 0.5e-5);
  result += azi2 == 0 ? 0 : 1;
  result += 1/azi2 > 0 ? 0 : 1; /* Check that azi2 = +0.0 not -0.0 */
  return result;
}