PythonSTB commited on
Commit
81b964e
·
verified ·
1 Parent(s): 7bd06e8

Delete pyproj/Test_Pyproj.py

Browse files
Files changed (1) hide show
  1. pyproj/Test_Pyproj.py +0 -132
pyproj/Test_Pyproj.py DELETED
@@ -1,132 +0,0 @@
1
- """Test_Pyproj.py - device test for pyproj 3.8.0 Android wheels.
2
-
3
- Runs on-device via PipManager Scripts folder (needs PROJ native libs from
4
- this wheel; needs `certifi` installed from its own package).
5
- Exit-code contract: exit 0 iff every check PASSes, else exit 1.
6
- Each check prints [PASS] / [FAIL] with the measured values.
7
-
8
- Generated by RIMI
9
- """
10
- import os
11
- import sys
12
-
13
- PASS = 0
14
- FAIL = 0
15
-
16
-
17
- def check(name, cond, detail=""):
18
- global PASS, FAIL
19
- if cond:
20
- PASS += 1
21
- print("[PASS] %s %s" % (name, detail))
22
- else:
23
- FAIL += 1
24
- print("[FAIL] %s %s" % (name, detail))
25
-
26
-
27
- def approx(a, b, tol):
28
- return abs(a - b) <= tol
29
-
30
-
31
- print("pyproj device test - python %s" % sys.version.split()[0])
32
-
33
- # 1. import + version
34
- try:
35
- import pyproj
36
- from pyproj import CRS, Geod, Transformer
37
- from pyproj import datadir, proj_version_str
38
- check("import pyproj", True, "version=%s" % pyproj.__version__)
39
- except Exception as e:
40
- check("import pyproj", False, repr(e))
41
- print("RESULT: %d PASS, %d FAIL" % (PASS, FAIL))
42
- sys.exit(1)
43
-
44
- check("pyproj version 3.8.0", pyproj.__version__ == "3.8.0",
45
- "got=%s" % pyproj.__version__)
46
-
47
- # 2. runtime dep present
48
- try:
49
- import certifi
50
- check("import certifi", True, certifi.where()[:60])
51
- except Exception as e:
52
- check("import certifi", False, repr(e))
53
-
54
- # 3. PROJ version wired to our bundled 9.8.1
55
- try:
56
- check("PROJ version 9.8.1", proj_version_str == "9.8.1",
57
- "got=%s" % proj_version_str)
58
- except Exception as e:
59
- check("PROJ version 9.8.1", False, repr(e))
60
-
61
- # 4. datum DB vendored (internal proj_dir wins by default)
62
- try:
63
- ddir = datadir.get_data_dir()
64
- db = os.path.join(ddir, "proj.db")
65
- check("datum proj.db vendored",
66
- os.path.isfile(db) and os.path.getsize(db) > 1000000,
67
- "dir=%s size=%d" % (ddir, os.path.getsize(db) if os.path.isfile(db) else -1))
68
- except Exception as e:
69
- check("datum proj.db vendored", False, repr(e))
70
-
71
- # 5. CRS object (needs proj.db)
72
- try:
73
- crs = CRS.from_epsg(4326)
74
- check("CRS EPSG:4326", crs.to_epsg() == 4326 and "WGS" in crs.name,
75
- "name=%s" % crs.name)
76
- except Exception as e:
77
- check("CRS EPSG:4326", False, repr(e))
78
-
79
- # 6. CRS transform known answer: WGS84 lon/lat -> Web-Mercator (Copenhagen)
80
- try:
81
- t = Transformer.from_crs("EPSG:4326", "EPSG:3857", always_xy=True)
82
- x, y = t.transform(12.0, 55.0)
83
- ok = approx(x, 1335833.8895192828, 0.01) and approx(y, 7361866.113051185, 0.01)
84
- check("transform 4326->3857", ok, "x=%.4f y=%.4f" % (x, y))
85
- except Exception as e:
86
- check("transform 4326->3857", False, repr(e))
87
-
88
- # 7. transform origin + roundtrip
89
- try:
90
- t = Transformer.from_crs("EPSG:4326", "EPSG:3857", always_xy=True)
91
- x0, y0 = t.transform(0.0, 0.0)
92
- ti = Transformer.from_crs("EPSG:3857", "EPSG:4326", always_xy=True)
93
- lon, lat = ti.transform(x0, y0)
94
- check("transform origin+roundtrip",
95
- approx(x0, 0.0, 1e-9) and approx(y0, 0.0, 1e-9)
96
- and approx(lon, 0.0, 1e-9) and approx(lat, 0.0, 1e-9),
97
- "x=%.3e y=%.3e" % (x0, y0))
98
- except Exception as e:
99
- check("transform origin+roundtrip", False, repr(e))
100
-
101
- # 8. geodesic inverse known answer: 1 deg longitude on WGS84 equator
102
- try:
103
- g = Geod(ellps="WGS84")
104
- az12, az21, dist = g.inv(0.0, 0.0, 1.0, 0.0)
105
- ok = (approx(az12, 90.0, 1e-9) and approx(az21, -90.0, 1e-9)
106
- and approx(dist, 111319.49079327357, 1e-6))
107
- check("geodesic inverse equator", ok,
108
- "az12=%.6f az21=%.6f dist=%.6f" % (az12, az21, dist))
109
- except Exception as e:
110
- check("geodesic inverse equator", False, repr(e))
111
-
112
- # 9. geodesic forward consistency
113
- try:
114
- g = Geod(ellps="WGS84")
115
- lon2, lat2, back = g.fwd(0.0, 0.0, 90.0, 111319.49079327357)
116
- ok = approx(lon2, 1.0, 1e-9) and approx(lat2, 0.0, 1e-9)
117
- check("geodesic forward", ok,
118
- "lon=%.9f lat=%.9f backaz=%.6f" % (lon2, lat2, back))
119
- except Exception as e:
120
- check("geodesic forward", False, repr(e))
121
-
122
- # 10. list API (needs proj.db tables)
123
- try:
124
- from pyproj import get_ellps_map
125
- m = get_ellps_map()
126
- check("get_ellps_map", isinstance(m, dict) and "WGS84" in m,
127
- "entries=%d" % len(m))
128
- except Exception as e:
129
- check("get_ellps_map", False, repr(e))
130
-
131
- print("RESULT: %d PASS, %d FAIL" % (PASS, FAIL))
132
- sys.exit(0 if FAIL == 0 else 1)