Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
traffic-signal-platform
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
signal
traffic-signal-platform
Commits
f45fa8dd
Commit
f45fa8dd
authored
May 17, 2023
by
hanbing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[add] 快速特勤,备选路线路网不连续异常处理
parent
423c806f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
12 deletions
+57
-12
SpecialServiceServiceImpl.java
...net/wanji/web/service/impl/SpecialServiceServiceImpl.java
+57
-12
No files found.
signal-control-service/src/main/java/net/wanji/web/service/impl/SpecialServiceServiceImpl.java
View file @
f45fa8dd
...
...
@@ -402,7 +402,7 @@ public class SpecialServiceServiceImpl implements SpecialServiceService {
String
location
=
baseCrossInfoPO
.
getLocation
();
double
[]
lonLat
=
CrossUtil
.
getLonLat
(
location
);
String
ridPointLonLat
=
lonLat
[
0
]
+
","
+
lonLat
[
1
];
double
distance
=
gtsService
.
distance
(
start
LonLat
,
ridPointLonLat
);
double
distance
=
gtsService
.
distance
(
end
LonLat
,
ridPointLonLat
);
endMinDistance
=
Math
.
min
(
endMinDistance
,
distance
);
if
(
distance
==
endMinDistance
)
{
endCross
=
baseCrossInfoPO
;
...
...
@@ -430,9 +430,15 @@ public class SpecialServiceServiceImpl implements SpecialServiceService {
distanceList
.
add
(
distance
);
}
Collections
.
sort
(
distanceList
);
BaseCrossInfoPO
secondStartCross
=
distanceMap
.
get
(
distanceList
.
get
(
1
));
List
<
BaseCrossInfoPO
>
routeList2
=
getRouteList
(
secondStartCross
,
endCross
);
routeList2
.
add
(
0
,
startCross
);
BaseCrossInfoPO
secondStartCross
=
null
;
try
{
secondStartCross
=
distanceMap
.
get
(
distanceList
.
get
(
1
));
}
catch
(
IndexOutOfBoundsException
e
)
{
throw
new
RuntimeException
(
"路网数据不连续"
);
}
List
<
BaseCrossInfoPO
>
routeList2
=
new
ArrayList
<>();
routeList2
.
add
(
startCross
);
getSecondRouteList
(
secondStartCross
,
endCross
,
routeList2
);
List
<
RouteElementVO
>
route2
=
buildRoute
(
routeList2
);
res
.
add
(
route1
);
...
...
@@ -442,6 +448,44 @@ public class SpecialServiceServiceImpl implements SpecialServiceService {
return
null
;
}
private
void
getSecondRouteList
(
BaseCrossInfoPO
secondStartCross
,
BaseCrossInfoPO
endCross
,
List
<
BaseCrossInfoPO
>
routeList2
)
{
String
endCrossLonLatStr
=
getCrossLonLatStr
(
endCross
);
// 获取上游路口到终点距离最近的
BaseCrossInfoPO
nextStartCross
=
secondStartCross
;
while
(
ObjectUtil
.
notEqual
(
endCross
.
getId
(),
nextStartCross
.
getId
()))
{
String
nextCrossId
=
nextStartCross
.
getId
();
double
minDistance
=
Double
.
MAX_VALUE
;
List
<
RidInfoEntity
>
ridUpCrossList
=
ridInfoMapper
.
selectUpCross
(
nextStartCross
.
getId
());
for
(
RidInfoEntity
ridUpCross
:
ridUpCrossList
)
{
String
upCrossId
=
ridUpCross
.
getStartCrossId
();
BaseCrossInfoPO
upCross
=
baseCrossInfoMapper
.
selectById
(
upCrossId
);
String
upCrossLonLatStr
=
getCrossLonLatStr
(
upCross
);
double
distance
=
gtsService
.
distance
(
endCrossLonLatStr
,
upCrossLonLatStr
);
minDistance
=
Math
.
min
(
minDistance
,
distance
);
if
(
minDistance
==
distance
&&
!
hasCross
(
routeList2
,
upCross
))
{
// 已选过的路口不可再选
nextStartCross
=
upCross
;
}
}
if
(
ObjectUtil
.
equal
(
nextStartCross
.
getId
(),
nextCrossId
))
{
throw
new
RuntimeException
(
"路网数据不连续"
);
}
routeList2
.
add
(
nextStartCross
);
}
routeList2
.
add
(
1
,
secondStartCross
);
}
private
boolean
hasCross
(
List
<
BaseCrossInfoPO
>
routeList
,
BaseCrossInfoPO
upCross
)
{
for
(
BaseCrossInfoPO
baseCrossInfoPO
:
routeList
)
{
String
id
=
baseCrossInfoPO
.
getId
();
String
upCrossId
=
upCross
.
getId
();
if
(
ObjectUtil
.
equal
(
id
,
upCrossId
))
{
return
true
;
}
}
return
false
;
}
@Override
public
void
isValidPoint
(
IsValidPointBO
isValidPointBO
)
{
String
lonLat
=
isValidPointBO
.
getLonLat
();
...
...
@@ -469,28 +513,29 @@ public class SpecialServiceServiceImpl implements SpecialServiceService {
@NotNull
private
List
<
BaseCrossInfoPO
>
getRouteList
(
BaseCrossInfoPO
startCross
,
BaseCrossInfoPO
endCross
)
{
String
endCrossLonLatStr
=
getCrossLonLatStr
(
endCross
);
// 获取起点路口所有上游路口
String
startCrossId
=
startCross
.
getId
();
List
<
RidInfoEntity
>
ridUpCrossList
=
ridInfoMapper
.
selectUpCross
(
startCrossId
);
// 获取上有路口到终点距离最近的
// 获取上游路口到终点距离最近的
BaseCrossInfoPO
nextStartCross
=
startCross
;
List
<
BaseCrossInfoPO
>
routeList
=
new
ArrayList
<>();
routeList
.
add
(
nextStartCross
);
while
(
ObjectUtil
.
notEqual
(
endCross
,
nextStartCross
))
{
while
(
ObjectUtil
.
notEqual
(
endCross
.
getId
(),
nextStartCross
.
getId
()))
{
String
nextCrossId
=
nextStartCross
.
getId
();
double
minDistance
=
Double
.
MAX_VALUE
;
List
<
RidInfoEntity
>
ridUpCrossList
=
ridInfoMapper
.
selectUpCross
(
nextStartCross
.
getId
());
for
(
RidInfoEntity
ridUpCross
:
ridUpCrossList
)
{
String
upCrossId
=
ridUpCross
.
getStartCrossId
();
BaseCrossInfoPO
upCross
=
baseCrossInfoMapper
.
selectById
(
upCrossId
);
String
upCrossLonLatStr
=
getCrossLonLatStr
(
upCross
);
double
distance
=
gtsService
.
distance
(
endCrossLonLatStr
,
upCrossLonLatStr
);
minDistance
=
Math
.
min
(
minDistance
,
distance
);
if
(
minDistance
==
distance
&&
!
routeList
.
contains
(
nextStart
Cross
))
{
// 已选过的路口不可再选
if
(
minDistance
==
distance
&&
!
hasCross
(
routeList
,
up
Cross
))
{
// 已选过的路口不可再选
nextStartCross
=
upCross
;
}
}
if
(
ObjectUtil
.
equal
(
nextStartCross
.
getId
(),
nextCrossId
))
{
throw
new
RuntimeException
(
"路网数据不连续"
);
}
routeList
.
add
(
nextStartCross
);
}
routeList
.
add
(
end
Cross
);
routeList
.
add
(
0
,
start
Cross
);
return
routeList
;
}
...
...
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