Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gk
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
micro_app
gk
Commits
bfde63a4
Commit
bfde63a4
authored
Apr 30, 2020
by
yangshuxing
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
af108c86
7c38ca7c
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
137 additions
and
28 deletions
+137
-28
GpsTransform.java
...om/dlbridge/jadp/plugins/cmpt/utils/gps/GpsTransform.java
+89
-21
GpxParserUtil.java
...m/dlbridge/jadp/plugins/cmpt/utils/gps/GpxParserUtil.java
+4
-4
KmlParserUtil.java
...m/dlbridge/jadp/plugins/cmpt/utils/gps/KmlParserUtil.java
+2
-2
PlaceMark.java
...a/com/dlbridge/jadp/plugins/cmpt/utils/gps/PlaceMark.java
+21
-0
TracePoint.java
.../com/dlbridge/jadp/plugins/cmpt/utils/gps/TracePoint.java
+20
-0
application.properties
src/main/resources/application.properties
+1
-1
No files found.
src/main/java/com/dlbridge/jadp/plugins/cmpt/utils/gps/Gps
2Baidu
.java
→
src/main/java/com/dlbridge/jadp/plugins/cmpt/utils/gps/Gps
Transform
.java
View file @
bfde63a4
...
...
@@ -4,18 +4,10 @@ package com.dlbridge.jadp.plugins.cmpt.utils.gps;
import
java.util.List
;
/**
* Gps坐标转换为百度坐标
* WGS84坐标系:即地球坐标系,国际上通用的坐标系。设备一般包含GPS芯片或者北斗芯片获取的经纬度为WGS84地理坐标系,谷歌地图采用的是WGS84地理坐标系(中国范围除外);
*
*/
public
class
Gps2Baidu
{
public
static
Point
gpsToBD
(
double
gps_lat
,
double
gps_lon
)
{
Point
bdPoint
=
new
Point
();
Point
marPoint
=
new
Point
();
EvilTransform
.
gpsToMars
(
gps_lat
,
gps_lon
,
marPoint
);
EvilTransform
.
marsToBD
(
marPoint
.
getLat
(),
marPoint
.
getLon
(),
bdPoint
);
return
bdPoint
;
}
public
class
GpsTransform
{
/**
* 路标点转成百度坐标
*/
...
...
@@ -40,17 +32,75 @@ public class Gps2Baidu {
return
tracePointList
;
}
/**
* 路标点转成火星坐标系
*/
public
static
List
<
PlaceMark
>
placeMarker2Mar
(
List
<
PlaceMark
>
placeMarkList
)
{
for
(
PlaceMark
pm
:
placeMarkList
)
{
Point
marPoint
=
gpsToMar
(
pm
.
getLatitude
(),
pm
.
getLongitude
());
pm
.
setMarLat
(
marPoint
.
getLat
());
pm
.
setMarLng
(
marPoint
.
getLon
());
}
return
placeMarkList
;
}
/**
* 轨迹点转成火星坐标系
*/
public
static
List
<
TracePoint
>
tracePoint2Mar
(
List
<
TracePoint
>
tracePointList
)
{
for
(
TracePoint
tp
:
tracePointList
)
{
Point
marPoint
=
gpsToMar
(
tp
.
getLatitude
(),
tp
.
getLongitude
());
tp
.
setMarLat
(
marPoint
.
getLat
());
tp
.
setMarLng
(
marPoint
.
getLon
());
}
return
tracePointList
;
}
/**
* 原始坐标系转为为百度坐标系
* @param gps_lat
* @param gps_lon
* @return
*/
public
static
Point
gpsToBD
(
double
gps_lat
,
double
gps_lon
)
{
Point
bdPoint
=
new
Point
();
Point
marPoint
=
new
Point
();
EvilTransform
.
gpsToMars
(
gps_lat
,
gps_lon
,
marPoint
);
EvilTransform
.
marsToBD
(
marPoint
.
getLat
(),
marPoint
.
getLon
(),
bdPoint
);
return
bdPoint
;
}
/**
* 地球坐标系转为火星坐标系
* @param gps_lat
* @param gps_lon
* @return
*/
public
static
Point
gpsToMar
(
double
gps_lat
,
double
gps_lon
){
Point
marPoint
=
new
Point
();
EvilTransform
.
gpsToMars
(
gps_lat
,
gps_lon
,
marPoint
);
return
marPoint
;
}
/**
* 转化经纬度坐标的内部类
*/
static
class
EvilTransform
{
static
double
pi
=
3.14159265358979324
;
// Krasovsky 1940
// a = 6378245.0, 1/f = 298.3
// b = a * (1 - f)
// ee = (a^2 - b^2) / a^2;
static
double
a
=
6378245.0
;
static
double
ee
=
0.00669342162296594323
;
// World Geodetic System ==> Mars Geodetic System
/**
* 地球坐标系转为火星坐标系
* World Geodetic System ==> Mars Geodetic System
* @param wgLat
* @param wgLon
* @param marPoint
*/
public
static
void
gpsToMars
(
double
wgLat
,
double
wgLon
,
Point
marPoint
)
{
if
(
outOfChina
(
wgLat
,
wgLon
))
{
marPoint
.
setLat
(
wgLat
);
...
...
@@ -68,8 +118,13 @@ public class Gps2Baidu {
marPoint
.
setLat
(
wgLat
+
dLat
);
marPoint
.
setLon
(
wgLon
+
dLon
);
}
// Mars Geodetic System ==> baidu Geodetic System
/**
* 火星坐标系转为百度坐标系
* Mars Geodetic System ==> baidu Geodetic System
* @param mar_lat
* @param mar_lon
* @param bdpoint
*/
static
void
marsToBD
(
double
mar_lat
,
double
mar_lon
,
Point
bdpoint
)
{
double
x_pi
=
3.14159265358979324
*
3000.0
/
180.0
;
double
x
=
mar_lon
,
y
=
mar_lat
;
...
...
@@ -78,7 +133,12 @@ public class Gps2Baidu {
bdpoint
.
setLon
(
z
*
Math
.
cos
(
theta
)
+
0.0065
);
bdpoint
.
setLat
(
z
*
Math
.
sin
(
theta
)
+
0.006
);
}
/**
* 判断是不是不在中国,不在中国直接设置,国内要做偏移算法
* @param lat
* @param lon
* @return
*/
static
boolean
outOfChina
(
double
lat
,
double
lon
)
{
if
(
lon
<
72.004
||
lon
>
137.8347
)
return
true
;
...
...
@@ -86,7 +146,12 @@ public class Gps2Baidu {
return
true
;
return
false
;
}
/**
* 转化纬度的方法
* @param x
* @param y
* @return
*/
static
double
transformLat
(
double
x
,
double
y
)
{
double
ret
=
-
100.0
+
2.0
*
x
+
3.0
*
y
+
0.2
*
y
*
y
+
0.1
*
x
*
y
+
0.2
*
Math
.
sqrt
(
Math
.
abs
(
x
));
...
...
@@ -97,7 +162,12 @@ public class Gps2Baidu {
/
30.0
))
*
2.0
/
3.0
;
return
ret
;
}
/**
* 转化经度的方法
* @param x
* @param y
* @return
*/
static
double
transformLon
(
double
x
,
double
y
)
{
double
ret
=
300.0
+
x
+
2.0
*
y
+
0.1
*
x
*
x
+
0.1
*
x
*
y
+
0.1
*
Math
.
sqrt
(
Math
.
abs
(
x
));
...
...
@@ -108,7 +178,5 @@ public class Gps2Baidu {
*
pi
))
*
2.0
/
3.0
;
return
ret
;
}
}
}
src/main/java/com/dlbridge/jadp/plugins/cmpt/utils/gps/GpxParserUtil.java
View file @
bfde63a4
...
...
@@ -78,10 +78,10 @@ public class GpxParserUtil {
place
.
setAltitude
(
Float
.
parseFloat
(
altitude
));
route
.
getPlaceMark
().
add
(
place
);
}
// 轨迹点转换
百度
坐标系
route
.
setTracePoint
(
Gps
2Baidu
.
tracePoint2Baidu
(
route
.
getTracePoint
()));
// 路标转
百度坐标
route
.
setPlaceMark
(
Gps
2Baidu
.
placeMarker2Baidu
(
route
.
getPlaceMark
()));
// 轨迹点转换
火星坐标系,本系统小程序使用的火星
坐标系
route
.
setTracePoint
(
Gps
Transform
.
tracePoint2Mar
(
route
.
getTracePoint
()));
// 路标转
化为火星坐标系,本系统小程序使用的火星坐标系
route
.
setPlaceMark
(
Gps
Transform
.
placeMarker2Mar
(
route
.
getPlaceMark
()));
}
catch
(
Exception
e
)
{
logger
.
info
(
"parseGpx --"
+
e
.
getMessage
());
}
...
...
src/main/java/com/dlbridge/jadp/plugins/cmpt/utils/gps/KmlParserUtil.java
View file @
bfde63a4
...
...
@@ -104,9 +104,9 @@ public class KmlParserUtil {
// 轨迹点转换百度坐标系
route
.
setTracePoint
(
Gps
2Baidu
.
tracePoint2Baidu
(
route
.
getTracePoint
()));
route
.
setTracePoint
(
Gps
Transform
.
tracePoint2Baidu
(
route
.
getTracePoint
()));
// 路标转百度坐标
route
.
setPlaceMark
(
Gps
2Baidu
.
placeMarker2Baidu
(
route
.
getPlaceMark
()));
route
.
setPlaceMark
(
Gps
Transform
.
placeMarker2Baidu
(
route
.
getPlaceMark
()));
}
catch
(
Exception
e
)
{
...
...
src/main/java/com/dlbridge/jadp/plugins/cmpt/utils/gps/PlaceMark.java
View file @
bfde63a4
...
...
@@ -22,6 +22,12 @@ public class PlaceMark {
// 百度坐标系纬度
private
double
baiduLng
;
//火星坐标系的经度
private
double
marLat
;
//火星坐标系的维度
private
double
marLng
;
// 海拔
private
double
altitude
;
...
...
@@ -84,4 +90,19 @@ public class PlaceMark {
this
.
type
=
type
;
}
public
double
getMarLat
()
{
return
marLat
;
}
public
void
setMarLat
(
double
marLat
)
{
this
.
marLat
=
marLat
;
}
public
double
getMarLng
()
{
return
marLng
;
}
public
void
setMarLng
(
double
marLng
)
{
this
.
marLng
=
marLng
;
}
}
src/main/java/com/dlbridge/jadp/plugins/cmpt/utils/gps/TracePoint.java
View file @
bfde63a4
...
...
@@ -10,6 +10,11 @@ public class TracePoint {
private
double
baiduLat
;
// 百度坐标系纬度
private
double
baiduLng
;
// 火星坐标系经度
private
double
marLat
;
// 火星坐标系纬度
private
double
marLng
;
//海拔
private
float
altitude
;
// 时间戳
...
...
@@ -74,4 +79,19 @@ public class TracePoint {
this
.
altitude
=
altitude
;
}
public
double
getMarLat
()
{
return
marLat
;
}
public
void
setMarLat
(
double
marLat
)
{
this
.
marLat
=
marLat
;
}
public
double
getMarLng
()
{
return
marLng
;
}
public
void
setMarLng
(
double
marLng
)
{
this
.
marLng
=
marLng
;
}
}
src/main/resources/application.properties
View file @
bfde63a4
spring.profiles.active
=
dev
spring.profiles.active
=
test
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