@fleet-frontend/mower-maps 0.2.6-beta.8 → 0.2.6-beta.9
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 +24 -16
- package/dist/index.js +24 -16
- package/dist/render/MowerMapRenderer.d.ts.map +1 -1
- package/dist/render/svgElement/ChannelElement/index.d.ts.map +1 -1
- package/dist/render/svgElement/PathElement/index.d.ts.map +1 -1
- package/dist/render/svgElement/PolygonELement/index.d.ts.map +1 -1
- package/dist/utils/pathData.d.ts +2 -0
- package/dist/utils/pathData.d.ts.map +1 -0
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -24693,6 +24693,24 @@ const Tooltip = ({ open, x, y, text, style, onClick }) => {
|
|
|
24693
24693
|
}, children: text }), document.body);
|
|
24694
24694
|
};
|
|
24695
24695
|
|
|
24696
|
+
function getPathData(points) {
|
|
24697
|
+
// 1. 安全守卫:如果没有点,返回空字符串
|
|
24698
|
+
if (!points || points.length === 0)
|
|
24699
|
+
return '';
|
|
24700
|
+
// 2. 如果只有 1 个点,只生成起点 M 即可(或者在最外层判断中直接 return 过滤掉)
|
|
24701
|
+
if (points.length === 1) {
|
|
24702
|
+
return `M ${points[0][0]} ${points[0][1]}`;
|
|
24703
|
+
}
|
|
24704
|
+
// 3. 2个点及以上时,再进行 L 拼接
|
|
24705
|
+
const pathData = points.map((p, index) => {
|
|
24706
|
+
if (index === 0) {
|
|
24707
|
+
return `M ${p[0]} ${p[1]}`;
|
|
24708
|
+
}
|
|
24709
|
+
return ` L ${p[0]} ${p[1]}`;
|
|
24710
|
+
}).join('');
|
|
24711
|
+
return pathData;
|
|
24712
|
+
}
|
|
24713
|
+
|
|
24696
24714
|
/**
|
|
24697
24715
|
* 将坐标点数组转换为polygon points字符串
|
|
24698
24716
|
* @param coordinates 坐标点数组 [[x1, y1], [x2, y2], ...]
|
|
@@ -24776,10 +24794,7 @@ const groupCoordinatesByType = (coordinates, autoClose = true) => {
|
|
|
24776
24794
|
const createPathData = (points) => {
|
|
24777
24795
|
if (points.length < 2)
|
|
24778
24796
|
return '';
|
|
24779
|
-
|
|
24780
|
-
for (let i = 1; i < points.length; i++) {
|
|
24781
|
-
pathData += ` L ${points[i][0]} ${points[i][1]}`;
|
|
24782
|
-
}
|
|
24797
|
+
const pathData = getPathData(points);
|
|
24783
24798
|
return pathData;
|
|
24784
24799
|
};
|
|
24785
24800
|
const PolygonElement = ({ canSelect = false, isHover = false, points, fillColor = 'rgba(0, 0, 0, 0.1)', hoverFillColor = '', fillOpacity = 1, strokeColor = '#000', strokeWidth = 2, strokeOpacity = 1, createMode = false, showPoints = false, onPointClick, completed = false, mousePos = null, editMode = false, onCoordinatesChange, onPathClick, onPolygonClick, onVertexDelete, draggable = true, // 新增参数,如果未指定则根据createMode和editMode自动判断
|
|
@@ -25721,10 +25736,7 @@ const ChannelElement = ({ data }) => {
|
|
|
25721
25736
|
const clipPathUrl = `url(#${channelClipPathId})`;
|
|
25722
25737
|
const points = data.points;
|
|
25723
25738
|
const style = data.style;
|
|
25724
|
-
|
|
25725
|
-
for (let i = 1; i < points.length; i++) {
|
|
25726
|
-
pathData += ` L ${points[i][0]} ${points[i][1]}`;
|
|
25727
|
-
}
|
|
25739
|
+
const pathData = getPathData(points);
|
|
25728
25740
|
const topLineWidth = dp2px(style.lineWidth).toString();
|
|
25729
25741
|
const bottomLineWidth = dp2px(style.bottomLineWidth).toString();
|
|
25730
25742
|
const dashLength = dp2px(style.lineWidth);
|
|
@@ -27917,10 +27929,7 @@ const PathElement = forwardRef(({ mapConfig, pathData, mowPartitionData }, ref)
|
|
|
27917
27929
|
return;
|
|
27918
27930
|
}
|
|
27919
27931
|
// 构建路径数据
|
|
27920
|
-
|
|
27921
|
-
for (let i = 1; i < points.length; i++) {
|
|
27922
|
-
pathData += ` L ${points[i][0]} ${points[i][1]}`;
|
|
27923
|
-
}
|
|
27932
|
+
const pathData = getPathData(points);
|
|
27924
27933
|
// 根据路径类型设置不同的颜色
|
|
27925
27934
|
let lineColor;
|
|
27926
27935
|
if (pathType === PathSegmentType.TRANS) {
|
|
@@ -27953,7 +27962,7 @@ const PathElement = forwardRef(({ mapConfig, pathData, mowPartitionData }, ref)
|
|
|
27953
27962
|
const result = [];
|
|
27954
27963
|
partitionTypeGroups.forEach((groupData, groupKey) => {
|
|
27955
27964
|
const { pathData, style } = groupData;
|
|
27956
|
-
if (pathData.length === 0)
|
|
27965
|
+
if (!pathData || pathData.length === 0)
|
|
27957
27966
|
return;
|
|
27958
27967
|
// 从groupKey中提取分区ID
|
|
27959
27968
|
const partitionId = groupKey.split('-')[0];
|
|
@@ -27961,8 +27970,8 @@ const PathElement = forwardRef(({ mapConfig, pathData, mowPartitionData }, ref)
|
|
|
27961
27970
|
const clipPathId = clipPathData[partitionId]?.id;
|
|
27962
27971
|
if (!clipPathId)
|
|
27963
27972
|
return;
|
|
27964
|
-
|
|
27965
|
-
path:
|
|
27973
|
+
result.push({
|
|
27974
|
+
path: pathData.join(' '),
|
|
27966
27975
|
style,
|
|
27967
27976
|
clipPathId: clipPathId,
|
|
27968
27977
|
});
|
|
@@ -30176,7 +30185,6 @@ modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTim
|
|
|
30176
30185
|
const newSvgElementDatas = { ...svgElementDatas };
|
|
30177
30186
|
Object.keys(newSvgElementDatas).forEach((key) => {
|
|
30178
30187
|
if (key === DataType.OBSTACLE) {
|
|
30179
|
-
console.error('newSvgElementDatas[key] 000---->', newSvgElementDatas[key]);
|
|
30180
30188
|
newSvgElementDatas[key] =
|
|
30181
30189
|
newSvgElementDatas[key].filter((item) => {
|
|
30182
30190
|
return (item.status === 1 &&
|
package/dist/index.js
CHANGED
|
@@ -24713,6 +24713,24 @@ const Tooltip = ({ open, x, y, text, style, onClick }) => {
|
|
|
24713
24713
|
}, children: text }), document.body);
|
|
24714
24714
|
};
|
|
24715
24715
|
|
|
24716
|
+
function getPathData(points) {
|
|
24717
|
+
// 1. 安全守卫:如果没有点,返回空字符串
|
|
24718
|
+
if (!points || points.length === 0)
|
|
24719
|
+
return '';
|
|
24720
|
+
// 2. 如果只有 1 个点,只生成起点 M 即可(或者在最外层判断中直接 return 过滤掉)
|
|
24721
|
+
if (points.length === 1) {
|
|
24722
|
+
return `M ${points[0][0]} ${points[0][1]}`;
|
|
24723
|
+
}
|
|
24724
|
+
// 3. 2个点及以上时,再进行 L 拼接
|
|
24725
|
+
const pathData = points.map((p, index) => {
|
|
24726
|
+
if (index === 0) {
|
|
24727
|
+
return `M ${p[0]} ${p[1]}`;
|
|
24728
|
+
}
|
|
24729
|
+
return ` L ${p[0]} ${p[1]}`;
|
|
24730
|
+
}).join('');
|
|
24731
|
+
return pathData;
|
|
24732
|
+
}
|
|
24733
|
+
|
|
24716
24734
|
/**
|
|
24717
24735
|
* 将坐标点数组转换为polygon points字符串
|
|
24718
24736
|
* @param coordinates 坐标点数组 [[x1, y1], [x2, y2], ...]
|
|
@@ -24796,10 +24814,7 @@ const groupCoordinatesByType = (coordinates, autoClose = true) => {
|
|
|
24796
24814
|
const createPathData = (points) => {
|
|
24797
24815
|
if (points.length < 2)
|
|
24798
24816
|
return '';
|
|
24799
|
-
|
|
24800
|
-
for (let i = 1; i < points.length; i++) {
|
|
24801
|
-
pathData += ` L ${points[i][0]} ${points[i][1]}`;
|
|
24802
|
-
}
|
|
24817
|
+
const pathData = getPathData(points);
|
|
24803
24818
|
return pathData;
|
|
24804
24819
|
};
|
|
24805
24820
|
const PolygonElement = ({ canSelect = false, isHover = false, points, fillColor = 'rgba(0, 0, 0, 0.1)', hoverFillColor = '', fillOpacity = 1, strokeColor = '#000', strokeWidth = 2, strokeOpacity = 1, createMode = false, showPoints = false, onPointClick, completed = false, mousePos = null, editMode = false, onCoordinatesChange, onPathClick, onPolygonClick, onVertexDelete, draggable = true, // 新增参数,如果未指定则根据createMode和editMode自动判断
|
|
@@ -25741,10 +25756,7 @@ const ChannelElement = ({ data }) => {
|
|
|
25741
25756
|
const clipPathUrl = `url(#${channelClipPathId})`;
|
|
25742
25757
|
const points = data.points;
|
|
25743
25758
|
const style = data.style;
|
|
25744
|
-
|
|
25745
|
-
for (let i = 1; i < points.length; i++) {
|
|
25746
|
-
pathData += ` L ${points[i][0]} ${points[i][1]}`;
|
|
25747
|
-
}
|
|
25759
|
+
const pathData = getPathData(points);
|
|
25748
25760
|
const topLineWidth = dp2px(style.lineWidth).toString();
|
|
25749
25761
|
const bottomLineWidth = dp2px(style.bottomLineWidth).toString();
|
|
25750
25762
|
const dashLength = dp2px(style.lineWidth);
|
|
@@ -27937,10 +27949,7 @@ const PathElement = React.forwardRef(({ mapConfig, pathData, mowPartitionData },
|
|
|
27937
27949
|
return;
|
|
27938
27950
|
}
|
|
27939
27951
|
// 构建路径数据
|
|
27940
|
-
|
|
27941
|
-
for (let i = 1; i < points.length; i++) {
|
|
27942
|
-
pathData += ` L ${points[i][0]} ${points[i][1]}`;
|
|
27943
|
-
}
|
|
27952
|
+
const pathData = getPathData(points);
|
|
27944
27953
|
// 根据路径类型设置不同的颜色
|
|
27945
27954
|
let lineColor;
|
|
27946
27955
|
if (pathType === PathSegmentType.TRANS) {
|
|
@@ -27973,7 +27982,7 @@ const PathElement = React.forwardRef(({ mapConfig, pathData, mowPartitionData },
|
|
|
27973
27982
|
const result = [];
|
|
27974
27983
|
partitionTypeGroups.forEach((groupData, groupKey) => {
|
|
27975
27984
|
const { pathData, style } = groupData;
|
|
27976
|
-
if (pathData.length === 0)
|
|
27985
|
+
if (!pathData || pathData.length === 0)
|
|
27977
27986
|
return;
|
|
27978
27987
|
// 从groupKey中提取分区ID
|
|
27979
27988
|
const partitionId = groupKey.split('-')[0];
|
|
@@ -27981,8 +27990,8 @@ const PathElement = React.forwardRef(({ mapConfig, pathData, mowPartitionData },
|
|
|
27981
27990
|
const clipPathId = clipPathData[partitionId]?.id;
|
|
27982
27991
|
if (!clipPathId)
|
|
27983
27992
|
return;
|
|
27984
|
-
|
|
27985
|
-
path:
|
|
27993
|
+
result.push({
|
|
27994
|
+
path: pathData.join(' '),
|
|
27986
27995
|
style,
|
|
27987
27996
|
clipPathId: clipPathId,
|
|
27988
27997
|
});
|
|
@@ -30196,7 +30205,6 @@ modelType, showStraddleBoundaryBorder = true, mapRef, mapJson, pathJson, realTim
|
|
|
30196
30205
|
const newSvgElementDatas = { ...svgElementDatas };
|
|
30197
30206
|
Object.keys(newSvgElementDatas).forEach((key) => {
|
|
30198
30207
|
if (key === exports.DataType.OBSTACLE) {
|
|
30199
|
-
console.error('newSvgElementDatas[key] 000---->', newSvgElementDatas[key]);
|
|
30200
30208
|
newSvgElementDatas[key] =
|
|
30201
30209
|
newSvgElementDatas[key].filter((item) => {
|
|
30202
30210
|
return (item.status === 1 &&
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MowerMapRenderer.d.ts","sourceRoot":"","sources":["../../src/render/MowerMapRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KASN,MAAM,OAAO,CAAC;AAwBf,OAAO,EAGL,qBAAqB,EACrB,mBAAmB,EAEpB,MAAM,mBAAmB,CAAC;AA2B3B,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,EAAE,GAAG,CAAC;KACb;CACF;AAMD,eAAO,MAAM,gBAAgB,
|
|
1
|
+
{"version":3,"file":"MowerMapRenderer.d.ts","sourceRoot":"","sources":["../../src/render/MowerMapRenderer.tsx"],"names":[],"mappings":"AAAA,OAAO,KASN,MAAM,OAAO,CAAC;AAwBf,OAAO,EAGL,qBAAqB,EACrB,mBAAmB,EAEpB,MAAM,mBAAmB,CAAC;AA2B3B,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,EAAE,GAAG,CAAC;KACb;CACF;AAMD,eAAO,MAAM,gBAAgB,mGA81B5B,CAAC;AAIF,eAAe,gBAAgB,CAAC;AAChC,YAAY,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/render/svgElement/ChannelElement/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/render/svgElement/ChannelElement/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAKlD,UAAU,mBAAmB;IAC3B,IAAI,EAAE,WAAW,CAAC;CACnB;AAED,QAAA,MAAM,cAAc,GAAI,UAAU,mBAAmB,4CAmCpD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/render/svgElement/PathElement/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,QAAQ,EAGR,qBAAqB,EACrB,WAAW,EACZ,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/render/svgElement/PathElement/index.tsx"],"names":[],"mappings":"AAEA,OAAO,EACL,QAAQ,EAGR,qBAAqB,EACrB,WAAW,EACZ,MAAM,gBAAgB,CAAC;AAKxB,UAAU,gBAAgB;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAChC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,gBAAgB,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAAC;CACjD;AAED,MAAM,WAAW,cAAc;IAC7B,cAAc,EAAE,CAAC,QAAQ,EAAE,QAAQ,EAAE,gBAAgB,CAAC,EAAE,qBAAqB,KAAK,IAAI,CAAC;IACvF,8BAA8B,EAAE,CAAC,QAAQ,EAAE;QACzC,CAAC,EAAE,MAAM,CAAC;QACV,CAAC,EAAE,MAAM,CAAC;QACV,YAAY,CAAC,EAAE,WAAW,CAAC;KAC5B,KAAK,IAAI,CAAC;CACZ;AAuED,QAAA,MAAM,WAAW,6GA4OhB,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/render/svgElement/PolygonELement/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6E,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/render/svgElement/PolygonELement/index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA6E,MAAM,OAAO,CAAC;AAuBlG;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAAI,aAAa,MAAM,EAAE,EAAE,KAAG,MAE7D,CAAC;AA+BF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GACjC,aAAa,MAAM,EAAE,EAAE,EACvB,YAAW,OAAc,KACxB,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,EAAE,EAAE,CAAA;CAAE,CAyC5C,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,cAAc,GAAI,QAAQ,MAAM,EAAE,EAAE,KAAG,MAMnD,CAAC;AAgBF,UAAU,mBAAmB;IAC3B,MAAM,EAAE,MAAM,EAAE,EAAE,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAE5B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAC7D,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;IAE3C,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,mBAAmB,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,KAAK,IAAI,CAAC;IACxD,WAAW,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAC5C,cAAc,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,KAAK,IAAI,CAAC;IAE/C,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,EAAE,CAAC,mBAAmB,CA+zCxD,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pathData.d.ts","sourceRoot":"","sources":["../../src/utils/pathData.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,EAAE,GAAG,MAAM,CAiBvD"}
|