Skip to content

Commit c9c502a

Browse files
committedJan 8, 2019
Use proj geodesic.h instead of GeographicLib
Because it contains the same functionality and avoids a new dependency
1 parent 9c7be5f commit c9c502a

File tree

8 files changed

+22
-24
lines changed

8 files changed

+22
-24
lines changed
 

‎.docker/qgis3-build-deps-cosmic.dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ RUN apt-get update \
3030
libfcgi-dev \
3131
libgdal-dev \
3232
libgeos-dev \
33-
libgeographic-dev \
3433
libgsl-dev \
3534
libpq-dev \
3635
libproj-dev \

‎.docker/qgis3-build-deps.dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ RUN apt-get update \
3030
libexpat1-dev \
3131
libfcgi-dev \
3232
libgdal-dev \
33-
libgeographic-dev \
3433
libgeos-dev \
3534
libgsl-dev \
3635
libpq-dev \

‎CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ IF(WITH_CORE)
297297
FIND_PACKAGE(GDAL)
298298
FIND_PACKAGE(Expat REQUIRED)
299299
FIND_PACKAGE(Spatialindex REQUIRED)
300-
FIND_PACKAGE(GeographicLib REQUIRED)
301300
IF (WITH_GUI)
302301
FIND_PACKAGE(Qwt REQUIRED)
303302
ENDIF (WITH_GUI)

‎debian/control

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ Build-Depends:
1010
dh-python,
1111
flex,
1212
grass-dev,
13-
libgeographic-dev,
1413
libexiv2-dev,
1514
libexpat1-dev,
1615
libfcgi-dev,
@@ -187,7 +186,6 @@ Depends:
187186
libexiv2-dev,
188187
libexpat1-dev,
189188
libgdal-dev (>= 1.11),
190-
libgeographic-dev,
191189
libgeos-dev (>= 3.0.0),
192190
libgsl-dev,
193191
libpq-dev,

‎doc/linux.t2t

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ new subdirectory called `build` or `build-qt5` in it.
264264
=== Install build dependencies ===
265265

266266
```
267-
dnf install qt5-qtwebkit-devel qt5-qtlocation-devel qt5-qttools-static qca-qt5-devel qca-qt5-ossl qt5-qt3d-devel python3-qt5-devel python3-qscintilla-qt5-devel qscintilla-qt5-devel python3-qscintilla-devel python3-qscintilla-qt5 clang flex bison geos-devel gdal-devel sqlite-devel libspatialite-devel qt5-qtsvg-devel qt5-qtxmlpatterns-devel spatialindex-devel expat-devel proj-devel qwt-qt5-devel gsl-devel postgresql-devel cmake python3-future gdal-python3 python3-psycopg2 python3-PyYAML python3-pygments python3-jinja2 python3-OWSLib qca-qt5-ossl qwt-qt5-devel qtkeychain-qt5-devel qwt-devel sip-devel libzip-devel exiv2-devel GeographicLib-devel
267+
dnf install qt5-qtwebkit-devel qt5-qtlocation-devel qt5-qttools-static qca-qt5-devel qca-qt5-ossl qt5-qt3d-devel python3-qt5-devel python3-qscintilla-qt5-devel qscintilla-qt5-devel python3-qscintilla-devel python3-qscintilla-qt5 clang flex bison geos-devel gdal-devel sqlite-devel libspatialite-devel qt5-qtsvg-devel qt5-qtxmlpatterns-devel spatialindex-devel expat-devel proj-devel qwt-qt5-devel gsl-devel postgresql-devel cmake python3-future gdal-python3 python3-psycopg2 python3-PyYAML python3-pygments python3-jinja2 python3-OWSLib qca-qt5-ossl qwt-qt5-devel qtkeychain-qt5-devel qwt-devel sip-devel libzip-devel exiv2-devel
268268
```
269269

270270
To build QGIS server additional dependencies are required:

‎rpm/qgis.spec.template

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ BuildRequires: libspatialite-devel
6767
BuildRequires: proj-devel
6868
BuildRequires: spatialindex-devel
6969
BuildRequires: grass-devel
70-
BuildRequires: GeographicLib-devel
7170

7271
# Other stuff
7372
BuildRequires: exiv2-devel

‎src/core/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1250,10 +1250,8 @@ INCLUDE_DIRECTORIES(SYSTEM
12501250
${QCA_INCLUDE_DIR}
12511251
${QTKEYCHAIN_INCLUDE_DIR}
12521252
${Qt5SerialPort_INCLUDE_DIRS}
1253-
${GeographicLib_INCLUDE_DIR}
12541253
)
12551254

1256-
ADD_DEFINITIONS(${GeographicLib_DEFINITIONS})
12571255

12581256
IF (HAVE_OPENCL)
12591257
SET(QGIS_CORE_SRCS ${QGIS_CORE_SRCS}
@@ -1380,7 +1378,6 @@ TARGET_LINK_LIBRARIES(qgis_core
13801378
${SQLITE3_LIBRARY}
13811379
${SPATIALITE_LIBRARY}
13821380
${LIBZIP_LIBRARY}
1383-
${GeographicLib_LIBRARIES}
13841381
)
13851382

13861383
IF (Qt5SerialPort_FOUND)

‎src/core/qgsdistancearea.cpp

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
#include "qgsunittypes.h"
3535
#include "qgsexception.h"
3636

37-
#include <GeographicLib/Geodesic.hpp>
38-
#include <GeographicLib/GeodesicLine.hpp>
37+
#include <geodesic.h>
3938

4039
#define DEG2RAD(x) ((x)*M_PI/180)
4140
#define RAD2DEG(r) (180.0 * (r) / M_PI)
@@ -476,9 +475,13 @@ double QgsDistanceArea::latitudeGeodesicCrossesDateLine( const QgsPointXY &pp1,
476475
double lat = p2y;
477476
double lon = p2x;
478477

479-
GeographicLib::Geodesic geod( mSemiMajor, 1 / mInvFlattening );
480-
GeographicLib::GeodesicLine line = geod.InverseLine( p1y, p1x, p2y, p2x );
481-
double intersectionDist = line.Distance();
478+
geod_geodesic geod;
479+
geod_init( &geod, mSemiMajor, 1 / mInvFlattening );
480+
481+
geod_geodesicline line;
482+
geod_inverseline( &line, &geod, p1y, p1x, p2y, p2x, GEOD_ALL );
483+
484+
double intersectionDist = line.s13;
482485

483486
int iterations = 0;
484487
double t = 0;
@@ -500,8 +503,8 @@ double QgsDistanceArea::latitudeGeodesicCrossesDateLine( const QgsPointXY &pp1,
500503
}
501504
QgsDebugMsgLevel( QStringLiteral( "Narrowed window to %1, %2 - %3, %4" ).arg( p1x ).arg( p1y ).arg( p2x ).arg( p2y ), 4 );
502505

503-
line = geod.InverseLine( p1y, p1x, p2y, p2x );
504-
intersectionDist = line.Distance() * 0.5;
506+
geod_inverseline( &line, &geod, p1y, p1x, p2y, p2x, GEOD_ALL );
507+
intersectionDist = line.s13 * 0.5;
505508
}
506509
else
507510
{
@@ -513,9 +516,10 @@ double QgsDistanceArea::latitudeGeodesicCrossesDateLine( const QgsPointXY &pp1,
513516

514517
// now work out the point on the geodesic this far from p1 - this becomes our new candidate for crossing the date line
515518

516-
// (use LONG_UNROLL - we don't want to wrap longitudes > 180 around)
517-
( void )line.GenPosition( false, intersectionDist, GeographicLib::GeodesicLine::LATITUDE | GeographicLib::GeodesicLine::LONGITUDE | GeographicLib::GeodesicLine::LONG_UNROLL,
518-
lat, lon, t, t, t, t, t, t );
519+
geod_position( &line, intersectionDist, &lat, &lon, &t );
520+
// we don't want to wrap longitudes > 180 around)
521+
if ( lon < 0 )
522+
lon += 360;
519523

520524
iterations++;
521525
QgsDebugMsgLevel( QStringLiteral( "After %1 iterations lon is %2, lat is %3, dist from p1: %4" ).arg( iterations ).arg( lon ).arg( lat ).arg( intersectionDist ), 4 );
@@ -532,7 +536,8 @@ QList< QList<QgsPointXY> > QgsDistanceArea::geodesicLine( const QgsPointXY &p1,
532536
return QList< QList< QgsPointXY > >() << ( QList< QgsPointXY >() << p1 << p2 );
533537
}
534538

535-
GeographicLib::Geodesic geod( mSemiMajor, 1 / mInvFlattening );
539+
geod_geodesic geod;
540+
geod_init( &geod, mSemiMajor, 1 / mInvFlattening );
536541

537542
QgsPointXY pp1, pp2;
538543
try
@@ -546,15 +551,17 @@ QList< QList<QgsPointXY> > QgsDistanceArea::geodesicLine( const QgsPointXY &p1,
546551
return QList< QList< QgsPointXY > >();
547552
}
548553

549-
GeographicLib::GeodesicLine line = geod.InverseLine( pp1.y(), pp1.x(), pp2.y(), pp2.x() );
550-
const double totalDist = line.Distance();
554+
geod_geodesicline line;
555+
geod_inverseline( &line, &geod, pp1.y(), pp1.x(), pp2.y(), pp2.x(), GEOD_ALL );
556+
const double totalDist = line.s13;
551557

552558
QList< QList< QgsPointXY > > res;
553559
QList< QgsPointXY > currentPart;
554560
currentPart << p1;
555561
double d = interval;
556562
double prevLon = p1.x();
557563
bool lastRun = false;
564+
double t = 0;
558565
while ( true )
559566
{
560567
double lat, lon;
@@ -567,7 +574,7 @@ QList< QList<QgsPointXY> > QgsDistanceArea::geodesicLine( const QgsPointXY &p1,
567574
}
568575
else
569576
{
570-
( void )line.Position( d, lat, lon );
577+
geod_position( &line, d, &lat, &lon, &t );
571578
}
572579

573580
if ( breakLine && ( ( prevLon < -120 && lon > 120 ) || ( prevLon > 120 && lon < -120 ) ) )

3 commit comments

Comments
 (3)

marisn commented on Jan 8, 2019

@marisn
Contributor

Something seems to be missing:

src/core/qgsdistancearea.cpp: In member function ‘double QgsDistanceArea::latitudeGeodesicCrossesDateLine(const QgsPointXY&, const QgsPointXY&, double&) const’:
src/core/qgsdistancearea.cpp:482:3: error: ‘geod_inverseline’ was not declared in this scope
geod_inverseline( &line, &geod, p1y, p1x, p2y, p2x, GEOD_ALL );
^~~~~~~~~~~~~~~~
src/core/qgsdistancearea.cpp:482:3: note: suggested alternative: ‘geod_inverse’
geod_inverseline( &line, &geod, p1y, p1x, p2y, p2x, GEOD_ALL );
^~~~~~~~~~~~~~~~
geod_inverse
src/core/qgsdistancearea.cpp:484:33: error: ‘struct geod_geodesicline’ has no member named ‘s13’
const double totalDist = line.s13;
^~~
src/core/qgsdistancearea.cpp:485:34: error: ‘struct geod_geodesicline’ has no member named ‘s13’
double intersectionDist = line.s13;
^~~
src/core/qgsdistancearea.cpp:508:31: error: ‘struct geod_geodesicline’ has no member named ‘s13’
intersectionDist = line.s13 * 0.5;
^~~
src/core/qgsdistancearea.cpp: In member function ‘QVector<QVector > QgsDistanceArea::geodesicLine(const QgsPointXY&, const QgsPointXY&, double, bool) const’:
src/core/qgsdistancearea.cpp:558:3: error: ‘geod_inverseline’ was not declared in this scope
geod_inverseline( &line, &geod, pp1.y(), pp1.x(), pp2.y(), pp2.x(), GEOD_ALL );
^~~~~~~~~~~~~~~~
src/core/qgsdistancearea.cpp:558:3: note: suggested alternative: ‘geod_inverse’
geod_inverseline( &line, &geod, pp1.y(), pp1.x(), pp2.y(), pp2.x(), GEOD_ALL );
^~~~~~~~~~~~~~~~
geod_inverse
src/core/qgsdistancearea.cpp:559:33: error: ‘struct geod_geodesicline’ has no member named ‘s13’
const double totalDist = line.s13;

nyalldawson commented on Jan 10, 2019

@nyalldawson
CollaboratorAuthor

@marisn You need to upgrade to proj >= 4.9.3

elpaso commented on Jan 10, 2019

@elpaso
Contributor

@nyalldawson can you add a CMAKE check for the minimum required proj version?

Please sign in to comment.