Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
8d84693d
Commit
8d84693d
authored
Jul 17, 2019
by
Valentin Platzgummer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
about to modify wimaarea
parent
a48f3fe2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
2 deletions
+88
-2
qgroundcontrol.pro
qgroundcontrol.pro
+4
-2
GeoUtilities.cc
src/Wima/GeoUtilities.cc
+62
-0
GeoUtilities.h
src/Wima/GeoUtilities.h
+22
-0
No files found.
qgroundcontrol.pro
View file @
8d84693d
...
...
@@ -429,7 +429,8 @@ HEADERS += \
src
/
Wima
/
PlanimetryCalculus
.
h
\
src
/
Wima
/
Circle
.
h
\
src
/
Wima
/
PolygonCalculus
.
h
\
src
/
Wima
/
OptimisationTools
.
h
src
/
Wima
/
OptimisationTools
.
h
\
src
/
Wima
/
GeoUtilities
.
h
SOURCES
+=
\
src
/
api
/
QGCCorePlugin
.
cc
\
src
/
api
/
QGCOptions
.
cc
\
...
...
@@ -457,7 +458,8 @@ SOURCES += \
src
/
Wima
/
PlanimetryCalculus
.
cc
\
src
/
Wima
/
Circle
.
cc
\
src
/
Wima
/
PolygonCalculus
.
cc
\
src
/
Wima
/
OptimisationTools
.
cc
src
/
Wima
/
OptimisationTools
.
cc
\
src
/
Wima
/
GeoUtilities
.
cc
#
#
Unit
Test
specific
configuration
goes
here
(
requires
full
debug
build
with
all
plugins
)
...
...
src/Wima/GeoUtilities.cc
0 → 100644
View file @
8d84693d
#include "GeoUtilities.h"
#include <QtMath>
QGeoCoordinate
GeoUtilites
::
toGeo
(
const
QVector3D
&
point
,
const
QGeoCoordinate
&
origin
)
{
double
x
=
point
.
x
();
double
y
=
point
.
y
();
double
z
=
point
.
z
();
double
lat
=
origin
.
latitude
()
/
180
*
M_PI
;
double
lon
=
origin
.
longitude
()
/
180
*
M_PI
;
double
h
=
origin
.
altitude
();
if
(
!
qFuzzyCompare
(
lat
,
M_PI_2
))
// this could (unlikely) be a problem, replace with different coordinate transformation
return
QGeoCoordinate
(
/* lat */
qAtan
(
x
/
cos
(
lat
)
/
earthRadius
)
+
lon
,
/* lon */
qAtan
(
y
/
earthRadius
)
+
lat
,
/* alt */
h
+
z
);
else
return
QGeoCoordinate
();
// singularity occurred (1/cos(pi/2) = inf)
}
QVector3D
GeoUtilites
::
toCartesian
(
const
QGeoCoordinate
&
point
,
const
QGeoCoordinate
&
origin
)
{
double
lat
=
point
.
latitude
()
/
180
*
M_PI
;
double
lon
=
point
.
longitude
()
/
180
*
M_PI
;
double
h
=
point
.
altitude
();
double
latO
=
origin
.
latitude
()
/
180
*
M_PI
;
double
lonO
=
origin
.
longitude
()
/
180
*
M_PI
;
double
hO
=
origin
.
altitude
();
double
dlon
=
lon
-
lonO
;
double
dlat
=
lat
-
latO
;
if
(
!
qFuzzyCompare
(
dlon
,
M_PI_2
)
&&
!
qFuzzyCompare
(
dlat
,
M_PI_2
))
return
QVector3D
(
/* x */
qTan
(
dlon
)
*
earthRadius
*
qCos
(
latO
),
/* y */
qTan
(
dlat
)
*
earthRadius
,
/* z */
h
-
hO
);
else
return
QVector3D
();
// singularity occurred (tan(pi/2) = inf)
}
GeoUtilites
::
QGeoList
GeoUtilites
::
toGeo
(
const
GeoUtilites
::
QVector3DFList
&
points
,
const
QGeoCoordinate
&
origin
)
{
GeoUtilites
::
QGeoList
coordinates
;
for
(
auto
point
:
points
)
coordinates
.
append
(
toGeo
(
point
,
origin
));
return
coordinates
;
}
GeoUtilites
::
QVector3DFList
GeoUtilites
::
toCartesian
(
const
GeoUtilites
::
QGeoList
&
coordinates
,
const
QGeoCoordinate
&
origin
)
{
GeoUtilites
::
QVector3DFList
points
;
for
(
auto
coordinate
:
coordinates
)
points
.
append
(
toCartesian
(
coordinate
,
origin
));
return
points
;
}
src/Wima/GeoUtilities.h
0 → 100644
View file @
8d84693d
#ifndef GEOPOLYGONUTILITIES_H
#define GEOPOLYGONUTILITIES_H
#include <QPointF>
#include <QGeoCoordinate>
#include <QVector3D>
#include <QGeoCoordinate>
namespace
GeoUtilites
{
typedef
QList
<
QVector3D
>
QVector3DFList
;
typedef
QList
<
QGeoCoordinate
>
QGeoList
;
const
double
earthRadius
=
6378137
;
// meter
QGeoCoordinate
toGeo
(
const
QVector3D
&
point
,
const
QGeoCoordinate
&
origin
);
QGeoList
toGeo
(
const
QVector3DFList
&
points
,
const
QGeoCoordinate
&
origin
);
QVector3D
toCartesian
(
const
QGeoCoordinate
&
point
,
const
QGeoCoordinate
&
origin
);
QVector3DFList
toCartesian
(
const
QGeoList
&
coordinates
,
const
QGeoCoordinate
&
origin
);
}
#endif // GEOPOLYGONUTILITIES_H
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment