@rytass/wms-map-react-components 0.1.1 → 0.1.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/index.cjs.js +17 -29
- package/package.json +1 -1
- package/typings.d.ts +0 -4
- package/utils/api-data-transform.js +2 -2
- package/utils/map-data-transform.js +15 -27
package/index.cjs.js
CHANGED
|
@@ -282,14 +282,13 @@ const calculateStaggeredPosition = (index, baseX = 100, baseY = 100, viewportX,
|
|
|
282
282
|
// RectangleNode 轉換為 MapRectangleRange
|
|
283
283
|
const rectData = node.data;
|
|
284
284
|
const rectangleRange = {
|
|
285
|
-
id: node.id,
|
|
285
|
+
id: rectData.label || node.id,
|
|
286
286
|
type: MapRangeType.RECTANGLE,
|
|
287
287
|
color: rectData.color || '#0000FF',
|
|
288
288
|
x: node.position.x,
|
|
289
289
|
y: node.position.y,
|
|
290
290
|
width: rectData.width || 100,
|
|
291
|
-
height: rectData.height || 100
|
|
292
|
-
text: rectData.label
|
|
291
|
+
height: rectData.height || 100
|
|
293
292
|
};
|
|
294
293
|
ranges.push(rectangleRange);
|
|
295
294
|
break;
|
|
@@ -299,11 +298,10 @@ const calculateStaggeredPosition = (index, baseX = 100, baseY = 100, viewportX,
|
|
|
299
298
|
// PathNode 轉換為 MapPolygonRange
|
|
300
299
|
const pathData = node.data;
|
|
301
300
|
const polygonRange = {
|
|
302
|
-
id: node.id,
|
|
301
|
+
id: pathData.label || node.id,
|
|
303
302
|
type: MapRangeType.POLYGON,
|
|
304
303
|
color: pathData.color || '#0000FF',
|
|
305
|
-
points: pathData.points || []
|
|
306
|
-
text: pathData.label
|
|
304
|
+
points: pathData.points || []
|
|
307
305
|
};
|
|
308
306
|
ranges.push(polygonRange);
|
|
309
307
|
break;
|
|
@@ -367,14 +365,13 @@ const calculateStaggeredPosition = (index, baseX = 100, baseY = 100, viewportX,
|
|
|
367
365
|
{
|
|
368
366
|
const rectData = node.data;
|
|
369
367
|
const mapRectangleRange = {
|
|
370
|
-
id: node.id,
|
|
368
|
+
id: rectData.label || node.id,
|
|
371
369
|
type: MapRangeType.RECTANGLE,
|
|
372
370
|
color: rectData.color || '#0000FF',
|
|
373
371
|
x: node.position.x,
|
|
374
372
|
y: node.position.y,
|
|
375
373
|
width: rectData.width || 100,
|
|
376
|
-
height: rectData.height || 100
|
|
377
|
-
text: rectData.label
|
|
374
|
+
height: rectData.height || 100
|
|
378
375
|
};
|
|
379
376
|
const clickInfo = {
|
|
380
377
|
...baseInfo,
|
|
@@ -384,8 +381,7 @@ const calculateStaggeredPosition = (index, baseX = 100, baseY = 100, viewportX,
|
|
|
384
381
|
size: {
|
|
385
382
|
width: rectData.width || 100,
|
|
386
383
|
height: rectData.height || 100
|
|
387
|
-
}
|
|
388
|
-
text: rectData.label
|
|
384
|
+
}
|
|
389
385
|
},
|
|
390
386
|
mapRectangleRange
|
|
391
387
|
};
|
|
@@ -401,11 +397,10 @@ const calculateStaggeredPosition = (index, baseX = 100, baseY = 100, viewportX,
|
|
|
401
397
|
maxY: Math.max(...pathData.points.map((p)=>p.y))
|
|
402
398
|
} : null;
|
|
403
399
|
const mapPolygonRange = {
|
|
404
|
-
id: node.id,
|
|
400
|
+
id: pathData.label || node.id,
|
|
405
401
|
type: MapRangeType.POLYGON,
|
|
406
402
|
color: pathData.color || '#0000FF',
|
|
407
|
-
points: pathData.points || []
|
|
408
|
-
text: pathData.label
|
|
403
|
+
points: pathData.points || []
|
|
409
404
|
};
|
|
410
405
|
const clickInfo = {
|
|
411
406
|
...baseInfo,
|
|
@@ -415,8 +410,7 @@ const calculateStaggeredPosition = (index, baseX = 100, baseY = 100, viewportX,
|
|
|
415
410
|
strokeWidth: pathData.strokeWidth || 2,
|
|
416
411
|
pointCount: pathData.points?.length || 0,
|
|
417
412
|
points: pathData.points || [],
|
|
418
|
-
bounds
|
|
419
|
-
text: pathData.label
|
|
413
|
+
bounds
|
|
420
414
|
},
|
|
421
415
|
mapPolygonRange
|
|
422
416
|
};
|
|
@@ -482,8 +476,7 @@ const calculateStaggeredPosition = (index, baseX = 100, baseY = 100, viewportX,
|
|
|
482
476
|
size: {
|
|
483
477
|
width: rectData.width || 100,
|
|
484
478
|
height: rectData.height || 100
|
|
485
|
-
}
|
|
486
|
-
text: rectData.label
|
|
479
|
+
}
|
|
487
480
|
});
|
|
488
481
|
// 轉換格式(對應儲存時的格式)
|
|
489
482
|
const rectangleRange = {
|
|
@@ -493,8 +486,7 @@ const calculateStaggeredPosition = (index, baseX = 100, baseY = 100, viewportX,
|
|
|
493
486
|
x: node.position.x,
|
|
494
487
|
y: node.position.y,
|
|
495
488
|
width: rectData.width || 100,
|
|
496
|
-
height: rectData.height || 100
|
|
497
|
-
text: rectData.label
|
|
489
|
+
height: rectData.height || 100
|
|
498
490
|
};
|
|
499
491
|
console.log('💾 儲存格式 (MapRectangleRange):', rectangleRange);
|
|
500
492
|
break;
|
|
@@ -507,7 +499,6 @@ const calculateStaggeredPosition = (index, baseX = 100, baseY = 100, viewportX,
|
|
|
507
499
|
strokeWidth: pathData.strokeWidth,
|
|
508
500
|
pointCount: pathData.points?.length || 0,
|
|
509
501
|
points: pathData.points,
|
|
510
|
-
text: pathData.label,
|
|
511
502
|
// 計算路徑邊界
|
|
512
503
|
bounds: pathData.points?.length > 0 ? {
|
|
513
504
|
minX: Math.min(...pathData.points.map((p)=>p.x)),
|
|
@@ -521,8 +512,7 @@ const calculateStaggeredPosition = (index, baseX = 100, baseY = 100, viewportX,
|
|
|
521
512
|
id: node.id,
|
|
522
513
|
type: MapRangeType.POLYGON,
|
|
523
514
|
color: pathData.color || '#0000FF',
|
|
524
|
-
points: pathData.points || []
|
|
525
|
-
text: pathData.label
|
|
515
|
+
points: pathData.points || []
|
|
526
516
|
};
|
|
527
517
|
console.log('💾 儲存格式 (MapPolygonRange):', polygonRange);
|
|
528
518
|
break;
|
|
@@ -573,8 +563,7 @@ const calculateStaggeredPosition = (index, baseX = 100, baseY = 100, viewportX,
|
|
|
573
563
|
size: {
|
|
574
564
|
width: rect.width,
|
|
575
565
|
height: rect.height
|
|
576
|
-
}
|
|
577
|
-
text: rect.text
|
|
566
|
+
}
|
|
578
567
|
});
|
|
579
568
|
} else if (range.type === MapRangeType.POLYGON) {
|
|
580
569
|
const poly = range;
|
|
@@ -583,8 +572,7 @@ const calculateStaggeredPosition = (index, baseX = 100, baseY = 100, viewportX,
|
|
|
583
572
|
type: poly.type,
|
|
584
573
|
color: poly.color,
|
|
585
574
|
pointCount: poly.points.length,
|
|
586
|
-
points: poly.points
|
|
587
|
-
text: poly.text
|
|
575
|
+
points: poly.points
|
|
588
576
|
});
|
|
589
577
|
}
|
|
590
578
|
});
|
|
@@ -4843,7 +4831,7 @@ const WMSMapModalContainer = ({ open, onClose, viewMode = ViewMode.EDIT, colorPa
|
|
|
4843
4831
|
width: rectRange.width,
|
|
4844
4832
|
height: rectRange.height,
|
|
4845
4833
|
color: rectRange.color,
|
|
4846
|
-
label: rectRange.
|
|
4834
|
+
label: rectRange.id
|
|
4847
4835
|
},
|
|
4848
4836
|
zIndex: baseZIndex,
|
|
4849
4837
|
draggable: true,
|
|
@@ -4869,7 +4857,7 @@ const WMSMapModalContainer = ({ open, onClose, viewMode = ViewMode.EDIT, colorPa
|
|
|
4869
4857
|
data: {
|
|
4870
4858
|
points: relativePoints,
|
|
4871
4859
|
color: polyRange.color,
|
|
4872
|
-
label: polyRange.
|
|
4860
|
+
label: polyRange.id,
|
|
4873
4861
|
strokeWidth: 2
|
|
4874
4862
|
},
|
|
4875
4863
|
zIndex: baseZIndex,
|
package/package.json
CHANGED
package/typings.d.ts
CHANGED
|
@@ -34,7 +34,6 @@ export interface MapRectangleRange extends MapRange {
|
|
|
34
34
|
y: number;
|
|
35
35
|
width: number;
|
|
36
36
|
height: number;
|
|
37
|
-
text?: string;
|
|
38
37
|
}
|
|
39
38
|
export interface MapPolygonRangePoint {
|
|
40
39
|
x: number;
|
|
@@ -43,7 +42,6 @@ export interface MapPolygonRangePoint {
|
|
|
43
42
|
export interface MapPolygonRange extends MapRange {
|
|
44
43
|
type: MapRangeType.POLYGON;
|
|
45
44
|
points: MapPolygonRangePoint[];
|
|
46
|
-
text?: string;
|
|
47
45
|
}
|
|
48
46
|
export declare enum EditMode {
|
|
49
47
|
BACKGROUND = "BACKGROUND",
|
|
@@ -106,7 +104,6 @@ export interface RectangleNodeClickInfo extends NodeClickInfo {
|
|
|
106
104
|
width: number;
|
|
107
105
|
height: number;
|
|
108
106
|
};
|
|
109
|
-
text?: string;
|
|
110
107
|
};
|
|
111
108
|
mapRectangleRange: MapRectangleRange;
|
|
112
109
|
}
|
|
@@ -129,7 +126,6 @@ export interface PathNodeClickInfo extends NodeClickInfo {
|
|
|
129
126
|
maxX: number;
|
|
130
127
|
maxY: number;
|
|
131
128
|
} | null;
|
|
132
|
-
text?: string;
|
|
133
129
|
};
|
|
134
130
|
mapPolygonRange: MapPolygonRange;
|
|
135
131
|
}
|
|
@@ -43,7 +43,7 @@ import { MapRangeType } from '../typings.js';
|
|
|
43
43
|
width: rectRange.width,
|
|
44
44
|
height: rectRange.height,
|
|
45
45
|
color: rectRange.color,
|
|
46
|
-
label: rectRange.
|
|
46
|
+
label: rectRange.id
|
|
47
47
|
},
|
|
48
48
|
zIndex: baseZIndex,
|
|
49
49
|
draggable: true,
|
|
@@ -69,7 +69,7 @@ import { MapRangeType } from '../typings.js';
|
|
|
69
69
|
data: {
|
|
70
70
|
points: relativePoints,
|
|
71
71
|
color: polyRange.color,
|
|
72
|
-
label: polyRange.
|
|
72
|
+
label: polyRange.id,
|
|
73
73
|
strokeWidth: 2
|
|
74
74
|
},
|
|
75
75
|
zIndex: baseZIndex,
|
|
@@ -27,14 +27,13 @@ import { MapRangeType } from '../typings.js';
|
|
|
27
27
|
// RectangleNode 轉換為 MapRectangleRange
|
|
28
28
|
const rectData = node.data;
|
|
29
29
|
const rectangleRange = {
|
|
30
|
-
id: node.id,
|
|
30
|
+
id: rectData.label || node.id,
|
|
31
31
|
type: MapRangeType.RECTANGLE,
|
|
32
32
|
color: rectData.color || '#0000FF',
|
|
33
33
|
x: node.position.x,
|
|
34
34
|
y: node.position.y,
|
|
35
35
|
width: rectData.width || 100,
|
|
36
|
-
height: rectData.height || 100
|
|
37
|
-
text: rectData.label
|
|
36
|
+
height: rectData.height || 100
|
|
38
37
|
};
|
|
39
38
|
ranges.push(rectangleRange);
|
|
40
39
|
break;
|
|
@@ -44,11 +43,10 @@ import { MapRangeType } from '../typings.js';
|
|
|
44
43
|
// PathNode 轉換為 MapPolygonRange
|
|
45
44
|
const pathData = node.data;
|
|
46
45
|
const polygonRange = {
|
|
47
|
-
id: node.id,
|
|
46
|
+
id: pathData.label || node.id,
|
|
48
47
|
type: MapRangeType.POLYGON,
|
|
49
48
|
color: pathData.color || '#0000FF',
|
|
50
|
-
points: pathData.points || []
|
|
51
|
-
text: pathData.label
|
|
49
|
+
points: pathData.points || []
|
|
52
50
|
};
|
|
53
51
|
ranges.push(polygonRange);
|
|
54
52
|
break;
|
|
@@ -112,14 +110,13 @@ import { MapRangeType } from '../typings.js';
|
|
|
112
110
|
{
|
|
113
111
|
const rectData = node.data;
|
|
114
112
|
const mapRectangleRange = {
|
|
115
|
-
id: node.id,
|
|
113
|
+
id: rectData.label || node.id,
|
|
116
114
|
type: MapRangeType.RECTANGLE,
|
|
117
115
|
color: rectData.color || '#0000FF',
|
|
118
116
|
x: node.position.x,
|
|
119
117
|
y: node.position.y,
|
|
120
118
|
width: rectData.width || 100,
|
|
121
|
-
height: rectData.height || 100
|
|
122
|
-
text: rectData.label
|
|
119
|
+
height: rectData.height || 100
|
|
123
120
|
};
|
|
124
121
|
const clickInfo = {
|
|
125
122
|
...baseInfo,
|
|
@@ -129,8 +126,7 @@ import { MapRangeType } from '../typings.js';
|
|
|
129
126
|
size: {
|
|
130
127
|
width: rectData.width || 100,
|
|
131
128
|
height: rectData.height || 100
|
|
132
|
-
}
|
|
133
|
-
text: rectData.label
|
|
129
|
+
}
|
|
134
130
|
},
|
|
135
131
|
mapRectangleRange
|
|
136
132
|
};
|
|
@@ -146,11 +142,10 @@ import { MapRangeType } from '../typings.js';
|
|
|
146
142
|
maxY: Math.max(...pathData.points.map((p)=>p.y))
|
|
147
143
|
} : null;
|
|
148
144
|
const mapPolygonRange = {
|
|
149
|
-
id: node.id,
|
|
145
|
+
id: pathData.label || node.id,
|
|
150
146
|
type: MapRangeType.POLYGON,
|
|
151
147
|
color: pathData.color || '#0000FF',
|
|
152
|
-
points: pathData.points || []
|
|
153
|
-
text: pathData.label
|
|
148
|
+
points: pathData.points || []
|
|
154
149
|
};
|
|
155
150
|
const clickInfo = {
|
|
156
151
|
...baseInfo,
|
|
@@ -160,8 +155,7 @@ import { MapRangeType } from '../typings.js';
|
|
|
160
155
|
strokeWidth: pathData.strokeWidth || 2,
|
|
161
156
|
pointCount: pathData.points?.length || 0,
|
|
162
157
|
points: pathData.points || [],
|
|
163
|
-
bounds
|
|
164
|
-
text: pathData.label
|
|
158
|
+
bounds
|
|
165
159
|
},
|
|
166
160
|
mapPolygonRange
|
|
167
161
|
};
|
|
@@ -227,8 +221,7 @@ import { MapRangeType } from '../typings.js';
|
|
|
227
221
|
size: {
|
|
228
222
|
width: rectData.width || 100,
|
|
229
223
|
height: rectData.height || 100
|
|
230
|
-
}
|
|
231
|
-
text: rectData.label
|
|
224
|
+
}
|
|
232
225
|
});
|
|
233
226
|
// 轉換格式(對應儲存時的格式)
|
|
234
227
|
const rectangleRange = {
|
|
@@ -238,8 +231,7 @@ import { MapRangeType } from '../typings.js';
|
|
|
238
231
|
x: node.position.x,
|
|
239
232
|
y: node.position.y,
|
|
240
233
|
width: rectData.width || 100,
|
|
241
|
-
height: rectData.height || 100
|
|
242
|
-
text: rectData.label
|
|
234
|
+
height: rectData.height || 100
|
|
243
235
|
};
|
|
244
236
|
console.log('💾 儲存格式 (MapRectangleRange):', rectangleRange);
|
|
245
237
|
break;
|
|
@@ -252,7 +244,6 @@ import { MapRangeType } from '../typings.js';
|
|
|
252
244
|
strokeWidth: pathData.strokeWidth,
|
|
253
245
|
pointCount: pathData.points?.length || 0,
|
|
254
246
|
points: pathData.points,
|
|
255
|
-
text: pathData.label,
|
|
256
247
|
// 計算路徑邊界
|
|
257
248
|
bounds: pathData.points?.length > 0 ? {
|
|
258
249
|
minX: Math.min(...pathData.points.map((p)=>p.x)),
|
|
@@ -266,8 +257,7 @@ import { MapRangeType } from '../typings.js';
|
|
|
266
257
|
id: node.id,
|
|
267
258
|
type: MapRangeType.POLYGON,
|
|
268
259
|
color: pathData.color || '#0000FF',
|
|
269
|
-
points: pathData.points || []
|
|
270
|
-
text: pathData.label
|
|
260
|
+
points: pathData.points || []
|
|
271
261
|
};
|
|
272
262
|
console.log('💾 儲存格式 (MapPolygonRange):', polygonRange);
|
|
273
263
|
break;
|
|
@@ -318,8 +308,7 @@ import { MapRangeType } from '../typings.js';
|
|
|
318
308
|
size: {
|
|
319
309
|
width: rect.width,
|
|
320
310
|
height: rect.height
|
|
321
|
-
}
|
|
322
|
-
text: rect.text
|
|
311
|
+
}
|
|
323
312
|
});
|
|
324
313
|
} else if (range.type === MapRangeType.POLYGON) {
|
|
325
314
|
const poly = range;
|
|
@@ -328,8 +317,7 @@ import { MapRangeType } from '../typings.js';
|
|
|
328
317
|
type: poly.type,
|
|
329
318
|
color: poly.color,
|
|
330
319
|
pointCount: poly.points.length,
|
|
331
|
-
points: poly.points
|
|
332
|
-
text: poly.text
|
|
320
|
+
points: poly.points
|
|
333
321
|
});
|
|
334
322
|
}
|
|
335
323
|
});
|