@fleet-frontend/mower-maps 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +29 -21
- package/dist/index.js +29 -21
- package/dist/render/MowerMapRenderer.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -23478,7 +23478,7 @@ const groupCoordinatesByType = (coordinates, autoClose = true) => {
|
|
|
23478
23478
|
}
|
|
23479
23479
|
// 只有在需要自动闭合时才处理封闭边界
|
|
23480
23480
|
if (autoClose) {
|
|
23481
|
-
if (segments.length > 1
|
|
23481
|
+
if (segments.length > 1) {
|
|
23482
23482
|
const firstSegment = segments[0];
|
|
23483
23483
|
const lastSegment = segments[segments.length - 1];
|
|
23484
23484
|
// 将第一个点添加到最后一段,形成封闭
|
|
@@ -28845,7 +28845,9 @@ modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTim
|
|
|
28845
28845
|
const [processStateIsMowing, setProcessStateIsMowing] = useState(false);
|
|
28846
28846
|
const [currentMowingPartitionId, setCurrentMowingPartitionId] = useState('');
|
|
28847
28847
|
const [mowPartitionData, setMowPartitionData] = useState(null);
|
|
28848
|
+
const mowPartitionDataRef = useRef(null);
|
|
28848
28849
|
const isTaskDelayRef = useRef(false);
|
|
28850
|
+
const currentVehicleStateRef = useRef(undefined);
|
|
28849
28851
|
// drag.x/y 现在存储的是 EPSG:3857 投影坐标的偏移量(米)
|
|
28850
28852
|
const [drag, setDrag] = useState({
|
|
28851
28853
|
x: 0,
|
|
@@ -29151,62 +29153,68 @@ modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTim
|
|
|
29151
29153
|
if (!realTimeData || realTimeData.length === 0 || !Array.isArray(realTimeData)) {
|
|
29152
29154
|
return;
|
|
29153
29155
|
}
|
|
29154
|
-
let curMowPartitionData = mowPartitionData;
|
|
29156
|
+
// let curMowPartitionData = mowPartitionData;
|
|
29155
29157
|
// realtime中包含当前割草任务的数据,根据数据进行path路径和边界的高亮操作,
|
|
29156
29158
|
const mowingPartition = realTimeData.find((item) => item.type === RealTimeDataType.PARTITION);
|
|
29157
29159
|
if (mowingPartition) {
|
|
29158
29160
|
setMowPartitionData(mowingPartition);
|
|
29159
|
-
|
|
29161
|
+
mowPartitionDataRef.current = mowingPartition;
|
|
29160
29162
|
}
|
|
29161
29163
|
// 获取当前的割草
|
|
29162
29164
|
const vehicleStatusData = realTimeData?.find((item) => item?.type === RealTimeDataType.STATUS);
|
|
29163
29165
|
if (vehicleStatusData) {
|
|
29164
29166
|
// console.error('vehicleStatusData 000---->', vehicleStatusData?.taskDelay);
|
|
29165
29167
|
// 如果上一次状态是true,当前变成了false,则认为不需要高亮分区
|
|
29166
|
-
if
|
|
29167
|
-
|
|
29168
|
-
|
|
29169
|
-
|
|
29170
|
-
|
|
29171
|
-
}
|
|
29168
|
+
// if(isTaskDelayRef.current === true && vehicleStatusData?.taskDelay === false) {
|
|
29169
|
+
// // 兜底收不到割草地块的实时数据,使用状态来兜底
|
|
29170
|
+
// setMowingPartitions(undefined);
|
|
29171
|
+
// setMowPartitionData({});
|
|
29172
|
+
// // curMowPartitionData = {};
|
|
29173
|
+
// mowPartitionDataRef.current = {};
|
|
29174
|
+
// // console.error('0.50.5--mowPartitionDataRef.current---->', mowPartitionDataRef.current);
|
|
29175
|
+
// }
|
|
29172
29176
|
isTaskDelayRef.current = vehicleStatusData?.taskDelay !== undefined ? vehicleStatusData?.taskDelay : isTaskDelayRef.current;
|
|
29173
29177
|
// console.error('isTaskDelayRef.current 111---->', isTaskDelayRef.current);
|
|
29174
29178
|
}
|
|
29175
29179
|
const positionData = realTimeData?.find((item) => item?.type === RealTimeDataType.LOCATION);
|
|
29176
29180
|
// 如果当前是taskDelay的状态,或者状态为mowing或者standby,则指定的地块需要高亮,或者全局高亮
|
|
29177
29181
|
if ((isTaskDelayRef.current || positionData?.vehicleState === RobotStatus.MOWING || positionData?.vehicleState === RobotStatus.STANDBY) &&
|
|
29178
|
-
|
|
29179
|
-
!
|
|
29182
|
+
mowPartitionDataRef.current &&
|
|
29183
|
+
!mowPartitionDataRef.current?.partitionIds) {
|
|
29180
29184
|
// 设置全局高亮
|
|
29181
|
-
if (
|
|
29182
|
-
!
|
|
29185
|
+
if (mowPartitionDataRef.current &&
|
|
29186
|
+
!mowPartitionDataRef.current?.partitionIds) {
|
|
29183
29187
|
const allPartitionIds = generateBoundaryData(mapJson)
|
|
29184
29188
|
?.filter((item) => !item?.isIsolated)
|
|
29185
29189
|
.map((item) => item?.id);
|
|
29186
29190
|
setMowPartitionData({
|
|
29187
29191
|
partitionIds: allPartitionIds,
|
|
29188
29192
|
});
|
|
29189
|
-
|
|
29193
|
+
mowPartitionDataRef.current = {
|
|
29190
29194
|
partitionIds: allPartitionIds,
|
|
29191
29195
|
};
|
|
29192
29196
|
}
|
|
29193
29197
|
}
|
|
29194
|
-
else if (!isTaskDelayRef.current && positionData?.vehicleState === RobotStatus.WORKING) {
|
|
29198
|
+
else if (!isTaskDelayRef.current && positionData?.vehicleState === RobotStatus.WORKING && (currentVehicleStateRef.current === RobotStatus.MOWING || currentVehicleStateRef.current === RobotStatus.STANDBY)) {
|
|
29199
|
+
// 非deskDelay的状态下
|
|
29200
|
+
// 1. 如果当前是working状态,且上一次是mowing或者standby状态,则取消高亮
|
|
29195
29201
|
// 兜底收不到割草地块的实时数据,使用状态来兜底
|
|
29196
29202
|
setMowingPartitions(undefined);
|
|
29197
29203
|
setMowPartitionData({});
|
|
29198
|
-
|
|
29204
|
+
mowPartitionDataRef.current = {};
|
|
29199
29205
|
}
|
|
29206
|
+
// 更新当前车辆状态
|
|
29207
|
+
currentVehicleStateRef.current = positionData?.vehicleState !== undefined ? positionData?.vehicleState : currentVehicleStateRef.current;
|
|
29200
29208
|
if (!mapJson || !svgMapRef.current)
|
|
29201
29209
|
return;
|
|
29202
29210
|
// 根据后端推送的实时数据,进行不同处理
|
|
29203
|
-
if (
|
|
29204
|
-
const isMowing =
|
|
29211
|
+
if (mowPartitionDataRef.current) {
|
|
29212
|
+
const isMowing = mowPartitionDataRef.current?.partitionIds && mowPartitionDataRef.current.partitionIds.length > 0;
|
|
29205
29213
|
if (!isMowing) {
|
|
29206
29214
|
setMowingPartitions(undefined);
|
|
29207
29215
|
}
|
|
29208
29216
|
else {
|
|
29209
|
-
setMowingPartitions(
|
|
29217
|
+
setMowingPartitions(mowPartitionDataRef.current?.partitionIds);
|
|
29210
29218
|
}
|
|
29211
29219
|
}
|
|
29212
29220
|
if (!pathJson)
|
|
@@ -29225,7 +29233,7 @@ modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTim
|
|
|
29225
29233
|
setCurrentMowingPartitionId(currentMowingPartition);
|
|
29226
29234
|
}
|
|
29227
29235
|
if (pathData) {
|
|
29228
|
-
svgMapRef.current?.updatePathData?.(pathData,
|
|
29236
|
+
svgMapRef.current?.updatePathData?.(pathData, mowPartitionDataRef.current);
|
|
29229
29237
|
}
|
|
29230
29238
|
}
|
|
29231
29239
|
else {
|
|
@@ -29239,7 +29247,7 @@ modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTim
|
|
|
29239
29247
|
if (currentMowingPartition !== currentMowingPartitionId) {
|
|
29240
29248
|
setCurrentMowingPartitionId(currentMowingPartition);
|
|
29241
29249
|
}
|
|
29242
|
-
svgMapRef.current?.updatePathData?.(pathData,
|
|
29250
|
+
svgMapRef.current?.updatePathData?.(pathData, mowPartitionDataRef.current);
|
|
29243
29251
|
}
|
|
29244
29252
|
}, [realTimeData, mapJson, pathJson, sn]);
|
|
29245
29253
|
useEffect(() => {
|
package/dist/index.js
CHANGED
|
@@ -23498,7 +23498,7 @@ const groupCoordinatesByType = (coordinates, autoClose = true) => {
|
|
|
23498
23498
|
}
|
|
23499
23499
|
// 只有在需要自动闭合时才处理封闭边界
|
|
23500
23500
|
if (autoClose) {
|
|
23501
|
-
if (segments.length > 1
|
|
23501
|
+
if (segments.length > 1) {
|
|
23502
23502
|
const firstSegment = segments[0];
|
|
23503
23503
|
const lastSegment = segments[segments.length - 1];
|
|
23504
23504
|
// 将第一个点添加到最后一段,形成封闭
|
|
@@ -28865,7 +28865,9 @@ modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTim
|
|
|
28865
28865
|
const [processStateIsMowing, setProcessStateIsMowing] = React.useState(false);
|
|
28866
28866
|
const [currentMowingPartitionId, setCurrentMowingPartitionId] = React.useState('');
|
|
28867
28867
|
const [mowPartitionData, setMowPartitionData] = React.useState(null);
|
|
28868
|
+
const mowPartitionDataRef = React.useRef(null);
|
|
28868
28869
|
const isTaskDelayRef = React.useRef(false);
|
|
28870
|
+
const currentVehicleStateRef = React.useRef(undefined);
|
|
28869
28871
|
// drag.x/y 现在存储的是 EPSG:3857 投影坐标的偏移量(米)
|
|
28870
28872
|
const [drag, setDrag] = React.useState({
|
|
28871
28873
|
x: 0,
|
|
@@ -29171,62 +29173,68 @@ modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTim
|
|
|
29171
29173
|
if (!realTimeData || realTimeData.length === 0 || !Array.isArray(realTimeData)) {
|
|
29172
29174
|
return;
|
|
29173
29175
|
}
|
|
29174
|
-
let curMowPartitionData = mowPartitionData;
|
|
29176
|
+
// let curMowPartitionData = mowPartitionData;
|
|
29175
29177
|
// realtime中包含当前割草任务的数据,根据数据进行path路径和边界的高亮操作,
|
|
29176
29178
|
const mowingPartition = realTimeData.find((item) => item.type === RealTimeDataType.PARTITION);
|
|
29177
29179
|
if (mowingPartition) {
|
|
29178
29180
|
setMowPartitionData(mowingPartition);
|
|
29179
|
-
|
|
29181
|
+
mowPartitionDataRef.current = mowingPartition;
|
|
29180
29182
|
}
|
|
29181
29183
|
// 获取当前的割草
|
|
29182
29184
|
const vehicleStatusData = realTimeData?.find((item) => item?.type === RealTimeDataType.STATUS);
|
|
29183
29185
|
if (vehicleStatusData) {
|
|
29184
29186
|
// console.error('vehicleStatusData 000---->', vehicleStatusData?.taskDelay);
|
|
29185
29187
|
// 如果上一次状态是true,当前变成了false,则认为不需要高亮分区
|
|
29186
|
-
if
|
|
29187
|
-
|
|
29188
|
-
|
|
29189
|
-
|
|
29190
|
-
|
|
29191
|
-
}
|
|
29188
|
+
// if(isTaskDelayRef.current === true && vehicleStatusData?.taskDelay === false) {
|
|
29189
|
+
// // 兜底收不到割草地块的实时数据,使用状态来兜底
|
|
29190
|
+
// setMowingPartitions(undefined);
|
|
29191
|
+
// setMowPartitionData({});
|
|
29192
|
+
// // curMowPartitionData = {};
|
|
29193
|
+
// mowPartitionDataRef.current = {};
|
|
29194
|
+
// // console.error('0.50.5--mowPartitionDataRef.current---->', mowPartitionDataRef.current);
|
|
29195
|
+
// }
|
|
29192
29196
|
isTaskDelayRef.current = vehicleStatusData?.taskDelay !== undefined ? vehicleStatusData?.taskDelay : isTaskDelayRef.current;
|
|
29193
29197
|
// console.error('isTaskDelayRef.current 111---->', isTaskDelayRef.current);
|
|
29194
29198
|
}
|
|
29195
29199
|
const positionData = realTimeData?.find((item) => item?.type === RealTimeDataType.LOCATION);
|
|
29196
29200
|
// 如果当前是taskDelay的状态,或者状态为mowing或者standby,则指定的地块需要高亮,或者全局高亮
|
|
29197
29201
|
if ((isTaskDelayRef.current || positionData?.vehicleState === RobotStatus.MOWING || positionData?.vehicleState === RobotStatus.STANDBY) &&
|
|
29198
|
-
|
|
29199
|
-
!
|
|
29202
|
+
mowPartitionDataRef.current &&
|
|
29203
|
+
!mowPartitionDataRef.current?.partitionIds) {
|
|
29200
29204
|
// 设置全局高亮
|
|
29201
|
-
if (
|
|
29202
|
-
!
|
|
29205
|
+
if (mowPartitionDataRef.current &&
|
|
29206
|
+
!mowPartitionDataRef.current?.partitionIds) {
|
|
29203
29207
|
const allPartitionIds = generateBoundaryData(mapJson)
|
|
29204
29208
|
?.filter((item) => !item?.isIsolated)
|
|
29205
29209
|
.map((item) => item?.id);
|
|
29206
29210
|
setMowPartitionData({
|
|
29207
29211
|
partitionIds: allPartitionIds,
|
|
29208
29212
|
});
|
|
29209
|
-
|
|
29213
|
+
mowPartitionDataRef.current = {
|
|
29210
29214
|
partitionIds: allPartitionIds,
|
|
29211
29215
|
};
|
|
29212
29216
|
}
|
|
29213
29217
|
}
|
|
29214
|
-
else if (!isTaskDelayRef.current && positionData?.vehicleState === RobotStatus.WORKING) {
|
|
29218
|
+
else if (!isTaskDelayRef.current && positionData?.vehicleState === RobotStatus.WORKING && (currentVehicleStateRef.current === RobotStatus.MOWING || currentVehicleStateRef.current === RobotStatus.STANDBY)) {
|
|
29219
|
+
// 非deskDelay的状态下
|
|
29220
|
+
// 1. 如果当前是working状态,且上一次是mowing或者standby状态,则取消高亮
|
|
29215
29221
|
// 兜底收不到割草地块的实时数据,使用状态来兜底
|
|
29216
29222
|
setMowingPartitions(undefined);
|
|
29217
29223
|
setMowPartitionData({});
|
|
29218
|
-
|
|
29224
|
+
mowPartitionDataRef.current = {};
|
|
29219
29225
|
}
|
|
29226
|
+
// 更新当前车辆状态
|
|
29227
|
+
currentVehicleStateRef.current = positionData?.vehicleState !== undefined ? positionData?.vehicleState : currentVehicleStateRef.current;
|
|
29220
29228
|
if (!mapJson || !svgMapRef.current)
|
|
29221
29229
|
return;
|
|
29222
29230
|
// 根据后端推送的实时数据,进行不同处理
|
|
29223
|
-
if (
|
|
29224
|
-
const isMowing =
|
|
29231
|
+
if (mowPartitionDataRef.current) {
|
|
29232
|
+
const isMowing = mowPartitionDataRef.current?.partitionIds && mowPartitionDataRef.current.partitionIds.length > 0;
|
|
29225
29233
|
if (!isMowing) {
|
|
29226
29234
|
setMowingPartitions(undefined);
|
|
29227
29235
|
}
|
|
29228
29236
|
else {
|
|
29229
|
-
setMowingPartitions(
|
|
29237
|
+
setMowingPartitions(mowPartitionDataRef.current?.partitionIds);
|
|
29230
29238
|
}
|
|
29231
29239
|
}
|
|
29232
29240
|
if (!pathJson)
|
|
@@ -29245,7 +29253,7 @@ modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTim
|
|
|
29245
29253
|
setCurrentMowingPartitionId(currentMowingPartition);
|
|
29246
29254
|
}
|
|
29247
29255
|
if (pathData) {
|
|
29248
|
-
svgMapRef.current?.updatePathData?.(pathData,
|
|
29256
|
+
svgMapRef.current?.updatePathData?.(pathData, mowPartitionDataRef.current);
|
|
29249
29257
|
}
|
|
29250
29258
|
}
|
|
29251
29259
|
else {
|
|
@@ -29259,7 +29267,7 @@ modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTim
|
|
|
29259
29267
|
if (currentMowingPartition !== currentMowingPartitionId) {
|
|
29260
29268
|
setCurrentMowingPartitionId(currentMowingPartition);
|
|
29261
29269
|
}
|
|
29262
|
-
svgMapRef.current?.updatePathData?.(pathData,
|
|
29270
|
+
svgMapRef.current?.updatePathData?.(pathData, mowPartitionDataRef.current);
|
|
29263
29271
|
}
|
|
29264
29272
|
}, [realTimeData, mapJson, pathJson, sn]);
|
|
29265
29273
|
React.useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MowerMapRenderer.d.ts","sourceRoot":"","sources":["../../src/render/MowerMapRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAQN,MAAM,OAAO,CAAC;AAuBf,OAAO,EAGL,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AA0B3B,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,EAAE,GAAG,CAAC;KACb;CACF;AA8FD,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"MowerMapRenderer.d.ts","sourceRoot":"","sources":["../../src/render/MowerMapRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KAQN,MAAM,OAAO,CAAC;AAuBf,OAAO,EAGL,qBAAqB,EACrB,mBAAmB,EACpB,MAAM,mBAAmB,CAAC;AA0B3B,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,EAAE,GAAG,CAAC;KACb;CACF;AA8FD,eAAO,MAAM,gBAAgB,mGAgvB5B,CAAC;AAIF,eAAe,gBAAgB,CAAC;AAChC,YAAY,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,CAAC"}
|