summary refs log tree commit diff
path: root/gnu/packages/patches/xygrib-newer-proj.patch
blob: 740410557ac533d97d14ffdccafb291e235b8f7f (plain) (blame)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
These two patches are already applied upstream.
https://patch-diff.githubusercontent.com/raw/opengribs/XyGrib/pull/289.patch

removing cmake/FindPROJ4.cmake removed since it didn't apply cleanly.

From 95aa7b47bfe83ee276806acd8ce08867fd7a28d9 Mon Sep 17 00:00:00 2001
From: Fyleo <fyleo45@gmail.com>
Date: Tue, 7 Sep 2021 18:10:39 +0200
Subject: [PATCH 1/2] port to PROJ 8.0 API

---
 CMakeLists.txt                 | 14 +++----
 cmake/FindPROJ4.cmake          | 77 ----------------------------------
 cmake/FindPROJ8.cmake          | 76 +++++++++++++++++++++++++++++++++
 src/CMakeLists.txt             |  2 +-
 src/map/Projection.h           |  7 +---
 src/map/Projection_libproj.cpp | 30 ++++++-------
 6 files changed, 101 insertions(+), 105 deletions(-)
 delete mode 100644 cmake/FindPROJ4.cmake
 create mode 100644 cmake/FindPROJ8.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b066a044..77633a21 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -122,22 +122,22 @@ find_path(OPENJPEG_INCLUDE_DIR
 include_directories(${OPENJPEG_INCLUDE_DIR})
 
 if(NOT WIN32)
-    include(cmake/FindPROJ4.cmake)
-    if(NOT PROJ4_FOUND)
-      message(FATAL_ERROR "PROJ.4 library not found!")
+    include(cmake/FindPROJ8.cmake)
+    if(NOT PROJ8_FOUND)
+      message(FATAL_ERROR "PROJ.8 library not found!")
     endif()
-    include_directories(${PROJ4_INCLUDE_DIRS})
+    include_directories(${PROJ8_INCLUDE_DIRS})
 endif()
 if(WIN32)
-    find_library(PROJ4_LIBRARIES
+    find_library(PROJ8_LIBRARIES
         NAME "libproj.a"
         PATHS
         $ENV{EXTERNLIBS}/lib
          /opt/lib
         REQUIRED
     )
-    find_path(PROJ4_INCLUDE_DIRS
-         NAMES "proj_api.h"
+    find_path(PROJ8_INCLUDE_DIRS
+         NAMES "proj.h"
          PATHS
          $ENV{EXTERNLIBS}/include
          /opt/include
diff --git a/cmake/FindPROJ8.cmake b/cmake/FindPROJ8.cmake
new file mode 100644
index 00000000..33470ac2
--- /dev/null
+++ b/cmake/FindPROJ8.cmake
@@ -0,0 +1,76 @@
+# - Find PROJ8
+# Find the PROJ8 includes and library
+#
+#  PROJ8_INCLUDE_DIR - Where to find PROJ8 includes
+#  PROJ8_LIBRARIES   - List of libraries when using PROJ8
+#  PROJ8_FOUND       - True if PROJ8 was found
+
+IF(PROJ8_INCLUDE_DIR)
+  SET(PROJ8_FIND_QUIETLY TRUE)
+ENDIF(PROJ8_INCLUDE_DIR)
+
+FIND_PATH(PROJ8_INCLUDE_DIR "proj.h"
+  PATHS
+  $ENV{EXTERNLIBS}/include
+  $ENV{EXTERNLIBS}/PROJ8/include
+  ~/Library/Frameworks/include
+  /Library/Frameworks/include
+  /usr/local/include
+  /usr/include
+  /sw/include # Fink
+  /opt/local/include # DarwinPorts
+  /opt/csw/include # Blastwave
+  /opt/include
+  DOC "PROJ8 - Headers"
+)
+
+SET(PROJ8_NAMES PROJ8 proj proj_8_0)
+SET(PROJ8_DBG_NAMES PROJ8D projD proj_8_0_1)
+
+FIND_LIBRARY(PROJ8_LIBRARY NAMES ${PROJ8_NAMES}
+  PATHS
+  $ENV{EXTERNLIBS}
+  $ENV{EXTERNLIBS}/PROJ8
+  ~/Library/Frameworks
+  /Library/Frameworks
+  /usr/local
+  /usr
+  /sw
+  /opt/local
+  /opt/csw
+  /opt
+  PATH_SUFFIXES lib lib64
+  DOC "PROJ8 - Library"
+)
+
+INCLUDE(FindPackageHandleStandardArgs)
+
+IF(MSVC)
+  # VisualStudio needs a debug version
+  FIND_LIBRARY(PROJ8_LIBRARY_DEBUG NAMES ${PROJ8_DBG_NAMES}
+    PATHS
+    $ENV{EXTERNLIBS}/PROJ8/lib
+    DOC "PROJ8 - Library (Debug)"
+  )
+  
+  IF(PROJ8_LIBRARY_DEBUG AND PROJ8_LIBRARY)
+    SET(PROJ8_LIBRARIES optimized ${PROJ8_LIBRARY} debug ${PROJ8_LIBRARY_DEBUG})
+  ENDIF(PROJ8_LIBRARY_DEBUG AND PROJ8_LIBRARY)
+
+  FIND_PACKAGE_HANDLE_STANDARD_ARGS(PROJ8 DEFAULT_MSG PROJ8_LIBRARY PROJ8_LIBRARY_DEBUG PROJ8_INCLUDE_DIR)
+
+  MARK_AS_ADVANCED(PROJ8_LIBRARY PROJ8_LIBRARY_DEBUG PROJ8_INCLUDE_DIR)
+  
+ELSE(MSVC)
+  # rest of the world
+  SET(PROJ8_LIBRARIES ${PROJ8_LIBRARY})
+
+  FIND_PACKAGE_HANDLE_STANDARD_ARGS(PROJ8 DEFAULT_MSG PROJ8_LIBRARY PROJ8_INCLUDE_DIR)
+  
+  MARK_AS_ADVANCED(PROJ8_LIBRARY PROJ8_INCLUDE_DIR)
+  
+ENDIF(MSVC)
+
+IF(PROJ8_FOUND)
+  SET(PROJ8_INCLUDE_DIRS ${PROJ8_INCLUDE_DIR})
+ENDIF(PROJ8_FOUND)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2e5dbde4..9c96d49f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -118,7 +118,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/util)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/map ${MAP_GENERATED_HEADERS})
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/GUI ${GUI_GENERATED_HEADERS})
 
-target_link_libraries(${CMAKE_PROJECT_NAME} g2clib gui util map ${LIBNOVA_LIBRARY} ${OPENJPEG_LIBRARIES} ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5PrintSupport_LIBRARIES} ${BZIP2_LIBRARIES} ${ZLIB_LIBRARIES} ${PROJ4_LIBRARIES} ${PNG_LIBRARIES})
+target_link_libraries(${CMAKE_PROJECT_NAME} g2clib gui util map ${LIBNOVA_LIBRARY} ${OPENJPEG_LIBRARIES} ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5PrintSupport_LIBRARIES} ${BZIP2_LIBRARIES} ${ZLIB_LIBRARIES} ${PROJ8_LIBRARIES} ${PNG_LIBRARIES})
 
 # Sanitizers, part 2/2
 if ( CMAKE_VERSION VERSION_GREATER 3.4 )
diff --git a/src/map/Projection.h b/src/map/Projection.h
index b4ca7f5b..d482e0dd 100644
--- a/src/map/Projection.h
+++ b/src/map/Projection.h
@@ -21,10 +21,7 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #include <QObject>
 #include <cstdio>
 
-#ifndef ACCEPT_USE_OF_DEPRECATED_PROJ_API_H
-#define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H
-#endif
-#include "proj_api.h"
+#include "proj.h"
 
 class Projection : public QObject
 {
@@ -141,7 +138,7 @@ class Projection_libproj : public Projection
 		int   getProjection()   {return currentProj;}
 
 	private :
-		projPJ libProj;
+		PJ * libProj;
 		int  currentProj;
 };
 
diff --git a/src/map/Projection_libproj.cpp b/src/map/Projection_libproj.cpp
index 1dcbd540..0299714e 100644
--- a/src/map/Projection_libproj.cpp
+++ b/src/map/Projection_libproj.cpp
@@ -93,9 +93,9 @@ void Projection_libproj::setProjection(int code)
     params[nbpar++] = "no_defs";
     params[nbpar++] = "over";	// allow longitude > 180°
     // XXX ouch pj_init
-    libProj = pj_init(nbpar, (char **)params);
+    libProj = proj_create_argv(PJ_DEFAULT_CTX, nbpar, (char **)params);
 	if (!libProj)
-		printf("proj error: %s\n", pj_strerrno(pj_errno));
+		printf("proj error: %s\n", proj_errno_string(proj_errno(libProj)));
 	assert(libProj);
 	currentProj = code;
 //	libProj->over = 1;		// allow longitude > 180°
@@ -106,23 +106,23 @@ void Projection_libproj::setProjection(int code)
 Projection_libproj::~Projection_libproj()
 {
     if (libProj != nullptr) {
-		pj_free(libProj);
+		proj_destroy(libProj);
 	}
 }
 
 //-------------------------------------------------------------------------------
 void Projection_libproj::map2screen(double x, double y, int *i, int *j) const
 {
-	projUV data, res;
+	PJ_COORD data, res;
 	if (y <= -90.0)
 		y = -90.0+1e-5;
 	if (y >= 90.0)
 		y = 90.0-1e-5;
-	data.v =  y * DEG_TO_RAD;
-	data.u =  x * DEG_TO_RAD;
-	res = pj_fwd(data, libProj);
-	*i =  (int) (W/2.0 + scale * (res.u/111319.0-CX) + 0.5);
-	*j =  (int) (H/2.0 - scale * (res.v/111319.0-CY) + 0.5);
+	data.uv.v =  y;
+	data.uv.u =  x;
+	res = proj_trans(libProj, PJ_FWD, data);
+	*i =  (int) (W/2.0 + scale * (res.uv.u/111319.0-CX) + 0.5);
+	*j =  (int) (H/2.0 - scale * (res.uv.v/111319.0-CY) + 0.5);
 	//printf("PROJ   map2screen (%f %f) -> (%3d %3d)\n", x,y, *i,*j);
 }
 
@@ -130,12 +130,12 @@ void Projection_libproj::map2screen(double x, double y, int *i, int *j) const
 //-------------------------------------------------------------------------------
 void Projection_libproj::screen2map(int i, int j, double *x, double *y) const
 {
-	projUV data, res;
-	data.u =  ((i-W/2.0)/scale+ CX)*111319.0 ;
-	data.v =  ((H/2.0-j)/scale+ CY)*111319.0 ;
-	res = pj_inv(data, libProj);
-	*x = (double)(res.u*RAD_TO_DEG);
-	*y = (double)(res.v*RAD_TO_DEG);
+	PJ_COORD data, res;
+	data.uv.u =  ((i-W/2.0)/scale+ CX)*111319.0 ;
+	data.uv.v =  ((H/2.0-j)/scale+ CY)*111319.0 ;
+	res = proj_trans(libProj, PJ_INV, data);
+	*x = (double)(res.uv.u);
+	*y = (double)(res.uv.v);
 	//printf("PROJ   screen2map (%3d %3d) -> (%f %f)\n", i,j, *x,*y);
 }
 //--------------------------------------------------------------

From 720a2db307f5c93c0079f9811a3c35cfe8bb12f5 Mon Sep 17 00:00:00 2001
From: didier <didier@users.sourceforge.net>
Date: Mon, 24 Jan 2022 13:13:42 +0100
Subject: [PATCH 2/2] Use new libproj API if available

---
 CMakeLists.txt                 | 12 ++---
 cmake/FindPROJ.cmake           | 96 ++++++++++++++++++++++++++++++++++
 cmake/FindPROJ8.cmake          | 76 ---------------------------
 src/CMakeLists.txt             |  2 +-
 src/map/Projection.h           |  9 ++++
 src/map/Projection_libproj.cpp | 32 +++++++++++-
 6 files changed, 143 insertions(+), 84 deletions(-)
 create mode 100644 cmake/FindPROJ.cmake
 delete mode 100644 cmake/FindPROJ8.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 77633a21..358a87a2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -122,21 +122,21 @@ find_path(OPENJPEG_INCLUDE_DIR
 include_directories(${OPENJPEG_INCLUDE_DIR})
 
 if(NOT WIN32)
-    include(cmake/FindPROJ8.cmake)
-    if(NOT PROJ8_FOUND)
-      message(FATAL_ERROR "PROJ.8 library not found!")
+    include(cmake/FindPROJ.cmake)
+    if(NOT PROJ_FOUND)
+      message(FATAL_ERROR "PROJ library not found!")
     endif()
-    include_directories(${PROJ8_INCLUDE_DIRS})
+    include_directories(${PROJ_INCLUDE_DIRS})
 endif()
 if(WIN32)
-    find_library(PROJ8_LIBRARIES
+    find_library(PROJ_LIBRARIES
         NAME "libproj.a"
         PATHS
         $ENV{EXTERNLIBS}/lib
          /opt/lib
         REQUIRED
     )
-    find_path(PROJ8_INCLUDE_DIRS
+    find_path(PROJ_INCLUDE_DIRS
          NAMES "proj.h"
          PATHS
          $ENV{EXTERNLIBS}/include
diff --git a/cmake/FindPROJ.cmake b/cmake/FindPROJ.cmake
new file mode 100644
index 00000000..33b53000
--- /dev/null
+++ b/cmake/FindPROJ.cmake
@@ -0,0 +1,96 @@
+# - Find PROJ
+# Find the PROJ includes and library
+#
+#  PROJ_INCLUDE_DIR - Where to find PROJ includes
+#  PROJ_LIBRARIES   - List of libraries when using PROJ
+#  PROJ_FOUND       - True if PROJ was found
+
+IF(PROJ_INCLUDE_DIR)
+  SET(PROJ_FIND_QUIETLY TRUE)
+ENDIF(PROJ_INCLUDE_DIR)
+
+FIND_PATH(PROJ_INCLUDE_DIR "proj.h"
+  PATHS
+  $ENV{EXTERNLIBS}/include
+  $ENV{EXTERNLIBS}/PROJ/include
+  ~/Library/Frameworks/include
+  /Library/Frameworks/include
+  /usr/local/include
+  /usr/include
+  /sw/include # Fink
+  /opt/local/include # DarwinPorts
+  /opt/csw/include # Blastwave
+  /opt/include
+  DOC "PROJ - Headers"
+)
+
+IF(PROJ_INCLUDE_DIR)
+    SET(PROJ_NAMES PROJ proj proj_8_0)
+    SET(PROJ_DBG_NAMES PROJD projD proj_8_0_1)
+ELSE(PROJ_INCLUDE_DIR)
+    FIND_PATH(PROJ_INCLUDE_DIR "proj_api.h"
+      PATHS
+      $ENV{EXTERNLIBS}/include
+      $ENV{EXTERNLIBS}/PROJ/include
+      ~/Library/Frameworks/include
+      /Library/Frameworks/include
+      /usr/local/include
+      /usr/include
+      /sw/include # Fink
+      /opt/local/include # DarwinPorts
+      /opt/csw/include # Blastwave
+      /opt/include
+      DOC "PROJ - Headers"
+    )
+    ADD_DEFINITIONS(-DACCEPT_USE_OF_DEPRECATED_PROJ_API_H=1)
+    SET(PROJ_NAMES PROJ proj proj_4_9)
+    SET(PROJ_DBG_NAMES PROJD projD proj_4_9_D)
+ENDIF(PROJ_INCLUDE_DIR)
+
+FIND_LIBRARY(PROJ_LIBRARY NAMES ${PROJ_NAMES}
+  PATHS
+  $ENV{EXTERNLIBS}
+  $ENV{EXTERNLIBS}/PROJ
+  ~/Library/Frameworks
+  /Library/Frameworks
+  /usr/local
+  /usr
+  /sw
+  /opt/local
+  /opt/csw
+  /opt
+  PATH_SUFFIXES lib lib64
+  DOC "PROJ - Library"
+)
+
+INCLUDE(FindPackageHandleStandardArgs)
+
+IF(MSVC)
+  # VisualStudio needs a debug version
+  FIND_LIBRARY(PROJ_LIBRARY_DEBUG NAMES ${PROJ_DBG_NAMES}
+    PATHS
+    $ENV{EXTERNLIBS}/PROJ/lib
+    DOC "PROJ - Library (Debug)"
+  )
+  
+  IF(PROJ_LIBRARY_DEBUG AND PROJ_LIBRARY)
+    SET(PROJ_LIBRARIES optimized ${PROJ_LIBRARY} debug ${PROJ_LIBRARY_DEBUG})
+  ENDIF(PROJ_LIBRARY_DEBUG AND PROJ_LIBRARY)
+
+  FIND_PACKAGE_HANDLE_STANDARD_ARGS(PROJ DEFAULT_MSG PROJ_LIBRARY PROJ_LIBRARY_DEBUG PROJ_INCLUDE_DIR)
+
+  MARK_AS_ADVANCED(PROJ_LIBRARY PROJ_LIBRARY_DEBUG PROJ_INCLUDE_DIR)
+  
+ELSE(MSVC)
+  # rest of the world
+  SET(PROJ_LIBRARIES ${PROJ_LIBRARY})
+
+  FIND_PACKAGE_HANDLE_STANDARD_ARGS(PROJ DEFAULT_MSG PROJ_LIBRARY PROJ_INCLUDE_DIR)
+  
+  MARK_AS_ADVANCED(PROJ_LIBRARY PROJ_INCLUDE_DIR)
+  
+ENDIF(MSVC)
+
+IF(PROJ_FOUND)
+  SET(PROJ_INCLUDE_DIRS ${PROJ_INCLUDE_DIR})
+ENDIF(PROJ_FOUND)
diff --git a/cmake/FindPROJ8.cmake b/cmake/FindPROJ8.cmake
deleted file mode 100644
index 33470ac2..00000000
--- a/cmake/FindPROJ8.cmake
+++ /dev/null
@@ -1,76 +0,0 @@
-# - Find PROJ8
-# Find the PROJ8 includes and library
-#
-#  PROJ8_INCLUDE_DIR - Where to find PROJ8 includes
-#  PROJ8_LIBRARIES   - List of libraries when using PROJ8
-#  PROJ8_FOUND       - True if PROJ8 was found
-
-IF(PROJ8_INCLUDE_DIR)
-  SET(PROJ8_FIND_QUIETLY TRUE)
-ENDIF(PROJ8_INCLUDE_DIR)
-
-FIND_PATH(PROJ8_INCLUDE_DIR "proj.h"
-  PATHS
-  $ENV{EXTERNLIBS}/include
-  $ENV{EXTERNLIBS}/PROJ8/include
-  ~/Library/Frameworks/include
-  /Library/Frameworks/include
-  /usr/local/include
-  /usr/include
-  /sw/include # Fink
-  /opt/local/include # DarwinPorts
-  /opt/csw/include # Blastwave
-  /opt/include
-  DOC "PROJ8 - Headers"
-)
-
-SET(PROJ8_NAMES PROJ8 proj proj_8_0)
-SET(PROJ8_DBG_NAMES PROJ8D projD proj_8_0_1)
-
-FIND_LIBRARY(PROJ8_LIBRARY NAMES ${PROJ8_NAMES}
-  PATHS
-  $ENV{EXTERNLIBS}
-  $ENV{EXTERNLIBS}/PROJ8
-  ~/Library/Frameworks
-  /Library/Frameworks
-  /usr/local
-  /usr
-  /sw
-  /opt/local
-  /opt/csw
-  /opt
-  PATH_SUFFIXES lib lib64
-  DOC "PROJ8 - Library"
-)
-
-INCLUDE(FindPackageHandleStandardArgs)
-
-IF(MSVC)
-  # VisualStudio needs a debug version
-  FIND_LIBRARY(PROJ8_LIBRARY_DEBUG NAMES ${PROJ8_DBG_NAMES}
-    PATHS
-    $ENV{EXTERNLIBS}/PROJ8/lib
-    DOC "PROJ8 - Library (Debug)"
-  )
-  
-  IF(PROJ8_LIBRARY_DEBUG AND PROJ8_LIBRARY)
-    SET(PROJ8_LIBRARIES optimized ${PROJ8_LIBRARY} debug ${PROJ8_LIBRARY_DEBUG})
-  ENDIF(PROJ8_LIBRARY_DEBUG AND PROJ8_LIBRARY)
-
-  FIND_PACKAGE_HANDLE_STANDARD_ARGS(PROJ8 DEFAULT_MSG PROJ8_LIBRARY PROJ8_LIBRARY_DEBUG PROJ8_INCLUDE_DIR)
-
-  MARK_AS_ADVANCED(PROJ8_LIBRARY PROJ8_LIBRARY_DEBUG PROJ8_INCLUDE_DIR)
-  
-ELSE(MSVC)
-  # rest of the world
-  SET(PROJ8_LIBRARIES ${PROJ8_LIBRARY})
-
-  FIND_PACKAGE_HANDLE_STANDARD_ARGS(PROJ8 DEFAULT_MSG PROJ8_LIBRARY PROJ8_INCLUDE_DIR)
-  
-  MARK_AS_ADVANCED(PROJ8_LIBRARY PROJ8_INCLUDE_DIR)
-  
-ENDIF(MSVC)
-
-IF(PROJ8_FOUND)
-  SET(PROJ8_INCLUDE_DIRS ${PROJ8_INCLUDE_DIR})
-ENDIF(PROJ8_FOUND)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9c96d49f..d1c42f95 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -118,7 +118,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/util)
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/map ${MAP_GENERATED_HEADERS})
 include_directories(${CMAKE_CURRENT_SOURCE_DIR}/GUI ${GUI_GENERATED_HEADERS})
 
-target_link_libraries(${CMAKE_PROJECT_NAME} g2clib gui util map ${LIBNOVA_LIBRARY} ${OPENJPEG_LIBRARIES} ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5PrintSupport_LIBRARIES} ${BZIP2_LIBRARIES} ${ZLIB_LIBRARIES} ${PROJ8_LIBRARIES} ${PNG_LIBRARIES})
+target_link_libraries(${CMAKE_PROJECT_NAME} g2clib gui util map ${LIBNOVA_LIBRARY} ${OPENJPEG_LIBRARIES} ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Network_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5PrintSupport_LIBRARIES} ${BZIP2_LIBRARIES} ${ZLIB_LIBRARIES} ${PROJ_LIBRARIES} ${PNG_LIBRARIES})
 
 # Sanitizers, part 2/2
 if ( CMAKE_VERSION VERSION_GREATER 3.4 )
diff --git a/src/map/Projection.h b/src/map/Projection.h
index d482e0dd..9ac13426 100644
--- a/src/map/Projection.h
+++ b/src/map/Projection.h
@@ -20,8 +20,13 @@ along with this program.  If not, see <http://www.gnu.org/licenses/>.
 #define PROJECTION_H
 #include <QObject>
 #include <cstdio>
+//#define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H
 
+#ifdef ACCEPT_USE_OF_DEPRECATED_PROJ_API_H
+#include "proj_api.h"
+#else
 #include "proj.h"
+#endif
 
 class Projection : public QObject
 {
@@ -138,7 +143,11 @@ class Projection_libproj : public Projection
 		int   getProjection()   {return currentProj;}
 
 	private :
+#ifdef ACCEPT_USE_OF_DEPRECATED_PROJ_API_H
+		projPJ libProj;
+#else
 		PJ * libProj;
+#endif
 		int  currentProj;
 };
 
diff --git a/src/map/Projection_libproj.cpp b/src/map/Projection_libproj.cpp
index 0299714e..e2ea525c 100644
--- a/src/map/Projection_libproj.cpp
+++ b/src/map/Projection_libproj.cpp
@@ -92,10 +92,15 @@ void Projection_libproj::setProjection(int code)
     params[nbpar++] = "ellps=WGS84";
     params[nbpar++] = "no_defs";
     params[nbpar++] = "over";	// allow longitude > 180°
-    // XXX ouch pj_init
+#ifdef ACCEPT_USE_OF_DEPRECATED_PROJ_API_H
+    libProj = pj_init(nbpar, (char **)params);
+	if (!libProj)
+		printf("proj error: %s\n", pj_strerrno(pj_errno));
+#else
     libProj = proj_create_argv(PJ_DEFAULT_CTX, nbpar, (char **)params);
 	if (!libProj)
 		printf("proj error: %s\n", proj_errno_string(proj_errno(libProj)));
+#endif
 	assert(libProj);
 	currentProj = code;
 //	libProj->over = 1;		// allow longitude > 180°
@@ -106,23 +111,39 @@ void Projection_libproj::setProjection(int code)
 Projection_libproj::~Projection_libproj()
 {
     if (libProj != nullptr) {
+#ifdef ACCEPT_USE_OF_DEPRECATED_PROJ_API_H
+		pj_free(libProj);
+#else
 		proj_destroy(libProj);
+#endif
 	}
 }
 
 //-------------------------------------------------------------------------------
 void Projection_libproj::map2screen(double x, double y, int *i, int *j) const
 {
+#ifdef ACCEPT_USE_OF_DEPRECATED_PROJ_API_H
+	projUV data, res;
+#else
 	PJ_COORD data, res;
+#endif
 	if (y <= -90.0)
 		y = -90.0+1e-5;
 	if (y >= 90.0)
 		y = 90.0-1e-5;
+#ifdef ACCEPT_USE_OF_DEPRECATED_PROJ_API_H
+	data.v =  y * DEG_TO_RAD;
+	data.u =  x * DEG_TO_RAD;
+	res = pj_fwd(data, libProj);
+	*i =  (int) (W/2.0 + scale * (res.u/111319.0-CX) + 0.5);
+	*j =  (int) (H/2.0 - scale * (res.v/111319.0-CY) + 0.5);
+#else
 	data.uv.v =  y;
 	data.uv.u =  x;
 	res = proj_trans(libProj, PJ_FWD, data);
 	*i =  (int) (W/2.0 + scale * (res.uv.u/111319.0-CX) + 0.5);
 	*j =  (int) (H/2.0 - scale * (res.uv.v/111319.0-CY) + 0.5);
+#endif
 	//printf("PROJ   map2screen (%f %f) -> (%3d %3d)\n", x,y, *i,*j);
 }
 
@@ -130,12 +151,21 @@ void Projection_libproj::map2screen(double x, double y, int *i, int *j) const
 //-------------------------------------------------------------------------------
 void Projection_libproj::screen2map(int i, int j, double *x, double *y) const
 {
+#ifdef ACCEPT_USE_OF_DEPRECATED_PROJ_API_H
+	projUV data, res;
+	data.u =  ((i-W/2.0)/scale+ CX)*111319.0 ;
+	data.v =  ((H/2.0-j)/scale+ CY)*111319.0 ;
+	res = pj_inv(data, libProj);
+	*x = (double)(res.u*RAD_TO_DEG);
+	*y = (double)(res.v*RAD_TO_DEG);
+#else
 	PJ_COORD data, res;
 	data.uv.u =  ((i-W/2.0)/scale+ CX)*111319.0 ;
 	data.uv.v =  ((H/2.0-j)/scale+ CY)*111319.0 ;
 	res = proj_trans(libProj, PJ_INV, data);
 	*x = (double)(res.uv.u);
 	*y = (double)(res.uv.v);
+#endif
 	//printf("PROJ   screen2map (%3d %3d) -> (%f %f)\n", i,j, *x,*y);
 }
 //--------------------------------------------------------------