ofs-object 0.1.4 → 0.1.5
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.d.ts +37 -19
- package/dist/ofs-object.cjs +121 -120
- package/dist/ofs-object.js +9212 -9128
- package/docs/API.md +26 -1
- package/package.json +1 -1
package/docs/API.md
CHANGED
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
`OFSDataSource` ทำหน้าที่เป็น **Single Source of Truth** จัดเก็บข้อมูล Layer, Feature และสถานะการเลือก (Selection) ทั้งหมด พร้อมระบบ Event Bus แบบ Reactive
|
|
12
12
|
|
|
13
13
|
```typescript
|
|
14
|
+
// Buffer: ผลเป็น polygon เสมอ — ต้นทางเป็น polygon ลงเลเยอร์เดิม, เป็นเส้น/จุดลงเลเยอร์ `<id>_buffer`
|
|
15
|
+
// (สร้างให้ครั้งแรก) · ระบุ targetLayerId ที่ไม่ใช่ polygon → throw · คืน feature ที่เก็บแล้ว (มี id)
|
|
16
|
+
// ofs.dataSource.buffer('canals', 'c1', 10) → เลเยอร์ 'canals_buffer'
|
|
17
|
+
|
|
14
18
|
// การเพิ่ม Layer
|
|
15
19
|
const layer = ofs.dataSource.addLayer({
|
|
16
20
|
id: 'canals',
|
|
@@ -63,6 +67,22 @@ ofs.dataSource.on('layer:updated', ({ layer }) => { ... });
|
|
|
63
67
|
|
|
64
68
|
เครื่องมือวาดเรขาคณิตความแม่นยำสูงระดับ CAD มาพร้อมระบบช่วยจับเส้น/จุดอัตโนมัติ และระบบเลือกวัตถุ (Selection System)
|
|
65
69
|
|
|
70
|
+
**Event `draw:complete`** — สิ่งที่ควรรู้ก่อนผูก handler:
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
ofs.drawTools.on('draw:complete', ({ mode, feature, layerId }) => {
|
|
74
|
+
if (mode === 'modify') return; // ① ยิงตอนจบการแก้ด้วย grips ด้วย — กรองด้วย mode
|
|
75
|
+
openAttributeForm(layerId, feature.id); // ② feature คือตัวที่เก็บลง dataSource แล้ว มี id เสมอ
|
|
76
|
+
ofs.drawTools.setMode('polygon'); // ③ ออกจากโหมดแล้วก่อนยิง event จึงเริ่มวาดต่อในนี้ได้
|
|
77
|
+
});
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
- ② ก่อน 29 ก.ย. 2026 `feature` เป็น object ก่อนเก็บ **ไม่มี `id`** — ค่าที่ `finishDrawing()`,
|
|
81
|
+
`drawPointByCoords` / `drawLineByCoords` / `drawPolygonByCoords`, offset แบบ copy และ `dataSource.buffer()`
|
|
82
|
+
คืนมาก็เป็นแบบนั้น ตอนนี้คืนตัวที่เก็บแล้วทั้งหมด
|
|
83
|
+
- ④ รูปที่วาด**บันทึก undo ไปแล้ว**ตอน event ยิง — ถ้า handler แก้ feature ต่อ (เช่นเติม property) จะเป็น undo อีกขั้น
|
|
84
|
+
ใช้ `ofs.dataSource.runTransaction()` ครอบถ้าต้องการให้ undo ทีเดียว
|
|
85
|
+
|
|
66
86
|
```typescript
|
|
67
87
|
// เปิดโหมดการวาดและเลือกวัตถุ
|
|
68
88
|
ofs.drawTools.setMode('polygon'); // 'point' | 'line' | 'polygon' | 'circle' | 'rectangle' | 'select' | 'select-box' | 'select-polygon' | 'modify'
|
|
@@ -327,7 +347,7 @@ ofs.attributes.statistics('plots', 'yield'); // count, min, max, sum
|
|
|
327
347
|
|
|
328
348
|
| กลุ่ม | ตัวอย่าง |
|
|
329
349
|
|---|---|
|
|
330
|
-
| ฟิลด์ / ข้อความ | `crop`, `"ชื่อ มีเว้นวรรค"`, `'ข้าว'` |
|
|
350
|
+
| ฟิลด์ / ข้อความ | `crop`, `"ชื่อ มีเว้นวรรค"`, `'ข้าว'` · ในข้อความ: `\n` ขึ้นบรรทัดใหม่, `\t`, `\\`, `\'` หรือ `''` = quote (แบบ QGIS) — backslash หน้าตัวอื่นคงไว้ตามเดิม |
|
|
331
351
|
| ตัวดำเนินการ | `= <> < <= > >= + - * / % ^ \|\|` · `AND OR NOT` · `IN ('ข้าว','อ้อย')` · `LIKE 'A%'` / `ILIKE` · `IS NULL` |
|
|
332
352
|
| ค่าเรขาคณิต | `$area` (ตร.ม.), `$perimeter`, `$length`, `$x`, `$y`, `$id`, `area('rai')`, `perimeter('km')` |
|
|
333
353
|
| หน่วยไทย | `area('rai')`, `area('ngan')`, `area('wa')`, `rai_ngan_wa()` → `"3-2-45.5"` (1 ไร่ = 4 งาน = 400 ตร.วา = 1,600 ตร.ม.) |
|
|
@@ -349,7 +369,12 @@ ofs.attributes.statistics('plots', 'yield'); // count, min, max, sum
|
|
|
349
369
|
// Label จากฟิลด์ หรือจากนิพจน์ (คำนวณให้ก่อนส่งเข้าแผนที่ จึงใช้ $area / rai_ngan_wa() ได้)
|
|
350
370
|
ofs.legendTools.setLabel('plots', { field: 'owner', size: 13, haloColor: '#fff', minZoom: 14 });
|
|
351
371
|
ofs.legendTools.setLabel('plots', { expression: "concat(owner, ' ', rai_ngan_wa())" });
|
|
372
|
+
ofs.legendTools.setLabel('plots', { expression: "\"owner\" || '\\n' || rai_ngan_wa()" }); // 2 บรรทัด
|
|
352
373
|
ofs.legendTools.setLabel('plots', null); // เอาป้ายออก
|
|
374
|
+
// ฟอนต์: ไม่ระบุ → ใช้ฟอนต์เดียวกับป้ายของ basemap (มีบน glyph server ของ style นั้นแน่นอน เช่น Noto Sans
|
|
375
|
+
// บน OpenFreeMap) · ระบุเองด้วย { font: ['Noto Sans Bold'] } · เปลี่ยน renderer (Single/Categorized/
|
|
376
|
+
// Graduated) แล้ว label ไม่หาย
|
|
377
|
+
// เส้นช่วยขณะวาด: ofs.drawTools.setGuides({ font: ['Noto Sans Regular'] }) มีผลทันที · null = ตาม basemap
|
|
353
378
|
|
|
354
379
|
// วัดระยะ / พื้นที่ / มุม (ระยะบนพื้นจริง)
|
|
355
380
|
import { measureDistance, measureArea, measureAngle, formatArea } from 'ofs-object';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ofs-object",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Framework-agnostic TypeScript Library for GIS Map Tools (Data Adapter, Draw Tools, Legend & Thematic Symbology, Map Adapters, Web CLI & AI Bridge)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "On-Farm Solution Co.,Ltd.",
|