File: test_geo_utils.cpp

package info (click to toggle)
gdal 2.4.2+dfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 106,252 kB
  • sloc: cpp: 1,034,818; ansic: 177,912; python: 23,610; perl: 7,420; sh: 6,283; java: 5,382; xml: 3,100; cs: 2,343; yacc: 1,198; makefile: 519; sql: 112
file content (50 lines) | stat: -rw-r--r-- 1,877 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <cstdio>
#include "ogr_geo_utils.h"

int main( int /* argc */ , char* /* argv */ [])
{
  const double latA = 49;
  const double lonA = 2;
  const double latB = 49.00001;
  const double lonB = 2.00001;

  double heading = OGR_GreatCircle_InitialHeading(latA, lonA, latB, lonB);
  double distance = OGR_GreatCircle_Distance(latA, lonA, latB, lonB);
  double latC = 0.0;
  double lonC = 0.0;
  OGR_GreatCircle_ExtendPosition(latA, lonA, distance, heading, &latC, &lonC);
  printf("heading=%f, distance=%f\n", heading, distance);
  printf("%.15f=%.15f, %.15f=%.15f\n", latB, latC, lonB, lonC);

  heading = OGR_GreatCircle_InitialHeading(latB, lonB, latA, lonA);
  distance = OGR_GreatCircle_Distance(latB, lonB, latA, lonA);
  OGR_GreatCircle_ExtendPosition(latB, lonB, distance, heading, &latC, &lonC);
  printf("heading=%f, distance=%f\n", heading, distance);
  printf("%.15f=%.15f, %.15f=%.15f\n", latA, latC, lonA, lonC);

  OGR_GreatCircle_ExtendPosition(0, 100, 100000, 0, &latC, &lonC);
  printf("lat=%.15f, lon=%.15f\n", latC, lonC);

  OGR_GreatCircle_ExtendPosition(0, 100, 100000, 90, &latC, &lonC);
  printf("lat=%.15f, lon=%.15f\n", latC, lonC);

  OGR_GreatCircle_ExtendPosition(0, 100, 100000, 180, &latC, &lonC);
  printf("lat=%.15f, lon=%.15f\n", latC, lonC);

  OGR_GreatCircle_ExtendPosition(0, 100, 100000, 270, &latC, &lonC);
  printf("lat=%.15f, lon=%.15f\n", latC, lonC);

  OGR_GreatCircle_ExtendPosition(0, 0, 100000, 0, &latC, &lonC);
  printf("lat=%.15f, lon=%.15f\n", latC, lonC);

  OGR_GreatCircle_ExtendPosition(0, 0, 100000, 90, &latC, &lonC);
  printf("lat=%.15f, lon=%.15f\n", latC, lonC);

  OGR_GreatCircle_ExtendPosition(0, 0, 100000, 180, &latC, &lonC);
  printf("lat=%.15f, lon=%.15f\n", latC, lonC);

  OGR_GreatCircle_ExtendPosition(0, 0, 100000, 270, &latC, &lonC);
  printf("lat=%.15f, lon=%.15f\n", latC, lonC);

  return 0;
}