ตารางเวลาคำนวณได้ + หน้ารายละเอียดป้ายขับเคลื่อนด้วยข้อมูล + แผนที่ Leaflet

Schedules — กติกา "จุดนี้ = เวลาจุดอ้างอิง ± n นาที"
- ฟิลด์ derive { from_station_id, offset_min } คำนวณที่ ui/partials/schedules.js (ท่อเดียว) รองรับอ้างจุดข้ามทิศ
- จุดย่อยของ "8 other_stop" ใช้ offsets_min จับคู่ตามลำดับ (เช่น ตลาดสามโก้ = ตลาดท่าช้าง +45 นาที)
- เครื่องมือ resource/tools/derive-times.py + ตาราง resource/data/derive-times.csv (--check / --audit ชี้จุดที่ควรตั้งกฎ)
- แยกตารางเป็นรายสาย: scheduleslist/schedules<route_id>.json และ schedules.json เป็นสารบัญ (โหลดแบบ lazy + cache)
- ตรวจจับวันทำงาน/วันหยุด + schema 3 (weekday/holiday → directions) · ไฟล์ข้อมูลเป็น CRLF ทั้งชุด
- ล้างค่าที่ไม่ใช่ HH:MM ที่ฝังใน times (ทำให้ KPI เพี้ยน) + กันค่าหลอกในตัวสรุปเวลา

UI
- หน้ารายละเอียดป้าย/ตารางเวลา ขับเคลื่อนด้วย JSON (stopDetail.init.js) · จุดขึ้นรถประจำทางอื่นๆ รองรับหลายจุดต่อสาย
- #/stops: แสดง 6 ป้ายแรก + ปุ่ม "แสดงป้ายทั้งหมด" (โหลดรูปเฉพาะที่แสดง) · ชิปสาย → #/routes/<route_id>
- หน้าแรก: ตัดตัวเลือก "ทุกสถานีในจังหวัดนี้" · ตัวกรองจังหวัด/สถานี + ปุ่มแชร์ (share URL)
- การ์ดติดต่อ: ไอคอน/ชื่อ/สีเปลี่ยนตามชนิด URL (Facebook / LINE / เว็บไซต์) + ปุ่มเปิดลิงก์จาก web_url
- รูปรองรับหลายนามสกุล (.jpg → .jpeg → .webp → .png) · ป้าย "ประมาณ" + หมายเหตุสำหรับตารางที่คำนวณ
- หน้าเครดิตเหลือ 3 หมวด · แก้ข้อความหมวดแผนที่ให้ตรงกับข้อมูลจริง
- แผนที่ Leaflet (vendor ในโปรเจกต์ ไม่ใช้ CDN): เส้นทาง + หมุด + ป๊อปอัป · แก้ CSS ที่ทำให้ SVG ยุบ 0x0

เครื่องมือและเอกสาร
- qgis-to-web.py อ่าน .shp ตรง → geojson-web (สร้างใหม่ 10 ไฟล์) + audit-geojson.py ตรวจ 3 ส่วน
- stop-km.py วัดระยะ กม. ตามเส้นจริง → stop-km.json · schedules-editor.html (แก้ทีละไฟล์ · มุมมองตารางแบบ Excel)
- AGENTS.md: กติกา derive · offsets_min · นามสกุลรูป · ชิปสาย · หน้ารายละเอียดป้ายมาจากไหน
This commit is contained in:
Bkk1234 committed 2026-09-30 03:25:18 +07:00
1 parent 88311326e6
commit 1cfaeb1526
91 files changed
+7560 -844

No files matched your search

+125
View File
@@ -0,0 +1,125 @@
{
"other_stop": [
{
"route_id": "2231",
"station_name_th": "วัดมหานาม",
"city_th": "ไชโย",
"province_th": "อ่างทอง",
"station_type": "local_stop",
"latitude": 14.712584910077634,
"longitude": 100.44760308824014
},
{
"route_id": "324",
"station_name_th": "วัดไชโย",
"city_th": "ไชโย",
"province_th": "อ่างทอง",
"station_type": "local_stop",
"note": "จริงๆรถต้องวิ่งถึงวัดพิกุลแต่ลุงบอกว่าวิ่งแค่วัดไขโย",
"latitude": 14.717479991438898,
"longitude": 100.43705964220595
},
{
"route_id": "951",
"station_name_th": [
"ตลาดวิเศษชัยชาญ",
"ตลาดอ่างทอง"
],
"city_th": "เดิมบางนางบวช",
"province_th": "สุพรรณบุรี",
"station_type": "local_stop",
"latitude": [
14.597539758809786,
14.593647962599608
],
"longitude": [
100.35278002613065,
100.45092564287958
]
},
{
"route_id": "954",
"station_name_th": [
"ตลาดท่าช้าง",
"ตลาดสามโก้",
"ตลาดวิเศษชัยชาญ",
"ตลาดอ่างทอง"
],
"city_th": "เดิมบางนางบวช",
"province_th": "สุพรรณบุรี",
"station_type": "local_stop",
"latitude": [
14.642589723339519,
14.605201653648821,
14.597539758809786,
14.593647962599608
],
"longitude": [
100.14899973132988,
100.24275649657521,
100.35278002613065,
100.45092564287958
],
"offsets_min": [
0,
45,
null,
null
]
},
{
"route_id": "8",
"station_name_th": [
"ตลาดสรรคบุรี",
"ตลาดแสวงหา",
"ตลาดสดเทศบาลตำบลโพธิ์ทอง"
],
"city_th": "สรรคบุรี",
"province_th": "ชัยนาท",
"station_type": "local_stop",
"latitude": [
15.046181529690447,
14.749622456669288,
14.661318107670693
],
"longitude": [
100.15958536582698,
100.32660174886443,
100.40858605122014
]
},
{
"route_id": "2194",
"station_name_th": [
"วัดหัวเวียง",
"วัดถนน"
],
"city_th": [
"เสนา",
"ป่าโมก"
],
"province_th": [
"อยุธยา",
"อ่างทอง"
],
"station_type": "local_stop",
"latitude": [
14.368659201047619,
14.44214017212655
],
"longitude": [
100.41580160519578,
100.46123794436457
]
},
{
"route_id": "1101",
"station_name_th": "วัดสีบัวทอง",
"city_th": "แสวงหา",
"province_th": "อ่างทอง",
"station_type": "local_stop",
"latitude": 14.787802367428677,
"longitude": 100.23218786664407
}
]
}
+93
View File
@@ -0,0 +1,93 @@
# `8 other_stop.json` — บันทึกเตือนความจำ (ห้ามเพิ่ม/ห้ามลบมั่ว)
> 📌 **ไฟล์นี้เป็นบันทึกของเจ้าของข้อมูล ไม่ใช่ข้อมูลสำหรับเว็บ** — เว็บอ่านเฉพาะ `8 other_stop.json`
> ไฟล์นี้มีไว้กันการ "ช่วยเติมข้อมูล" ที่ไม่ได้รับอนุญาต (เช่น AI หรือผู้พัฒนาที่เข้ามาทีหลัง)
อัปเดตล่าสุด: **2026-09-26** · ผู้ตัดสินใจ: เจ้าของข้อมูล (ทีม Atroute)
---
## 1. ไฟล์นี้คืออะไร
`stations.json` มีจุดจอดกลางชื่อ **"จุดขึ้นรถประจำทางอื่นๆ"** (`station_id: 8`, `station_code: other_stop`)
ซึ่งเป็น**ชื่อรวม**ของทุกสายที่ไม่ได้ขึ้นที่สถานีหลัก — ของจริงของแต่ละสายอยู่ใน `8 other_stop.json` เช่น
```json
{ "route_id": "1101", "station_name_th": "วัดสีบัวทอง", "city_th": "แสวงหา", "province_th": "อ่างทอง",
"station_type": "local_stop", "latitude": 14.787802367428677, "longitude": 100.23218786664407 }
```
หน้าเว็บ (`#/stops/other_stop?route=1011`) จะขึ้น **"จุดขึ้นรถประจำทางอื่นๆ · วัดสีบัวทอง"** โดยจับคู่จากไฟล์นี้
ตัวจับคู่อยู่ที่ `ui/partials/otherStop.js` (ใช้ทั้งหน้า `#/stops/...` และ `#/routes/...`) — **อ่านไฟล์นี้เท่านั้น ไม่ต้องแก้โค้ดเมื่อเพิ่ม/ลบรายการ**
---
## 2. ⛔ ห้ามเพิ่ม 7 สายนี้ (เจ้าของข้อมูลกำหนด)
| สาย | ชื่อสาย | มี`station_id 8` ในเส้นทางไหม | สถานะข้อมูลของจุดนั้น | คำสั่ง |
| ------------- | ------------------------------------------------ | --------------------------------------------- | ---------------------------------------------------------------------------- | ------------------------------------------------------------------------------------ |
| | | | | |
| **952** | กรุงเทพ-วิเศษชัยชาญ | มี (จุดที่ 3/3) | มีเวลา 3 เที่ยว แต่ยังไม่ระบุชื่อจุดจริง | ⛔ ห้ามเพิ่ม entry (อย่าเพิ่มเพราะเห็นว่ามีเวลา) |
| **641** | อ่างทอง-บ้านแพรก-ลพบุรี | มี (จุดที่ 3/3) | ยังไม่มีข้อมูลเวลาที่จุดนี้ | ⛔ ห้ามเพิ่ม entry |
| **15** | กรุงเทพ-อ่างทอง สายใน | ไม่มี | — | ⛔ ห้ามเพิ่ม — เพิ่มไปก็ไม่แสดงผล |
| **902** | กรุงเทพ-อ่างทอง สายเอเซีย | ไม่มี | — | ⛔ ห้ามเพิ่ม — เพิ่มไปก็ไม่แสดงผล |
| **464** | สุพรรณ-อ่างทอง-สระบุรี | ไม่มี | — | ⛔ ห้ามเพิ่ม — เพิ่มไปก็ไม่แสดงผล |
| **101** | อ่างทอง-ป่าโมก-อยุธยา | ไม่มี | — | ⛔ ห้ามเพิ่ม — เพิ่มไปก็ไม่แสดงผล |
**ผลเมื่อไม่มี entry:** หน้าเว็บยังทำงานปกติ — แถวของสายนั้นจะแสดงตำแหน่งในเส้นทางแทน
(เช่น `จุดจอดที่ 3/3` หรือ `Passing · 4/5`) **ไม่ใช่ข้อผิดพลาด** และไม่ต้องไปเติมให้ครบ
---
## 3. ✅ 6 รายการที่มีอยู่แล้ว — ห้ามลบ
| `route_id` ในไฟล์ | ใช้กับสาย | ชื่อจุดจริง | อำเภอ/จังหวัด |
| ------------------------- | ------------------ | ------------------------ | -------------------------------------------------- |
| `2231` | 2231 | วัดมหานาม | ไชโย · อ่างทอง |
| `324` | 324 | วัดไชโย | ไชโย · อ่างทอง |
| `954` | 954 | ตลาดท่าช้าง | เดิมบางนางบวช · สุพรรณบุรี |
| `8` | 8 | ตลาดสรรคบุรี | สรรคบุรี · ชัยนาท |
| `2194` | 2194 | วัดหัวเวียง | เสนา · อยุธยา |
| **`1101`** | **1011** | วัดสีบัวทอง | แสวงหา · อ่างทอง |
> ⚠️ `1101` **ไม่ใช่รหัสสายจริง** — เป็นรหัสที่ระบบเดิมใช้แทนสาย **1011**
> โค้ดรองรับไว้แล้ว (เทียบแบบ "ตัวเลขชุดเดียวกัน สลับตำแหน่ง" เฉพาะรหัส ≥3 หลัก และหาคู่ได้ไม่กำกวม)
> จะแก้เป็น `"1011"` ก็ได้ (โค้ดรองรับทั้งสองแบบ) แต่ **ห้ามลบ** เพราะจุดนี้เป็นของสาย 1011
---
## 4. กติกาที่โค้ดใช้จับคู่ (`ui/partials/otherStop.js`)
1. **ตรงตัวก่อน** — `route_id` ในไฟล์ตรงกับรหัสสายจริง → ใช้เลย
2. **ไม่ตรง → เทียบแบบสลับตำแหน่งตัวเลข** เฉพาะรหัส **≥3 หลัก** และต้องหาคู่ได้ **ตัวเดียว** → `1101 → 1011` ✅
3. **ไม่รู้จัก / กำกวม → ไม่เดา** (คืนค่าว่าง แล้ว UI ถอยไปแสดงตำแหน่งในเส้นทาง) — เช่น `51` จะไม่ถูกจับเป็น `15`
## 5. ถ้าอนาคตจะเพิ่มรายการใหม่ (ต้องได้รับการยืนยันจากเจ้าของข้อมูลก่อน)
คีย์ที่ต้องมี: `route_id`, `station_name_th`, `city_th`, `province_th`, `station_type` (`local_stop`), `latitude`, `longitude` (+ `note` ถ้ามี)
หลังเพิ่ม: หน้า `#/stops/other_stop?route=<รหัสสาย>` ต้องขึ้นชื่อจุดนั้นทันที · และ `#/routes/<รหัสสาย>` จะแสดงจุดนั้นพร้อม กม. ตามเส้นทาง
**ข้อห้าม:** อย่าเพิ่มรายการเพราะ "เห็นว่ายังไม่มี" — ถ้าไม่มีในตาราง §3 แปลว่ายังไม่ได้รับข้อมูลจากเจ้าของ
## 6. กติกา "หลายจุดต่อสาย" (สำคัญ — เจ้าของข้อมูลกำหนด)
สายเดียวผ่านได้หลายจุด (เช่น **954** = ตลาดท่าช้าง · ตลาดสามโก้ · ตลาดวิเศษชัยชาญ · ตลาดอ่างทอง)
```json
"station_name_th": ["ตลาดท่าช้าง", "ตลาดสามโก้", "ตลาดวิเศษชัยชาญ", "ตลาดอ่างทอง"],
"latitude": 14.651061064977933, ← พิกัด "ของชื่อแรก" (ตลาดท่าช้าง)
"longitude": 100.14903762295052
```
- `station_name_th` เป็นได้ทั้ง **ข้อความเดียว** หรือ **array หลายชื่อ**
- `latitude`/`longitude` เป็นได้ทั้ง **ตัวเลขเดียว** (ของชื่อแรก) หรือ **array** จับคู่ **ตามลำดับ**
- ตัวอย่าง array: สาย 8 → `latitude: [15.0474, 14.7497, 14.6603]` + 4 ชื่อ → ชื่อที่ 4 (ตลาดอ่างทอง) ยังไม่มีพิกัด
- **ชื่อที่เกินจำนวนพิกัด = ยังไม่มีพิกัด** → เว็บแสดงชื่อพร้อมป้าย "ยังไม่มีพิกัด" (ไม่ซ่อน ไม่เดา)
- `city_th`/`province_th` ในไฟล์อธิบาย **จุดแรก** เท่านั้น (จุดอื่นไม่ทราบ)
**การแสดงผล:** `#/stops/other_stop?route=954` → แสดง "จุดขึ้นรถประจำทางอื่นๆ · ตลาดท่าช้าง" (ชื่อย่อ = จุดแรก)
+ รายการ **ทุกจุด** ของสายนั้น (แถวที่ไม่มีพิกัดขึ้นป้ายเตือน) · แผนที่ปักหมุดเฉพาะจุดที่มีพิกัด
**ข้อสังเกตของเจ้าของข้อมูล (ยังไม่แก้ ต้องยืนยัน):**
- สาย **951** และ **954** มีค่า `latitude/longitude` **เท่ากันเป๊ะ** (14.651061064977933, 100.14903762295052)
ทั้งที่จุดแรกของ 951 คือ "ตลาดวิเศษชัยชาญ" คนละที่กับ "ตลาดท่าช้าง" ของ 954 — น่าจะคัดลอกวางผิด
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,101 @@
# GeoJSON-2 — โฟลเดอร์ส่งข้อมูลเส้นทางจาก QGIS → เว็บ
โฟลเดอร์นี้คือ **ทางเดียว** ที่ข้อมูลเส้นทางเดินรถเข้าสู่เว็บ mockup นี้
(QGIS export → ที่นี่ → สคริปต์แปลง → [`../../geojson-web/`](../../geojson-web/) → แผนที่ Leaflet อ่าน)
```
QGIS (minibus map.qgz) เว็บใช้จริง
แก้เส้นทางในเลเยอร์ .shp ──Save──▶ <รหัส>.shp ──รันสคริปต์──▶ resource/data/geojson-web/<รหัส>.geojson
(CRS = EPSG:4326) python resource/tools/qgis-to-web.py
(ทางเลือกเดิม: --from geojson อ่านจาก GeoJSON-2/*.geojson)
```
> **ไม่ต้อง export GeoJSON อีกแล้ว** — pipeline อ่าน `.shp` ตรง ๆ ผ่านตาราง `SHP_MAP` ในสคริปต์
> (เวอร์ชัน 26/09/2026 เปลี่ยนมาใช้ทางนี้ เพราะวิธีทำงานจริงคือแก้ใน QGIS แล้วกด Save)
---
## 1. ก่อน export (ใน QGIS)
เปิดโปรเจกต์: `resource/data/QGIS Project/minibus map.qgz`
| เรื่อง | กติกา |
|---|---|
| **CRS** | `EPSG:4326 – WGS84` **เท่านั้น** — ถ้า export เป็น UTM (EPSG:32647/32648) เว็บจะ **ปฏิเสธไฟล์** (หมุดจะไปเกาะผิดที่) |
| **ชื่อไฟล์** | `<รหัสสาย>.geojson` เช่น `101.geojson`, `902.geojson` (ชื่อไฟล์ = เลขสายที่เว็บใช้) |
| **ปลายทาง** | โฟลเดอร์นี้ (`resource/data/QGIS Project/GeoJSON-2/`) |
| **ชนิดข้อมูล** | LineString หรือ MultiLineString (หลายช่วงในไฟล์เดียวได้) |
**ขั้นตอน export:** คลิกขวาเลเยอร์ ▸ `Export` ▸ `Save Features As…`
```
Format : GeoJSON
File name : resource\data\QGIS Project\GeoJSON-2\101.geojson
CRS : EPSG:4326 - WGS84 ← สำคัญที่สุด
Layer Options / Geometry → เปิด Use RFC7946 ถ้ามี
```
## 2. เลเยอร์ไหนคือสายไหน (ในโปรเจกต์ QGIS มีหลายเวอร์ชันต่อสาย — เลือกให้ถูก)
| รหัสสาย | ไฟล์ .shp ที่ตรงกับที่เว็บใช้อยู่ | เวอร์ชันอื่นในโปรเจกต์ (ใช้ได้แต่ต้องเลือกโดยตั้งใจ) |
|---|---|---|
| 101 | `101-Angthong-pamok-Ayuthaya.shp` (68 จุด) | — |
| 902 | `902.shp` (83 จุด) | `902 Ang Thong-Bangkok.shp` (57 จุด, ไม่มี .prj) |
| 15 | `15 angthong-Bangkok-local.shp` (120 จุด) | `15 Angthong-2.shp` (11 จุด) |
| 951 | `951 Bangkok-wisead-suphanburi.shp` (34 จุด) | — |
| 952 | `952 กรุงเทพ-วิเศษชัยชาญ.shp` (53 จุด) | — |
| 954 | `954.shp` (95 จุด) | `954 bangkok-singburi.shp` (56 จุด) |
| 8 | `8 Bangkok-Chainat.shp` (138 จุด) | — |
| 464 | `464 -suphanburi-saraburi.shp` (103 จุด, 2 ช่วง) | — |
| 641 | `641-Angthong-lopburi1.shp` (109 จุด) | `641-Angthong-lopburi.shp` (97 จุด) |
| 2194 | `2194.shp` (345 จุด) | `2194-Huaweanh-ayuthaya.shp` (32 จุด) |
| 324 | `324-Angthong-watpikungthong1.shp` (86 จุด) | `324-Angthong-watpikungthong.shp` (54 จุด) |
| 1011 | `1011.shp` (85 จุด) | `1011-Ang thong-Sribuathong.shp` (59 จุด) |
| 2231 | `2231.shp` (83 จุด) | `2231-Ang Thong-mahanam.shp` (54 จุด) |
| 905 | `905 bangkok-singburi.shp` (37 จุด) | (ยังไม่มีใน `routes.json`) |
| 1012, XXX1, XXX2 | ไม่มีไฟล์ชื่อตรง (มีเฉพาะใน `geojson-web/`) | — |
| **999** | **ไม่มี geometry เลย** — ต้องวาดใหม่ใน QGIS | — |
> ⚠️ ตัวเลข "จุด" = จำนวนจุดในเส้น ยิ่งมากยิ่งเกาะถนนละเอียด (จุดห่างกันน้อย)
> เส้นที่หยาบ (เช่น 902 = 48 จุด/100 กม.) จะเห็นเป็นเส้นตัดตรงข้ามโค้งถนนเมื่อซูมเข้า
## 3. แปลงเป็นไฟล์ที่เว็บใช้ (หลังกด Save ใน QGIS)
```bash
cd D:\Git\web-at-transit-mock
python resource/tools/qgis-to-web.py --check # ตรวจก่อน (ไม่เขียนไฟล์) — "เหมือนเดิม ✓" = QGIS ไม่มีการเปลี่ยน
python resource/tools/qgis-to-web.py --list # ดูตารางรหัสสาย ↔ ไฟล์ .shp + สถานะ
python resource/tools/qgis-to-web.py # เขียนจริง → resource/data/geojson-web/
```
สคริปต์จะ: อ่านไฟล์ `.shp` ตามตาราง `SHP_MAP` · **ปฏิเสธ**ไฟล์ที่ CRS เป็น UTM (เช็คจาก `.prj` + รูปแบบพิกัด) ·
ตัดจุดที่หลุดกรอบประเทศไทย (lng 97–103, lat 12–17.5) · ปัดพิกัด 5 ตำแหน่ง · เขียน 1 record = 1 feature (MultiLineString) ·
properties `{"route_id": "<รหัส>"}` · **ไม่เขียนทับไฟล์ที่ไม่มีการเปลี่ยนแปลง**
> ⚠️ ถ้าเปลี่ยนชื่อไฟล์ `.shp` ใน QGIS ต้องแก้ตาราง `SHP_MAP` ในสคริปต์ด้วย (ไม่งั้นจะขึ้น "ไม่พบไฟล์")
## 3.1 ตรวจสุขภาพข้อมูล (แนะนำให้รันก่อน/หลังแก้เส้น)
```bash
python resource/tools/audit-geojson.py
```
ตรวจ 3 ส่วน: **A)** ไฟล์ส่งออกใน QGIS Project (CRS/ว่าง/ซ้ำ/หยาบ) · **B)** ข้อมูลที่เว็บใช้จริง `geojson-web/`
(รวม **ปลายเส้นตรงกับจุดจอดจริงไหม** เทียบ `stations.json` + `8 other_stop.json`) · **C)** **sync: shapefile ↔ geojson-web**
(บอกว่า "ต้องรัน qgis-to-web.py" หรือไม่)
เกณฑ์: CRS ต้อง WGS84 · ตัดตรง > 1.5 กม. = หยาบเกินไป · ปลายเส้นห่างจุดจอด > 1.0 กม. = ไม่ตรง
## 4. ทดสอบ
เปิด `http://localhost:8090/ui/index.html#/routes/101` (เปลี่ยนเลขสายตามที่แก้) แล้วกด **Ctrl+Shift+R**
- ไฟล์ `.geojson` เป็น network-first ใน Service Worker → ไม่ต้อง bump `VERSION` เมื่อแก้แต่ข้อมูลเส้น
- bump `VERSION` ใน `ui/sw.js` เฉพาะเมื่อแก้ไฟล์ในรายการ precache (HTML/CSS/JS)
## 5. ขอบเขตข้อมูล
| เรื่อง | รายละเอียด |
|---|---|
| `geojson-web/` มี 17 ไฟล์ | แต่ `routes.json` ใช้ 14 สาย → `1012`, `905`, `XXX1`, `XXX2` มีข้อมูลแต่ยังไม่ถูกเรียกใช้ |
| กี่สายที่แสดงบนแผนที่ได้ | 13/14 (ทุกสายใน `routes.json` ยกเว้น **999** ที่ไม่มี geometry) |
| ป้ายหยุดรถ | ไม่ได้อยู่ในโฟลเดอร์นี้ — มาจาก `resource/data/busstop_list.json` (154 ป้าย) |
| หมุดสถานี | มาจาก `resource/data/stations.json` (ต้องมีพิกัดเป็น **number** ไม่ใช่ string) |
Binary file not shown.
@@ -0,0 +1,86 @@
{
"schema": 2,
"route_id": "101",
"generated_from": "schedules.json",
"station_order": [
2
],
"directions": [
{
"dir_id": "Ayuthya2Angthong",
"dir_label": null,
"stops": []
},
{
"dir_id": "Angthong2Ayuthya",
"dir_label": null,
"stops": []
},
{
"dir_id": "dir-1",
"dir_label": "ไปอยุธยา",
"stops": [
{
"station_id": 2,
"times": [
"06:30",
"07:20",
"08:10",
"09:00",
"09:50",
"10:40",
"11:30",
"12:20",
"13:10",
"14:00",
"14:50",
"15:40",
"16:30",
"17:30"
],
"dir_note": "ตารางวันทำงาน"
},
{
"station_id": 2,
"times": [
"07:40",
"09:20",
"10:50",
"12:30",
"13:20"
],
"dir_note": "ตารางวันหยุด"
}
]
},
{
"dir_id": "dir-2",
"dir_label": "ไปอ่างทอง",
"stops": [
{
"station_id": 2,
"times": [
"08:00",
"08:50",
"09:40",
"10:30",
"11:20",
"12:20",
"13:30",
"14:30",
"15:30"
],
"dir_note": "ตารางวันทำงาน"
},
{
"station_id": 2,
"times": [
"06:20",
"08:30"
],
"dir_note": "ตารางวันหยุด"
}
]
}
]
}
@@ -0,0 +1,42 @@
{
"schema": 2,
"route_id": "8",
"generated_from": "schedules.json",
"station_order": [
5,
6,
8,
13
],
"directions": [
{
"dir_id": "all",
"dir_label": null,
"stops": [
{
"station_id": 13,
"times": [
"07:30",
"10:00"
]
}
],
"speedKmh": 60
},
{
"dir_id": "dir-1",
"dir_label": null,
"stops": [
{
"station_id": 6,
"times": [
"10:00",
"13:00"
],
"dir_note": "ตลาดโพธิ์ทอง",
"note":
}
]
}
]
}
+874
View File
@@ -0,0 +1,874 @@
{
"schema": 2,
"routes": [
{
"route_id": "101",
"station_order": [
1,
2,
3
],
"directions": [
{
"dir_id": "Ayuthya2Angthong",
"dir_label": null,
"stops": [
{
"station_id": 3,
"times": [
"07:30",
"08:20",
"09:10",
"10:00",
"10:50",
"11:40",
"12:30",
"13:20",
"14:10",
"15:00",
"15:50",
"16:40",
"17:30",
"18:30"
],
"dir_note": "ตารางวันทำงาน",
"note": null
},
{
"station_id": 3,
"times": [
"06:50",
"08:30",
"10:00",
"11:40",
"13:20",
"15:00",
"17:00"
],
"dir_note": "ตารางวันหยุด",
"note": null
}
]
},
{
"dir_id": "Angthong2Ayuthya",
"dir_label": null,
"stops": [
{
"station_id": 1,
"times": [
"07:30",
"08:20",
"09:10",
"10:00",
"10:50",
"11:50",
"13:00",
"14:00",
"15:00"
],
"dir_note": "ตารางวันทำงาน"
},
{
"station_id": 1,
"times": [
"09:30",
"10:30",
"12:00",
"14:30"
],
"dir_note": "ตารางวันหยุด"
}
]
},
{
"dir_id": "dir-1",
"dir_label": "ไปอยุธยา",
"stops": [
{
"station_id": 2,
"times": [
"06:30",
"07:20",
"08:10",
"09:00",
"09:50",
"10:40",
"11:30",
"12:20",
"13:10",
"14:00",
"14:50",
"15:40",
"16:30",
"17:30"
],
"dir_note": "ตารางวันทำงาน"
},
{
"station_id": 2,
"times": [
"07:40",
"09:20",
"10:50",
"12:30",
"13:20"
],
"dir_note": "ตารางวันหยุด"
}
]
},
{
"dir_id": "dir-2",
"dir_label": "ไปอ่างทอง",
"stops": [
{
"station_id": 2,
"times": [
"08:00",
"08:50",
"09:40",
"10:30",
"11:20",
"12:20",
"13:30",
"14:30",
"15:30"
],
"dir_note": "ตารางวันทำงาน"
},
{
"station_id": 2,
"times": [
"06:20",
"08:30"
],
"dir_note": "ตารางวันหยุด"
}
]
}
]
},
{
"route_id": "15",
"station_order": [
1,
2,
4,
5,
6
],
"directions": [
{
"dir_id": "from-1",
"dir_label": null,
"stops": [
{
"station_id": 1,
"times": [
"05:00",
"05:45",
"06:30",
"07:30"
]
}
]
},
{
"dir_id": "all",
"dir_label": null,
"stops": [
{
"station_id": 2,
"times": [
"05:30",
"06:20",
"07:05",
"07:55",
"08:40",
"09:30",
"11:20",
"12:10",
"13:00",
"15:00"
]
},
{
"station_id": 6,
"times": [
"06:00",
"08:30",
"09:15",
"10:00",
"12:30",
"14:00",
"15:00",
"16:00"
]
}
]
},
{
"dir_id": "new-3",
"dir_label": null,
"stops": [
{
"station_id": 6,
"times": []
}
],
"autoTimes": true
}
]
},
{
"route_id": "902",
"station_order": [
1,
5,
6
],
"directions": [
{
"dir_id": "from-1",
"dir_label": null,
"stops": [
{
"station_id": 1,
"times": [
"04:00",
"04:30",
"05:00",
"05:30",
"06:00",
"06:30",
"07:00",
"07:30",
"08:00",
"08:30",
"09:00",
"09:30",
"10:00",
"10:30",
"11:00",
"11:30",
"12:00",
"12:30",
"13:00",
"13:30",
"14:00",
"14:30",
"15:00",
"15:30",
"16:00",
"16:30",
"17:00",
"17:30"
]
}
]
},
{
"dir_id": "all",
"dir_label": null,
"stops": [
{
"station_id": 6,
"times": [
"06:00",
"06:30",
"07:00",
"07:30",
"08:00",
"08:30",
"09:00",
"09:30",
"10:00",
"10:30",
"11:00",
"11:30",
"12:00",
"12:30",
"13:00",
"13:30",
"14:00",
"14:30",
"15:00",
"15:30",
"16:00",
"16:30",
"17:00",
"17:30",
"18:00"
]
}
]
}
]
},
{
"route_id": "951",
"station_order": [
9,
20,
5,
6,
8
],
"directions": [
{
"dir_id": "from-9",
"dir_label": null,
"stops": [
{
"station_id": 9,
"times": [
"04:00",
"04:20",
"04:40",
"05:00",
"05:20",
"05:40",
"06:00",
"06:20",
"06:40",
"07:00",
"07:20",
"07:40",
"08:00",
"08:20",
"08:40",
"09:00",
"09:20",
"09:40",
"10:00",
"10:20",
"10:40",
"11:00",
"11:20",
"11:40",
"12:00",
"12:20",
"12:40",
"13:00",
"13:20",
"13:40",
"14:00",
"14:20",
"14:40",
"15:00",
"15:20",
"15:40",
"16:00",
"16:20",
"16:40",
"17:00",
"17:20",
"17:40",
"18:00"
]
},
{
"station_id": 8,
"times": [
"05:45"
],
"dir_note": "ตลาดวิเศษชัยชาญ",
"note": "ตลาดวิเศษชัยชาญ"
},
{
"station_id": 8,
"times": [
"10:35"
],
"dir_note": "ตลาดอ่างทอง",
"note": "ตลาดอ่างทอง"
}
]
},
{
"dir_id": "new-2",
"dir_label": null,
"stops": [
{
"station_id": 6,
"times": [
"04:00"
]
},
{
"station_id": 5,
"times": [
"05:00"
]
},
{
"station_id": 9,
"times": []
}
]
}
]
},
{
"route_id": "952",
"station_order": [
11,
12
],
"directions": [
{
"dir_id": "dir-1",
"dir_label": "จากตลาดวิเศษ",
"stops": [
{
"station_id": 8,
"times": [
"04:30",
"10:00",
"15:00"
],
"dir_note": "จากตลาดวิเศษ",
"note": "10:00 มีเฉพาะวันหยุด"
}
]
},
{
"dir_id": "all",
"dir_label": null,
"stops": [
{
"station_id": 12,
"times": [
"07:00",
"10:30",
"15:00"
],
"note": " 7:00 มีเฉพาะวันหยุด"
}
]
}
]
},
{
"route_id": "954",
"station_order": [
20,
5,
6,
8
],
"directions": [
{
"dir_id": "dir-1",
"dir_label": "จากตลาดท่าช้าง",
"stops": [
{
"station_id": 8,
"times": [
"03:30",
"05:10",
"10:20",
"12:40"
],
"dir_note": "จากตลาดท่าช้าง"
}
]
}
]
},
{
"route_id": "8",
"station_order": [
5,
6,
8,
13
],
"directions": [
{
"dir_id": "all",
"dir_label": null,
"stops": [
{
"station_id": 13,
"times": [
"07:30",
"10:00"
]
}
],
"speedKmh": 60
},
{
"dir_id": "dir-1",
"dir_label": null,
"stops": [
{
"station_id": 6,
"times": [
"10:00",
"13:00"
],
"dir_note": "จากโพธิ์ทอง",
"note": "เวลาเปลี่ยนทุกวัน"
}
]
}
]
},
{
"route_id": "464",
"station_order": [
1,
9,
10
],
"directions": [
{
"dir_id": "all",
"dir_label": null,
"stops": [
{
"station_id": 9,
"times": [
"04:40",
"05:10",
"05:40",
"06:10",
"06:40",
"07:10",
"07:40",
"08:15",
"08:50",
"09:25",
"10:00",
"10:35",
"11:10",
"11:45",
"12:20",
"12:55",
"13:30",
"14:05",
"14:40",
"15:15",
"15:50",
"16:25",
"17:00",
"17:40"
]
},
{
"station_id": 10,
"times": [
"05:00",
"05:40",
"06:20",
"07:10",
"08:00",
"08:40",
"09:20",
"10:00",
"10:40",
"11:20",
"12:00",
"12:40",
"13:20",
"14:00",
"14:40",
"15:20",
"16:00",
"16:40",
"17:20",
"18:00"
]
}
]
},
{
"dir_id": "dir-1",
"dir_label": "ไปสุพรรณบุรี",
"stops": [
{
"station_id": 1,
"times": [
"06:30",
"07:10",
"07:50",
"08:40",
"09:30",
"10:10",
"10:50",
"11:30",
"12:10",
"12:50",
"13:30",
"14:10",
"14:50",
"15:30",
"16:10",
"16:50",
"17:30",
"18:10",
"18:50",
"19:30"
],
"dir_note": "ไปสุพรรณบุรี"
}
]
},
{
"dir_id": "dir-2",
"dir_label": "ไปสระบุรี",
"stops": [
{
"station_id": 1,
"times": [
"05:40",
"06:10",
"06:40",
"07:10",
"07:40",
"08:10",
"08:40",
"09:15",
"09:50",
"10:25",
"11:00",
"11:35",
"12:10",
"12:45",
"13:20",
"13:55",
"14:30",
"15:05",
"15:40",
"16:15",
"16:50",
"17:25",
"18:00",
"18:40"
],
"dir_note": "ไปสระบุรี",
"note": null
}
]
}
]
},
{
"route_id": "641",
"station_order": [
1,
7,
8
],
"directions": [
{
"dir_id": "from-1",
"dir_label": null,
"stops": [
{
"station_id": 1,
"times": [
"07:00",
"08:00",
"09:00",
"10:00",
"11:00",
"12:00",
"13:30",
"14:30",
"16:30"
]
}
]
},
{
"dir_id": "all",
"dir_label": null,
"stops": [
{
"station_id": 7,
"times": [
"07:00",
"08:00",
"09:00",
"10:00",
"11:00",
"12:00",
"13:30",
"14:30",
"16:30"
],
"note": "10:00 และ 13:30 ไม่ได้มีทุกวัน"
}
]
}
]
},
{
"route_id": "2194",
"station_order": [
4,
8
],
"directions": [
{
"dir_id": "dir-1",
"dir_label": "จากวัดหัวเวียง",
"stops": [
{
"station_id": 8,
"times": [
"05:00",
"06:00",
"07:00"
],
"dir_note": "จากวัดหัวเวียง"
}
]
},
{
"dir_id": "from-4",
"dir_label": null,
"stops": [
{
"station_id": 4,
"times": [
"16:00",
"17:00",
"18:00"
]
}
]
}
]
},
{
"route_id": "324",
"station_order": [
1,
8
],
"directions": [
{
"dir_id": "from-1",
"dir_label": null,
"stops": [
{
"station_id": 1,
"times": [
"10:00"
]
}
]
},
{
"dir_id": "dir-1",
"dir_label": "จากวัดไชโยวรวิหาร",
"stops": [
{
"station_id": 8,
"times": [
"08:00"
],
"dir_note": "จากวัดไชโยวรวิหาร"
}
]
}
]
},
{
"route_id": "1011",
"station_order": [
1,
8
],
"directions": [
{
"dir_id": "from-1",
"dir_label": null,
"stops": [
{
"station_id": 1,
"times": [
"12:00",
"16:00",
"17:00"
]
}
]
},
{
"dir_id": "dir-1",
"dir_label": "จากวัดสีบัวทอง",
"stops": [
{
"station_id": 8,
"times": [
"06:00",
"06:30",
"14:30"
],
"dir_note": "จากวัดสีบัวทอง"
}
]
}
]
},
{
"route_id": "2231",
"station_order": [
1,
8
],
"directions": [
{
"dir_id": "from-1",
"dir_label": null,
"stops": [
{
"station_id": 1,
"times": [
"16:00"
]
}
]
},
{
"dir_id": "dir-1",
"dir_label": "จากวัดมหานาม",
"stops": [
{
"station_id": 8,
"times": [
"08:00"
],
"dir_note": "จากวัดมหานาม"
}
]
}
]
},
{
"route_id": "999",
"station_order": [
14
],
"directions": [
{
"dir_id": "from-14",
"dir_label": null,
"stops": [
{
"station_id": 14,
"times": [],
"note": "ยังไม่มีข้อมูลตารางเวลา"
}
]
}
]
}
]
}
+19
View File
@@ -0,0 +1,19 @@
# ตารางกฎ "จุดนี้ = เวลาจุดอ้างอิง ± n นาที" (ใช้โดย resource/tools/derive-times.py)
#
# คอลัมน์: route_id, station_id, from_station_id, offset_min, note
# route_id รหัสสาย (ตรงกับชื่อไฟล์ schedules<route_id>.json)
# station_id จุดที่จะ "คำนวณ" (ต้องมีจุดนี้อยู่ในไฟล์ของสายแล้ว)
# from_station_id จุดอ้างอิง (ต้องมี "เวลาจริง" อยู่ในไฟล์ของสาย — จะอยู่ทิศไหนก็ได้)
# offset_min บวก/ลบ กี่นาที (+30 = หลังจุดอ้างอิง 30 นาที · -15 = ก่อนหน้า 15 นาที)
# note หมายเหตุ (ไม่ใส่ก็ได้)
#
# วิธีใช้:
# python resource/tools/derive-times.py --check → ดูว่าจะเปลี่ยนอะไร
# python resource/tools/derive-times.py → เขียนไฟล์จริง
# python resource/tools/derive-times.py --audit → ตรวจว่าไฟล์ตรงกับตารางไหม
#
# ⚠️ เว็บจะแสดงเวลาที่คำนวณเป็น "ชิปเส้นประ + ประมาณ" พร้อมข้อความ
# "ตารางจากการคำนวณ (จาก <จุดอ้างอิง> +n นาที) — อาจเปลี่ยนแปลงตามการจราจรจริง" ให้อัตโนมัติ
route_id,station_id,from_station_id,offset_min,note
902,15,6,30,รอรถที่ 7-11 หน้ากินซ่า (รถจากจตุจักรผ่านมาถึง)
951,5,6,30,ท่ารถตู้ต่างจังหวัด รังสิต (รถจากจตุจักรผ่านมาถึง)
Can't render this file because it contains an unexpected character in line 1 and column 25.
+1 -1
View File
@@ -1 +1 @@
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"route_id":"1011"},"geometry":{"type":"MultiLineString","coordinates":[[[100.4517,14.59479],[100.45235,14.59405],[100.45212,14.59376],[100.45214,14.59354],[100.45196,14.59333],[100.45168,14.59358],[100.45092,14.59379],[100.44497,14.59278],[100.44407,14.59676],[100.44377,14.59752],[100.44326,14.59812],[100.44261,14.59829],[100.43689,14.6005],[100.42636,14.60307],[100.42433,14.60344],[100.4236,14.60379],[100.42318,14.60428],[100.42239,14.60601],[100.41085,14.63685],[100.41029,14.63838],[100.41021,14.63973],[100.41001,14.6427],[100.40999,14.64611],[100.41061,14.64889],[100.41206,14.65596],[100.41212,14.65664],[100.41212,14.65744],[100.41169,14.65815],[100.40154,14.66939],[100.40057,14.67096],[100.40013,14.67208],[100.39877,14.67419],[100.39804,14.67497],[100.39686,14.67569],[100.33513,14.72467],[100.33415,14.72548],[100.33371,14.72672],[100.32664,14.74673],[100.32644,14.74796],[100.32644,14.75101],[100.32413,14.75111],[100.32299,14.75143],[100.32234,14.75167],[100.32098,14.75232],[100.31987,14.75282],[100.31875,14.75324],[100.31748,14.75364],[100.30222,14.75596],[100.30119,14.75614],[100.28755,14.76192],[100.28042,14.7665],[100.27939,14.7676],[100.2753,14.77133],[100.27225,14.77263],[100.26863,14.77424],[100.26414,14.77548],[100.26081,14.77532],[100.25018,14.77895],[100.24905,14.7796],[100.24744,14.78086],[100.24034,14.78537],[100.23705,14.78643],[100.23148,14.78848]]]}}]}
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"route_id":"1011"},"geometry":{"type":"MultiLineString","coordinates":[[[100.22899,14.78903],[100.23181,14.7874],[100.23293,14.78654],[100.23348,14.78787],[100.23734,14.7863],[100.24031,14.78555],[100.24175,14.78474],[100.2479,14.78069],[100.24912,14.7796],[100.25118,14.77854],[100.25312,14.77794],[100.25711,14.77664],[100.25888,14.77616],[100.26111,14.77547],[100.26244,14.77544],[100.26332,14.77549],[100.26438,14.77545],[100.26679,14.77491],[100.26771,14.77472],[100.26874,14.77423],[100.27033,14.77335],[100.27186,14.77289],[100.27279,14.77269],[100.27426,14.77186],[100.27569,14.77088],[100.27948,14.76761],[100.2818,14.76552],[100.2854,14.76329],[100.28872,14.76146],[100.29292,14.75969],[100.2976,14.75746],[100.30227,14.75576],[100.30675,14.75488],[100.3121,14.75454],[100.31637,14.75387],[100.32051,14.75244],[100.32369,14.75115],[100.32426,14.75105],[100.32523,14.75085],[100.32637,14.75078],[100.32667,14.74725],[100.32673,14.74655],[100.32721,14.74505],[100.33155,14.73232],[100.33402,14.72558],[100.34471,14.71654],[100.35979,14.704],[100.36932,14.69614],[100.39487,14.67733],[100.39755,14.6754],[100.39897,14.67401],[100.39965,14.67269],[100.40107,14.66991],[100.40182,14.66886],[100.40778,14.66252],[100.41175,14.65805],[100.41191,14.65785],[100.41207,14.65749],[100.41216,14.65698],[100.41211,14.65649],[100.41203,14.65608],[100.41023,14.64694],[100.41006,14.64623],[100.41006,14.64562],[100.41027,14.6385],[100.41348,14.62989],[100.42243,14.60564],[100.42287,14.60449],[100.42355,14.60378],[100.42435,14.6033],[100.42543,14.6033],[100.4326,14.60161],[100.43694,14.60054],[100.44238,14.59844],[100.44373,14.59769],[100.44407,14.5971],[100.445,14.59276],[100.44753,14.59307],[100.44951,14.59361],[100.45085,14.59382],[100.45128,14.59376],[100.45173,14.5937],[100.45208,14.59369],[100.45229,14.594],[100.45169,14.59471]]]}}]}
+1 -1
View File
@@ -1 +1 @@
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"route_id":"2231"},"geometry":{"type":"MultiLineString","coordinates":[[[100.45164,14.59464],[100.45228,14.59402],[100.45214,14.59384],[100.45207,14.59372],[100.45207,14.5936],[100.45207,14.59342],[100.45212,14.59328],[100.45365,14.58981],[100.45563,14.58528],[100.45638,14.58393],[100.45676,14.58342],[100.45747,14.5829],[100.45811,14.58241],[100.45914,14.58211],[100.47001,14.57913],[100.47149,14.57895],[100.47336,14.57895],[100.47438,14.57893],[100.47623,14.57899],[100.47767,14.57915],[100.4784,14.57925],[100.47974,14.57975],[100.48045,14.58026],[100.48076,14.58126],[100.48096,14.58419],[100.4808,14.58504],[100.47913,14.58792],[100.47645,14.59231],[100.47452,14.5953],[100.47142,14.59995],[100.47071,14.60022],[100.47035,14.60088],[100.46888,14.60105],[100.46811,14.60155],[100.46742,14.60228],[100.46659,14.60293],[100.46704,14.60401],[100.4672,14.60468],[100.46689,14.60545],[100.46681,14.60611],[100.46495,14.60999],[100.46248,14.61562],[100.46221,14.61635],[100.46196,14.61743],[100.46173,14.61837],[100.46163,14.61901],[100.46167,14.62107],[100.46193,14.62386],[100.4622,14.62485],[100.46254,14.62557],[100.46298,14.62662],[100.46593,14.63379],[100.46618,14.63472],[100.46614,14.63577],[100.46618,14.63694],[100.46576,14.639],[100.46462,14.64452],[100.46445,14.64564],[100.46469,14.64662],[100.46503,14.64738],[100.46545,14.64802],[100.4663,14.64909],[100.47133,14.65713],[100.47143,14.65775],[100.47158,14.65854],[100.47149,14.6595],[100.47111,14.66149],[100.47091,14.66213],[100.47066,14.66272],[100.47035,14.66318],[100.47,14.66375],[100.46657,14.6679],[100.46611,14.66857],[100.46588,14.66915],[100.46596,14.66959],[100.46602,14.67578],[100.46601,14.67744],[100.46598,14.67805],[100.46587,14.67859],[100.46569,14.67907],[100.46548,14.67961],[100.46513,14.68009],[100.46474,14.68048],[100.45835,14.68575],[100.4571,14.68667],[100.45637,14.68742],[100.45603,14.68838],[100.45586,14.68949],[100.45594,14.69051],[100.45553,14.69491],[100.45548,14.69567],[100.45512,14.69633],[100.45481,14.69691],[100.45296,14.70066],[100.45288,14.70144],[100.45256,14.70265],[100.45196,14.70671],[100.45172,14.70739],[100.45113,14.70824],[100.44969,14.71083],[100.44821,14.71356],[100.4467,14.71258]]]}}]}
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"route_id":"2231"},"geometry":{"type":"MultiLineString","coordinates":[[[100.45166,14.59468],[100.45229,14.594],[100.45218,14.5939],[100.45203,14.59367],[100.45207,14.59364],[100.45208,14.59356],[100.45208,14.5935],[100.45207,14.59346],[100.45211,14.59322],[100.45569,14.58517],[100.45606,14.58431],[100.45653,14.58368],[100.45716,14.58312],[100.45786,14.58255],[100.45903,14.58207],[100.46276,14.581],[100.46962,14.57918],[100.47066,14.57901],[100.47179,14.5789],[100.47569,14.57891],[100.47788,14.57915],[100.47904,14.57953],[100.48031,14.58029],[100.48063,14.58102],[100.48097,14.58439],[100.48066,14.5854],[100.47915,14.58822],[100.47095,14.60087],[100.46952,14.60091],[100.46875,14.60113],[100.46782,14.60183],[100.46638,14.60291],[100.46678,14.60351],[100.46702,14.60423],[100.46708,14.60501],[100.46695,14.60565],[100.46645,14.60665],[100.46265,14.61527],[100.46197,14.61717],[100.46157,14.61871],[100.46152,14.62047],[100.46157,14.62237],[100.46184,14.62422],[100.46581,14.63344],[100.46622,14.63493],[100.46622,14.63629],[100.46622,14.63769],[100.46464,14.64437],[100.46446,14.64578],[100.46486,14.64704],[100.4655,14.64835],[100.47137,14.6573],[100.47162,14.65787],[100.47167,14.65878],[100.47138,14.66043],[100.47112,14.6619],[100.47075,14.66265],[100.47026,14.66348],[100.46883,14.66524],[100.46633,14.6683],[100.46599,14.66879],[100.46597,14.66924],[100.46602,14.66956],[100.46617,14.67763],[100.46604,14.67854],[100.46579,14.6791],[100.4655,14.67971],[100.46502,14.68032],[100.4643,14.68086],[100.46328,14.68172],[100.45691,14.68701],[100.45641,14.68757],[100.45603,14.68832],[100.45551,14.69494],[100.4554,14.69566],[100.45522,14.69648],[100.45325,14.70025],[100.45306,14.70075],[100.45291,14.70154],[100.45205,14.70683],[100.45189,14.7073],[100.45139,14.70827],[100.44817,14.71339]]]}}]}
+1 -1
View File
@@ -1 +1 @@
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"route_id":"324"},"geometry":{"type":"MultiLineString","coordinates":[[[100.4517,14.59495],[100.45181,14.59451],[100.45229,14.59398],[100.45278,14.5944],[100.45693,14.59676],[100.45745,14.5974],[100.45745,14.59849],[100.45882,14.6068],[100.45874,14.60889],[100.45769,14.61042],[100.45496,14.61275],[100.45352,14.61572],[100.45239,14.61901],[100.45175,14.6211],[100.45183,14.62335],[100.45199,14.62431],[100.45271,14.6252],[100.4536,14.62568],[100.45657,14.62905],[100.45801,14.6309],[100.45809,14.63146],[100.45801,14.63412],[100.45817,14.63781],[100.45817,14.64014],[100.45769,14.64327],[100.4552,14.64608],[100.45408,14.64954],[100.45344,14.65299],[100.45496,14.65548],[100.45737,14.65749],[100.45809,14.65805],[100.46099,14.66207],[100.46107,14.664],[100.4597,14.66697],[100.45745,14.67637],[100.45657,14.6779],[100.45472,14.67974],[100.44942,14.68368],[100.44821,14.68569],[100.44717,14.68971],[100.445,14.70208],[100.44444,14.70489],[100.44299,14.70722],[100.43809,14.7118],[100.43335,14.71678],[100.4311,14.72095],[100.42974,14.72433],[100.42998,14.7281],[100.43126,14.73228],[100.43456,14.73549],[100.43833,14.74264],[100.44002,14.74481],[100.44106,14.74779],[100.44096,14.74953],[100.43992,14.75101],[100.43807,14.75351],[100.43546,14.75628],[100.4347,14.75978],[100.43715,14.76072],[100.43894,14.76156],[100.44028,14.76401],[100.44052,14.76666],[100.43434,14.77883],[100.42315,14.77895],[100.41889,14.77944],[100.41664,14.77827],[100.40475,14.78173],[100.40283,14.78221]]]}}]}
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"route_id":"324"},"geometry":{"type":"MultiLineString","coordinates":[[[100.40278,14.78146],[100.40157,14.77782],[100.39886,14.77286],[100.39586,14.76769],[100.39602,14.76531],[100.39702,14.76335],[100.39915,14.7623],[100.40383,14.76151],[100.4052,14.75997],[100.40704,14.75708],[100.41277,14.75445],[100.41342,14.75362],[100.41582,14.75426],[100.41761,14.75443],[100.41938,14.75358],[100.42025,14.75367],[100.42117,14.76139],[100.42234,14.76547],[100.42346,14.76643],[100.42473,14.76635],[100.42665,14.76654],[100.42792,14.7665],[100.43024,14.76543],[100.43059,14.76431],[100.43028,14.76291],[100.43062,14.76195],[100.43147,14.76078],[100.43326,14.75955],[100.43448,14.75976],[100.43556,14.75651],[100.43654,14.75498],[100.43773,14.75329],[100.43959,14.75149],[100.44037,14.75014],[100.44098,14.74878],[100.44108,14.7477],[100.44064,14.74648],[100.44,14.74509],[100.43549,14.73607],[100.43468,14.73499],[100.43244,14.73282],[100.43082,14.73085],[100.43027,14.7295],[100.43027,14.72719],[100.43,14.72557],[100.43054,14.72252],[100.43237,14.71865],[100.43387,14.71615],[100.43617,14.71418],[100.43773,14.7133],[100.44417,14.70449],[100.44471,14.70245],[100.44573,14.6992],[100.44776,14.68842],[100.44864,14.6853],[100.44979,14.6832],[100.45284,14.68042],[100.45671,14.67731],[100.45752,14.67561],[100.46091,14.66484],[100.46111,14.66334],[100.4605,14.66178],[100.45996,14.66056],[100.45854,14.6584],[100.45467,14.65426],[100.45379,14.65216],[100.454,14.64992],[100.45474,14.6483],[100.45813,14.64138],[100.45839,14.64008],[100.45817,14.63462],[100.45823,14.63181],[100.45755,14.63008],[100.45661,14.62825],[100.45498,14.6271],[100.45257,14.62395],[100.4521,14.6229],[100.4519,14.621],[100.45271,14.619],[100.45457,14.61469],[100.45545,14.61286],[100.45654,14.61141],[100.45796,14.60988],[100.45874,14.60859],[100.45871,14.60744],[100.45823,14.60314],[100.45776,14.6011],[100.45793,14.59921],[100.45739,14.59761],[100.45654,14.59643],[100.45488,14.59565],[100.45325,14.59481],[100.45264,14.59434],[100.45237,14.59405],[100.45184,14.59447],[100.45167,14.59483]]]}}]}
+1 -1
View File
@@ -1 +1 @@
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"route_id":"8"},"geometry":{"type":"MultiLineString","coordinates":[[[100.55007,13.81176],[100.54803,13.80926],[100.54817,13.80233],[100.54837,13.79739],[100.55096,13.79765],[100.55932,13.81199],[100.55734,13.8308],[100.558,13.84056],[100.56146,13.84754],[100.61897,13.95121],[100.62067,13.95497],[100.62008,13.96216],[100.61538,13.98922],[100.61479,13.99393],[100.61527,14.00753],[100.61823,14.16709],[100.60966,14.19564],[100.60864,14.20469],[100.6093,14.21337],[100.61089,14.22871],[100.6128,14.24543],[100.61237,14.28331],[100.61237,14.3378],[100.6128,14.35769],[100.60666,14.37822],[100.59968,14.39092],[100.5728,14.41525],[100.55259,14.42975],[100.54582,14.43578],[100.54327,14.43887],[100.5416,14.44528],[100.53845,14.46125],[100.52642,14.48879],[100.51891,14.50921],[100.50661,14.52233],[100.49527,14.56107],[100.49141,14.56936],[100.48326,14.58238],[100.47767,14.57883],[100.47017,14.57939],[100.4635,14.58117],[100.4627,14.58118],[100.4623,14.57997],[100.46122,14.5785],[100.45918,14.57794],[100.44667,14.5764],[100.44534,14.5762],[100.44438,14.57661],[100.44392,14.57701],[100.44346,14.57798],[100.44071,14.58996],[100.44063,14.5915],[100.44129,14.59218],[100.4448,14.59287],[100.4438,14.59779],[100.43675,14.60078],[100.42449,14.60376],[100.42388,14.60396],[100.42329,14.6044],[100.42289,14.60501],[100.42254,14.60614],[100.41076,14.63763],[100.41039,14.6384],[100.41022,14.63929],[100.41008,14.6463],[100.4121,14.65673],[100.4121,14.65762],[100.41166,14.65835],[100.4096,14.66052],[100.40609,14.66459],[100.41407,14.66951],[100.41493,14.67859],[100.41783,14.6857],[100.4111,14.69372],[100.41251,14.70205],[100.40656,14.7078],[100.40484,14.72717],[100.41094,14.73307],[100.41203,14.74906],[100.41255,14.74963],[100.41209,14.75035],[100.40899,14.7497],[100.40539,14.75027],[100.40229,14.75203],[100.38994,14.76034],[100.38734,14.76316],[100.38692,14.76781],[100.38851,14.77257],[100.39485,14.77659],[100.39612,14.78347],[100.39358,14.78929],[100.38734,14.79289],[100.37909,14.79522],[100.36819,14.80643],[100.3575,14.81712],[100.35475,14.82135],[100.35539,14.82558],[100.36724,14.84664],[100.36787,14.85309],[100.36576,14.85722],[100.35856,14.86082],[100.35094,14.86198],[100.32703,14.86918],[100.32364,14.87277],[100.31603,14.88505],[100.31285,14.88642],[100.27481,14.92044],[100.27217,14.9234],[100.26984,14.9325],[100.26667,14.93462],[100.25735,14.93631],[100.25566,14.93822],[100.25376,14.95335],[100.23852,14.97631],[100.2346,14.98033],[100.21112,14.99472],[100.2091,14.99536],[100.20339,15.01313],[100.20455,15.02371],[100.20437,15.02842],[100.20174,15.03251],[100.18005,15.0389],[100.16375,15.04419],[100.15783,15.04778],[100.15476,15.05159],[100.15222,15.05318],[100.15275,15.05953],[100.14206,15.08027],[100.13603,15.10238],[100.13772,15.10736],[100.14746,15.11434],[100.14915,15.12175],[100.14354,15.13931],[100.14016,15.1464],[100.14301,15.15307],[100.14545,15.1719],[100.13063,15.18883],[100.12587,15.18544]]]}}]}
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"route_id":"8"},"geometry":{"type":"MultiLineString","coordinates":[[[100.55007,13.81176],[100.54803,13.80926],[100.54817,13.80233],[100.54837,13.79739],[100.55096,13.79765],[100.55932,13.81199],[100.55734,13.8308],[100.558,13.84056],[100.56146,13.84754],[100.61897,13.95121],[100.62067,13.95497],[100.62008,13.96216],[100.61538,13.98922],[100.61479,13.99393],[100.61527,14.00753],[100.61823,14.16709],[100.60966,14.19564],[100.60864,14.20469],[100.6093,14.21337],[100.61089,14.22871],[100.6128,14.24543],[100.61237,14.28331],[100.61237,14.3378],[100.6128,14.35769],[100.60666,14.37822],[100.59968,14.39092],[100.5728,14.41525],[100.55259,14.42975],[100.54582,14.43578],[100.54327,14.43887],[100.5416,14.44528],[100.53845,14.46125],[100.52642,14.48879],[100.51891,14.50921],[100.50661,14.52233],[100.49527,14.56107],[100.49141,14.56936],[100.48326,14.58238],[100.47767,14.57883],[100.47017,14.57939],[100.4635,14.58117],[100.4627,14.58118],[100.4623,14.57997],[100.46122,14.5785],[100.45918,14.57794],[100.44667,14.5764],[100.44534,14.5762],[100.44438,14.57661],[100.44392,14.57701],[100.44346,14.57798],[100.44071,14.58996],[100.44063,14.5915],[100.44129,14.59218],[100.4448,14.59287],[100.4438,14.59779],[100.43675,14.60078],[100.42449,14.60376],[100.42388,14.60396],[100.42329,14.6044],[100.42289,14.60501],[100.42254,14.60614],[100.41076,14.63763],[100.41039,14.6384],[100.41022,14.63929],[100.41008,14.6463],[100.4121,14.65673],[100.4121,14.65762],[100.41166,14.65835],[100.4096,14.66052],[100.40609,14.66459],[100.39799,14.67529],[100.33391,14.72569],[100.32655,14.74711],[100.3261,14.75441],[100.35579,14.76102],[100.36039,14.76428],[100.3685,14.76828],[100.37059,14.76903],[100.37272,14.76899],[100.37526,14.76845],[100.38069,14.76768],[100.38686,14.76728],[100.38893,14.7721],[100.39485,14.77659],[100.39612,14.78347],[100.39358,14.78929],[100.38734,14.79289],[100.37909,14.79522],[100.36819,14.80643],[100.3575,14.81712],[100.35475,14.82135],[100.35539,14.82558],[100.36724,14.84664],[100.36787,14.85309],[100.36576,14.85722],[100.35856,14.86082],[100.35094,14.86198],[100.32703,14.86918],[100.32364,14.87277],[100.31603,14.88505],[100.31285,14.88642],[100.27481,14.92044],[100.27217,14.9234],[100.26984,14.9325],[100.26667,14.93462],[100.25735,14.93631],[100.25566,14.93822],[100.25376,14.95335],[100.23852,14.97631],[100.2346,14.98033],[100.21112,14.99472],[100.2091,14.99536],[100.20339,15.01313],[100.20455,15.02371],[100.20437,15.02842],[100.20174,15.03251],[100.18005,15.0389],[100.16375,15.04419],[100.15783,15.04778],[100.15476,15.05159],[100.15222,15.05318],[100.15275,15.05953],[100.14206,15.08027],[100.13603,15.10238],[100.13772,15.10736],[100.14746,15.11434],[100.14915,15.12175],[100.14354,15.13931],[100.14016,15.1464],[100.14301,15.15307],[100.14545,15.1719],[100.13063,15.18883],[100.12587,15.18544]]]}}]}
+1 -1
View File
@@ -1 +1 @@
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"route_id":"902"},"geometry":{"type":"MultiLineString","coordinates":[[[100.45159,14.59489],[100.45223,14.59404],[100.45207,14.5937],[100.45206,14.59319],[100.45222,14.59284],[100.45637,14.58414],[100.4579,14.58261],[100.46047,14.58157],[100.46649,14.5794],[100.47083,14.57884],[100.47589,14.57868],[100.4779,14.57892],[100.47943,14.57972],[100.48063,14.58085],[100.48288,14.58213],[100.48971,14.57185],[100.49742,14.55707],[100.50619,14.52372],[100.51856,14.50717],[100.54073,14.46347],[100.54177,14.44589],[100.54884,14.43239],[100.57768,14.41222],[100.59768,14.39512],[100.61053,14.37648],[100.61374,14.3617],[100.61182,14.30257],[100.61182,14.23638],[100.60869,14.20881],[100.61183,14.18624],[100.61809,14.17475],[100.61567,14.00631],[100.61472,13.99328],[100.61649,13.98171],[100.6221,13.95682],[100.60829,13.93295],[100.55784,13.84065],[100.55719,13.83407],[100.55853,13.81952],[100.55949,13.81173],[100.5543,13.80355],[100.55044,13.79744],[100.54933,13.79775],[100.54819,13.79796],[100.54774,13.80721],[100.54782,13.80912],[100.54891,13.81089],[100.54983,13.81384]]]}}]}
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"route_id":"902"},"geometry":{"type":"MultiLineString","coordinates":[[[100.45166,14.59467],[100.45227,14.59401],[100.45211,14.59383],[100.45206,14.59369],[100.45212,14.59356],[100.45207,14.59333],[100.45588,14.5848],[100.45646,14.58371],[100.45694,14.58333],[100.45777,14.58264],[100.45858,14.58222],[100.46912,14.57931],[100.46998,14.57903],[100.47079,14.57895],[100.47583,14.57892],[100.47765,14.57908],[100.47899,14.57951],[100.48039,14.58039],[100.48322,14.58213],[100.49056,14.57125],[100.49363,14.56605],[100.49594,14.55982],[100.50181,14.54256],[100.50674,14.52584],[100.50913,14.52145],[100.51302,14.51648],[100.51618,14.5126],[100.51822,14.50921],[100.52025,14.50442],[100.52273,14.49751],[100.5292,14.48314],[100.53765,14.46434],[100.53828,14.46235],[100.54208,14.4412],[100.54289,14.43967],[100.54415,14.43732],[100.54614,14.43524],[100.54912,14.43244],[100.56846,14.41861],[100.59476,14.39529],[100.60037,14.38969],[100.6029,14.38653],[100.60642,14.38038],[100.60958,14.37369],[100.61193,14.36456],[100.61329,14.35742],[100.61347,14.3398],[100.61347,14.24572],[100.61148,14.23117],[100.60922,14.21337],[100.60877,14.20632],[100.60922,14.20017],[100.6104,14.1924],[100.61537,14.17785],[100.6179,14.16881],[100.61844,14.12914],[100.6188,14.10054],[100.61573,14.01897],[100.61465,13.99511],[100.61478,13.99204],[100.61548,13.98834],[100.62068,13.95917],[100.62099,13.95668],[100.62032,13.95384],[100.61815,13.94959],[100.56193,13.84796],[100.55983,13.84426],[100.55807,13.84076],[100.55757,13.83843],[100.55721,13.83599],[100.55959,13.81233],[100.55696,13.80777],[100.55428,13.80336],[100.55289,13.8011],[100.55221,13.79989],[100.55169,13.79878],[100.55108,13.79782],[100.54831,13.79762],[100.54811,13.80903],[100.54872,13.81014],[100.54942,13.81132],[100.54982,13.81224],[100.55034,13.81168]]]}}]}
+1 -1
View File
@@ -1 +1 @@
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"route_id":"905"},"geometry":{"type":"MultiLineString","coordinates":[[[100.49047,14.57355],[100.4806,14.58802],[100.4733,14.59933],[100.47165,14.60236],[100.47098,14.60526],[100.47072,14.60862],[100.47118,14.61158],[100.47575,14.63674],[100.47639,14.64121],[100.47628,14.64658],[100.47586,14.65223],[100.47246,14.67175],[100.47132,14.67465],[100.47028,14.67773],[100.46771,14.68158],[100.46022,14.69346],[100.45812,14.69807],[100.45745,14.70214],[100.45717,14.70783],[100.45742,14.71185],[100.45524,14.75272],[100.45322,14.76316],[100.45247,14.76863],[100.45311,14.77436],[100.45546,14.77945],[100.45838,14.78557],[100.45956,14.78814],[100.45968,14.79297],[100.45888,14.7973],[100.45801,14.79988],[100.45535,14.80392],[100.45203,14.80791],[100.44974,14.81158],[100.44828,14.81588],[100.44827,14.82216],[100.44875,14.83024],[100.44948,14.83569]]]}}]}
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"route_id":"905"},"geometry":{"type":"MultiLineString","coordinates":[[[100.55004,13.81284],[100.54836,13.80925],[100.54809,13.80545],[100.5483,13.79803],[100.55077,13.79753],[100.55928,13.81209],[100.55702,13.83493],[100.55798,13.84065],[100.62071,13.95458],[100.61528,13.98972],[100.61813,14.16786],[100.61032,14.19288],[100.6089,14.2064],[100.61199,14.23544],[100.61302,14.24319],[100.61349,14.26506],[100.61246,14.31525],[100.61246,14.34929],[100.61279,14.3588],[100.61079,14.37032],[100.60561,14.38317],[100.5916,14.39953],[100.56022,14.42423],[100.5447,14.43574],[100.53802,14.46178],[100.52017,14.50634],[100.50915,14.52102],[100.49747,14.5559],[100.49163,14.56909],[100.48352,14.58143],[100.4806,14.58802],[100.4733,14.59933],[100.47165,14.60236],[100.47098,14.60526],[100.47072,14.60862],[100.47118,14.61158],[100.47575,14.63674],[100.47639,14.64121],[100.47628,14.64658],[100.47586,14.65223],[100.47246,14.67175],[100.47132,14.67465],[100.47028,14.67773],[100.46771,14.68158],[100.46022,14.69346],[100.45812,14.69807],[100.45745,14.70214],[100.45717,14.70783],[100.45742,14.71185],[100.45524,14.75272],[100.45322,14.76316],[100.45247,14.76863],[100.45311,14.77436],[100.45546,14.77945],[100.45838,14.78557],[100.45956,14.78814],[100.45968,14.79297],[100.45888,14.7973],[100.45801,14.79988],[100.45535,14.80392],[100.45203,14.80791],[100.44926,14.81067],[100.44725,14.81534],[100.44725,14.8216],[100.447,14.83049],[100.4471,14.84128],[100.43908,14.86989],[100.43624,14.87607],[100.42247,14.89626],[100.41582,14.90147],[100.41044,14.8975],[100.40719,14.89753],[100.39705,14.89915],[100.39511,14.89711],[100.39709,14.89267],[100.39841,14.89322]]]}}]}
+1 -1
View File
@@ -1 +1 @@
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"route_id":"951"},"geometry":{"type":"MultiLineString","coordinates":[[[100.13279,14.47858],[100.13193,14.52844],[100.14825,14.52836],[100.24155,14.56942],[100.27346,14.57214],[100.323,14.59282],[100.36646,14.59945],[100.42402,14.60556],[100.42505,14.60346],[100.43838,14.60014],[100.44512,14.59746],[100.44669,14.59228],[100.45228,14.59347],[100.45403,14.59228],[100.45709,14.58509],[100.4592,14.58218],[100.46425,14.58044],[100.47239,14.57849],[100.47962,14.57867],[100.4847,14.5813],[100.49456,14.5662],[100.50828,14.52539],[100.52059,14.50852],[100.5401,14.46189],[100.54065,14.44872]]]}}]}
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"route_id":"951"},"geometry":{"type":"MultiLineString","coordinates":[[[100.13279,14.47858],[100.13039,14.52831],[100.1475,14.52935],[100.18806,14.54854],[100.23913,14.56982],[100.27346,14.57214],[100.323,14.59282],[100.36646,14.59945],[100.42241,14.60592],[100.42327,14.60413],[100.42445,14.6034],[100.43838,14.60014],[100.44429,14.59701],[100.44535,14.59282],[100.45071,14.59378],[100.45271,14.59186],[100.4562,14.5845],[100.4592,14.58218],[100.46425,14.58044],[100.47239,14.57849],[100.47898,14.57901],[100.48365,14.58193],[100.49456,14.5662],[100.50828,14.52539],[100.52059,14.50852],[100.53899,14.46155],[100.54445,14.43629],[100.57309,14.41404],[100.59807,14.3941],[100.61103,14.36716],[100.61239,14.24713],[100.61034,14.19427],[100.61614,14.1762],[100.61409,13.99274],[100.62144,13.95978],[100.61854,13.95041],[100.55833,13.84142],[100.55729,13.83622],[100.55783,13.8299],[100.55912,13.81131],[100.55115,13.79777],[100.54831,13.79775],[100.54782,13.80925]]]}}]}
+1 -1
View File
@@ -1 +1 @@
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"route_id":"952"},"geometry":{"type":"MultiLineString","coordinates":[[[100.35413,14.59636],[100.35402,14.59677],[100.35111,14.596],[100.3505,14.59608],[100.34874,14.59598],[100.32492,14.59303],[100.32407,14.59296],[100.3234,14.59277],[100.32257,14.59255],[100.27396,14.57216],[100.27333,14.5719],[100.27273,14.57172],[100.27226,14.57159],[100.27146,14.5715],[100.27052,14.57146],[100.24239,14.56975],[100.24146,14.56961],[100.24031,14.56946],[100.23913,14.569],[100.16546,14.53693],[100.14986,14.52932],[100.14747,14.52839],[100.13271,14.52809],[100.13333,14.4442],[100.1508,14.42409],[100.15198,14.42118],[100.15299,14.41595],[100.15815,14.40475],[100.16439,14.40225],[100.178,14.38564],[100.19177,14.34217],[100.21802,14.32491],[100.29154,14.20385],[100.29382,14.2006],[100.29437,14.19824],[100.29442,14.19407],[100.29097,14.11771],[100.29133,14.11535],[100.29195,14.11339],[100.41694,13.94372],[100.41841,13.94168],[100.41955,13.93906],[100.41837,13.93482],[100.40891,13.90452],[100.40886,13.90371],[100.40888,13.90276],[100.41164,13.87333],[100.41508,13.83494],[100.41411,13.82156],[100.41102,13.78249],[100.44374,13.77903],[100.44675,13.78021],[100.47041,13.78704]]]}}]}
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"route_id":"952"},"geometry":{"type":"MultiLineString","coordinates":[[[100.35413,14.59636],[100.35402,14.59677],[100.35111,14.596],[100.3505,14.59608],[100.34874,14.59598],[100.32492,14.59303],[100.32407,14.59296],[100.3234,14.59277],[100.32257,14.59255],[100.27396,14.57216],[100.27333,14.5719],[100.27273,14.57172],[100.27226,14.57159],[100.27146,14.5715],[100.27052,14.57146],[100.24239,14.56975],[100.24146,14.56961],[100.24031,14.56946],[100.23913,14.569],[100.16546,14.53693],[100.14986,14.52932],[100.14747,14.52839],[100.13271,14.52809],[100.13333,14.4442],[100.1508,14.42409],[100.15198,14.42118],[100.15299,14.41595],[100.15815,14.40475],[100.16439,14.40225],[100.178,14.38564],[100.19177,14.34217],[100.21802,14.32491],[100.29154,14.20385],[100.29382,14.2006],[100.29437,14.19824],[100.29442,14.19407],[100.29097,14.11771],[100.29133,14.11535],[100.29195,14.11339],[100.41694,13.94372],[100.41841,13.94168],[100.41955,13.93906],[100.41837,13.93482],[100.40891,13.90452],[100.40886,13.90371],[100.40888,13.90276],[100.41164,13.87333],[100.41411,13.83537],[100.41311,13.82152],[100.4094,13.78294],[100.44328,13.78007],[100.44729,13.78119],[100.45588,13.78395],[100.46756,13.78733],[100.469,13.78719],[100.48195,13.77368],[100.48164,13.77327],[100.46888,13.78686],[100.46817,13.78646]]]}}]}
+1 -1
View File
@@ -1 +1 @@
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"route_id":"954"},"geometry":{"type":"MultiLineString","coordinates":[[[100.08091,14.95336],[100.08171,14.9479],[100.08059,14.9434],[100.08669,14.9246],[100.08203,14.9087],[100.09344,14.90002],[100.08525,14.88203],[100.08685,14.86596],[100.10437,14.84186],[100.11047,14.83672],[100.11272,14.82981],[100.11577,14.81519],[100.11947,14.8123],[100.11706,14.80908],[100.10389,14.7927],[100.09103,14.78916],[100.08621,14.78531],[100.09039,14.77181],[100.10935,14.71718],[100.10228,14.70819],[100.10067,14.69983],[100.10517,14.6918],[100.11288,14.68601],[100.11192,14.67123],[100.11658,14.66915],[100.1312,14.66384],[100.13714,14.66015],[100.14212,14.65244],[100.15,14.63862],[100.1598,14.64119],[100.17088,14.63476],[100.19241,14.6195],[100.20077,14.61484],[100.22824,14.60552],[100.24286,14.60504],[100.24329,14.60467],[100.24456,14.60435],[100.24614,14.60476],[100.24705,14.60497],[100.24754,14.60605],[100.26666,14.59751],[100.27261,14.59155],[100.28786,14.57885],[100.32071,14.59217],[100.36389,14.6002],[100.42398,14.60582],[100.42462,14.60245],[100.44366,14.59759],[100.44491,14.59273],[100.45061,14.59421],[100.4525,14.59285],[100.45577,14.58472],[100.45818,14.58251],[100.46987,14.57909],[100.47513,14.57893],[100.4777,14.57893],[100.48321,14.58194],[100.49113,14.57004],[100.49446,14.5641],[100.49735,14.55631],[100.50108,14.54412],[100.50731,14.52287],[100.51823,14.50921],[100.52916,14.48415],[100.53852,14.46306],[100.54093,14.44876],[100.54317,14.43752],[100.59041,14.39912],[100.60246,14.38755],[100.60644,14.37895],[100.61029,14.37124],[100.61286,14.36096],[100.61383,14.3518],[100.61367,14.33638],[100.61431,14.24207],[100.6111,14.22343],[100.60933,14.20993],[100.61013,14.19917],[100.61093,14.18905],[100.61945,14.16961],[100.61487,13.9942],[100.61487,13.99042],[100.62096,13.95905],[100.62096,13.95648],[100.62064,13.95255],[100.61871,13.95062],[100.5597,13.84448],[100.55713,13.83797],[100.55769,13.83082],[100.55938,13.81174],[100.55095,13.79809],[100.54862,13.79809],[100.54838,13.80885],[100.54936,13.8111],[100.55028,13.81235]]]}}]}
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"route_id":"954"},"geometry":{"type":"MultiLineString","coordinates":[[[100.14612,14.64665],[100.14775,14.6434],[100.14979,14.63958],[100.15411,14.641],[100.15664,14.64106],[100.16006,14.64017],[100.17088,14.63476],[100.19241,14.6195],[100.20077,14.61484],[100.22824,14.60552],[100.24286,14.60504],[100.24329,14.60467],[100.24456,14.60435],[100.24614,14.60476],[100.24705,14.60497],[100.24754,14.60605],[100.26666,14.59751],[100.27261,14.59155],[100.28786,14.57885],[100.32071,14.59217],[100.36389,14.6002],[100.42398,14.60582],[100.42462,14.60245],[100.44366,14.59759],[100.44491,14.59273],[100.45061,14.59421],[100.4525,14.59285],[100.45577,14.58472],[100.45818,14.58251],[100.46987,14.57909],[100.47513,14.57893],[100.4777,14.57893],[100.48321,14.58194],[100.49113,14.57004],[100.49446,14.5641],[100.49735,14.55631],[100.50108,14.54412],[100.50731,14.52287],[100.51823,14.50921],[100.52916,14.48415],[100.53852,14.46306],[100.54093,14.44876],[100.54317,14.43752],[100.59041,14.39912],[100.60246,14.38755],[100.60644,14.37895],[100.61029,14.37124],[100.61286,14.36096],[100.61383,14.3518],[100.61367,14.33638],[100.61431,14.24207],[100.6111,14.22343],[100.60933,14.20993],[100.61013,14.19917],[100.61093,14.18905],[100.61945,14.16961],[100.61487,13.9942],[100.61487,13.99042],[100.62096,13.95905],[100.62096,13.95648],[100.62064,13.95255],[100.61871,13.95062],[100.5597,13.84448],[100.55713,13.83797],[100.55769,13.83082],[100.55938,13.81174],[100.55095,13.79809],[100.54862,13.79809],[100.54838,13.80885],[100.54936,13.8111],[100.55028,13.81235]]]}}]}
+1 -1
View File
@@ -1 +1 @@
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"route_id":"XXX2"},"geometry":{"type":"MultiLineString","coordinates":[[[100.36831,14.45774],[100.36761,14.45943],[100.36614,14.46058],[100.36621,14.46365],[100.36523,14.46636],[100.36684,14.47053],[100.36725,14.4745],[100.36685,14.4756],[100.3623,14.47933],[100.36098,14.48293],[100.36144,14.48619],[100.36336,14.48879],[100.3658,14.49105],[100.36645,14.49415],[100.36642,14.4965],[100.36585,14.49837],[100.39136,14.50028],[100.39327,14.50179],[100.41506,14.50231],[100.42255,14.50357],[100.42768,14.50281],[100.44699,14.49885],[100.44596,14.49676],[100.44547,14.49511],[100.44493,14.4947],[100.44612,14.4939],[100.44635,14.4944],[100.44654,14.49472]]]}}]}
{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"route_id":"XXX2"},"geometry":{"type":"MultiLineString","coordinates":[[[100.36831,14.45774],[100.37086,14.45153],[100.36877,14.44936],[100.37061,14.44519],[100.37561,14.4451],[100.37536,14.46087],[100.37762,14.47381],[100.38112,14.47656],[100.39055,14.48474],[100.39456,14.48783],[100.39698,14.48833],[100.40365,14.48858],[100.41725,14.48933],[100.44109,14.49002],[100.44105,14.4924],[100.44149,14.49378],[100.44249,14.49467],[100.44493,14.4947],[100.44612,14.4939],[100.44635,14.4944],[100.44654,14.49472]]]}}]}
+5
View File
@@ -0,0 +1,5 @@
{
"_note": "วันหยุดนักขัตฤกษ์ (ใช้ร่วมกับเสาร์-อาทิตย์ เพื่อเลือกตาราง 'วันหยุด'). เดือน/วัน รูปแบบ YYYY-MM-DD",
"_source": "ยังไม่ได้กรอก — เจ้าของข้อมูลต้องยืนยันกับประกาศของทางราชการก่อน (อย่าเดาเอง)",
"holidays": []
}
+6 -6
View File
@@ -9,7 +9,7 @@
"province_ids": [1, 2, 3, 4],
"phone": ["+6684 337 7376", "+6662 381 5828"],
"web_url": "https://www.facebook.com/profile.php?id=100063523693753",
"station_ids": [1, 5, 6]
"station_ids": [1, 15, 6]
},
{
"route_id": "15",
@@ -31,7 +31,7 @@
"province_ids": [1, 5, 4],
"phone": ["+6686 099 4250"],
"web_url": "https://www.facebook.com/groups/1323166441639529",
"station_ids": [9, 5, 6, 8 , 20]
"station_ids": [9, 5, 6, 8 ]
},
{
"route_id": "952",
@@ -53,7 +53,7 @@
"province_ids": [1, 2, 3, 4, 5],
"phone": ["+6690 140 3636"],
"web_url": "https://shorturl.asia/Qe0s3",
"station_ids": [20, 5, 6, 8]
"station_ids": [ 5, 6, 8]
},
{
"route_id": "8",
@@ -141,14 +141,14 @@
"province_ids": [1],
"phone": [],
"web_url": null,
"station_ids": [1]
"station_ids": [1,8]
},
{
"route_id": "999",
"route_name_th": "บริษัท ขนส่ง จำกัด (บขส.อ่างทอง)",
"vehicle_type": "bus",
"route_group": "in_province",
"route_group_id": 4,
"route_group": "bangkok",
"route_group_id": 2,
"province_ids": [1],
"phone": ["0-3561-1344"],
"web_url": "999.html",
File diff suppressed because it is too large. Load diff
+62 -200
View File
@@ -1,244 +1,106 @@
{
"schedules": [
"schema": 2,
"index": true,
"note": "สารบัญชี้ไป scheduleslist/schedules<route_id>.json (1 ไฟล์ = 1 เส้นทาง) — แก้ไฟล์ย่อยนั้นโดยตรง หรือใช้ resource/data/schedules-editor.html",
"dir": "scheduleslist/",
"routes": [
{
"schedule_id": 1,
"route_id": "101",
"station_id": 3,
"direction_note": null,
"departure_times": ["06:30", "07:20", "08:10", "09:00", "09:50", "10:40", "11:30", "12:20", "13:10", "14:00", "14:50", "15:40", "16:30", "17:30"],
"schedule_note": null
"file": "schedules101.json",
"n_directions": 4,
"n_stops": 8,
"n_trips": 64
},
{
"schedule_id": 2,
"route_id": "101",
"station_id": 1,
"direction_note": null,
"departure_times": ["07:30", "08:20", "09:10", "10:00", "10:50", "11:50", "13:00", "14:00", "15:00"],
"schedule_note": null
},
{
"schedule_id": 3,
"route_id": "101",
"station_id": 2,
"direction_note": "ไปอ่างทอง",
"departure_times": ["07:30", "08:20", "09:10", "10:00", "10:50", "11:40", "12:30", "13:20", "14:10", "15:00", "15:50", "16:40", "17:30", "18:30"],
"schedule_note": null
},
{
"schedule_id": 4,
"route_id": "101",
"station_id": 2,
"direction_note": "ไปอยุธยา",
"departure_times": ["08:00", "08:50", "09:40", "10:30", "11:20", "12:20", "13:30", "14:30", "15:30"],
"schedule_note": "เวลารถเปลี่ยนทุกวัน โดยเฉพาะวันหยุด"
},
{
"schedule_id": 5,
"route_id": "15",
"station_id": 1,
"direction_note": null,
"departure_times": ["05:00", "05:45", "06:30", "07:30"],
"schedule_note": null
"file": "schedules15.json",
"n_directions": 3,
"n_stops": 4,
"n_trips": 22
},
{
"schedule_id": 6,
"route_id": "15",
"station_id": 2,
"direction_note": null,
"departure_times": ["05:30", "06:20", "07:05", "07:55", "08:40", "09:30", "11:20", "12:10", "13:00", "15:00"],
"schedule_note": null
},
{
"schedule_id": 7,
"route_id": "15",
"station_id": 6,
"direction_note": null,
"departure_times": ["06:00", "08:30", "09:15", "10:00", "12:30", "14:00", "15:00", "16:00"],
"schedule_note": "เวลารถเปลี่ยนทุกวัน"
},
{
"schedule_id": 8,
"route_id": "902",
"station_id": 1,
"direction_note": null,
"departure_times": ["04:00", "04:30", "05:00", "05:30", "06:00", "06:30", "07:00", "07:30", "08:00", "08:30", "09:00", "09:30", "10:00", "10:30", "11:00", "11:30", "12:00", "12:30", "13:00", "13:30", "14:00", "14:30", "15:00", "15:30", "16:00", "16:30", "17:00", "17:30"],
"schedule_note": null
"file": "schedules902.json",
"n_directions": 2,
"n_stops": 2,
"n_trips": 53
},
{
"schedule_id": 9,
"route_id": "902",
"station_id": 6,
"direction_note": null,
"departure_times": ["06:00", "06:30", "07:00", "07:30", "08:00", "08:30", "09:00", "09:30", "10:00", "10:30", "11:00", "11:30", "12:00", "12:30", "13:00", "13:30", "14:00", "14:30", "15:00", "15:30", "16:00", "16:30", "17:00", "17:30", "18:00"],
"schedule_note": null
},
{
"schedule_id": 10,
"route_id": "951",
"station_id": 9,
"direction_note": null,
"departure_times": ["04:00", "04:20", "04:40", "05:00", "05:20", "05:40", "06:00", "06:20", "06:40", "07:00", "07:20", "07:40", "08:00", "08:20", "08:40", "09:00", "09:20", "09:40", "10:00", "10:20", "10:40", "11:00", "11:20", "11:40", "12:00", "12:20", "12:40", "13:00", "13:20", "13:40", "14:00", "14:20", "14:40", "15:00", "15:20", "15:40", "16:00", "16:20", "16:40", "17:00", "17:20", "17:40", "18:00"],
"schedule_note": null
"file": "schedules951.json",
"n_directions": 2,
"n_stops": 6,
"n_trips": 47
},
{
"schedule_id": 11,
"route_id": "952",
"station_id": 8,
"direction_note": "จากตลาดวิเศษ",
"departure_times": ["04:30", "10:00", "15:00"],
"schedule_note": null
"file": "schedules952.json",
"n_directions": 2,
"n_stops": 2,
"n_trips": 6
},
{
"schedule_id": 12,
"route_id": "952",
"station_id": 12,
"direction_note": null,
"departure_times": ["07:00", "10:30", "15:00"],
"schedule_note": "10:30 และ 7:00 มีเฉพาะวันหยุด"
},
{
"schedule_id": 13,
"route_id": "954",
"station_id": 8,
"direction_note": "จากท่าช้าง",
"departure_times": ["08:00"],
"schedule_note": "เวลาเปลี่ยนทุกวัน"
"file": "schedules954.json",
"n_directions": 1,
"n_stops": 1,
"n_trips": 4
},
{
"schedule_id": 14,
"route_id": "8",
"station_id": 13,
"direction_note": null,
"departure_times": ["03:30", "04:00", "04:30", "05:00", "05:30", "06:00", "06:30", "07:00", "07:30", "08:00", "08:30", "09:00", "09:30", "11:00", "12:00", "13:00", "14:00", "15:00", "17:00"],
"schedule_note": null
"file": "schedules8.json",
"n_directions": 2,
"n_stops": 2,
"n_trips": 4
},
{
"schedule_id": 15,
"route_id": "8",
"station_id": 8,
"direction_note": "จากโพธิ์ทอง",
"departure_times": ["05:00", "05:30", "06:00", "06:30", "07:00", "07:30", "08:00", "08:30", "09:00", "09:30", "10:00", "10:30", "12:30", "13:30", "14:30", "15:30", "16:30", "18:30"],
"schedule_note": "เวลาเปลี่ยนทุกวัน"
},
{
"schedule_id": 16,
"route_id": "464",
"station_id": 9,
"direction_note": null,
"departure_times": ["04:40", "05:10", "05:40", "06:10", "06:40", "07:10", "07:40", "08:15", "08:50", "09:25", "10:00", "10:35", "11:10", "11:45", "12:20", "12:55", "13:30", "14:05", "14:40", "15:15", "15:50", "16:25", "17:00", "17:40"],
"schedule_note": null
"file": "schedules464.json",
"n_directions": 3,
"n_stops": 4,
"n_trips": 88
},
{
"schedule_id": 17,
"route_id": "464",
"station_id": 10,
"direction_note": null,
"departure_times": ["05:00", "05:40", "06:20", "07:10", "08:00", "08:40", "09:20", "10:00", "10:40", "11:20", "12:00", "12:40", "13:20", "14:00", "14:40", "15:20", "16:00", "16:40", "17:20", "18:00"],
"schedule_note": null
},
{
"schedule_id": 18,
"route_id": "464",
"station_id": 1,
"direction_note": "ไปสุพรรณบุรี",
"departure_times": ["06:30", "07:10", "07:50", "08:40", "09:30", "10:10", "10:50", "11:30", "12:10", "12:50", "13:30", "14:10", "14:50", "15:30", "16:10", "16:50", "17:30", "18:10", "18:50", "19:30"],
"schedule_note": null
},
{
"schedule_id": 19,
"route_id": "464",
"station_id": 1,
"direction_note": "ไปสระบุรี",
"departure_times": ["05:40", "06:10", "06:40", "07:10", "07:40", "08:10", "08:40", "09:15", "09:50", "10:25", "11:00", "11:35", "12:10", "12:45", "13:20", "13:55", "14:30", "15:05", "15:40", "16:15", "16:50", "17:25", "18:00", "18:40"],
"schedule_note": "เวลารถเปลี่ยนทุกวัน"
},
{
"schedule_id": 20,
"route_id": "641",
"station_id": 1,
"direction_note": null,
"departure_times": ["07:00", "08:00", "09:00", "10:00", "11:00", "12:00", "13:30", "14:30", "16:30"],
"schedule_note": null
"file": "schedules641.json",
"n_directions": 2,
"n_stops": 2,
"n_trips": 18
},
{
"schedule_id": 21,
"route_id": "641",
"station_id": 7,
"direction_note": null,
"departure_times": ["07:00", "08:00", "09:00", "10:00", "11:00", "12:00", "13:30", "14:30", "16:30"],
"schedule_note": "10:00 และ 13:30 ไม่ได้มีทุกวัน"
},
{
"schedule_id": 22,
"route_id": "2194",
"station_id": 8,
"direction_note": "จากวัดหัวเวียง",
"departure_times": ["05:00", "06:00", "07:00"],
"schedule_note": null
"file": "schedules2194.json",
"n_directions": 2,
"n_stops": 2,
"n_trips": 6
},
{
"schedule_id": 23,
"route_id": "2194",
"station_id": 4,
"direction_note": null,
"departure_times": ["16:00", "17:00", "18:00"],
"schedule_note": null
},
{
"schedule_id": 24,
"route_id": "324",
"station_id": 1,
"direction_note": null,
"departure_times": ["10:00"],
"schedule_note": null
"file": "schedules324.json",
"n_directions": 2,
"n_stops": 2,
"n_trips": 2
},
{
"schedule_id": 25,
"route_id": "324",
"station_id": 8,
"direction_note": "จากวัดไชโยวรวิหาร",
"departure_times": ["08:00"],
"schedule_note": null
},
{
"schedule_id": 26,
"route_id": "1011",
"station_id": 1,
"direction_note": null,
"departure_times": ["12:00", "16:00", "17:00"],
"schedule_note": null
"file": "schedules1011.json",
"n_directions": 2,
"n_stops": 2,
"n_trips": 6
},
{
"schedule_id": 27,
"route_id": "1011",
"station_id": 8,
"direction_note": "จากวัดสีบัวทอง",
"departure_times": ["06:00", "06:30", "14:30"],
"schedule_note": null
},
{
"schedule_id": 28,
"route_id": "2231",
"station_id": 1,
"direction_note": null,
"departure_times": ["16:00"],
"schedule_note": null
"file": "schedules2231.json",
"n_directions": 2,
"n_stops": 2,
"n_trips": 2
},
{
"schedule_id": 29,
"route_id": "2231",
"station_id": 8,
"direction_note": "จากวัดมหานาม",
"departure_times": ["08:00"],
"schedule_note": null
},
{
"schedule_id": 30,
"route_id": "999",
"station_id": 14,
"direction_note": null,
"departure_times": [],
"schedule_note": "ยังไม่มีข้อมูลตารางเวลา"
"file": "schedules999.json",
"n_directions": 1,
"n_stops": 1,
"n_trips": 0
}
]
}
}
@@ -0,0 +1,124 @@
{
"schema": 3,
"route_id": "101",
"route_name": "อ่างทอง-ป่าโมก-อยุธยา",
"station_order": [
1,
2,
3
],
"weekday": {
"label": "เวลาวันทำงาน",
"directions": {
"ออกจากอ่างทอง": {
"from_station_id": 1,
"departures": [
"07:30",
"08:20",
"09:10",
"10:00",
"10:50",
"11:50",
"13:00",
"14:00",
"15:00"
]
},
"ออกจากอยุธยา": {
"from_station_id": 3,
"departures": [
"07:30",
"08:20",
"09:10",
"10:00",
"10:50",
"11:40",
"12:30",
"13:20",
"14:10",
"15:00",
"15:50",
"16:40",
"17:30",
"18:30"
]
},
"ป่าโมกไปอ่างทอง": {
"from_station_id": 2,
"departures": [
"08:00",
"08:50",
"09:40",
"10:30",
"11:20",
"12:20",
"13:30",
"14:30",
"15:30"
]
},
"ป่าโมกไปอยุธยา": {
"from_station_id": 2,
"departures": [
"06:30",
"07:20",
"08:10",
"09:00",
"09:50",
"10:40",
"11:30",
"12:20",
"13:10",
"14:00",
"14:50",
"15:40",
"16:30",
"17:30"
]
}
}
},
"holiday": {
"label": "เวลาวันหยุด",
"directions": {
"ออกจากอ่างทอง": {
"from_station_id": 1,
"departures": [
"09:30",
"10:30",
"12:00",
"14:30"
]
},
"ออกจากอยุธยา": {
"from_station_id": 3,
"departures": [
"06:50",
"08:30",
"10:00",
"11:40",
"13:20",
"15:00",
"17:00"
]
},
"ป่าโมกไปอ่างทอง": {
"from_station_id": 2,
"departures": [
"06:20",
"08:30"
]
},
"ป่าโมกไปอยุธยา": {
"from_station_id": 2,
"departures": [
"07:40",
"09:20",
"10:50",
"12:30",
"13:20"
]
}
}
}
}
@@ -0,0 +1,40 @@
{
"schema": 2,
"route_id": "1011",
"generated_from": "schedules.json",
"station_order": [
1,
8
],
"directions": [
{
"dir_id": "from-1",
"dir_label": null,
"stops": [
{
"station_id": 1,
"times": [
"12:00",
"16:00",
"17:00"
]
}
]
},
{
"dir_id": "dir-1",
"dir_label": "จากวัดสีบัวทอง",
"stops": [
{
"station_id": 8,
"times": [
"06:00",
"06:30",
"14:30"
],
"dir_note": "จากวัดสีบัวทอง"
}
]
}
]
}
@@ -0,0 +1,79 @@
{
"schema": 2,
"route_id": "15",
"generated_from": "schedules.json",
"station_order": [
1,
2,
4,
5,
6
],
"directions": [
{
"dir_id": "from-1",
"dir_label": null,
"stops": [
{
"station_id": 1,
"times": [
"05:00",
"05:45",
"06:30",
"07:30"
]
}
]
},
{
"dir_id": "all",
"dir_label": null,
"stops": [
{
"station_id": 2,
"times": [
"05:30",
"06:20",
"07:05",
"07:55",
"08:40",
"09:30",
"11:20",
"12:10",
"13:00",
"15:00"
]
},
{
"station_id": 6,
"times": [
"06:00",
"08:30",
"09:15",
"10:00",
"12:30",
"14:00",
"15:00",
"16:00"
]
}
]
},
{
"dir_id": "new-3",
"dir_label": null,
"stops": [
{
"station_id": 5,
"derive": {
"from_station_id": 6,
"offset_min": 30,
"note": "ท่ารถมินิบัสต่างจังหวัด"
},
"times": []
}
],
"autoTimes": true
}
]
}
@@ -0,0 +1,40 @@
{
"schema": 2,
"route_id": "2194",
"generated_from": "schedules.json",
"station_order": [
4,
8
],
"directions": [
{
"dir_id": "dir-1",
"dir_label": "จากวัดหัวเวียง",
"stops": [
{
"station_id": 8,
"times": [
"05:00",
"06:00",
"07:00"
],
"dir_note": "จากวัดหัวเวียง"
}
]
},
{
"dir_id": "from-4",
"dir_label": null,
"stops": [
{
"station_id": 4,
"times": [
"16:00",
"17:00",
"18:00"
]
}
]
}
]
}
@@ -0,0 +1,36 @@
{
"schema": 2,
"route_id": "2231",
"generated_from": "schedules.json",
"station_order": [
1,
8
],
"directions": [
{
"dir_id": "from-1",
"dir_label": null,
"stops": [
{
"station_id": 1,
"times": [
"16:00"
]
}
]
},
{
"dir_id": "dir-1",
"dir_label": "จากวัดมหานาม",
"stops": [
{
"station_id": 8,
"times": [
"08:00"
],
"dir_note": "จากวัดมหานาม"
}
]
}
]
}
@@ -0,0 +1,36 @@
{
"schema": 2,
"route_id": "324",
"generated_from": "schedules.json",
"station_order": [
1,
8
],
"directions": [
{
"dir_id": "from-1",
"dir_label": null,
"stops": [
{
"station_id": 1,
"times": [
"10:00"
]
}
]
},
{
"dir_id": "dir-1",
"dir_label": "จากวัดไชโยวรวิหาร",
"stops": [
{
"station_id": 8,
"times": [
"08:00"
],
"dir_note": "จากวัดไชโยวรวิหาร"
}
]
}
]
}
@@ -0,0 +1,141 @@
{
"schema": 2,
"route_id": "464",
"generated_from": "schedules.json",
"station_order": [
1,
9,
10
],
"directions": [
{
"dir_id": "all",
"dir_label": null,
"stops": [
{
"station_id": 9,
"times": [
"04:40",
"05:10",
"05:40",
"06:10",
"06:40",
"07:10",
"07:40",
"08:15",
"08:50",
"09:25",
"10:00",
"10:35",
"11:10",
"11:45",
"12:20",
"12:55",
"13:30",
"14:05",
"14:40",
"15:15",
"15:50",
"16:25",
"17:00",
"17:40"
]
},
{
"station_id": 10,
"times": [
"05:00",
"05:40",
"06:20",
"07:10",
"08:00",
"08:40",
"09:20",
"10:00",
"10:40",
"11:20",
"12:00",
"12:40",
"13:20",
"14:00",
"14:40",
"15:20",
"16:00",
"16:40",
"17:20",
"18:00"
]
}
]
},
{
"dir_id": "dir-1",
"dir_label": "ไปสุพรรณบุรี",
"stops": [
{
"station_id": 1,
"times": [
"06:30",
"07:10",
"07:50",
"08:40",
"09:30",
"10:10",
"10:50",
"11:30",
"12:10",
"12:50",
"13:30",
"14:10",
"14:50",
"15:30",
"16:10",
"16:50",
"17:30",
"18:10",
"18:50",
"19:30"
],
"dir_note": "ไปสุพรรณบุรี"
}
]
},
{
"dir_id": "dir-2",
"dir_label": "ไปสระบุรี",
"stops": [
{
"station_id": 1,
"times": [
"05:40",
"06:10",
"06:40",
"07:10",
"07:40",
"08:10",
"08:40",
"09:15",
"09:50",
"10:25",
"11:00",
"11:35",
"12:10",
"12:45",
"13:20",
"13:55",
"14:30",
"15:05",
"15:40",
"16:15",
"16:50",
"17:25",
"18:00",
"18:40"
],
"dir_note": "ไปสระบุรี",
"note": null
}
]
}
]
}
@@ -0,0 +1,53 @@
{
"schema": 2,
"route_id": "641",
"generated_from": "schedules.json",
"station_order": [
1,
7,
8
],
"directions": [
{
"dir_id": "from-1",
"dir_label": null,
"stops": [
{
"station_id": 1,
"times": [
"07:00",
"08:00",
"09:00",
"10:00",
"11:00",
"12:00",
"13:30",
"14:30",
"16:30"
]
}
]
},
{
"dir_id": "all",
"dir_label": null,
"stops": [
{
"station_id": 7,
"times": [
"07:00",
"08:00",
"09:00",
"10:00",
"11:00",
"12:00",
"13:30",
"14:30",
"16:30"
],
"note": "10:00 และ 13:30 ไม่ได้มีทุกวัน"
}
]
}
]
}
@@ -0,0 +1,88 @@
{
"schema": 2,
"route_id": "8",
"generated_from": "schedules.json",
"station_order": [
13,
8,
6,
5
],
"directions": [
{
"dir_id": "all",
"dir_label": null,
"stops": [
{
"station_id": 13,
"times": [
"07:30",
"10:00"
]
}
],
"speedKmh": 60
},
{
"dir_id": "dir-1",
"dir_label": null,
"stops": [
{
"station_id": 6,
"times": [
"10:00",
"13:00"
],
"dir_note": null,
"note": null
}
]
},
{
"dir_id": "rungsit",
"dir_label": "ตลาดแสวงหา",
"stops": [
{
"station_id": 8,
"derive": {
"from_station_id": 13,
"offset_min": 90,
"note": null
},
"times": []
}
]
},
{
"dir_id": "rungsit",
"dir_label": "ตลาดสดเทศบาลตำบลโพธิ์ทอง",
"stops": [
{
"station_id": 8,
"derive": {
"from_station_id": 13,
"offset_min": 110,
"note": null
},
"times": []
}
]
},
{
"dir_id": "rungsit",
"dir_label": null,
"stops": [
{
"station_id": 5,
"derive": {
"from_station_id": 6,
"offset_min": 30,
"note": null
},
"times": []
}
]
}
]
}
@@ -0,0 +1,102 @@
{
"schema": 2,
"route_id": "902",
"generated_from": "schedules.json",
"station_order": [
1,
15,
6
],
"directions": [
{
"dir_id": "from-1",
"dir_label": null,
"stops": [
{
"station_id": 1,
"times": [
"04:00",
"04:30",
"05:00",
"05:30",
"06:00",
"06:30",
"07:00",
"07:30",
"08:00",
"08:30",
"09:00",
"09:30",
"10:00",
"10:30",
"11:00",
"11:30",
"12:00",
"12:30",
"13:00",
"13:30",
"14:00",
"14:30",
"15:00",
"15:30",
"16:00",
"16:30",
"17:00",
"17:30"
]
}
]
},
{
"dir_id": "rungsit",
"dir_label": null,
"stops": [
{
"station_id": 15,
"derive": {
"from_station_id": 6,
"offset_min": 30,
"note": "รอรถที่ 7-11 หน้ากินซ่า (รถจากจตุจักรผ่านมาถึง)"
},
"times": []
}
]
},
{
"dir_id": "all",
"dir_label": null,
"stops": [
{
"station_id": 6,
"times": [
"06:00",
"06:30",
"07:00",
"07:30",
"08:00",
"08:30",
"09:00",
"09:30",
"10:00",
"10:30",
"11:00",
"11:30",
"12:00",
"12:30",
"13:00",
"13:30",
"14:00",
"14:30",
"15:00",
"15:30",
"16:00",
"16:30",
"17:00",
"17:30",
"18:00"
]
}
]
}
]
}
@@ -0,0 +1,147 @@
{
"schema": 2,
"route_id": "951",
"generated_from": "schedules.json",
"station_order": [
9,
5,
6,
8
],
"directions": [
{
"dir_id": "from-9",
"dir_label": null,
"stops": [
{
"station_id": 9,
"times": [
"04:00",
"04:20",
"04:40",
"05:00",
"05:20",
"05:40",
"06:00",
"06:20",
"06:40",
"07:00",
"07:20",
"07:40",
"08:00",
"08:20",
"08:40",
"09:00",
"09:20",
"09:40",
"10:00",
"10:20",
"10:40",
"11:00",
"11:20",
"11:40",
"12:00",
"12:20",
"12:40",
"13:00",
"13:20",
"13:40",
"14:00",
"14:20",
"14:40",
"15:00",
"15:20",
"15:40",
"16:00",
"16:20",
"16:40",
"17:00",
"17:20",
"17:40",
"18:00"
]
},
{
"station_id": 8,
"times": [],
"dir_note": "ตลาดวิเศษชัยชาญ",
"note": "ตลาดวิเศษชัยชาญ"
},
{
"station_id": 8,
"times": [],
"dir_note": "ตลาดอ่างทอง",
"note": "ตลาดอ่างทอง"
}
]
},
{
"dir_id": "new-2",
"dir_label": null,
"stops": [
{
"station_id": 6,
"times": [
"04:20",
"04:40",
"05:00",
"05:20",
"05:40",
"06:00",
"06:20",
"06:40",
"07:00",
"07:20",
"07:40",
"08:00",
"08:20",
"08:40",
"09:00",
"09:20",
"09:40",
"10:00",
"10:20",
"10:40",
"11:00",
"11:20",
"11:40",
"12:00",
"12:20",
"12:40",
"13:00",
"13:20",
"13:40",
"14:00",
"14:20",
"14:40",
"15:00",
"15:20",
"15:40",
"16:00",
"16:20",
"16:40",
"17:00",
"17:20",
"17:40",
"18:00",
"18:20",
"18:40"
]
},
{
"station_id": 5,
"derive": {
"from_station_id": 6,
"offset_min": 30,
"note": "ท่ารถตู้ต่างจังหวัด รังสิต (รถจากจตุจักรผ่านมาถึง)"
},
"times": []
},
{
"station_id": 9,
"times": []
}
]
}
]
}
@@ -0,0 +1,42 @@
{
"schema": 2,
"route_id": "952",
"generated_from": "schedules.json",
"station_order": [
11,
12
],
"directions": [
{
"dir_id": "dir-1",
"dir_label": "จากตลาดวิเศษ",
"stops": [
{
"station_id": 11,
"times": [
"04:30",
"10:00",
"15:00"
],
"dir_note": "จากตลาดวิเศษ",
"note": "10:00 มีเฉพาะวันหยุด"
}
]
},
{
"dir_id": "all",
"dir_label": null,
"stops": [
{
"station_id": 12,
"times": [
"07:00",
"10:30",
"15:00"
],
"note": " 7:00 มีเฉพาะวันหยุด"
}
]
}
]
}
@@ -0,0 +1,68 @@
{
"schema": 2,
"route_id": "954",
"generated_from": "schedules.json",
"station_order": [
8,
5,
6
],
"directions": [
{
"dir_id": "dir-1",
"dir_label": "จากตลาดท่าช้าง",
"stops": [
{
"station_id": 8,
"times": [
"03:30",
"05:10",
"10:20",
"12:40"
],
"dir_note": "จากตลาดท่าช้าง"
},
{
"station_id": 6,
"times": [
"07:00",
"09:00",
"14:00",
"16:00"
],
"dir_note": null
}
]
},
{
"dir_id": "rungsit",
"dir_label": null,
"stops": [
{
"station_id": 5,
"derive": {
"from_station_id": 6,
"offset_min": 30,
"note": ""
},
"times": []
}
]
},
{
"dir_id": "rungsit",
"dir_label": "ตลาดสามโก้",
"stops": [
{
"station_id": 8,
"derive": {
"from_station_id": 8,
"offset_min": 45,
"note": "จากตลาดสามโก้"
},
"times": []
}
]
}
]
}
@@ -0,0 +1,21 @@
{
"schema": 2,
"route_id": "999",
"generated_from": "schedules.json",
"station_order": [
14
],
"directions": [
{
"dir_id": "from-14",
"dir_label": null,
"stops": [
{
"station_id": 14,
"times": [],
"note": "ยังไม่มีข้อมูลตารางเวลา"
}
]
}
]
}
+36 -76
View File
@@ -8,7 +8,7 @@
"province_th": "อ่างทอง",
"station_type": "main_terminal",
"latitude": 14.594892813219857,
"longitude":100.45160878714961
"longitude": 100.45160878714961
},
{
"station_id": 2,
@@ -16,9 +16,9 @@
"station_name_th": "สถานีขนส่งป่าโมก",
"city_th": "ป่าโมก",
"province_th": "อ่างทอง",
"station_type": "main_terminal",
"latitude": 14.494620342173755,
"longitude":100.44663039105356
"station_type": "local_terminal",
"latitude": 14.494620342173755,
"longitude": 100.44663039105356
},
{
"station_id": 3,
@@ -27,8 +27,8 @@
"city_th": "พระนครศรีอยุธยา",
"province_th": "อยุธยา",
"station_type": "local_stop",
"latitude": 14.359304063054642,
"longitude":100.57729051741023
"latitude": 14.359304063054642,
"longitude": 100.57729051741023
},
{
"station_id": 4,
@@ -37,8 +37,8 @@
"city_th": "พระนครศรีอยุธยา",
"province_th": "อยุธยา",
"station_type": "market",
"latitude": 14.358600551289177,
"longitude":100.57740172977549
"latitude": 14.358600551289177,
"longitude": 100.57740172977549
},
{
"station_id": 5,
@@ -46,9 +46,9 @@
"station_name_th": "ท่ารถตู้ต่างจังหวัด รังสิต",
"city_th": "รังสิต",
"province_th": "ปทุมธานี",
"station_type": "van_terminal",
"latitude": 13.989149716177037,
"longitude":100.61472107391762
"station_type": "main_terminal",
"latitude": 13.989149716177037,
"longitude": 100.61472107391762
},
{
"station_id": 6,
@@ -56,9 +56,9 @@
"station_name_th": "สถานีเดินรถโดยสารขนาดเล็ก (จตุจักร) รถตู้/มินิบัส",
"city_th": "จตุจักร",
"province_th": "กรุงเทพมหานคร",
"station_type": "van_terminal",
"latitude": 13.811802065338766,
"longitude":100.5498111488118
"station_type": "main_terminal",
"latitude": 13.811802065338766,
"longitude": 100.5498111488118
},
{
"station_id": 7,
@@ -67,8 +67,8 @@
"city_th": "เมืองลพบุรี",
"province_th": "ลพบุรี",
"station_type": "main_terminal",
"latitude": 14.798689894136096,
"longitude":100.63316793418102
"latitude": 14.798689894136096,
"longitude": 100.63316793418102
},
{
"station_id": 8,
@@ -85,8 +85,8 @@
"city_th": "เมืองสุพรรณบุรี",
"province_th": "สุพรรณบุรี",
"station_type": "main_terminal",
"latitude": 14.473737243267138,
"longitude":100.12544591300441
"latitude": 14.473737243267138,
"longitude": 100.12544591300441
},
{
"station_id": 10,
@@ -95,8 +95,8 @@
"city_th": "เมืองสระบุรี",
"province_th": "สระบุรี",
"station_type": "main_terminal",
"latitude": 14.523709233795955,
"longitude":100.91901540002084
"latitude": 14.523709233795955,
"longitude": 100.91901540002084
},
{
"station_id": 11,
@@ -105,8 +105,8 @@
"city_th": "วิเศษชัยชาญ",
"province_th": "อ่างทอง",
"station_type": "private_stop",
"latitude": 14.59666118926178,
"longitude":100.35213848667698
"latitude": 14.59666118926178,
"longitude": 100.35213848667698
},
{
"station_id": 12,
@@ -114,9 +114,9 @@
"station_name_th": "สายใต้เก่า ปิ่นเกล้า จุดจอดรถตู้",
"city_th": "บางกอกน้อย",
"province_th": "กรุงเทพมหานคร",
"station_type": "van_terminal",
"latitude": 13.786761431062317,
"longitude":100.46776017448384
"station_type": "main_terminal",
"latitude": 13.786761431062317,
"longitude": 100.46776017448384
},
{
"station_id": 13,
@@ -125,8 +125,8 @@
"city_th": "เมืองชัยนาท",
"province_th": "ชัยนาท",
"station_type": "main_terminal",
"latitude": 15.197359140046297,
"longitude":100.1245558104688
"latitude": 15.197359140046297,
"longitude": 100.1245558104688
},
{
"station_id": 14,
@@ -135,58 +135,18 @@
"city_th": "เมืองอ่างทอง",
"province_th": "อ่างทอง",
"station_type": "main_terminal",
"latitude": 14.580083239362345,
"longitude":100.4841456500421
"latitude": 14.580083239362345,
"longitude": 100.4841456500421
},
{
"station_id": 15,
"station_code": "chaiyo_terminal",
"station_name_th": "สถานีขนส่งไชโย",
"city_th": "ไชโย",
"province_th": "อ่างทอง",
"station_type": "main_terminal"
},
{
"station_id": 16,
"station_code": "pho_thong_terminal",
"station_name_th": "สถานีขนส่งโพธิ์ทอง",
"city_th": "โพธิ์ทอง",
"province_th": "อ่างทอง",
"station_type": "main_terminal"
},
{
"station_id": 17,
"station_code": "sawaeng_ha_terminal",
"station_name_th": "สถานีขนส่งแสวงหา",
"city_th": "แสวงหา",
"province_th": "อ่างทอง",
"station_type": "main_terminal"
},
{
"station_id": 18,
"station_code": "wiset_chai_chan_terminal",
"station_name_th": "สถานีขนส่งวิเศษชัยชาญ",
"city_th": "วิเศษชัยชาญ",
"province_th": "อ่างทอง",
"station_type": "main_terminal"
},
{
"station_id": 19,
"station_code": "samko_terminal",
"station_name_th": "สถานีขนส่งสามโก้",
"city_th": "สามโก้",
"province_th": "อ่างทอง",
"station_type": "main_terminal"
},
{
"station_id": 20,
"station_code": "at_market",
"station_name_th": "ตลาดอ่างทอง",
"city_th": "เมืองอ่างทอง",
"province_th": "อ่างทอง",
"station_code": "7-11 kinsa",
"station_name_th": "7-11 สาขากินซ่า",
"city_th": "รังสิต",
"province_th": "ปทุมธานี",
"station_type": "main_terminal",
"latitude": 14.59372148660796,
"longitude":100.45079590645398
"latitude": 13.9906952188289,
"longitude": 100.61469598208095
}
]
}
}
+57
View File
@@ -0,0 +1,57 @@
{
"8": {
"13": 197.42,
"6": 0.01
},
"15": {
"1": 0.02,
"2": 14.32,
"6": 109.52
},
"101": {
"3": 39.76,
"1": 0.02,
"2": 14.39
},
"324": {
"1": 29.52,
"8": 9.76
},
"464": {
"9": 0.0,
"10": 103.15,
"1": 44.95
},
"641": {
"1": 0.0,
"7": 43.53
},
"902": {
"1": 0.0,
"6": 100.28,
"15": 77
},
"951": {
"9": 0.0,
"20": 42.25
},
"952": {
"12": 129.46
},
"954": {
"8": 0.0
},
"1011": {
"1": 36.02,
"8": 0.36
},
"2194": {
"8": 1.11,
"4": 40.84
},
"2231": {
"1": 0.0,
"8": 20.13
}
}
Binary file not shown.
+220
View File
@@ -0,0 +1,220 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""ตรวจสุขภาพข้อมูลเส้นทาง — QGIS → GeoJSON ที่เว็บใช้
รันจาก root ของโปรเจกต์:
python resource/tools/audit-geojson.py
ตรวจ 3 ส่วน:
A. ไฟล์ส่งออกใน QGIS Project (GeoJSON-2/3/4) — CRS · พิกัดว่าง/ซ้ำ/หลุดกรอบ · ความหยาบของเส้น
B. ข้อมูลที่เว็บใช้จริง (resource/data/geojson-web/) — สถิติ + "ปลายเส้นตรงกับจุดจอดไหม"
C. เทียบ shapefile (ต้นทาง QGIS) ↔ geojson-web (ว่าต้องรัน pipeline ไหม)
"""
import importlib.util
import json
import math
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
TOOL = Path(__file__).with_name("qgis-to-web.py")
QDIR = ROOT / "resource" / "data" / "QGIS Project"
WEB = ROOT / "resource" / "data" / "geojson-web"
DATA = ROOT / "resource" / "data"
BBOX = (97.0, 103.0, 12.0, 17.5)
JUMP_KM = 1.5
END_TOL_KM = 1.0
# ยืมตัวอ่าน shapefile + ตารางจับคู่จาก pipeline (DRY)
_spec = importlib.util.spec_from_file_location("q2w", TOOL)
q2w = importlib.util.module_from_spec(_spec)
_spec.loader.exec_module(q2w)
issues = []
def note(level, msg): issues.append((level, msg))
def hav(a, b):
R = 6371.0
p1, p2 = math.radians(a[1]), math.radians(b[1])
dp, dl = p2 - p1, math.radians(b[0] - a[0])
h = math.sin(dp / 2) ** 2 + math.cos(p1) * math.cos(p2) * math.sin(dl / 2) ** 2
return 2 * R * math.asin(math.sqrt(h))
def read_features(p):
txt = p.read_text(encoding="utf-8", errors="replace")
try:
d = json.loads(txt)
feats = list(d.get("features") or [])
if d.get("type") == "Feature" and "geometry" in d:
feats.append(d)
return feats, ("FeatureCollection" if "features" in d else "Feature")
except json.JSONDecodeError:
return [json.loads(l) for l in txt.splitlines() if l.strip()], "GeoJSONLines"
def lines_of(geom):
if not geom:
return []
t, cs = geom.get("type"), geom.get("coordinates") or []
if t == "LineString":
return [cs] if cs else []
if t == "MultiLineString":
return [l for l in cs if l]
return []
def audit_file(p):
feats, kind = read_features(p)
lines, empty = [], 0
for f in feats:
ls = lines_of(f.get("geometry"))
if not ls:
empty += 1
continue
lines += ls
pts = [c for l in lines for c in l]
if not pts:
return {"kind": kind, "feats": len(feats), "empty_feats": empty, "pts": 0}
jumps = [hav(l[i - 1], l[i]) for l in lines for i in range(1, len(l)) if hav(l[i - 1], l[i]) > JUMP_KM]
return {
"kind": kind, "feats": len(feats), "empty_feats": empty, "lines": len(lines), "pts": len(pts),
"km": sum(hav(l[i - 1], l[i]) for l in lines for i in range(1, len(l))),
"jumps": jumps, "max_jump": max(jumps) if jumps else 0.0,
"dups": sum(1 for l in lines for i in range(1, len(l)) if l[i] == l[i - 1]),
"out_of_box": sum(1 for c in pts if not (BBOX[0] < c[0] < BBOX[1] and BBOX[2] < c[1] < BBOX[3])),
"utm": max(abs(min(c[0] for c in pts)), abs(max(c[0] for c in pts))) > 1000,
"lines_pts": lines, "first": lines[0][0], "last": lines[-1][-1],
}
def table_header(title):
print("\n" + "=" * 104)
print(title)
print("=" * 104)
def stops_for(rid, routes, stations, others):
out = []
for sid in (routes.get(rid, {}).get("station_ids") or []):
s = stations.get(sid)
if s and s.get("latitude") not in (None, ""):
out.append((s["station_name_th"], float(s["longitude"]), float(s["latitude"])))
for o in others.get(rid, []):
out.append((o["station_name_th"] + "*", float(o["longitude"]), float(o["latitude"])))
return out
def main():
routes = {str(r["route_id"]): r for r in json.loads((DATA / "routes.json").read_text(encoding="utf-8"))["routes"]}
stations = {s["station_id"]: s for s in json.loads((DATA / "stations.json").read_text(encoding="utf-8"))["stations"]}
others = {}
op = DATA / "8 other_stop.json"
if op.exists():
for o in json.loads(op.read_text(encoding="utf-8")).get("other_stop", []):
others.setdefault(str(o["route_id"]), []).append(o)
# ── A. ไฟล์ส่งออกใน QGIS Project ──
table_header("A. ไฟล์ส่งออกใน QGIS Project (ต้นฉบับ — ยังไม่ได้เข้าสู่เว็บจนกว่าจะรัน pipeline)")
print(f"\n{'ไฟล์':<34}{'แบบ':<16}{'feat':<6}{'ว่าง':<6}{'จุด':<7}{'กม.':<8}{'ตัดตรง':<8}{'สูงสุด':<8}{'ซ้ำ':<5}{'นอกกรอบ':<9}CRS")
print("-" * 104)
for p in sorted(x for x in QDIR.rglob("*") if x.suffix.lower() in (".geojson", ".json") and x.suffix.lower() != ".qmd"):
st = audit_file(p)
rel = str(p.relative_to(QDIR))
if st["pts"] == 0:
print(f"{rel:<34}{st['kind']:<16}{st['feats']:<6}{st['empty_feats']:<6}{'0':<7}{'-':<8}{'-':<8}{'-':<8}{'-':<5}{'-':<9}⚠️ ไม่มีพิกัด")
continue
if st["utm"]:
note("ERROR", f"{rel}: พิกัดเป็น UTM — ต้องบันทึก/export ใหม่เป็น EPSG:4326")
if st["out_of_box"]:
note("WARN", f"{rel}: มี {st['out_of_box']} จุดหลุดกรอบประเทศไทย")
print(f"{rel:<34}{st['kind']:<16}{st['feats']:<6}{st['empty_feats']:<6}{st['pts']:<7}{st['km']:<8.1f}"
f"{len(st['jumps']):<8}{st['max_jump']:<8.1f}{st['dups']:<5}{st['out_of_box']:<9}{'UTM ❌' if st['utm'] else 'WGS84 ✓'}")
# ── B. ข้อมูลที่เว็บใช้จริง ──
table_header("B. ข้อมูลที่เว็บใช้จริง (resource/data/geojson-web/) — ชุดที่แผนที่โหลด")
print(f"\n{'สาย':<8}{'feat':<6}{'จุด':<7}{'กม.':<8}{'ตัดตรง':<8}{'สูงสุด':<8}ปลายเส้น ↔ จุดจอด (ห่างเกิน {END_TOL_KM} กม. = ⚠️)")
print("-" * 104)
for p in sorted(WEB.glob("*.geojson")):
rid = p.stem
st = audit_file(p)
if st["pts"] == 0:
print(f"{rid:<8}⚠️ ไม่มีพิกัด")
continue
cands = stops_for(rid, routes, stations, others)
ends = ""
if cands:
da, na = min((hav(st["first"], [c[1], c[2]]), c[0]) for c in cands)
db, nb = min((hav(st["last"], [c[1], c[2]]), c[0]) for c in cands)
ends = f"เริ่ม {na[:18]} {da:.1f} กม.{'✓' if da <= END_TOL_KM else '⚠️'} · จบ {nb[:18]} {db:.1f} กม.{'✓' if db <= END_TOL_KM else '⚠️'}"
if da > END_TOL_KM:
note("WARN", f"สาย {rid}: จุดเริ่มเส้นห่างจุดจอดที่ใกล้สุด {da:.1f} กม. ({na})")
if db > END_TOL_KM:
note("WARN", f"สาย {rid}: จุดจบเส้นห่างจุดจอดที่ใกล้สุด {db:.1f} กม. ({nb})")
if st["max_jump"] > 10:
note("WARN", f"สาย {rid}: ช่วงตัดตรงยาวสุด {st['max_jump']:.1f} กม. (เส้นหยาบ/ไม่เกาะถนน)")
print(f"{rid:<8}{st['feats']:<6}{st['pts']:<7}{st['km']:<8.1f}{len(st['jumps']):<8}{st['max_jump']:<8.1f}{ends}")
# ── C. sync shapefile ↔ geojson-web ──
table_header("C. ตรวจ sync: shapefile (QGIS) ↔ geojson-web (เว็บใช้)")
print(f"\n{'สาย':<8}{'shapefile':<40}{'shp: จุด/กม.':<18}{'web: จุด/กม.':<18}สถานะ")
print("-" * 104)
stale = []
for rid in sorted(q2w.SHP_MAP):
shp = QDIR / f"{q2w.SHP_MAP[rid]}.shp"
web = WEB / f"{rid}.geojson"
if not shp.exists():
print(f"{rid:<8}{q2w.SHP_MAP[rid][:38]:<40}{'—':<18}{'—':<18}⚠️ ไม่พบ shapefile (ชื่อเปลี่ยน?)")
note("WARN", f"สาย {rid}: ไม่พบ shapefile {shp.name} — ชื่ออาจเปลี่ยนใน QGIS")
continue
recs = q2w.read_shp(shp)
sl = [l for r in recs for l in r]
skm = sum(hav(l[i - 1], l[i]) for l in sl for i in range(1, len(l)))
sn = sum(len(l) for l in sl)
if web.exists():
wst = audit_file(web)
wn, wkm = wst["pts"], wst["km"]
else:
wn, wkm = 0, 0.0
same = abs(sn - wn) <= 5 and abs(skm - wkm) < 0.05
state = "ตรงกัน ✓" if same else "⚠️ ต้องรัน qgis-to-web.py"
if not same:
stale.append(rid)
print(f"{rid:<8}{shp.stem[:38]:<40}{f'{sn} / {skm:.1f}':<18}{f'{wn} / {wkm:.1f}':<18}{state}")
if stale:
note("WARN", f"geojson-web ไม่ตรงกับ shapefile {len(stale)} สาย ({', '.join(stale)}) → รัน `python resource/tools/qgis-to-web.py`")
else:
print("\n→ geojson-web ตรงกับ shapefile ทุกสาย ✓")
# ── ไฟล์ประกอบอื่น ──
csvs = [str(p.relative_to(QDIR)) for p in QDIR.rglob("*.csv")]
if csvs:
note("INFO", f"ไฟล์ .csv ในโฟลเดอร์ QGIS (น่าจะเป็นไฟล์ทดสอบ): {csvs}")
zips = [p.name for p in QDIR.glob("*.zip")]
if zips:
note("INFO", f"มี .zip สำเนาโฟลเดอร์: {zips}")
no_prj = [p.name for p in QDIR.glob("*.shp") if not p.with_suffix(".prj").exists()]
if no_prj:
note("WARN", f"shapefile ไม่มี .prj (CRS ไม่ทราบ): {no_prj}")
no_geom = sorted(set(routes) - {p.stem for p in WEB.glob("*.geojson")})
unused = sorted({p.stem for p in WEB.glob("*.geojson")} - set(routes))
if no_geom:
note("INFO", f"อยู่ใน routes.json แต่ไม่มี geometry: {no_geom}")
if unused:
note("INFO", f"มี geometry แต่ไม่อยู่ใน routes.json: {unused}")
print("\n" + "=" * 104)
print(f"สรุปประเด็น: {len(issues)} ข้อ")
for level in ("ERROR", "WARN", "INFO"):
ls = [m for lv, m in issues if lv == level]
if ls:
print(f"\n[{level}] {len(ls)} ข้อ")
for m in ls:
print(" -", m)
print(f"\nเกณฑ์: CRS ต้อง WGS84 · ตัดตรง >{JUMP_KM} กม. = หยาบเกินไป · ปลายเส้นห่างจุดจอด >{END_TOL_KM} กม. = ไม่ตรง")
return 1 if any(lv == "ERROR" for lv, _ in issues) else 0
if __name__ == "__main__":
sys.exit(main())
+179
View File
@@ -0,0 +1,179 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""derive-times.py — เติมกฎ "จุดนี้ = เวลาจุดอ้างอิง ± n นาที" ให้ไฟล์สาย (resource/data/scheduleslist/)
แนวคิด: เขียนกฎครั้งเดียวเป็นตาราง (resource/data/derive-times.csv) แล้วรันสคริปต์นี้
→ เติมบล็อก "derive" ให้จุดเป้าหมาย + ลบเวลาที่คัดลอกมาทิ้ง (กันข้อมูลไม่ตรงกัน)
ไม่ต้องจดจำไวยากรณ์ JSON และไม่ต้องแก้ทีละสายด้วยมือ
ตาราง (CSV, คั่นด้วยจุลภาค — บรรทัดขึ้นต้น # = ความเห็น):
route_id, station_id, from_station_id, offset_min, note
902, 15, 6, 30, รอรถที่ 7-11 หน้ากินซ่า
วิธีใช้:
python resource/tools/derive-times.py --check # ดูว่าจะเปลี่ยนอะไร (ไม่เขียนไฟล์)
python resource/tools/derive-times.py # เขียนจริง
python resource/tools/derive-times.py --audit # ตรวจกฎ vs ไฟล์ (ไม่เขียน)
"""
import argparse
import csv
import json
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
DATA = ROOT / "resource" / "data"
SUB_DIR = DATA / "scheduleslist"
TABLE = DATA / "derive-times.csv"
def read_table(path=TABLE):
"""อ่านตารางกฎ → [{route_id, station_id, from_station_id, offset_min, note}]"""
if not path.exists():
return []
rows = []
with path.open(encoding="utf-8-sig") as f:
for line in f:
line = line.strip()
if not line or line.startswith("#"):
continue
parts = [x.strip() for x in line.split(",")]
if parts[0].lower() == "route_id": # หัวตาราง
continue
if len(parts) < 4:
continue
rows.append({
"route_id": str(parts[0]),
"station_id": int(parts[1]),
"from_station_id": int(parts[2]),
"offset_min": int(parts[3]),
"note": (parts[4] if len(parts) > 4 else "").strip() or None,
})
return rows
def sub_path(rid):
return SUB_DIR / f"schedules{rid}.json"
def load_sub(rid):
"""คืน (ข้อมูล, ชนิดขึ้นบรรทัด) — อ่านเป็น bytes เพราะ Path.read_text() แปลง CRLF→LF ให้อัตโนมัติ
(ถ้าอ่านด้วย read_text() จะตรวจชนิดขึ้นบรรทัดผิด แล้วเขียนไฟล์เป็น LF ทั้งที่เดิม CRLF)"""
f = sub_path(rid)
if not f.exists():
return None, None
raw = f.read_bytes()
eol = "\r\n" if b"\r\n" in raw else "\n"
return json.loads(raw.decode("utf-8")), eol
def all_times(sub, station_id):
"""เวลาจริงของจุดนั้น (จากทุกทิศ)"""
for d in sub.get("directions", []):
for s in d.get("stops", []):
if int(s["station_id"]) == int(station_id) and (s.get("times") or []):
return s["times"], d.get("dir_id")
return [], None
def find_stop(sub, station_id):
"""คืน (ทิศ, จุด) ของจุดเป้าหมาย"""
for d in sub.get("directions", []):
for s in d.get("stops", []):
if int(s["station_id"]) == int(station_id):
return d, s
return None, None
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--check", action="store_true", help="dry run — ไม่เขียนไฟล์")
ap.add_argument("--audit", action="store_true", help="ตรวจกฎกับไฟล์ (ไม่เขียน)")
args = ap.parse_args()
rules = read_table()
if not rules:
print(f"ไม่พบกฎในตาราง {TABLE.relative_to(ROOT)} (หรือไฟล์ว่าง)")
return 0
print(f"กฎทั้งหมด: {len(rules)} ข้อ" + (" [--check = ไม่เขียนไฟล์]" if args.check else ""))
problems = 0
for r in rules:
rid = r["route_id"]
sub, eol = load_sub(rid)
if sub is None:
print(f" ✗ {rid}: ไม่พบไฟล์ {sub_path(rid).name}")
problems += 1
continue
src_times, src_dir = all_times(sub, r["from_station_id"])
d, stop = find_stop(sub, r["station_id"])
if stop is None:
print(f" ✗ {rid}: ไม่พบจุด {r['station_id']} ในไฟล์ (ต้องมีจุดก่อนจึงจะตั้งกฎได้)")
problems += 1
continue
if not src_times:
print(f" ✗ {rid}: จุดอ้างอิง {r['from_station_id']} ยังไม่มีเวลาจริง — คำนวณไม่ได้")
problems += 1
continue
had = len(stop.get("times") or [])
want = {"from_station_id": r["from_station_id"], "offset_min": r["offset_min"]}
if r["note"]:
want["note"] = r["note"]
already = stop.get("derive") == want and not had
if args.audit:
ok = already
print(f" {'✓' if ok else '✗'} {rid} จุด {r['station_id']} ← จุด {r['from_station_id']} "
f"{r['offset_min']:+d} นาที (ต้นทางมี {len(src_times)} เที่ยว"
+ (f" · ทิศ {src_dir}" if src_dir else "") + ")"
+ ("" if ok else f" — ไฟล์ยังไม่ตรง (มี times {had} · derive={stop.get('derive')})"))
if not ok:
problems += 1
continue
if already:
print(f" = {rid} จุด {r['station_id']}: ตั้งกฎไว้แล้ว ({r['offset_min']:+d} นาที) — ข้าม")
continue
print(f" → {rid} จุด {r['station_id']} ← จุด {r['from_station_id']} {r['offset_min']:+d} นาที"
+ (f" · ลบเวลาที่คัดลอกมา {had} เที่ยว" if had else ""))
if not args.check:
stop["derive"] = want
if had:
stop.pop("times", None) # ไม่เก็บเวลาซ้ำ — ให้เว็บคำนวณเสมอ
stop["times"] = []
txt = json.dumps(sub, ensure_ascii=False, indent=2)
if eol == "\r\n":
txt = txt.replace("\n", "\r\n")
sub_path(rid).write_text(txt + eol, encoding="utf-8", newline="")
if args.audit:
print(f"\nผลตรวจ: {len(rules) - problems}/{len(rules)} ตรงกัน" + (f" · ไม่ตรง {problems}" if problems else " ✓"))
print("\n— จุดที่ 'เวลาซ้ำกับอีกจุดในสายเดียวกัน' แต่ยังไม่มีกฎ (น่าจะต้องตั้ง derive) —")
cands = 0
for f in sorted(SUB_DIR.glob("schedules*.json")):
sub2, _ = load_sub(f.stem.replace("schedules", ""))
if not sub2:
continue
sig = {}
for d in sub2.get("directions", []):
for st in d.get("stops", []):
t = tuple(st.get("times") or [])
if t:
sig.setdefault(t, []).append((d.get("dir_id"), st["station_id"], st.get("derive")))
for times, who in sig.items():
if len(who) < 2:
continue
if any(w[2] for w in who): # มีกฎแล้วบางจุด → ถือว่าจัดการแล้ว
continue
cands += 1
print(f" · {sub2.get('route_id')}: " + " = ".join(f"จุด {w[1]} (ทิศ {w[0]})" for w in who)
+ f" · {len(times)} เที่ยวเท่ากันเป๊ะ → เลือกจุดอ้างอิง + ใส่ offset")
print(" (ไม่มี)" if not cands else f" รวม {cands} กลุ่ม")
else:
print(f"\n{'ตรวจแล้ว (ไม่เขียนไฟล์)' if args.check else 'เขียนไฟล์แล้ว'} · ปัญหา {problems} รายการ")
return 1 if problems else 0
if __name__ == "__main__":
sys.exit(main())
+72
View File
@@ -0,0 +1,72 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""รวมไฟล์ย่อย resource/data/scheduleslist/schedules<route_id>.json → schedules.json ไฟล์เดียว (schema 2)
ใช้เมื่อ: ต้องการย้อนกลับไปใช้ไฟล์เดียว (เช่น ส่งต่อ/สำรอง หรือโปรแกรมอื่นต้องการไฟล์รวม)
รัน: python resource/tools/merge-schedules.py # เขียน schedules.json (สำรองไฟล์เดิมเป็น .bak ก่อน)
python resource/tools/merge-schedules.py --check # ดูผลก่อน ไม่เขียน
"""
import argparse
import json
import shutil
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
DATA = ROOT / "resource" / "data"
LIST_DIR = DATA / "scheduleslist"
def jdump(o):
return json.dumps(o, ensure_ascii=False, indent=2).replace("\n", "\r\n") + "\r\n"
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--check", action="store_true")
args = ap.parse_args()
if not LIST_DIR.exists():
print("ไม่พบโฟลเดอร์ scheduleslist/"); return 1
files = sorted(LIST_DIR.glob("schedules*.json"),
key=lambda p: (len(p.stem.replace("schedules", "")), p.stem))
if not files:
print("ไม่พบไฟล์ย่อยใน scheduleslist/"); return 1
routes, bad = [], []
for f in files:
try:
d = json.loads(f.read_text(encoding="utf-8"))
except Exception as e:
bad.append((f.name, str(e)[:60])); continue
rid = d.get("route_id")
if rid is None:
rid = f.stem.replace("schedules", "")
routes.append({
"route_id": rid,
"station_order": d.get("station_order", []),
"directions": d.get("directions", []),
})
if bad:
print("ไฟล์ที่อ่านไม่ได้ (ข้าม):")
for n, e in bad:
print(f" {n}: {e}")
doc = {"schema": 2, "routes": routes}
trips = sum(len(s.get("times") or []) for r in routes for d in r["directions"] for s in (d.get("stops") or []))
stops = sum(len(d.get("stops") or []) for r in routes for d in r["directions"])
dirs = sum(len(r["directions"]) for r in routes)
print(f"รวมได้ {len(routes)} สาย · {dirs} ทิศ · {stops} จุด · {trips} เที่ยว")
if args.check:
print("[--check] ไม่เขียนไฟล์"); return 0
dst = DATA / "schedules.json"
if dst.exists():
shutil.copy2(dst, DATA / "schedules.json.bak")
print("สำรองไฟล์เดิมเป็น schedules.json.bak แล้ว")
dst.write_text(jdump(doc), encoding="utf-8", newline="")
print("เขียน schedules.json (ไฟล์เดียว) แล้ว")
return 0
if __name__ == "__main__":
sys.exit(main())
+263
View File
@@ -0,0 +1,263 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""QGIS → GeoJSON สำหรับเว็บ (resource/data/geojson-web/)
*** ไม่ใช่ build step ของเว็บ *** — เว็บเป็น static (AGENTS.md ข้อ 1)
สคริปต์นี้เป็นเครื่องมือ "เตรียมข้อมูล" รันมือ หลังแก้เส้นทางใน QGIS
แหล่งข้อมูล 2 ทาง (ค่าเริ่มต้น = shapefile เพราะวิธีทำงานจริงคือแก้ใน QGIS แล้วกด Save):
python resource/tools/qgis-to-web.py # อ่าน <รหัสสาย>.shp ตามตาราง SHP_MAP (แนะนำ)
python resource/tools/qgis-to-web.py --from geojson # อ่าน GeoJSON-2/*.geojson (เส้นทางเดิม)
ธงอื่น:
--check ตรวจเทียบกับไฟล์ปัจจุบัน ไม่เขียนไฟล์
--list แสดงตารางจับคู่รหัสสาย ↔ ไฟล์ + สถานะ
กติกาที่บังคับ:
1. CRS ต้องเป็น WGS84 (EPSG:4326) — .prj ต้องบอก WGS84 และพิกัดต้องไม่ใช่ UTM (หลักล้าน)
2. จุดที่หลุดกรอบประเทศไทย (lng 97–103, lat 12–17.5) ถูกตัดออก
3. ปัดพิกัดเหลือ 5 ตำแหน่ง (แม่นยำ ~1 ม. พอสำหรับแผนที่)
4. 1 record ของ shapefile = 1 feature (MultiLineString) · properties = {"route_id": "<รหัส>"}
"""
import argparse
import json
import re
import struct
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
QDIR = ROOT / "resource" / "data" / "QGIS Project"
SRC_GEOJSON = QDIR / "GeoJSON-2"
DST = ROOT / "resource" / "data" / "geojson-web"
BBOX = (97.0, 103.0, 12.0, 17.5) # lng_min, lng_max, lat_min, lat_max
# ── ตารางจับคู่ "รหัสสาย → ไฟล์ .shp ในโปรเจกต์ QGIS" ─────────────────────────
# โปรเจกต์มีหลายเวอร์ชันต่อสาย — ตารางนี้ระบุตัวที่ป้อนเว็บ (ตรวจด้วยจุดเริ่ม/จุดจบ
# ของเส้นว่าเข้าคู่กันแล้ว) ถ้ามีการเปลี่ยนชื่อไฟล์ใน QGIS ต้องแก้ที่ตารางนี้
SHP_MAP = {
"8": "8 Bangkok-Chainat",
"15": "15 angthong-Bangkok-local",
"101": "101-Angthong-pamok-Ayuthaya",
"324": "324-Angthong-watpikungthong1",
"464": "464 -suphanburi-saraburi",
"641": "641-Angthong-lopburi1",
"902": "902",
"905": "905 bangkok-singburi",
"951": "951 Bangkok-wisead-suphanburi",
"952": "952 กรุงเทพ-วิเศษชัยชาญ",
"954": "954",
"1011": "1011",
"2194": "2194",
"2231": "2231",
"XXX1": "XXX อ่างทอง-วิเศษฯ",
"XXX2": "XXX ป่าโมก-ผักไห่",
}
# ── อ่าน shapefile (polyline = type 3, รองรับ multi-part / หลาย record) ──
def read_shp(path):
"""คืน list ของ record; แต่ละ record = list ของเส้น; แต่ละเส้น = list ของ [lng, lat]"""
b = path.read_bytes()
if len(b) < 100:
return []
recs, off = [], 100
while off + 8 <= len(b):
_, clen = struct.unpack(">ii", b[off:off + 8])
rec = b[off + 8:off + 8 + clen * 2]
off += 8 + clen * 2
if len(rec) < 44 or struct.unpack("<i", rec[:4])[0] != 3:
continue # ข้ามชนิดที่ไม่ใช่เส้น
nparts, npoints = struct.unpack("<ii", rec[36:44])
parts = struct.unpack("<%di" % nparts, rec[44:44 + 4 * nparts])
poff = 44 + 4 * nparts
pts = [struct.unpack("<dd", rec[poff + 16 * i:poff + 16 * i + 16]) for i in range(npoints)]
lines = []
for i in range(nparts):
a = parts[i]
z = parts[i + 1] if i + 1 < nparts else npoints
if pts[a:z]:
lines.append([[x, y] for x, y in pts[a:z]])
if lines:
recs.append(lines)
return recs
def prj_ok(path):
"""ตรวจ .prj ว่าเป็น WGS84 (ไม่ใช่ UTM/meters) — ไม่มี .prj = เตือนแต่ไปต่อ (มีตัวกรอง bbox อีกชั้น)"""
prj = path.with_suffix(".prj")
if not prj.exists():
return None # ไม่มีข้อมูล CRS
t = prj.read_text(encoding="utf-8", errors="replace")
if "UTM" in t or "Transverse_Mercator" in t:
return False
return "4326" in t or "WGS_1984" in t
# ── ตัวกรอง/ทำความสะอาด (ใช้ร่วมกันทั้งสองแหล่ง) ──
def clean_lines(lines):
lng0, lng1, lat0, lat1 = BBOX
kept, dropped = [], 0
for l in lines:
good = [c for c in l if lng0 < float(c[0]) < lng1 and lat0 < float(c[1]) < lat1]
if len(good) >= 2:
kept.append([[round(float(c[0]), 5), round(float(c[1]), 5)] for c in good])
else:
dropped += 1
return kept, dropped
def looks_like_utm(lines):
xs = [c[0] for l in lines for c in l] or [0]
return max(abs(min(xs)), abs(max(xs))) > 1000
def from_shp(route_id):
"""คืน (features, รายงาน) จาก shapefile ตาม SHP_MAP"""
stem = SHP_MAP.get(route_id)
if not stem:
return None, ["ไม่มีในตาราง SHP_MAP — ข้าม"]
path = QDIR / f"{stem}.shp"
if not path.exists():
return None, [f"ไม่พบไฟล์ {path.name} (ชื่อเปลี่ยน? แก้ SHP_MAP)"]
ok = prj_ok(path)
if ok is False:
return None, [f"CRS ของ {path.name} เป็น UTM — ต้องบันทึกใหม่เป็น EPSG:4326"]
recs = read_shp(path)
if not recs:
return None, ["shapefile ไม่มีเส้น (หรือพิกัดว่าง)"]
if looks_like_utm([l for r in recs for l in r]):
return None, ["พิกัดเป็น UTM (ไม่ใช่ WGS84) — บันทึกใหม่โดยตั้ง CRS = EPSG:4326"]
feats, dropped, pts = [], 0, 0
for rec in recs:
kept, d = clean_lines(rec)
dropped += d
if not kept:
continue
feats.append({"type": "Feature", "properties": {"route_id": route_id},
"geometry": {"type": "MultiLineString", "coordinates": kept}})
pts += sum(len(l) for l in kept)
if not feats:
return None, ["หลังกรองแล้วไม่มีเส้นเหลือ — ข้าม"]
notes = [f"ไม่มี .prj (ไม่ทราบ CRS — ตรวจด้วยกรอบประเทศไทย)" if ok is None else ""]
if dropped:
notes.append(f"ตัด {dropped} ช่วงที่สั้น/หลุดกรอบ")
return feats, [n for n in notes if n]
def from_geojson(route_id):
"""คืน (features, รายงาน) จาก GeoJSON-2/<รหัส>.geojson (เส้นทางเดิม)"""
path = SRC_GEOJSON / f"{route_id}.geojson"
if not path.exists():
return None, ["ไม่พบไฟล์ใน GeoJSON-2 — ข้าม"]
try:
data = json.loads(path.read_text(encoding="utf-8"))
except Exception as e:
return None, [f"อ่าน JSON ไม่ได้: {e}"]
feats_in = data.get("features", [])
all_lines = []
for f in feats_in:
g = f.get("geometry") or {}
cs = g.get("coordinates") or []
all_lines += ([cs] if g.get("type") == "LineString" else cs)
if not all_lines:
return None, ["ไม่มีพิกัดในไฟล์ (coordinates ว่าง) — ข้าม"]
if looks_like_utm([l for l in all_lines if l]):
return None, ["พิกัดเป็น UTM (ไม่ใช่ WGS84) — export ใหม่โดยตั้ง CRS = EPSG:4326"]
out, dropped = [], 0
for f in feats_in:
g = f.get("geometry") or {}
gtype, src = g.get("type"), []
cs = g.get("coordinates") or []
src = [cs] if gtype == "LineString" else cs
if gtype not in ("LineString", "MultiLineString") or not src:
continue
kept, d = clean_lines(src)
dropped += d
if not kept:
continue
if gtype == "LineString" and len(kept) > 1:
gtype = "MultiLineString"
out.append({"type": "Feature", "properties": {"route_id": route_id},
"geometry": {"type": gtype, "coordinates": kept[0] if gtype == "LineString" else kept}})
if not out:
return None, ["หลังกรองแล้วไม่มีเส้นเหลือ — ข้าม"]
notes = [f"ตัด {dropped} ช่วงที่สั้น/หลุดกรอบ"] if dropped else []
return out, notes
def targets(mode):
"""รายการ route_id ที่จะสร้าง (จากตาราง SHP_MAP หรือไฟล์ GeoJSON-2)"""
if mode == "shp":
return sorted(SHP_MAP)
return sorted(p.stem for p in SRC_GEOJSON.glob("*.geojson"))
def main():
ap = argparse.ArgumentParser(description="QGIS (shapefile/GeoJSON) → resource/data/geojson-web/")
ap.add_argument("--from", dest="src", choices=["shp", "geojson"], default="shp",
help="แหล่งข้อมูล (ค่าเริ่มต้น shp)")
ap.add_argument("--check", action="store_true", help="ตรวจอย่างเดียว ไม่เขียนไฟล์")
ap.add_argument("--list", action="store_true", help="แสดงตารางจับคู่ + สถานะไฟล์")
args = ap.parse_args()
ids = targets(args.src)
if args.list:
print(f"{'สาย':<8}{'ไฟล์ต้นทาง':<46}{'มีไฟล์':<8}{'.prj':<14}ไฟล์เว็บปัจจุบัน")
for rid in ids:
stem = SHP_MAP.get(rid, "")
p = QDIR / f"{stem}.shp"
prj = "WGS84 ✓" if prj_ok(p) is True else ("UTM ❌" if prj_ok(p) is False else "ไม่มี")
web = DST / f"{rid}.geojson"
print(f"{rid:<8}{stem[:44]:<46}{'มี' if p.exists() else '❌ ไม่มี':<8}{prj:<14}{'มี' if web.exists() else '—'}")
return
from_shp_source = args.src == "shp"
label = "shapefile (QGIS Project/*.shp)" if from_shp_source else "GeoJSON-2/*.geojson"
print(f"ต้นทาง : {label} ({len(ids)} สาย)")
print(f"ปลายทาง: {DST.relative_to(ROOT)}" + (" [--check: ไม่เขียนไฟล์]\n" if args.check else "\n"))
DST.mkdir(parents=True, exist_ok=True)
print(f"{'สาย':<8}{'จุด':<7}{'ไฟล์เดิม':<10}สถานะ")
written = skipped = unchanged = 0
for rid in ids:
rid = re.sub(r"[^0-9A-Za-z]", "", rid) or rid
feats, notes = (from_shp(rid) if from_shp_source else from_geojson(rid))
if feats is None:
print(f"{rid:<8}{'-':<7}{'-':<10}ข้าม — {'; '.join(notes)}")
skipped += 1
continue
out = DST / f"{rid}.geojson"
had_old = out.exists()
old_kb = f"{out.stat().st_size // 1024}KB" if had_old else "-"
payload = json.dumps({"type": "FeatureCollection", "features": feats},
ensure_ascii=False, separators=(",", ":"))
n = sum(len(l) for f in feats for l in
([f["geometry"]["coordinates"]] if f["geometry"]["type"] == "LineString" else f["geometry"]["coordinates"]))
same = had_old and out.read_text(encoding="utf-8").strip() == payload.strip()
if args.check:
state = "เหมือนเดิม ✓" if same else ("ต่างจากเดิม ⚠️" if had_old else "ไฟล์ใหม่")
print(f"{rid:<8}{n:<7}{old_kb:<10}{state}")
continue
if same:
print(f"{rid:<8}{n:<7}{old_kb:<10}ไม่เปลี่ยน — ข้ามการเขียน")
unchanged += 1
continue
out.write_text(payload, encoding="utf-8")
written += 1
print(f"{rid:<8}{n:<7}{old_kb:<10}เขียนแล้ว ({len(payload) // 1024}KB)"
+ (f" — {'; '.join(notes)}" if notes else ""))
print(f"\nสรุป: เขียน {written} · ไม่เปลี่ยน {unchanged} · ข้าม {skipped}"
+ (" (โหมด --check)" if args.check else ""))
if not args.check and written:
print("ขั้นถัดไป: เปิดเว็บกด Ctrl+Shift+R (ไฟล์ .geojson เป็น network-first — ไม่ต้อง bump VERSION)")
if __name__ == "__main__":
main()
+212
View File
@@ -0,0 +1,212 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""schedules.json: แบบแบน (30 record) → แบบ 2 ชั้น routes[] → directions[] → stops[]
*** ไม่ใช่ build step ของเว็บ *** — เครื่องมือเตรียมข้อมูล รันมือครั้งเดียว (รันซ้ำได้ ไม่ทำลายข้อมูล)
แนวคิด "มัดรวมตามสาย → ซอยย่อยตามจุด":
routes[] หนึ่งรายการต่อสาย (ผูกกับ routes.json ด้วย route_id)
station_order[] ลำดับจุดจอดตามที่รถวิ่ง (ตรวจกับพิกัดจริงเทียบปลายเส้น geojson แล้ว)
directions[] แกนทิศ — สายที่รถแยกทาง/วิ่ง 2 ทาง จะมีหลายทิศ
stops[] จุดจอดในทิศนั้น
station_id
times[] เวลาออกของจุดนี้
dir_note ถ้อยคำทิศเดิมจากเจ้าของข้อมูล (เก็บไว้ ไม่แปลง)
note เงื่อนไขเวลาเดิมจากเจ้าของข้อมูล (เก็บไว้ ไม่แปลง)
groups[] (อนาคต) ใช้เมื่อเวลาชุดเดียวกันแยกตามวัน เช่น 10:00 เฉพาะวันหยุด
กติกาการแยกทิศ (ยึดข้อมูลจริง):
- "จุดแยกทิศ" = จุดที่มี record หลายทิศ = จุดที่รถแยกทาง (เช่น สาย 101 จุด 2 ป่าโมก มีทั้ง 'ไปอยุธยา'/'ไปออ่างทอง')
- record ที่ไม่ระบุทิศ → ใช้ทิศของจุดแยกทิศที่อยู่ก่อนหน้าในลำดับ (จุดที่รถผ่านมาก่อน)
- สายที่ไม่ระบุทิศเลย → ทิศเดียว dir_id = "all"
หมายเหตุ: เลิกใช้ schedule_id (ไม่มีโค้ดไหนอ้างถึง) — กุญแจคือ route_id + dir_id + station_id
"""
import argparse
import json
import math
import sys
from collections import OrderedDict
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
DATA = ROOT / "resource" / "data"
SRC = DATA / "schedules.json"
ALL = "__all__" # กุญแจทิศ "ไม่แยกทิศ" (ใช้สตริงธรรมดา กันอักขระพิเศษ)
# ── เรขาคณิตเล็ก ๆ (ใช้ตรวจลำดับจุดจอดกับปลายเส้น) ──
def _hav(a, b):
R = 6371.0
p1, p2 = math.radians(a[1]), math.radians(b[1])
dp, dl = p2 - p1, math.radians(b[0] - a[0])
h = math.sin(dp / 2) ** 2 + math.cos(p1) * math.cos(p2) * math.sin(dl / 2) ** 2
return 2 * R * math.asin(math.sqrt(h))
def stop_point(sid, stations):
st = stations.get(sid)
if not st:
return None
lat, lng = st.get("latitude"), st.get("longitude")
if lat in (None, "") or lng in (None, ""):
return None
try:
return (float(lng), float(lat))
except (TypeError, ValueError):
return None
def geo_ends(rid):
"""ปลายทั้งสองของเส้น (จุดแรก, จุดสุดท้าย) จาก geojson-web"""
p = DATA / "geojson-web" / f"{rid}.geojson"
if not p.exists():
return None
g = json.loads(p.read_text(encoding="utf-8"))
segs = []
for f in g.get("features", []):
cs = f["geometry"]["coordinates"]
segs += [cs] if f["geometry"]["type"] == "LineString" else cs
segs = [s for s in segs if s]
if not segs:
return None
return segs[0][0], segs[-1][-1]
def orient_order(rid, order, stations):
"""คืน station_order ที่ตรงกับทิศที่รถวิ่งจริง (เทียบพิกัดกับปลายเส้น) + ธงว่าสลับหรือไม่"""
if len(order) < 2:
return list(order), False
ends = geo_ends(rid)
if not ends:
return list(order), False
a, b = ends
pf, pl = stop_point(order[0], stations), stop_point(order[-1], stations)
if not (pf and pl):
return list(order), False
same = _hav(pf, a) + _hav(pl, b)
swap = _hav(pf, b) + _hav(pl, a)
if swap < same:
return list(reversed(order)), True
return list(order), False
# ── การแยกทิศ (ไม่เดา — ใช้ "ทิศทางที่ระบุ" (direction_note) และ "จุดต้นทาง" เท่านั้น) ──
def direction_of(rec, first_station):
"""ทิศของ record ตามข้อมูลที่ระบุไว้จริง
- มี direction_note → ทิศนั้น (แยกเป็น directions[] ของตัวเอง)
- ไม่มี note + เป็นจุดต้นทาง (station_order[0]) → 'ออกจากต้นทาง' (dir_id = from-<station>)
- ไม่มี note + จุดอื่น → ทิศทางเดียว (dir_id = "all")
ไม่พยายามเดาว่าจุดปลายทางอยู่ขาไหน (ข้อมูลเดิมขัดกันเอง — ต้องให้เจ้าของข้อมูลยืนยัน)
"""
label = rec.get("direction_note")
if label:
return ("label", label)
if rec["station_id"] == first_station:
return ("start", rec["station_id"])
return ("all", None)
def main():
ap = argparse.ArgumentParser(description="schedules.json: แบน → 2 ชั้น (routes → directions → stops)")
ap.add_argument("--check", action="store_true", help="แสดงผลลัพธ์ ไม่เขียนไฟล์")
ap.add_argument("--out", default=str(SRC), help="ไฟล์ปลายทาง (ค่าเริ่มต้น: ทับ schedules.json)")
args = ap.parse_args()
doc = json.loads(SRC.read_text(encoding="utf-8"))
if doc.get("schema") == 2:
print("ไฟล์เป็น schema 2 อยู่แล้ว — ไม่ต้องแปลง (รัน --force ไม่มี — แก้มือถ้าต้องการแปลงใหม่)")
return 0
records = doc.get("schedules") or []
routes = {str(r["route_id"]): r for r in json.loads((DATA / "routes.json").read_text(encoding="utf-8"))["routes"]}
stations = {x["station_id"]: x for x in json.loads((DATA / "stations.json").read_text(encoding="utf-8"))["stations"]}
by_route = OrderedDict()
for rec in records:
by_route.setdefault(str(rec["route_id"]), []).append(rec)
out_routes, warnings = [], []
n_dup = 0
for rid, recs in by_route.items():
raw_order = routes.get(rid, {}).get("station_ids") or []
order, flipped = orient_order(rid, raw_order, stations)
if flipped:
warnings.append(f"สาย {rid}: สลับ station_order ให้ตรงทิศที่รถวิ่งจริง (พิกัดบอกว่าเริ่มฝั่ง {order[0]})")
dirs = OrderedDict()
for rec in recs:
kind, val = direction_of(rec, order[0] if order else None)
key = (kind, val)
d = dirs.setdefault(key, {"recs": [], "label": val if kind == "label" else None})
d["recs"].append(rec)
dir_list = []
dir_seq = 1
for (kind, val), d in dirs.items():
stops = []
for rec in sorted(d["recs"], key=lambda r: r["station_id"]):
entry = {"station_id": rec["station_id"], "times": rec.get("departure_times") or []}
if rec.get("direction_note"):
entry["dir_note"] = rec["direction_note"]
if rec.get("schedule_note"):
entry["note"] = rec["schedule_note"]
stops.append(entry)
stops.sort(key=lambda x: (order.index(x["station_id"]) if x["station_id"] in order else 999))
dir_id = "all" if kind == "all" else (("from-%s" % val) if kind == "start" else "dir-%d" % dir_seq)
if kind == "label":
dir_seq += 1
dir_list.append({
"dir_id": dir_id,
"dir_label": d["label"],
"stops": stops,
})
n_dup += sum(len(s["times"]) for s in stops)
# เตือน: ทิศเดียวกันแต่จำนวนเที่ยวของแต่ละจุดไม่เท่ากัน (บ่งชี้ว่ายังแยกทิศไม่ครบ)
for dl in dir_list:
counts = {s["station_id"]: len(s["times"]) for s in dl["stops"] if s["times"]}
if len(set(counts.values())) > 1:
warnings.append(
f"สาย {rid} ทิศ '{dl['dir_label'] or 'ไม่แยกทิศ'}': จำนวนเที่ยวไม่เท่ากันข้ามจุด {counts} "
f"— อาจยังแยกทิศไม่ครบ (ต้องให้เจ้าของข้อมูลยืนยัน)")
# เตือนจุดจอดที่ไม่มีเวลา (ไม่สร้างข้อมูลปลอม — UI จะขึ้น "ยังไม่มีข้อมูล")
have = {s["station_id"] for dl in dir_list for s in dl["stops"]}
for sid in order:
if sid not in have:
warnings.append(f"สาย {rid}: จุดจอด station {sid} ยังไม่มีเวลาในไฟล์")
out_routes.append({"route_id": rid, "station_order": order, "directions": dir_list})
new = {"schema": 2, "routes": out_routes}
n_time = sum(len(s["times"]) for r in out_routes for d in r["directions"] for s in d["stops"])
n_distinct = sum(len(r.get("departure_times") or []) for r in records)
print(f"แปลง {len(records)} record → {len(out_routes)} สาย · "
f"{sum(len(r['directions']) for r in out_routes)} ทิศ · "
f"{sum(len(d['stops']) for r in out_routes for d in r['directions'])} จุด")
print(f"เที่ยวในข้อมูลเดิม (ไม่นับซ้ำ) = {n_distinct} · เก็บในโครงใหม่ = {n_time} "
f"(ส่วนต่าง {n_time - n_distinct} = จุดที่ถูกเก็บในหลายทิศ เช่นจุดแยกทิศ)")
print(f"\n{'สาย':<7}{'ทิศ':<24}{'จุด':<5}{'เที่ยว':<7}จุดจอดในทิศนั้น")
for r in out_routes:
for d in r["directions"]:
cells = ", ".join(f"{s['station_id']}×{len(s['times'])}" for s in d["stops"])
print(f"{r['route_id']:<7}{(d['dir_label'] or '(ไม่แยกทิศ)')[:22]:<24}{len(d['stops']):<5}"
f"{sum(len(s['times']) for s in d['stops']):<7}{cells}")
if warnings:
print(f"\nหมายเหตุ {len(warnings)} ข้อ:")
for w in warnings:
print(" -", w)
if args.check:
print("\n[--check] ไม่เขียนไฟล์")
return 0
Path(args.out).write_text(json.dumps(new, ensure_ascii=False, indent=2) + "\n", encoding="utf-8")
print(f"\nเขียนแล้ว: {Path(args.out).name}")
return 0
if __name__ == "__main__":
sys.exit(main())
+85
View File
@@ -0,0 +1,85 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""แตก resource/data/schedules.json → resource/data/scheduleslist/schedules<route_id>.json (1 ไฟล์ = 1 เส้นทาง)
และเขียน schedules.json ให้เป็น "สารบัญ" (index) ชี้ไปไฟล์ย่อย
ทำไม: ไฟล์เดียวรวม 14 สายอ่านยาก/แก้ยาก และเวลาแก้ทีละสายต้องเปิดทั้งไฟล์ → แยกเป็นไฟล์ต่อสาย
รูปแบบไฟล์:
scheduleslist/schedules101.json = { "schema": 2, "route_id": "101", "generated_from": "schedules.json",
"station_order": [...], "directions": [ ... ] } (เนื้อในเหมือนเดิมเป๊ะ)
schedules.json (สารบัญ) = { "schema": 2, "index": true, "dir": "scheduleslist/",
"routes": [ { "route_id": "101", "file": "schedules101.json", ... } ] }
รัน: python resource/tools/split-schedules.py # เขียนไฟล์จริง
python resource/tools/split-schedules.py --check # ดูผลก่อน ไม่เขียน
หมายเหตุ: ถ้า schedules.json เป็นสารบัญอยู่แล้ว คำสั่งนี้จะไม่ทำอะไร (กันเขียนทับไฟล์ย่อย) — ใช้ merge-schedules.py ย้อนกลับ
"""
import argparse
import json
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
DATA = ROOT / "resource" / "data"
LIST_DIR = DATA / "scheduleslist"
def jdump(obj):
return json.dumps(obj, ensure_ascii=False, indent=2).replace("\n", "\r\n") + "\r\n"
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--check", action="store_true")
args = ap.parse_args()
src = DATA / "schedules.json"
if not src.exists():
print("ไม่พบ schedules.json"); return 1
doc = json.loads(src.read_text(encoding="utf-8"))
if doc.get("index") or "directions" not in json.dumps(doc)[:200]:
if doc.get("index"):
print("schedules.json เป็นสารบัญอยู่แล้ว — ไม่ต้องแตกไฟล์ซ้ำ")
print("(ถ้าต้องการย้อนกลับเป็นไฟล์เดียว ใช้ resource/tools/merge-schedules.py)")
return 0
routes = doc.get("routes") or []
if not routes:
print("ไม่พบ routes[] ในไฟล์"); return 1
LIST_DIR.mkdir(exist_ok=True)
index_rows = []
for r in routes:
rid = str(r["route_id"])
sub = {
"schema": doc.get("schema", 2),
"route_id": r["route_id"],
"generated_from": "schedules.json",
"station_order": r.get("station_order", []),
"directions": r.get("directions", []),
}
fname = "schedules" + rid + ".json"
if not args.check:
(LIST_DIR / fname).write_text(jdump(sub), encoding="utf-8", newline="")
counts = {"n_directions": len(sub["directions"]),
"n_stops": sum(len(d.get("stops") or []) for d in sub["directions"]),
"n_trips": sum(len(s.get("times") or []) for d in sub["directions"] for s in (d.get("stops") or []))}
index_rows.append({"route_id": r["route_id"], "file": fname, **counts})
index = {
"schema": doc.get("schema", 2),
"index": True,
"note": "สารบัญชี้ไป scheduleslist/schedules<route_id>.json (1 ไฟล์ = 1 เส้นทาง) — แก้ไฟล์ย่อยนั้นโดยตรง หรือใช้ resource/data/schedules-editor.html",
"dir": "scheduleslist/",
"routes": index_rows,
}
if not args.check:
src.write_text(jdump(index), encoding="utf-8", newline="")
print(("ตรวจเท่านั้น: " if args.check else "เขียนแล้ว: ") + f"{len(index_rows)} ไฟล์ใน scheduleslist/ + สารบัญ schedules.json")
for row in index_rows:
print(f" {row['file']:<26} ทิศ {row['n_directions']:>2} · จุด {row['n_stops']:>2} · เที่ยว {row['n_trips']:>3}")
return 0
if __name__ == "__main__":
sys.exit(main())
+179
View File
@@ -0,0 +1,179 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""วัดระยะทาง (กม. ตามเส้นทางจริง) ของทุกจุดจอด แล้วบันทึกลงไฟล์แยก resource/data/stop-km.json
ทำไมต้องแยกไฟล์: schedules.json เป็นไฟล์ที่ "คนแก้มือ" (ผ่าน Excel/เครื่องมือแก้ไข) — ถ้าเก็บค่าที่คำนวณไว้ในนั้น
พอผู้ใช้กดบันทึกทับจากสำเนาเก่า ค่าที่คำนวณก็หายทั้งชุด → จึงแยกไว้ต่างหาก (ไฟล์นี้เป็น generated)
ทำไมต้องมี: ระบบ "คำนวณเวลาจากต้นทาง" (ไม่ต้องทำตารางที่จุดกลางทาง) ต้องรู้ว่าจุดอยู่ กม. ที่เท่าไรของเส้น
การวัดทำใน Python ครั้งเดียว แล้วเก็บค่า km ไว้ในไฟล์ → หน้าเว็บไม่ต้องโหลด GIS เลย
การทำงาน:
1. อ่าน điểmจอดของแต่ละทิศใน schedules.json (เฉพาะที่มี station_id)
2. หาพิกัดจาก stations.json (จุดที่เป็น 'จุดขึ้นรถประจำทางอื่นๆ' → หาจาก 8 other_stop.json ตาม route_id)
3. วัด กม. จากต้นทางตามเส้น geojson-web/<route>.geojson (เลือกปลายที่ใกล้ "จุดที่มีเวลาอยู่แล้ว" ที่สุดเป็นต้นทาง)
4. เขียนฟิลด์ "km" กลับเข้า stop (ทับค่าเดิมถ้ามี) + รายงานจุดที่วัดไม่ได้
รัน: python resource/tools/stop-km.py # เขียนไฟล์
python resource/tools/stop-km.py --check # ดูผลก่อน ไม่เขียน
"""
import argparse
import json
import math
import re
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parents[2]
DATA = ROOT / "resource" / "data"
OFF_ROUTE_KM = 2.0 # ห่างจากเส้นเกินนี้ = แจ้ง (พิกัดอาจผิด)
def hav(a, b):
R = 6371.0
r = math.pi / 180
dlat = (b[1] - a[1]) * r
dlng = (b[0] - a[0]) * r
h = math.sin(dlat / 2) ** 2 + math.cos(a[1] * r) * math.cos(b[1] * r) * math.sin(dlng / 2) ** 2
return 2 * R * math.asin(math.sqrt(h))
def km_on_line(lines, p):
"""ระยะตามเส้นจากต้นเส้นถึงจุดที่ใกล้ p ที่สุด + ระยะห่างจากเส้น (กม.)"""
best = None
cum = 0.0
for line in lines:
for i in range(1, len(line)):
a, b = line[i - 1], line[i]
seg = hav(a, b)
lat0 = math.radians((a[1] + b[1]) / 2)
k = 111.32
ax, ay = a[0] * math.cos(lat0) * k, a[1] * k
bx, by = b[0] * math.cos(lat0) * k, b[1] * k
px, py = p[0] * math.cos(lat0) * k, p[1] * k
dx, dy = bx - ax, by - ay
L2 = dx * dx + dy * dy
t = 0.0 if not L2 else max(0.0, min(1.0, ((px - ax) * dx + (py - ay) * dy) / L2))
dist = math.hypot(px - (ax + t * dx), py - (ay + t * dy))
if best is None or dist < best[0]:
best = (dist, cum + t * seg)
cum += seg
return best if best else (None, 0.0)
def load_lines(rid):
p = DATA / "geojson-web" / f"{rid}.geojson"
if not p.exists():
return None
g = json.loads(p.read_text(encoding="utf-8"))
segs = []
for f in g.get("features", []):
cs = f["geometry"]["coordinates"]
segs += [cs] if f["geometry"]["type"] == "LineString" else cs
segs = [s for s in segs if s]
return segs or None
def same_digits(a, b):
na = re.sub(r"\D", "", str(a))
nb = re.sub(r"\D", "", str(b))
return bool(na) and len(na) == len(nb) and sorted(na) == sorted(nb)
def other_for(rid, others, valid_ids):
"""จุดของสายนี้ใน 8 other_stop.json (รองรับรหัสเพี้ยน เช่น 1101 = 1011)"""
want = str(rid)
hit = [o for o in others if str(o["route_id"]) == want]
if hit:
return hit
for o in others:
fid = str(o["route_id"])
if fid in valid_ids:
continue
cands = [v for v in valid_ids if same_digits(v, fid)]
if len(cands) == 1 and cands[0] == want:
return [o]
return []
def point_of(sid, stations, others_by_route, rid):
st = stations.get(sid)
if not st:
return None, None
lat, lng = st.get("latitude"), st.get("longitude")
if not isinstance(lat, (int, float)) or not isinstance(lng, (int, float)):
# 'จุดขึ้นรถประจำทางอื่นๆ' → เอาจุดจริงของสายนั้น
for o in others_by_route.get(str(rid), []):
la, lo = o.get("latitude"), o.get("longitude")
if isinstance(la, (int, float)) and isinstance(lo, (int, float)):
return (float(lo), float(la)), o.get("station_name_th")
return None, (st.get("station_name_th") or "")
return (float(lng), float(lat)), (st.get("station_name_th") or "")
def main():
ap = argparse.ArgumentParser(description="วัด กม. จากต้นทางของทุกจุดจอด แล้วเขียนลง schedules.json")
ap.add_argument("--check", action="store_true", help="ไม่เขียนไฟล์ แค่รายงาน")
args = ap.parse_args()
doc = json.loads((DATA / "schedules.json").read_text(encoding="utf-8"))
stations = {s["station_id"]: s for s in json.loads((DATA / "stations.json").read_text(encoding="utf-8"))["stations"]}
others = json.loads((DATA / "8 other_stop.json").read_text(encoding="utf-8"))["other_stop"]
valid_ids = [str(r["route_id"]) for r in json.loads((DATA / "routes.json").read_text(encoding="utf-8"))["routes"]]
others_by_route = {}
for r in doc.get("routes", []):
others_by_route[str(r["route_id"])] = other_for(r["route_id"], others, valid_ids)
by_route = others_by_route
measured = skipped = offroute = 0
report = []
out = {}
for r in doc.get("routes", []):
rid = str(r["route_id"])
lines = load_lines(rid)
if not lines:
report.append((rid, "(ไม่มีไฟล์ geojson)", None, "—"))
continue
for d in r.get("directions", []):
for s in d.get("stops", []):
pt, name = point_of(s["station_id"], stations, by_route, rid)
if pt is None:
skipped += 1
report.append((rid, name or f"station {s['station_id']}", None, "ไม่มีพิกัด → วัดไม่ได้"))
pass
continue
dist, km = km_on_line(lines, pt)
out.setdefault(rid, {})[str(s["station_id"])] = round(km, 2)
measured += 1
if dist is not None and dist > OFF_ROUTE_KM:
offroute += 1
report.append((rid, name or f"station {s['station_id']}", out[rid][str(s["station_id"])], f"ห่างจากเส้น {dist:.1f} กม. (พิกัดอาจผิด)"))
print(f"วัดระยะได้ {measured} จุด · วัดไม่ได้ {skipped} จุด · ห่างเส้นเกิน {OFF_ROUTE_KM} กม. {offroute} จุด")
if report:
print("\nจุดที่ต้องดู:")
for rid, name, km, why in report:
kms = "—" if km is None else f"{km:g} กม."
print(f" สาย {rid:<5} {name[:34]:<36} {kms:<10} {why}")
if args.check:
print("\n[--check] ไม่เขียนไฟล์")
return 0
# เขียนไฟล์แยก (เรียงคีย์ให้อ่านง่าย)
ordered = {rid: out[rid] for rid in sorted(out, key=lambda x: (len(x), x))}
text = json.dumps(ordered, ensure_ascii=False, indent=2).replace("\n", "\r\n") + "\r\n"
(DATA / "stop-km.json").write_text(text, encoding="utf-8", newline="")
# เก็บกวาด: ถ้า schedules.json ยังมีฟิลด์ km ค้างจากรุ่นก่อน ให้เอาออก (ไฟล์ผู้ใช้ต้องสะอาด)
if any("km" in s for r in doc.get("routes", []) for d in r.get("directions", []) for s in d.get("stops", [])):
for r in doc.get("routes", []):
for d in r.get("directions", []):
for st in d.get("stops", []):
st.pop("km", None)
clean = json.dumps(doc, ensure_ascii=False, indent=2).replace("\n", "\r\n") + "\r\n"
(DATA / "schedules.json").write_text(clean, encoding="utf-8", newline="")
print("\nเก็บกวาด: ลบฟิลด์ km ที่ค้างใน schedules.json แล้ว (ไฟล์ผู้ใช้สะอาด)")
print("\nเขียนไฟล์แล้ว: resource/data/stop-km.json")
return 0
if __name__ == "__main__":
sys.exit(main())