Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
eshiled-new
/
ne-shield-trialdrive-admin
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 4895bd4c
authored
Jan 22, 2025
by
谢海旭
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'develop' into 'master'
v1.77.0 地图切换版本代码合并 See merge request
!3
2 parents
4b2f6bcf
f7cb3408
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
226 additions
and
4 deletions
src/main/java/cn/com/glsx/admin/modules/component/EFenceComponent.java
src/main/java/cn/com/glsx/admin/modules/converter/RiskAssessmentConvert.java
src/main/java/cn/com/glsx/admin/modules/model/imports/VehicleInfoImportListener.java
src/main/java/cn/com/glsx/admin/modules/model/vo/StayPointListVO.java
src/main/java/cn/com/glsx/admin/modules/service/RiskAssessmentService.java
src/main/java/cn/com/glsx/admin/modules/utils/GPSUtil.java
src/main/java/cn/com/glsx/admin/modules/component/EFenceComponent.java
View file @
4895bd4
...
...
@@ -8,6 +8,7 @@ import cn.com.glsx.admin.modules.mapper.DeviceMapper;
import
cn.com.glsx.admin.modules.mapper.ElectricFenceSnsMapper
;
import
cn.com.glsx.admin.modules.protobuf.ElectricFence.*
;
import
cn.com.glsx.admin.modules.utils.GCJ2WGS
;
import
cn.com.glsx.admin.modules.utils.GPSUtil
;
import
cn.hutool.json.JSONUtil
;
import
com.alibaba.fastjson.JSON
;
import
com.glsx.plat.common.utils.StringUtils
;
...
...
@@ -310,9 +311,9 @@ public class EFenceComponent {
String
[]
latString
=
lnglat
.
split
(
","
);
double
lng
=
Double
.
valueOf
(
latString
[
0
]);
double
lat
=
Double
.
valueOf
(
latString
[
1
]);
HashMap
<
String
,
Double
>
hm
=
GW_CONVERT
.
delta
(
lat
,
lng
);
gpsLocBuilder
.
setLat
((
int
)
(
hm
.
get
(
"lat"
)
*
1000000
));
gpsLocBuilder
.
setLng
((
int
)
(
hm
.
get
(
"lon"
)
*
1000000
));
GPSUtil
.
Point
point
=
GPSUtil
.
bd09ToWgs84
(
lat
,
lng
);
gpsLocBuilder
.
setLat
((
int
)
(
point
.
getLat
(
)
*
1000000
));
gpsLocBuilder
.
setLng
((
int
)
(
point
.
getLng
(
)
*
1000000
));
return
gpsLocBuilder
.
build
();
}
...
...
src/main/java/cn/com/glsx/admin/modules/converter/RiskAssessmentConvert.java
View file @
4895bd4
...
...
@@ -29,6 +29,8 @@ public class RiskAssessmentConvert {
stayPointListVO
.
setLocationType
(
"GPS"
);
Optional
.
of
(
stayPointRecordDTO
).
map
(
StayPointRecordDTO:
:
getStayGps
).
map
(
GpsLocation:
:
getElat
).
ifPresent
(
stayPointListVO:
:
setElat
);
Optional
.
of
(
stayPointRecordDTO
).
map
(
StayPointRecordDTO:
:
getStayGps
).
map
(
GpsLocation:
:
getElng
).
ifPresent
(
stayPointListVO:
:
setElng
);
Optional
.
of
(
stayPointRecordDTO
).
map
(
StayPointRecordDTO:
:
getStayGps
).
map
(
GpsLocation:
:
getBlat
).
ifPresent
(
stayPointListVO:
:
setBlat
);
Optional
.
of
(
stayPointRecordDTO
).
map
(
StayPointRecordDTO:
:
getStayGps
).
map
(
GpsLocation:
:
getBlng
).
ifPresent
(
stayPointListVO:
:
setBlng
);
stayPointListVO
.
setAddress
(
address
);
return
stayPointListVO
;
}
...
...
src/main/java/cn/com/glsx/admin/modules/model/imports/VehicleInfoImportListener.java
View file @
4895bd4
...
...
@@ -228,6 +228,7 @@ public class VehicleInfoImportListener extends AnalysisEventListener<VehicleInfo
List
<
VehicleInfoImport
>
fails
=
new
ArrayList
<>();
List
<
String
>
importSnList
=
new
ArrayList
<>();
// TODO 多线程获取登录用户信息会报错(目前没版本号修复)
Set
<
Long
>
userIds
=
ShieldContextHolder
.
getVisibleCreatorIds
();
log
.
info
(
"import vehicle user creatorIds:{}"
,
JSONObject
.
toJSONString
(
userIds
));
Map
<
String
,
User
>
authUserMapper
=
remoteUserApiService
.
getUserListByUserIds
(
ShieldContextHolder
.
getVisibleCreatorIds
());
...
...
src/main/java/cn/com/glsx/admin/modules/model/vo/StayPointListVO.java
View file @
4895bd4
...
...
@@ -84,6 +84,18 @@ public class StayPointListVO implements Serializable {
private
String
elng
;
/**
* 停留纬度-百度
* */
@ApiModelProperty
(
value
=
"停留纬度-百度"
)
private
String
blat
;
/**
* 停留经度-百度
* */
@ApiModelProperty
(
value
=
"停留经度-百度"
)
private
String
blng
;
/**
* 停留地址
* */
@ApiModelProperty
(
value
=
"停留地址"
)
...
...
src/main/java/cn/com/glsx/admin/modules/service/RiskAssessmentService.java
View file @
4895bd4
...
...
@@ -157,7 +157,10 @@ public class RiskAssessmentService {
List
<
LngLatDTO
>
lngLats
=
stayPointRecordList
.
stream
().
filter
(
e
->
Objects
.
nonNull
(
e
.
getStayGps
())).
map
(
e
->
new
LngLatDTO
(
e
.
getStayGps
().
getElng
(),
e
.
getStayGps
().
getElat
())).
collect
(
Collectors
.
toList
());
LngLatAddressDTO
addressDTO
=
remoteGpsBsService
.
getAddressMap
(
lngLats
);
Map
<
String
,
String
>
addressMap
=
Optional
.
ofNullable
(
addressDTO
).
map
(
LngLatAddressDTO:
:
getAddress
).
orElse
(
Maps
.
newHashMap
());
return
stayPointRecordList
.
stream
().
map
(
stayPoint
->
RiskAssessmentConvert
.
buildStayPointListVO
(
stayPoint
,
vehicle
,
sn
,
Optional
.
ofNullable
(
stayPoint
.
getStayGps
()).
map
(
e
->
e
.
getElat
()
+
e
.
getElng
()).
map
(
addressMap:
:
get
).
orElse
(
Constants
.
EMPTY_CONTENT_EXCEL
))).
collect
(
Collectors
.
toList
());
return
stayPointRecordList
.
stream
().
map
(
stayPoint
->
RiskAssessmentConvert
.
buildStayPointListVO
(
stayPoint
,
vehicle
,
sn
,
Optional
.
ofNullable
(
stayPoint
.
getStayGps
()).
map
(
e
->
e
.
getElat
()
+
e
.
getElng
()).
map
(
addressMap:
:
get
).
orElse
(
Constants
.
EMPTY_CONTENT_EXCEL
)))
.
collect
(
Collectors
.
toList
());
}
/**
...
...
src/main/java/cn/com/glsx/admin/modules/utils/GPSUtil.java
0 → 100644
View file @
4895bd4
package
cn
.
com
.
glsx
.
admin
.
modules
.
utils
;
import
com.alibaba.fastjson.JSON
;
/**
* 坐标转换工具
*/
public
class
GPSUtil
{
public
static
double
pi
=
3.1415926535897932384626
;
public
static
double
x_pi
=
3.14159265358979324
*
3000.0
/
180.0
;
public
static
double
a
=
6378245.0
;
public
static
double
ee
=
0.00669342162296594323
;
public
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
));
ret
+=
(
20.0
*
Math
.
sin
(
6.0
*
x
*
pi
)
+
20.0
*
Math
.
sin
(
2.0
*
x
*
pi
))
*
2.0
/
3.0
;
ret
+=
(
20.0
*
Math
.
sin
(
y
*
pi
)
+
40.0
*
Math
.
sin
(
y
/
3.0
*
pi
))
*
2.0
/
3.0
;
ret
+=
(
160.0
*
Math
.
sin
(
y
/
12.0
*
pi
)
+
320
*
Math
.
sin
(
y
*
pi
/
30.0
))
*
2.0
/
3.0
;
return
ret
;
}
public
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
));
ret
+=
(
20.0
*
Math
.
sin
(
6.0
*
x
*
pi
)
+
20.0
*
Math
.
sin
(
2.0
*
x
*
pi
))
*
2.0
/
3.0
;
ret
+=
(
20.0
*
Math
.
sin
(
x
*
pi
)
+
40.0
*
Math
.
sin
(
x
/
3.0
*
pi
))
*
2.0
/
3.0
;
ret
+=
(
150.0
*
Math
.
sin
(
x
/
12.0
*
pi
)
+
300.0
*
Math
.
sin
(
x
/
30.0
*
pi
))
*
2.0
/
3.0
;
return
ret
;
}
public
static
double
[]
transform
(
double
lat
,
double
lon
)
{
if
(
outOfChina
(
lat
,
lon
))
{
return
new
double
[]{
lat
,
lon
};
}
double
dLat
=
transformLat
(
lon
-
105.0
,
lat
-
35.0
);
double
dLon
=
transformLon
(
lon
-
105.0
,
lat
-
35.0
);
double
radLat
=
lat
/
180.0
*
pi
;
double
magic
=
Math
.
sin
(
radLat
);
magic
=
1
-
ee
*
magic
*
magic
;
double
sqrtMagic
=
Math
.
sqrt
(
magic
);
dLat
=
(
dLat
*
180.0
)
/
((
a
*
(
1
-
ee
))
/
(
magic
*
sqrtMagic
)
*
pi
);
dLon
=
(
dLon
*
180.0
)
/
(
a
/
sqrtMagic
*
Math
.
cos
(
radLat
)
*
pi
);
double
mgLat
=
lat
+
dLat
;
double
mgLon
=
lon
+
dLon
;
return
new
double
[]{
mgLat
,
mgLon
};
}
public
static
boolean
outOfChina
(
double
lat
,
double
lon
)
{
if
(
lon
<
72.004
||
lon
>
137.8347
)
return
true
;
if
(
lat
<
0.8293
||
lat
>
55.8271
)
return
true
;
return
false
;
}
/**
* 84 to 火星坐标系 (GCJ-02) World Geodetic System ==> Mars Geodetic System
*
* @param lat
* @param lon
* @return
*/
public
static
Point
wgs84ToGcj02
(
double
lat
,
double
lon
)
{
if
(
outOfChina
(
lat
,
lon
))
{
return
new
Point
(
lon
,
lat
);
}
double
dLat
=
transformLat
(
lon
-
105.0
,
lat
-
35.0
);
double
dLon
=
transformLon
(
lon
-
105.0
,
lat
-
35.0
);
double
radLat
=
lat
/
180.0
*
pi
;
double
magic
=
Math
.
sin
(
radLat
);
magic
=
1
-
ee
*
magic
*
magic
;
double
sqrtMagic
=
Math
.
sqrt
(
magic
);
dLat
=
(
dLat
*
180.0
)
/
((
a
*
(
1
-
ee
))
/
(
magic
*
sqrtMagic
)
*
pi
);
dLon
=
(
dLon
*
180.0
)
/
(
a
/
sqrtMagic
*
Math
.
cos
(
radLat
)
*
pi
);
double
mgLat
=
lat
+
dLat
;
double
mgLon
=
lon
+
dLon
;
return
new
Point
(
mgLon
,
mgLat
);
}
/**
* * 火星坐标系 (GCJ-02) to 84 * * @param lon * @param lat * @return
* */
public
static
Point
gcj02ToWgs84
(
double
lat
,
double
lon
)
{
double
[]
gps
=
transform
(
lat
,
lon
);
double
longitude
=
lon
*
2
-
gps
[
1
];
double
latitude
=
lat
*
2
-
gps
[
0
];
return
new
Point
(
longitude
,
latitude
);
}
/**
* 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法 将 GCJ-02 坐标转换成 BD-09 坐标
*
* @param lat
* @param lon
*/
public
static
Point
gcj02ToBd09
(
double
lat
,
double
lon
)
{
double
x
=
lon
,
y
=
lat
;
double
z
=
Math
.
sqrt
(
x
*
x
+
y
*
y
)
+
0.00002
*
Math
.
sin
(
y
*
x_pi
);
double
theta
=
Math
.
atan2
(
y
,
x
)
+
0.000003
*
Math
.
cos
(
x
*
x_pi
);
double
tempLon
=
z
*
Math
.
cos
(
theta
)
+
0.0065
;
double
tempLat
=
z
*
Math
.
sin
(
theta
)
+
0.006
;
return
new
Point
(
tempLon
,
tempLat
);
}
/**
* * 火星坐标系 (GCJ-02) 与百度坐标系 (BD-09) 的转换算法 * * 将 BD-09 坐标转换成GCJ-02 坐标 * * @param
* bd_lat * @param bd_lon * @return
*/
public
static
Point
bd09ToGcj02
(
double
lat
,
double
lon
)
{
double
x
=
lon
-
0.0065
,
y
=
lat
-
0.006
;
double
z
=
Math
.
sqrt
(
x
*
x
+
y
*
y
)
-
0.00002
*
Math
.
sin
(
y
*
x_pi
);
double
theta
=
Math
.
atan2
(
y
,
x
)
-
0.000003
*
Math
.
cos
(
x
*
x_pi
);
double
tempLon
=
z
*
Math
.
cos
(
theta
);
double
tempLat
=
z
*
Math
.
sin
(
theta
);
return
new
Point
(
tempLon
,
tempLat
);
}
/**将gps84转为bd09
* @param lat
* @param lon
* @return
*/
public
static
Point
wgs84ToBd09
(
double
lat
,
double
lon
){
Point
gcj02
=
wgs84ToGcj02
(
lat
,
lon
);
Point
bd09
=
gcj02ToBd09
(
gcj02
.
getLat
(),
gcj02
.
getLng
());
return
bd09
;
}
public
static
Point
bd09ToWgs84
(
double
lat
,
double
lon
){
Point
gcj02
=
bd09ToGcj02
(
lat
,
lon
);
Point
wgs84
=
gcj02ToWgs84
(
gcj02
.
getLat
(),
gcj02
.
getLng
());
//保留小数点后六位
wgs84
.
setLng
(
retain6
(
wgs84
.
getLng
()));
wgs84
.
setLat
(
retain6
(
wgs84
.
getLat
()));
return
wgs84
;
}
/**保留小数点后六位
* @param num
* @return
*/
private
static
double
retain6
(
double
num
){
String
result
=
String
.
format
(
"%.6f"
,
num
);
return
Double
.
valueOf
(
result
);
}
public
static
class
Point
{
/**
* 经度
*/
private
double
lng
;
/**
* 维度
*/
private
double
lat
;
/**
* @param lng 经度
* @param lat 维度
*/
public
Point
(
double
lng
,
double
lat
)
{
this
.
lng
=
lng
;
this
.
lat
=
lat
;
}
public
double
getLng
()
{
return
lng
;
}
public
void
setLng
(
double
lng
)
{
this
.
lng
=
lng
;
}
public
double
getLat
()
{
return
lat
;
}
public
void
setLat
(
double
lat
)
{
this
.
lat
=
lat
;
}
}
public
static
void
main
(
String
[]
args
)
{
// 百度坐标
double
longitude
=
115.909276
;
double
latitude
=
28.695681
;
// 百度坐标转火星坐标系
// Point gcj02 = bd09ToGcj02(latitude, longitude);
// System.out.println("JSON.toJSONString(gcj02) = " + JSON.toJSONString(gcj02));
// 火星坐标转原始坐标
// Point wgs84 = gcj02ToWgs84(gcj02.getLat(), gcj02.getLng());
// System.out.println("JSON.toJSONString(wgs84) = " + JSON.toJSONString(wgs84));
// 百度转原始坐标
Point
wgs84
=
bd09ToWgs84
(
latitude
,
longitude
);
System
.
out
.
println
(
"JSON.toJSONString(wgs84) = "
+
JSON
.
toJSONString
(
wgs84
));
// 高德坐标
// double longitude = 115.902842;
// double latitude = 28.689345;
// Point bd09 = gcj02ToBd09(latitude, longitude);
// System.out.println("JSON.toJSONString(bd09) = " + JSON.toJSONString(bd09));
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
Attach a file
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 post a comment