Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
W
wj-datacenter-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
jinan
wj-datacenter-platform
Commits
545be8ca
Commit
545be8ca
authored
Nov 15, 2023
by
hanbing
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
保存方向级别拥堵信息
parent
9b89cea1
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
619 additions
and
418 deletions
+619
-418
Constant.java
...src/main/java/com/wanji/indicators/constant/Constant.java
+5
-0
CarTrajectoryIndexMain.java
...ji/indicators/task/trajectory/CarTrajectoryIndexMain.java
+384
-382
CarDataValidatorFlatMap.java
...icators/task/trajectory/func/CarDataValidatorFlatMap.java
+1
-1
CoordCongestionDataFunction.java
...ors/task/trajectory/func/CoordCongestionDataFunction.java
+95
-0
VehicleGapTimeProcessFunction.java
...s/task/trajectory/func/VehicleGapTimeProcessFunction.java
+102
-24
RidIndexResult.java
...wanji/indicators/task/trajectory/pojo/RidIndexResult.java
+7
-1
StartDuration.java
.../wanji/indicators/task/trajectory/pojo/StartDuration.java
+13
-0
config.properties
wj-realtime-computing/src/main/resources/config.properties
+9
-7
ReadMe.md
...time-computing/src/main/resources/documentation/ReadMe.md
+3
-3
No files found.
wj-realtime-computing/src/main/java/com/wanji/indicators/constant/Constant.java
View file @
545be8ca
...
...
@@ -78,6 +78,11 @@ public class Constant {
*/
public
static
final
String
PEDESTRAIN_LIGHT_CODE
=
"20"
;
/**
* 右转灯转向
*/
public
static
final
String
RIGHT_LIGHT_CODE
=
"3"
;
/**
* 入侵结果
*/
...
...
wj-realtime-computing/src/main/java/com/wanji/indicators/task/trajectory/CarTrajectoryIndexMain.java
View file @
545be8ca
This diff is collapsed.
Click to expand it.
wj-realtime-computing/src/main/java/com/wanji/indicators/task/trajectory/func/CarDataValidatorFlatMap.java
View file @
545be8ca
...
...
@@ -88,6 +88,6 @@ public class CarDataValidatorFlatMap implements FlatMapFunction<FrameModel, CarT
}
public
static
boolean
isQualifiedPlate
(
String
plate
){
return
StringUtils
.
isNotEmpty
(
plate
)
&&
!
Objects
.
equals
(
"null"
,
plate
)
&&
!
Objects
.
equals
(
"默A00000"
,
plate
);
return
StringUtils
.
isNotEmpty
(
plate
)
&&
!
Objects
.
equals
(
"null"
,
plate
)
&&
!
plate
.
contains
(
"00000"
);
}
}
wj-realtime-computing/src/main/java/com/wanji/indicators/task/trajectory/func/CoordCongestionDataFunction.java
0 → 100644
View file @
545be8ca
package
com
.
wanji
.
indicators
.
task
.
trajectory
.
func
;
import
com.wanji.indicators.task.trajectory.CarTrajectoryIndexMain
;
import
com.wanji.indicators.task.trajectory.pojo.RidIndexResult
;
import
com.wanji.indicators.task.trajectory.pojo.StartDuration
;
import
org.apache.flink.api.common.state.MapState
;
import
org.apache.flink.api.common.state.MapStateDescriptor
;
import
org.apache.flink.configuration.Configuration
;
import
org.apache.flink.streaming.api.functions.KeyedProcessFunction
;
import
org.apache.flink.util.Collector
;
import
java.time.Instant
;
import
java.time.temporal.ChronoUnit
;
import
java.util.Iterator
;
/**
* 协调方向拥堵数据
*
* @author Kent HAN
* @date 2023/11/14 10:02
*/
public
class
CoordCongestionDataFunction
extends
KeyedProcessFunction
<
String
,
RidIndexResult
,
RidIndexResult
>
{
// Key:方向
private
MapState
<
Integer
,
StartDuration
>
dirState
;
@Override
public
void
open
(
Configuration
parameters
)
throws
Exception
{
dirState
=
getRuntimeContext
()
.
getMapState
(
new
MapStateDescriptor
<>(
"dir_map"
,
Integer
.
class
,
StartDuration
.
class
));
}
@Override
public
void
processElement
(
RidIndexResult
value
,
KeyedProcessFunction
<
String
,
RidIndexResult
,
RidIndexResult
>.
Context
ctx
,
Collector
<
RidIndexResult
>
out
)
throws
Exception
{
String
rid
=
ctx
.
getCurrentKey
();
Integer
dir
=
CarTrajectoryIndexMain
.
ridDirMap
.
get
(
rid
);
value
.
setDir
(
dir
);
Double
index
=
value
.
getIndex
();
boolean
isCongestion
=
index
>
1.5
;
Integer
stateKey
=
dir
;
if
(
isCongestion
)
{
try
{
if
(!
dirState
.
contains
(
stateKey
))
{
StartDuration
startDuration
=
new
StartDuration
();
// 获取当前的时间戳
Instant
now
=
Instant
.
now
();
// 获取1分钟前的时间戳
Instant
oneMinuteBefore
=
now
.
minus
(
1
,
ChronoUnit
.
MINUTES
);
// 转换成毫秒
long
timestampOneMinuteBefore
=
oneMinuteBefore
.
toEpochMilli
();
value
.
setStartTime
(
timestampOneMinuteBefore
);
startDuration
.
setStartTime
(
timestampOneMinuteBefore
);
value
.
setDuration
(
1
);
startDuration
.
setDuration
(
1
);
dirState
.
put
(
stateKey
,
startDuration
);
}
else
{
StartDuration
startDuration
=
dirState
.
get
(
stateKey
);
value
.
setStartTime
(
startDuration
.
getStartTime
());
Integer
duration
=
startDuration
.
getDuration
();
duration
+=
1
;
startDuration
.
setDuration
(
duration
);
value
.
setDuration
(
duration
);
dirState
.
put
(
stateKey
,
startDuration
);
}
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
else
{
// 删除状态
try
{
Iterator
<
Integer
>
mapStateIterator
=
dirState
.
keys
().
iterator
();
while
(
mapStateIterator
.
hasNext
()){
Integer
key
=
mapStateIterator
.
next
();
if
(
key
.
equals
(
stateKey
)){
mapStateIterator
.
remove
();
}
}
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
e
);
}
}
out
.
collect
(
value
);
}
}
wj-realtime-computing/src/main/java/com/wanji/indicators/task/trajectory/func/VehicleGapTimeProcessFunction.java
View file @
545be8ca
This diff is collapsed.
Click to expand it.
wj-realtime-computing/src/main/java/com/wanji/indicators/task/trajectory/pojo/RidIndexResult
OfEastAndWest
.java
→
wj-realtime-computing/src/main/java/com/wanji/indicators/task/trajectory/pojo/RidIndexResult.java
View file @
545be8ca
...
...
@@ -9,7 +9,10 @@ import lombok.Data;
* @Description :
*/
@Data
public
class
RidIndexResultOfEastAndWest
{
public
class
RidIndexResult
{
private
Integer
dir
;
private
String
rid
;
//该路段的结束路口
private
String
crossId
;
...
...
@@ -27,4 +30,7 @@ public class RidIndexResultOfEastAndWest {
private
Long
startTime
;
private
Long
endTime
;
private
Integer
duration
;
}
wj-realtime-computing/src/main/java/com/wanji/indicators/task/trajectory/pojo/StartDuration.java
0 → 100644
View file @
545be8ca
package
com
.
wanji
.
indicators
.
task
.
trajectory
.
pojo
;
import
lombok.Data
;
@Data
public
class
StartDuration
{
// 开始时间(毫秒时间戳)
private
Long
startTime
;
// 持续时长(分钟)
private
Integer
duration
;
}
wj-realtime-computing/src/main/resources/config.properties
View file @
545be8ca
...
...
@@ -44,15 +44,15 @@ cross.event.data.topic=analysis.cross.event
plate.prefix
=
鲁
#路段默认自由流速度配置值 km/h
rid.default.free.speed
=
80
#
东西
方向路段拥堵指数统计
#
协调
方向路段拥堵指数统计
rid.traffic.index.analysis.topic
=
rid.traffic.index.analysis
#
南北
方向饱和度计算
#
非协调
方向饱和度计算
rid.traffic.index.north.south.topic
=
rid.traffic.index.north.south.analysis
#
东西
方向路段的rid和方向
east.west
.rid.direction.list
=
13NED0B5Q9013NF80B5QN00:6,13NGH0B5RC013NF80B5QN00:2,13NI00B5RM013NGH0B5RC00:3,13NF80B5QN013NGH0B5RC00:6,13NGH0B5RC013NI00B5RM00:7,13NID0B5RM013NI00B5RM00:3
#
南北
方向路段的rid和方向
no
rth.south
.rid.direction.list
=
13NG40B5SK013NI00B5RM00:1,13NEH0B5RJ013NGH0B5RC00:1,13NEP0B5QJ013NGH0B5RC00:5,13NDG0B5RI013NF80B5QN00:1,13NDT0B5Q9013NF80B5QN00:4
#
协调
方向路段的rid和方向
coord
.rid.direction.list
=
13NED0B5Q9013NF80B5QN00:6,13NGH0B5RC013NF80B5QN00:2,13NI00B5RM013NGH0B5RC00:3,13NF80B5QN013NGH0B5RC00:6,13NGH0B5RC013NI00B5RM00:7,13NID0B5RM013NI00B5RM00:3
#
非协调
方向路段的rid和方向
no
.coord
.rid.direction.list
=
13NG40B5SK013NI00B5RM00:1,13NEH0B5RJ013NGH0B5RC00:1,13NEP0B5QJ013NGH0B5RC00:5,13NDG0B5RI013NF80B5QN00:1,13NDT0B5Q9013NF80B5QN00:4
#路口溢出评价指标
road.overflow.avg.speed
=
5.0
...
...
@@ -69,8 +69,10 @@ cross.road.deadlock.avg.speed=5.0
#相位灯的状态数据
light.status.topic
=
cross_lights_status
#虚拟路口区域
# 虚拟路口区域
# 霞景路西,旅游路与回龙山路交叉口
virtual.crossroad.13NED0B5Q90
=
13NED0B5Q90:117.08503591467242,36.64125732273356;117.08495255127629,36.641426722875224;117.08499878952986,36.641454206982246;117.08508543702352,36.641286700399476
# 福地街东,旅游路与隧道交叉口
virtual.crossroad.13NH20B5RH0
=
13NH20B5RH0:117.09669255282627,36.644871615002884;117.09669985552095,36.645055610398025;117.09675474612689,36.64505324101935;117.09674606214631,36.64486930675771
#相位空放topic
...
...
wj-realtime-computing/src/main/resources/documentation/ReadMe.md
View file @
545be8ca
...
...
@@ -5,9 +5,9 @@
## 2. 指标说明
### 2.1 拥堵
拥堵指标计算分为
东西方向和南北
方向
-
东西
方向拥堵指数计算会针对每个路口的进口路段进行计算,统计每个路段的拥堵指数,并根据拥堵指数进行阈值判断后,获取该路段的交通状态
-
南北方向的拥堵指数计算是根据饱和度计算绿灯时间内,车辆空档时间。根据算法文档给出的计算公式进行相关计算后,判断其阈值范围,从而获取该路段的交通状态
拥堵指标计算分为
协调方向方向和非协调
方向
-
协调
方向拥堵指数计算会针对每个路口的进口路段进行计算,统计每个路段的拥堵指数,并根据拥堵指数进行阈值判断后,获取该路段的交通状态
-
非协调方向的拥堵指数计算:根据绿灯时间内车辆空档时间,计算饱和度。根据算法文档阈值判断拥堵等级。
### 2.2 失衡
-
根据算法指标计算文档给出的计算公式,计算每个路口是否处于失衡状态
...
...
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