ตารางเวลาคำนวณได้ + หน้ารายละเอียดป้ายขับเคลื่อนด้วยข้อมูล + แผนที่ 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:
1 parent
88311326e6
commit
1cfaeb1526
91 files changed
+7560
-844
No files matched your search
@@ -98,6 +98,26 @@ python -m http.server 8090 # เปิด http://localhost:8090/ui/index.
|
||||
จะ render หน้าใหม่ให้อัตโนมัติ (ฟัง event `langchange`)
|
||||
- **ชื่อเฉพาะ (ชื่อสถานี/จังหวัด/สายรถ) ไม่ต้องแปล** — คงภาษาไทย
|
||||
|
||||
## ข้อมูลเส้นทางจาก GIS (QGIS → GeoJSON → แผนที่)
|
||||
|
||||
- **ห้ามแก้ `resource/data/geojson-web/*.geojson` ด้วยมือ** — เป็นไฟล์ที่ "สร้าง" จาก shapefile ใน
|
||||
`resource/data/QGIS Project/*.shp` (ตารางจับคู่ `SHP_MAP` อยู่ในสคริปต์) — user แก้ใน QGIS แล้วกด Save
|
||||
- แปลง/อัปเดตด้วยคำสั่งเดียว (ไม่ใช่ build step ของเว็บ — รันมือเมื่อข้อมูลเส้นเปลี่ยน):
|
||||
```bash
|
||||
python resource/tools/qgis-to-web.py --check # ตรวจก่อน (ไม่เขียนไฟล์) — "เหมือนเดิม ✓" = ไม่มีอะไรเปลี่ยน
|
||||
python resource/tools/qgis-to-web.py # เขียนจริง (--from geojson = ทางเดิมผ่าน GeoJSON-2/)
|
||||
python resource/tools/qgis-to-web.py --list # ดูตารางรหัสสาย ↔ ไฟล์ .shp
|
||||
```
|
||||
- สคริปต์จะ**ปฏิเสธ**ไฟล์ที่ CRS ไม่ใช่ WGS84 (พิกัดเป็น UTM) และตัดจุดที่หลุดกรอบประเทศไทย
|
||||
- **ตรวจสุขภาพข้อมูลก่อนใช้**: `python resource/tools/audit-geojson.py` (CRS · พิกัดว่าง/ซ้ำ ·
|
||||
ช่วงเส้นตัดตรง · ปลายเส้นตรงจุดจอดไหม · ไฟล์ซ้ำ/ไม่ถูกใช้)
|
||||
- กติกา + ตารางเลเยอร์↔รหัสสาย + วิธี export: `resource/data/QGIS Project/GeoJSON-2/README.md`
|
||||
- แผนที่ใช้ Leaflet (vendor ใน `ui/vendor/leaflet/`) — **ห้ามให้ CSS ภายนอกกำหนด width/height ของ
|
||||
`svg.leaflet-zoom-animated`** (จะถูกยุบเป็น 0×0 แล้ว "เส้นทางไม่แสดง" — มี guard ใน `ui/map.css` แล้ว)
|
||||
- ตรวจว่าเส้นทางแสดงจริง ต้องวัด `getBoundingClientRect()` เทียบกับกล่องแผนที่ — นับ `<path>` ใน DOM ไม่พอ
|
||||
|
||||
> 📌 กติกาจุดขึ้นรถประจำทางอื่นๆ (`8 other_stop.json`): ดู **`resource/data/8 other_stop.md`** — ระบุสายที่ **ห้ามเพิ่ม** entry และรายการที่ห้ามลบ
|
||||
|
||||
## ลำดับการอ่านไฟล์เมื่อเริ่มงาน
|
||||
|
||||
1. `AGENTS.md` (ไฟล์นี้) → `DESIGN.md` (ถ้าแตะ UI)
|
||||
@@ -109,3 +129,178 @@ python -m http.server 8090 # เปิด http://localhost:8090/ui/index.
|
||||
- commit ล่าสุดเน้น: sponsor marquee (เลื่อนสปอนเซอร์), ลบไฟล์ backup HTML
|
||||
- `.gitignore` ว่างเปล่า — ถ้าเพิ่มไฟล์ขยะ (เช่น .DS_Store) ให้เพิ่มใน .gitignore
|
||||
- งานถัดไปที่คาดว่าเกี่ยวข้อง: นำดีไซน์นี้ไป implement ใน `web-at-transit` (Next.js)
|
||||
|
||||
## หน้ารายละเอียดป้าย `#/stops/<รหัสป้าย>` — ข้อมูลมาจากไหน
|
||||
|
||||
หน้า `ui/partials/stopDetail.html` เป็น "โครงเปล่า" ล้วน ๆ (มีแต่ `<style>` + element ที่มี id)
|
||||
ข้อมูลทั้งหมดเรนเดอร์โดย `ui/partials/stopDetail.init.js` จาก JSON — **ห้ามฝังข้อมูลป้ายลง HTML**
|
||||
|
||||
| ส่วนบนหน้า | มาจาก |
|
||||
|---|---|
|
||||
| ชื่อป้าย · ประเภท · รหัส · จังหวัด | `resource/data/stations.json` (`station_name_th`, `station_type`, `station_code`, `city_th`, `province_th`) |
|
||||
| สายรถที่ผ่านป้ายนี้ + เวลารถ | `routes.json` (`station_ids`) × `schedules.json` (schema 2 ผ่านตัวอ่านกลาง `ui/partials/schedules.js`) |
|
||||
| จำนวนสาย · เที่ยวต่อวัน · เวลาบริการ (เปิด–ปิด) · เที่ยวถัดไป | **คำนวณอัตโนมัติ** จากข้อมูลข้างบน (ไม่ต้องกรอก) |
|
||||
| แผนที่ | `ui/map.js` (`ATMap.forStop`) วาดจาก `geojson-web/*.geojson` |
|
||||
| รูปป้าย | หาเองจาก `busstop_list.json` (ป้ายใกล้สุดภายใน 3 กม. → `.image/stops/<หลัก กม.>.jpg`) หรือกำหนดเอง |
|
||||
|
||||
**ฟิลด์เสริม (ไม่ใส่ก็ได้ — ถ้าไม่ใส่ ส่วนนั้นจะซ่อนเอง) ใส่ใน `stations.json` ของป้ายนั้น:**
|
||||
|
||||
```json
|
||||
{ "station_id": 1, "station_code": "at_main_terminal",
|
||||
"photo": "../.image/stops/54950.jpg",
|
||||
"description": "ข้อความแนะนำป้าย (แทนประโยคอัตโนมัติ)",
|
||||
"facilities": ["ห้องน้ำ", "ที่พักคอย", "ร้านอาหาร"],
|
||||
"landmarks": [ { "img": "../.image/landmarks/temple.png", "caption": "วัดสำคัญ", "sub": "เดิน 5 นาที" } ],
|
||||
"landmarks_note": "คำโปรยใต้หัวข้อใกล้เคียงป้าย" }
|
||||
```
|
||||
|
||||
URL ที่ใช้ได้: `#/stops/<station_code>` และ `#/stops/<station_code>?route=<รหัสสาย>` (กรองเฉพาะสายนั้น)
|
||||
|
||||
## ตารางเดินรถแยก "วันทำงาน / วันหยุด" (ดีไซน์ที่ไม่ต้องแก้โค้ดหน้าไหน)
|
||||
|
||||
**หลักคิด:** ใส่ตรรกะไว้ที่ตัวอ่านกลาง `ui/partials/schedules.js` ที่เดียว → หน้า check/busDetail/home/stopDetail
|
||||
เรียก API เดิม (`Schedules.records/route/directions/times/countTrips`) แล้วได้ข้อมูลของ "วันนี้" ให้เอง
|
||||
|
||||
**เพิ่มฟิลด์ไม่บังคับ 2 ระดับ (ไม่ใส่ = พฤติกรรมเดิมทุกอย่าง):**
|
||||
|
||||
| ระดับ | ฟิลด์ | ความหมาย |
|
||||
|---|---|---|
|
||||
| ทิศทาง | `"service": "weekday" \| "holiday"` | ทั้งทิศทางใช้เฉพาะวันนั้น (ไม่ใส่/`"all"` = ทุกวัน) |
|
||||
| จุดจอด | `"groups": [ { "label": "วันหยุด", "dayType": "holiday", "times": ["10:00"] } ]` | เวลาที่เพิ่มเฉพาะบางวัน — `times[]` ยังเป็นตารางพื้นฐานทุกวัน |
|
||||
|
||||
**การตรวจจับวัน:** เสาร์–อาทิตย์ = วันหยุด · นักขัตฤกษ์อ่านจาก `resource/data/holidays.json` (เจ้าของข้อมูลต้องกรอกเอง — **ห้ามเดา**)
|
||||
**ความปลอดภัย:** ถ้ากรองแล้วไม่มีทิศเหลือ → ถอยไปใช้ทั้งหมด + ติดธง `fallback` (หน้าเว็บไม่มีทางว่างเปล่า) + เครื่องมือแก้ไขเตือนไว้
|
||||
**GUI:** `resource/data/schedules-editor.html` มีช่อง "ใช้กับวัน" ต่อทิศ + ตรวจจับคำในหมายเหตุ (วันทำงาน/วันหยุด) แล้วเสนอให้ตั้งค่า
|
||||
**หน้าเว็บ:** หน้า `#/check` จะขึ้น "ตารางวันทำงาน (จ–ศ)" / "ตารางวันหยุด" ต่อท้ายคำอธิบาย **เฉพาะสายที่มีการแยกตารางตามวัน**
|
||||
|
||||
## จุดกลางทาง "ไม่ต้องทำตาราง" — คำนวณจากต้นทาง (autoTimes)
|
||||
|
||||
**หลักคิด:** 1 ทิศ มีจุดที่กรอกเวลาจริง (ต้นทาง/จุดอ้างอิง) ส่วนจุดอื่นปล่อยว่างได้ → ระบบคำนวณให้จาก
|
||||
`เวลา + (ผลต่าง กม. ÷ ความเร็ว)` แล้วทำเครื่องหมายว่าเป็น **ค่าประมาณ** (ไม่ใช่ตารางผู้ประกอบการ)
|
||||
|
||||
**ต้องมีอะไรบ้าง**
|
||||
1. พิกัดของจุดนั้นใน `stations.json` (ถ้าเป็น 'จุดขึ้นรถประจำทางอื่นๆ' → ใช้พิกัดจาก `8 other_stop.json`)
|
||||
2. ค่า `km` ของจุดใน `schedules.json` — วัดด้วย `python resource/tools/stop-km.py` (วัดตามเส้นจริงใน `geojson-web/`)
|
||||
3. ตั้ง `"autoTimes": true` ที่ทิศนั้น (และ `"speedKmh": 40` ถ้าต้องการความเร็วอื่น) — **ตั้งได้จาก GUI ช่อง "คำนวณจากต้นทาง"**
|
||||
|
||||
**กติกาในท่อกลาง (`ui/partials/schedules.js`)**
|
||||
- จุดที่มี `times[]` จริง → ใช้ของจริงเสมอ (ไม่คำนวณทับ)
|
||||
- จุดที่ว่าง → หาจุดที่มีเวลาซึ่งอยู่ใกล้ที่สุด (ตาม กม.) แล้วบวก/ลบเวลาตามระยะ
|
||||
- ไม่มี `km` หรือไม่มีจุดอ้างอิง → ถอยไปแสดง "ยังไม่มีข้อมูล" เหมือนเดิม (ไม่พัง)
|
||||
- หน้าเว็บแสดงเวลาที่คำนวณด้วย **กรอบเส้นประ + ข้อความ "~ เวลาคำนวณจากต้นทาง (ประมาณ)"** เสมอ
|
||||
|
||||
**อย่าลืม:** ถ้าแก้พิกัด/เส้นทางใหม่ ให้รัน `stop-km.py` ซ้ำ (ค่า กม. จะเปลี่ยน)
|
||||
|
||||
## เครื่องมือแก้ schedules.json — กติกา UX (resource/data/schedules-editor.html)
|
||||
|
||||
1. **ตัวเลือกจุดจอด คัดจาก `station_order` ของสายนั้น** (ไม่ใช่สถานีทั้งจังหวัด)
|
||||
- ถ้าเป็น `station_id 8` = "จุดขึ้นรถประจำทางอื่นๆ" → แสดง**ชื่อจุดจริงของสายนั้นจาก `8 other_stop.json`**
|
||||
(รองรับรหัสเพี้ยนสลับหลัก เช่น `1101` = สาย `1011` แบบเดียวกับ `ui/partials/otherStop.js`)
|
||||
- จุดที่อยู่นอก `station_order` ยังคงแสดงได้ (ไม่หาย) + บอกให้เห็นว่าอยู่นอกลำดับ
|
||||
2. **"สร้างตารางเวลาอัตโนมัติ" เป็นการ์ดแยก** ต่อทิศ (ไม่อยู่ในหัวการ์ดทิศ)
|
||||
- ขั้น 1 เลือก **จุดอ้างอิง** จาก dropdown ที่แสดงเฉพาะจุดในทิศนั้น**ที่มีตารางเวลาอยู่แล้ว** (พร้อมจำนวนเที่ยว) → เก็บเป็น `"baseSid"`
|
||||
- ขั้น 2 ใส่ **เวลาเดินทางโดยประมาณ (นาที)** → เก็บเป็น `"travelMin"` (ระบบคำนวณความเร็วให้เอง)
|
||||
- ขั้น 3 เลือก **จุดเป้าหมาย** จาก `station_order` ของสายนั้น (บอกสถานะ: มีตารางแล้ว / ว่างอยู่ / ยังไม่มีในทิศนี้ → จะเพิ่มจุดให้) → เก็บเป็น `"autoFor": [station_id]`
|
||||
· ถ้าไม่เลือก = ทุกจุดที่ว่าง · ถ้าจุดเป้าหมายยังไม่มีเป็นจุดในทิศนั้น ระบบจะ **เพิ่มจุดให้อัตโนมัติ** ตอนกดใช้ตาราง
|
||||
- ขั้น 4 กด **คำนวณตาราง** → พรีวิว (แถวเป้าหมายมี 🎯) → เลือก "ใช้ตารางนี้ (คำนวณอัตโนมัติ)" หรือ "เติมเวลาลงข้อมูลจริง"
|
||||
· "เติมเวลาลงข้อมูลจริง" จะเติม **เฉพาะจุดเป้าหมาย** ถ้าเลือกไว้ (ไม่ทับจุดอื่น)
|
||||
- ค่าที่พิมพ์ในแผงเป็นการชั่วคราว (ไม่แตะไฟล์จนกว่าจะกดปุ่ม) · เปิด/ปิดพรีวิวไม่ทำให้ไฟล์ "ยังไม่บันทึก"
|
||||
3. **ค่าที่คำนวณไม่เคยถูกเขียนลง `schedules.json`** — `km` อยู่ใน `resource/data/stop-km.json` (generated)
|
||||
4. ตัวอ่านกลาง `ui/partials/schedules.js` รองรับ `baseSid` (จุดอ้างอิง) → `baseEnd` → อัตโนมัติ ตามลำดับความสำคัญ
|
||||
และ `autoFor` จำกัดว่าคำนวณเฉพาะจุดใด (ไม่ใส่ = ทุกจุดที่ว่าง)
|
||||
|
||||
## เครื่องยนต์ตรวจวัน (จันทร์–อาทิตย์) — อยู่ที่ท่อกลางที่เดียว
|
||||
|
||||
อยู่ที่ `ui/partials/schedules.js` เท่านั้น → หน้า check/busDetail/home/stopDetail ได้ผลเหมือนกัน **ไม่ต้องแก้โค้ดหน้าไหน**
|
||||
|
||||
**ลำดับการตัดสิน (แม่น → หลวม):**
|
||||
1. `"days": ["sat","sun"]` ระบุตรง ๆ → ใช้ตามนั้น
|
||||
2. `"service": "weekday" | "holiday" | "all"` → เทียบกับวันนี้
|
||||
3. ไม่ระบุ → **ตรวจคำอัตโนมัติ** จาก `dir_label` + `dir_note`/`note` ของทุกจุดในทิศนั้น
|
||||
(เจอ "วันหยุด/นักขัตฤกษ์/ส-อา/weekend" = วันหยุด · "วันทำงาน/จ-ศ/ธรรมดา/workday" = วันทำงาน **ไม่เดาถ้าเจอทั้งคู่**)
|
||||
4. ตัดสินไม่ได้ → **แสดงทุกวัน** (ไม่ซ่อนข้อมูล) + ป้าย "ยังไม่ระบุวันของตาราง"
|
||||
|
||||
**วันหยุด = เสาร์–อาทิตย์ + นักขัตฤกษ์** จาก `resource/data/holidays.json` (เจ้าของข้อมูลกรอกเอง ห้ามเดา)
|
||||
|
||||
**API ที่เพิ่ม:** `Schedules.dayInfo(date)` → `{dayType, weekday, weekday_th, date}` · `Schedules.dayKey(date)` → `'mon'…'sun'`
|
||||
· `Schedules.detectDay(text)` · `Schedules.detectDayOfDir(dir)` · `Schedules.serviceOf(dir|null, dir)` → `{day, from, matches, conflict?, unknown?}`
|
||||
**การป้องกันข้อมูลหาย:** ถ้ากรองตามวันแล้วไม่มีทิศเหลือ → ถอยไปแสดงทั้งหมด + ติดธง `fallback`
|
||||
|
||||
## รูปภาพ — นามสกุลที่รองรับ (.jpg / .jpeg / .webp / .png)
|
||||
|
||||
**ทุกรูปในเว็บไล่ลองนามสกุลอัตโนมัติ** — ใส่ไฟล์นามสกุลไหนก็ได้ ไม่ต้องแก้โค้ด
|
||||
|
||||
| ลำดับ | นามสกุล |
|
||||
|---|---|
|
||||
| 1 | `.jpg` |
|
||||
| 2 | `.jpeg` |
|
||||
| 3 | `.webp` |
|
||||
| 4 | `.png` |
|
||||
|
||||
**ที่ใช้:**
|
||||
- รูปสถานี `.image/stations/<station_id>.<ext>` (รูปเสริม `<station_id>-2.<ext>`) — `PHOTO_EXTS` ใน `stopDetail.init.js`
|
||||
- รูปป้ายริมทาง `.image/stops/<pad5 กม.>.<ext>` + รูปสถานีบนการ์ด `#/stops` — `IMG_EXTS` + `firstExisting()` ใน `busStop.init.js`
|
||||
- รูปรถ `.image/routes/<รหัส>/car|boat.<ext>` · QR `.image/qrcode/<รหัส>.<ext>` — `CAR_EXTS`/`QR_EXTS` ใน `busDetail.init.js` (ทำมาก่อนแล้ว)
|
||||
|
||||
**กติกา:** เลือกนามสกุลแรกที่มีไฟล์จริง (ตรวจ HEAD ก่อนแสดง) · **ไม่มีไฟล์เลย → ไม่แสดงช่องว่าง** ในหน้าเว็บ (ไม่เหลือ `<img>` พาธลอย) · SW จัดการรูปทุกนามสกุลแบบ cache-first เหมือนกัน
|
||||
|
||||
**หมายเหตุ:** ถ้ามีทั้ง `.jpg` และ `.jpeg` ในชื่อเดียวกัน → **`.jpg` ชนะ** (รักษาพฤติกรรมเดิม)
|
||||
|
||||
## หัวแถวทิศในหน้า `#/check` — ใช้ `dir_label` ก่อน
|
||||
|
||||
การ์ดในหน้า check จัดกลุ่ม **ตามจุดจอด** (จุดเดียวกันที่มีหลายทิศ = การ์ดเดียว หลายแถว)
|
||||
หัวแถวจึงต้องใช้ **`dir_label`** (ชื่อทิศ เช่น `ป่าโมกไปอ่างทอง` / `ป่าโมกไปอยุธยา`) ไม่ใช่คำกลางว่า "ทิศทาง"
|
||||
|
||||
ลำดับที่ใช้แสดง: `dir_label` → `dir_note` (พร้อมป้าย "ทิศทาง") → "ที่จุด X"
|
||||
`records()` ส่งออกทั้ง `dir_label` และ `direction_note` — หน้าที่อื่นเรียกใช้ได้
|
||||
|
||||
## ชิปสาย (`buses-line`) ในหน้า `#/stops` → `#/routes/<รหัส>`
|
||||
|
||||
ชิป "สาย N" บนการ์ดป้าย **ลิงก์ไปหน้ารายละเอียดสาย** `#/routes/<รหัส>` (ไม่ใช่ `#/check`)
|
||||
- สายที่ไม่มีใน `routes.json` → คงเป็น `<span>` (ไม่ทำลิงก์) กันลิงก์ตาย
|
||||
- ข้อความปุ่ม: `stops.viewRoute` = "ดูรายละเอียดสาย {n}" / "View route {n}"
|
||||
- (หน้า `#/stops/<slug>` ปุ่ม "ดูตารางเวลาสาย N" ยังใช้ `#/check/<รหัส>` ตามเดิม — คนละบริบท)
|
||||
|
||||
## ลิงก์ติดต่อผู้ประกอบการ (หน้ารายละเอียดสาย `#/routes/<id>`)
|
||||
|
||||
ใช้ฟิลด์ **`web_url`** ใน `routes.json` (มีอยู่เดิม) — ไม่ต้องแก้โค้ดเวลาเพิ่ม/เปลี่ยนลิงก์
|
||||
|
||||
- **ไอคอน + ชื่อ + สี เปลี่ยนตามชนิด URL อัตโนมัติ** (`linkKind()` ใน `busDetail.init.js`):
|
||||
| ตรวจพบ | ไอคอน | โทนสี | ชื่อที่แสดง |
|
||||
|---|---|---|---|
|
||||
| `facebook.com` / `fb.me` | `ic-facebook` | `tone-sky` (ฟ้า) | Facebook |
|
||||
| `line.me` / `lin.ee` / `linevoom` | `ic-message-circle` | `tone-green` | LINE Official |
|
||||
| `http(s)://` อื่น ๆ | `ic-globe` | `tone-purple` | เว็บไซต์ |
|
||||
|
||||
- **ปุ่ม "เปิดลิงก์" แยกต่างหาก** (`route.openLink` + `route.link.*` ใน i18n) เปิดแท็บใหม่ `target="_blank" rel="noopener"` · โชว์ URL แบบสั้น (ตัด `https://`)
|
||||
- **QR** ตั้งชื่อตามรหัสสาย: `.image/qrcode/<route_id>.<png|JPG|jpeg|webp>` (ไล่ลองนามสกุล) หรือระบุเองที่ `caption<id>.json → qr_image`
|
||||
- **ไม่มี `web_url`** → แสดงเฉพาะแถว LINE+QR เหมือนเดิม (ไม่พัง)
|
||||
|
||||
## กฎ "จุดนี้ = เวลาจุดอ้างอิง ± n นาที" (`derive`) — แนวทาง A
|
||||
|
||||
**ปัญหาเดิม:** จุดระหว่างทางที่ไม่มีตารางของตัวเอง มักถูก "คัดลอกเวลา" จากจุดอื่นมา → เวลาผิด (เช่น 902 จุด 15
|
||||
คัดลอกจากจุด 6 ทั้ง 25 เที่ยว ทั้งที่รถวิ่งต่ออีก 30 นาที)
|
||||
|
||||
**วิธีแก้:** เขียนกฎครั้งเดียวต่อจุด **ในไฟล์สายของตัวเอง** แล้วให้เว็บคำนวณเสมอ (ไม่เก็บเวลาซ้ำ)
|
||||
|
||||
```json
|
||||
/* resource/data/scheduleslist/schedules902.json */
|
||||
{ "station_id": 15,
|
||||
"times": [],
|
||||
"derive": { "from_station_id": 6, "offset_min": 30, "note": "รอรถที่ 7-11 หน้ากินซ่า" } }
|
||||
```
|
||||
- `from_station_id` อ้างจุดได้ **ข้ามทิศ** (ใน 902 จุด 6 อยู่ทิศ `all` แต่จุด 15 อยู่ทิศ `rungsit`) ✓
|
||||
- `offset_min` เป็นบวก (หลังจุดอ้างอิง) หรือลบ (ก่อนหน้า) · เกินเที่ยงคืน = วนกลับแบบ mod 24
|
||||
- **กฎชนะเวลาที่เขียนไว้** (`times`) — และเครื่องมือจะลบ `times` ที่ซ้ำให้อัตโนมัติ
|
||||
|
||||
**เว็บแสดงผลอัตโนมัติ:** ชิปเส้นประ + ตัวเอียง (`is-est`) + ข้อความ
|
||||
`time.derived` = *"~ ตารางจากการคำนวณ (จาก {base} {n} นาที) — อาจเปลี่ยนแปลงตามการจราจรจริง"*
|
||||
({base} = ชื่อจุดอ้างอิง ดึงจาก `stations.json` · ถ้ายังโหลดชื่อไม่ทันใช้ `#<id>` แทน)
|
||||
|
||||
**เครื่องมือ:** `resource/tools/derive-times.py` + ตาราง `resource/data/derive-times.csv`
|
||||
```
|
||||
route_id,station_id,from_station_id,offset_min,note
|
||||
902,15,6,30,รอรถที่ 7-11 หน้ากินซ่า
|
||||
```
|
||||
- `--check` ดูก่อน · รันเปล่า = เขียนจริง · `--audit` = ตรวจว่าไฟล์ตรงตาราง + **ชี้จุดที่เวลาซ้ำแต่ยังไม่มีกฎ** ✓
|
||||
- รันซ้ำได้ (idempotent) · จุดอ้างอิงต้องมีเวลาจริง · เขียนไฟล์คง CRLF เดิม
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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.
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.
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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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":
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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": "ยังไม่มีข้อมูลตารางเวลา"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -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 @@
|
||||
{"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 @@
|
||||
{"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 @@
|
||||
{"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 @@
|
||||
{"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 @@
|
||||
{"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 @@
|
||||
{"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 @@
|
||||
{"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 @@
|
||||
{"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 @@
|
||||
{"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 @@
|
||||
{"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]]]}}]}
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"_note": "วันหยุดนักขัตฤกษ์ (ใช้ร่วมกับเสาร์-อาทิตย์ เพื่อเลือกตาราง 'วันหยุด'). เดือน/วัน รูปแบบ YYYY-MM-DD",
|
||||
"_source": "ยังไม่ได้กรอก — เจ้าของข้อมูลต้องยืนยันกับประกาศของทางราชการก่อน (อย่าเดาเอง)",
|
||||
"holidays": []
|
||||
}
|
||||
@@ -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
@@ -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
@@ -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
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -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.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -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())
|
||||
@@ -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())
|
||||
@@ -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())
|
||||
@@ -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()
|
||||
@@ -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())
|
||||
@@ -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())
|
||||
@@ -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())
|
||||
+80
-12
@@ -77,6 +77,7 @@
|
||||
'map.openInMaps': 'เปิดใน Google Maps',
|
||||
'map.viewStopPage': 'ดูรายละเอียดป้ายนี้',
|
||||
'map.km': 'กม.',
|
||||
'map.offRoute': 'นอกเส้นทาง',
|
||||
'map.alongRoute': 'จุดจอดตามเส้นทาง (กม. จากต้นทาง)',
|
||||
'map.useMyLocation': 'ป้ายใกล้ฉัน',
|
||||
'map.locating': 'กำลังหาตำแหน่งของคุณ…',
|
||||
@@ -100,7 +101,6 @@
|
||||
'home.lead': 'ดูสายรถ, ค้นหาป้าย และเปิดตัวอย่างเส้นทางได้ทันทีจากหน้าแรก',
|
||||
'home.chooseProvince': 'เลือกจังหวัด',
|
||||
'home.chooseStation': 'เลือกสถานีขนส่งผู้โดยสาร',
|
||||
'home.allStations': 'ทุกสถานีในจังหวัดนี้',
|
||||
'share.label': 'แชร์ลิงก์สั้น',
|
||||
'share.copied': 'คัดลอกลิงก์แล้ว',
|
||||
'share.short': 'ลิงก์สั้น',
|
||||
@@ -139,6 +139,8 @@
|
||||
'stops.unitRoutes': 'สายทางหลวง',
|
||||
'stops.highway': 'ทางหลวง',
|
||||
'stops.busPrefix': 'สาย',
|
||||
'stops.viewSchedule': 'ดูตารางเวลาสาย {n}',
|
||||
'stops.viewRoute': 'ดูรายละเอียดสาย {n}',
|
||||
'stops.noBusLine': 'ยังไม่ระบุสายรถ',
|
||||
'stops.modeCode': 'ค้นหาด้วยรหัสป้าย',
|
||||
'stops.modePlace': 'ค้นหาด้วยชื่อสถานที่',
|
||||
@@ -152,6 +154,7 @@
|
||||
'stops.reset': 'ล้างค่า',
|
||||
'stops.section': 'ตอน',
|
||||
'stops.showing': 'แสดง {a} จาก {b} ป้าย',
|
||||
'stops.showAll': 'แสดงป้ายทั้งหมด',
|
||||
'stops.noResult': 'ไม่พบป้ายหยุดรถที่ตรงกับเงื่อนไข',
|
||||
'stops.loading': 'กำลังโหลดข้อมูลป้าย…',
|
||||
'type.terminal': 'สถานีขนส่งผู้โดยสาร',
|
||||
@@ -168,6 +171,10 @@
|
||||
'route.overview': 'ภาพรวมของสาย',
|
||||
'route.contact': 'ติดต่อผู้ประกอบการ',
|
||||
'route.call': 'โทรสอบถาม',
|
||||
'route.openLink': 'เปิดลิงก์',
|
||||
'route.link.facebook': 'Facebook',
|
||||
'route.link.line': 'LINE Official',
|
||||
'route.link.www': 'เว็บไซต์',
|
||||
'route.vehicle': 'รถบัสประจำสาย',
|
||||
'route.mapTitle': 'เส้นทางเดินรถ',
|
||||
'route.photos': 'รูปรถประจำเส้นทางในเครือข่าย',
|
||||
@@ -192,6 +199,31 @@
|
||||
'stop.showing': 'แสดง {a} จาก {b} สาย',
|
||||
'stop.mapInfo': 'แผนที่และข้อมูลป้าย',
|
||||
'stop.nextArrival': 'เที่ยวถัดไป',
|
||||
'stop.subGeneric': 'จุดจอดใน{city} · ดูเวลารถทุกสายที่ผ่านป้ายนี้ได้ในหน้าเดียว',
|
||||
'stop.thisStop': 'ป้ายนี้',
|
||||
'stop.statRoutes': 'จำนวนสายรถ',
|
||||
'stop.statTrips': 'เที่ยวต่อวัน',
|
||||
'stop.statHours': 'เวลาบริการ',
|
||||
'stop.statType': 'ประเภท',
|
||||
'stop.nRoutes': '{n} สาย',
|
||||
'stop.tripsPerDay': '{n} รอบ/วัน',
|
||||
'stop.tripsPerDay1': '{n} รอบ/วัน',
|
||||
'stop.nRoutes1': '{n} สาย',
|
||||
'stop.noRoutes': 'ยังไม่มีสายรถที่บันทึกว่าผ่านป้ายนี้',
|
||||
'stop.noTimes': 'ยังไม่มีข้อมูลเวลาเดินรถที่ป้ายนี้',
|
||||
'stop.tomorrow': 'พรุ่งนี้',
|
||||
'stop.nextAt': 'ถัดไป',
|
||||
'stop.notFound': 'ไม่พบป้ายนี้',
|
||||
'stop.notFoundSub': 'ไม่พบรหัสป้าย “{code}” ในระบบ — ตรวจรหัสหรือกลับไปหน้ารายการป้าย',
|
||||
'stop.nearbySub': 'สถานที่น่าสนใจและจุดแวะระหว่างรอรถ',
|
||||
'stop.otherStopsTitle': 'จุดขึ้นรถประจำทางอื่นๆ · สาย {n} ({m} จุด)',
|
||||
'stop.otherMore': '(+{n} จุด)',
|
||||
'stop.otherStopsAll': 'จุดขึ้นรถประจำทางอื่นๆ ทั้งหมด ({m} จุด)',
|
||||
'stop.noCoord': 'ยังไม่มีพิกัด',
|
||||
'stop.open': 'เปิด',
|
||||
'stop.close': 'ปิด',
|
||||
'stop.nowAtStop': 'เวลาปัจจุบัน ณ ป้ายนี้',
|
||||
'stop.autoNext': 'กำลังคำนวณเที่ยวถัดไปอัตโนมัติ',
|
||||
|
||||
// ทั่วไป
|
||||
'common.backHome': '← กลับหน้าแรก',
|
||||
@@ -216,11 +248,6 @@
|
||||
'credits.icons': 'ไอคอน — Lucide',
|
||||
'credits.fonts': 'ฟอนต์ — Google Fonts',
|
||||
'credits.map': 'แผนที่',
|
||||
'credits.images': 'รูปภาพประกอบ',
|
||||
'credits.logos': 'โลโก้ผู้สนับสนุนและพาร์ทเนอร์',
|
||||
'credits.data': 'ข้อมูลการเดินรถ',
|
||||
'credits.pwa': 'โหมดออฟไลน์ (PWA / Service Worker)',
|
||||
'credits.notes': 'หมายเหตุ',
|
||||
'common.back': 'ย้อนกลับ',
|
||||
'check.scheduleAll': 'ตารางเวลาเดินรถทุกจุดจอด',
|
||||
'check.title': 'ตารางเวลาเดินรถ',
|
||||
@@ -231,6 +258,20 @@
|
||||
'check.kpiNext': 'รอบถัดไป',
|
||||
'check.direction': 'ทิศทาง',
|
||||
'check.atStop': 'ตารางเดินรถ ณ',
|
||||
'check.dayWeekday': 'Weekday timetable (Mon–Fri)',
|
||||
'check.dayHoliday': 'Weekend/holiday timetable',
|
||||
'check.dayMixed': 'This direction mixes weekday and holiday times — not split by day yet',
|
||||
'check.dayUnknown': 'Timetable day not specified (showing all days)',
|
||||
'check.dayOfWeek': 'today is',
|
||||
'time.estimated': '~ Estimated from the origin (not an operator timetable)',
|
||||
'time.derived': '~ ตารางจากการคำนวณ (จาก {base} {n} นาที) — อาจเปลี่ยนแปลงตามการจราจรจริง',
|
||||
'check.dayWeekday': 'ตารางวันทำงาน (จ–ศ)',
|
||||
'check.dayHoliday': 'ตารางวันหยุด (ส–อา/นักขัตฤกษ์)',
|
||||
'check.dayMixed': 'ทิศนี้มีทั้งตารางวันทำงานและวันหยุดในตัวเดียวกัน — ยังไม่แยกตามวัน',
|
||||
'check.dayUnknown': 'ยังไม่ระบุวันของตาราง (แสดงทุกวัน)',
|
||||
'check.dayOfWeek': 'วันนี้',
|
||||
'time.estimated': '~ เวลาคำนวณจากต้นทาง (ประมาณ — ไม่ใช่ตารางของผู้ประกอบการ)',
|
||||
'time.derived': '~ Computed timetable (from {base} {n} min) — may change with real traffic conditions',
|
||||
'check.now': 'เวลาปัจจุบัน',
|
||||
'check.nextAt': 'เที่ยวถัดไป',
|
||||
'check.noMoreToday': 'ไม่มีรถเหลือในวันนี้แล้ว',
|
||||
@@ -298,6 +339,7 @@
|
||||
'map.openInMaps': 'Open in Google Maps',
|
||||
'map.viewStopPage': 'View this stop',
|
||||
'map.km': 'km',
|
||||
'map.offRoute': 'off route',
|
||||
'map.alongRoute': 'Stops along the route (km from origin)',
|
||||
'map.useMyLocation': 'Stops near me',
|
||||
'map.locating': 'Finding your location…',
|
||||
@@ -320,7 +362,6 @@
|
||||
'home.lead': 'Browse routes, find stops, and preview a route right from this page',
|
||||
'home.chooseProvince': 'Select Province',
|
||||
'home.chooseStation': 'Select Terminal',
|
||||
'home.allStations': 'All terminals in this province',
|
||||
'share.label': 'Share short link',
|
||||
'share.copied': 'Link copied',
|
||||
'share.short': 'Short link',
|
||||
@@ -358,6 +399,8 @@
|
||||
'stops.unitRoutes': 'highways',
|
||||
'stops.highway': 'Highway',
|
||||
'stops.busPrefix': 'Route',
|
||||
'stops.viewSchedule': 'View schedule for route {n}',
|
||||
'stops.viewRoute': 'View route {n}',
|
||||
'stops.noBusLine': 'No bus line listed',
|
||||
'stops.modeCode': 'Search by stop code',
|
||||
'stops.modePlace': 'Search by place name',
|
||||
@@ -371,6 +414,7 @@
|
||||
'stops.reset': 'Clear',
|
||||
'stops.section': 'Section',
|
||||
'stops.showing': 'Showing {a} of {b} stops',
|
||||
'stops.showAll': 'Show all stops',
|
||||
'stops.noResult': 'No stops match your search',
|
||||
'stops.loading': 'Loading stop data…',
|
||||
'type.terminal': 'Passenger terminal',
|
||||
@@ -386,6 +430,10 @@
|
||||
'route.overview': 'Route overview',
|
||||
'route.contact': 'Contact operator',
|
||||
'route.call': 'Call us',
|
||||
'route.openLink': 'Open link',
|
||||
'route.link.facebook': 'Facebook',
|
||||
'route.link.line': 'LINE Official',
|
||||
'route.link.www': 'Website',
|
||||
'route.vehicle': 'Route vehicle',
|
||||
'route.mapTitle': 'Route map',
|
||||
'route.photos': 'Buses on this network',
|
||||
@@ -409,6 +457,31 @@
|
||||
'stop.showing': 'Showing {a} of {b} routes',
|
||||
'stop.mapInfo': 'Map & stop info',
|
||||
'stop.nextArrival': 'Next arrival',
|
||||
'stop.subGeneric': 'A stop in {city} · see every route that passes here on one page',
|
||||
'stop.thisStop': 'this stop',
|
||||
'stop.statRoutes': 'Routes',
|
||||
'stop.statTrips': 'Departures/day',
|
||||
'stop.statHours': 'Service hours',
|
||||
'stop.statType': 'Type',
|
||||
'stop.nRoutes': '{n} routes',
|
||||
'stop.tripsPerDay': '{n} trips/day',
|
||||
'stop.tripsPerDay1': '{n} trip/day',
|
||||
'stop.nRoutes1': '{n} route',
|
||||
'stop.noRoutes': 'No routes recorded for this stop yet',
|
||||
'stop.noTimes': 'No departure times for this stop yet',
|
||||
'stop.tomorrow': 'Tomorrow',
|
||||
'stop.nextAt': 'Next',
|
||||
'stop.notFound': 'Stop not found',
|
||||
'stop.notFoundSub': 'No stop with code “{code}” — check the code or go back to the stop list',
|
||||
'stop.nearbySub': 'Places of interest and stops to wait for your bus',
|
||||
'stop.otherStopsTitle': 'Other boarding points · route {n} ({m} stops)',
|
||||
'stop.otherMore': '(+{n} stops)',
|
||||
'stop.otherStopsAll': 'All other boarding points ({m} stops)',
|
||||
'stop.noCoord': 'No coordinates yet',
|
||||
'stop.open': 'Open',
|
||||
'stop.close': 'Close',
|
||||
'stop.nowAtStop': 'Current time at this stop',
|
||||
'stop.autoNext': 'Next departure is calculated automatically',
|
||||
|
||||
'common.backHome': '← Back to home',
|
||||
'common.backStops': '← Back to stops',
|
||||
@@ -432,11 +505,6 @@
|
||||
'credits.icons': 'Icons — Lucide',
|
||||
'credits.fonts': 'Fonts — Google Fonts',
|
||||
'credits.map': 'Maps',
|
||||
'credits.images': 'Images',
|
||||
'credits.logos': 'Sponsor & partner logos',
|
||||
'credits.data': 'Transit data',
|
||||
'credits.pwa': 'Offline mode (PWA / Service Worker)',
|
||||
'credits.notes': 'Notes',
|
||||
'common.back': 'Back',
|
||||
'check.scheduleAll': 'Departure times at every stop',
|
||||
'check.title': 'Departure Schedule',
|
||||
|
||||
@@ -304,6 +304,8 @@
|
||||
<script src="./i18n.js" defer></script>
|
||||
<script src="./vendor/leaflet/leaflet.js" defer></script>
|
||||
<script src="./map.js" defer></script>
|
||||
<script src="./partials/schedules.js" defer></script>
|
||||
<script src="./partials/otherStop.js" defer></script>
|
||||
<script src="./router.js" defer></script>
|
||||
<link rel="stylesheet" href="./responsive.css">
|
||||
</head>
|
||||
@@ -391,6 +393,7 @@
|
||||
</symbol>
|
||||
<symbol id="ic-share-2" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="18" cy="5" r="3"/><circle cx="6" cy="12" r="3"/><circle cx="18" cy="19" r="3"/><line x1="8.59" y1="13.51" x2="15.42" y2="17.49"/><line x1="15.41" y1="6.51" x2="8.59" y2="10.49"/></symbol>
|
||||
<symbol id="ic-link" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></symbol>
|
||||
<symbol id="ic-facebook" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M18 2h-3a5 5 0 0 0-5 5v3H7v4h3v8h4v-8h3l1-4h-4V7a1 1 0 0 1 1-1h3z"/></symbol>
|
||||
</svg>
|
||||
|
||||
<header class="mu-topbar">
|
||||
|
||||
+18
@@ -124,6 +124,11 @@
|
||||
.at-km-dot { width: 9px; height: 9px; border-radius: 3px; background: #f2a900; flex: none; }
|
||||
.at-km-name { flex: 1; font-weight: 600; }
|
||||
.at-km-val { font-variant-numeric: tabular-nums; font-weight: 700; color: #14532d; }
|
||||
/* จุดจอดที่ไม่มีหน้ารายละเอียด (มาจาก 8 other_stop.json) — ไม่ใช่ลิงก์ */
|
||||
.at-km-row.is-plain { cursor: default; }
|
||||
.at-km-row.is-plain .at-km-dot { background: #7a4cc0; }
|
||||
.at-km-row.is-plain:hover .at-km-name { color: inherit; text-decoration: none; }
|
||||
.at-km-row .at-km-val.is-off { color: #a3560f; font-weight: 600; font-size: .78rem; }
|
||||
|
||||
/* ---------- ป้ายใกล้ฉัน ---------- */
|
||||
.at-near-msg { margin: 14px 0 0; color: #6b7268; font-size: .86rem; }
|
||||
@@ -135,3 +140,16 @@
|
||||
.at-near-name { font-weight: 700; font-size: .9rem; }
|
||||
.at-near-meta { grid-column: 1; color: #6b7268; font-size: .76rem; }
|
||||
.at-near-dist { grid-column: 2; grid-row: 1 / span 2; font-variant-numeric: tabular-nums; font-weight: 800; color: #14532d; white-space: nowrap; }
|
||||
|
||||
/* ---------- กัน CSS ภายนอกทำลายขนาด SVG ของ Leaflet ----------
|
||||
responsive.css ตั้ง `img, svg, video { max-width: 100%; height: auto; }` และบาง partial
|
||||
เคยตั้ง `.mu-map-card svg { width: 100%; height: auto; }` → ทำให้ viewport SVG ของ Leaflet
|
||||
(ซึ่งถูกวางใน pane ขนาด 0x0) ยุบเป็น 0x0 แล้ว "เส้นทางไม่แสดง" ทั้งที่ถูกวาดแล้ว
|
||||
Leaflet กำหนดขนาดเองผ่าน attribute width/height เสมอ — ห้าม CSS อื่นทับ */
|
||||
.at-map svg.leaflet-zoom-animated,
|
||||
.at-map canvas.leaflet-zoom-animated {
|
||||
width: auto;
|
||||
height: auto;
|
||||
max-width: none;
|
||||
max-height: none;
|
||||
}
|
||||
@@ -20,6 +20,11 @@ window.ATMap = (function () {
|
||||
'use strict';
|
||||
|
||||
var DEF_BASE = '../resource/data/';
|
||||
/* station_id 8 = "จุดขึ้นรถประจำทางอื่นๆ" (ใช้ร่วมหลายสาย) → ต้องจับคู่ route_id
|
||||
ในไฟล์ '8 other_stop.json' เพื่อเอาชื่อ/พิกัดจริงของสายนั้น (สายเดียวมีได้หลายจุด) */
|
||||
var OTHER_STOP_ID = 8;
|
||||
var OTHER_STOP_FILE = '8%20other_stop.json';
|
||||
var OFF_ROUTE_M = 2000; /* ห่างจากเส้นเกินนี้ → แจ้ง "นอกเส้นทาง" */
|
||||
var TILES = 'https://tile.openstreetmap.org/{z}/{x}/{y}.png';
|
||||
var ATTRIB = '© OpenStreetMap';
|
||||
var NEAR_M = 40; /* ป้ายอยู่ "บนเส้นทาง" ถ้าใกล้ ≤ 40 ม. */
|
||||
@@ -118,16 +123,97 @@ window.ATMap = (function () {
|
||||
}
|
||||
function stops(o) { return loadJson('busstop_list.json', 'stops', o).then(function (d) { return d || []; }); }
|
||||
function stationList(o) { return loadJson('stations.json', 'stations', o).then(function (d) { return (d || {}).stations || []; }); }
|
||||
function otherStopList(o) { return loadJson(OTHER_STOP_FILE, 'otherStops', o).then(function (d) { return (d || {}).other_stop || []; }); }
|
||||
function routeList(o) { return loadJson('routes.json', 'routes', o).then(function (d) { return (d || {}).routes || []; }); }
|
||||
|
||||
/* จุดจอดตามเส้นทาง = routes.json → station_ids (ตามลำดับของสาย)
|
||||
- station_id 8 → จับคู่ route_id ใน '8 other_stop.json' (ถ้าไม่มีคู่ จับคู่ไม่ได้ → ใช้สถานี 8 ตามเดิม)
|
||||
- กม. จากต้นทาง = วัดตามเส้น geometry โดยเลือกปลายที่ใกล้จุดจอดแรกที่สุดเป็น "ต้นทาง"
|
||||
- พิกัดที่ห่างจากเส้นเกิน OFF_ROUTE_M → ขึ้น "นอกเส้นทาง" แทนตัวเลข กม. (กันเลขหลอก) */
|
||||
function routeStopRows(route, stations, others, main, validIds) {
|
||||
var byId = {};
|
||||
stations.forEach(function (st) { byId[st.station_id] = st; });
|
||||
|
||||
var stops = [];
|
||||
(route.station_ids || []).forEach(function (sid) {
|
||||
if (sid === OTHER_STOP_ID) {
|
||||
/* จับคู่ route → ชื่อสถานที่จริง (รองรับรหัสเพี้ยน เช่น 1101 = สาย 1011) ผ่าน OtherStop */
|
||||
var hit = (window.OtherStop && OtherStop.forRouteAll)
|
||||
? OtherStop.forRouteAll(others, route.route_id, validIds)
|
||||
: (others || []).filter(function (o) { return String(o.route_id) === String(route.route_id); });
|
||||
if (hit.length) {
|
||||
hit.forEach(function (o) {
|
||||
/* แตกเป็น "จุดจริง" ทีละจุด — ชื่อ ↔ พิกัด จับคู่ตามลำดับ (จุดที่ไม่มีพิกัด = ไม่ปักหมุด) */
|
||||
var subs = (window.OtherStop && OtherStop.stopsOf) ? OtherStop.stopsOf(o) : [];
|
||||
if (!subs.length) subs = [{ name: o.station_name_th, hasCoord: false, lat: null, lng: null }];
|
||||
subs.forEach(function (sub) {
|
||||
stops.push({
|
||||
name: sub.name,
|
||||
pt: sub.hasCoord ? [sub.lng, sub.lat] : null,
|
||||
code: null,
|
||||
note: o.note || null
|
||||
});
|
||||
});
|
||||
});
|
||||
return; /* จับคู่ได้ → ไม่ใช้ชื่อสถานีรวม */
|
||||
}
|
||||
}
|
||||
var st = byId[sid];
|
||||
if (st) stops.push({ name: st.station_name_th, pt: pointOf(st), code: st.station_code });
|
||||
});
|
||||
|
||||
var total = lineLengthKm([main]);
|
||||
var first = stops.filter(function (s) { return s.pt; })[0];
|
||||
var fromEnd = first ? kmFromStart(main, first.pt).km > total / 2 : false;
|
||||
|
||||
stops.forEach(function (s) {
|
||||
if (!s.pt) { s.km = null; s.off = false; return; }
|
||||
var k = kmFromStart(main, s.pt);
|
||||
var km = fromEnd ? total - k.km : k.km;
|
||||
s.off = k.d > OFF_ROUTE_M;
|
||||
s.km = Math.max(0, km).toFixed(1);
|
||||
});
|
||||
return stops;
|
||||
}
|
||||
|
||||
/* ---------- องค์ประกอบแผนที่ ---------- */
|
||||
/* แผนที่ทั้งหมดที่สร้างในหน้านี้ (ไว้จัดการ resize + ตรวจสอบ) */
|
||||
var MAPS = [];
|
||||
|
||||
function mapOptions() {
|
||||
return {
|
||||
zoomControl: true,
|
||||
attributionControl: true,
|
||||
scrollWheelZoom: true, /* ล้อเมาส์: หมุนเข้า/ออก = ซูม */
|
||||
touchZoom: true, /* มือถือ: ใช้นิ้ว 2 นิ้วจีบ/กาง = ซูม */
|
||||
doubleClickZoom: true,
|
||||
boxZoom: true,
|
||||
keyboard: true,
|
||||
wheelDebounceTime: 40 /* หน่วงนิดเดียว ไม่ให้ซูมกระโดดตอนหมุนเร็ว */
|
||||
};
|
||||
}
|
||||
|
||||
function makeMap(el) {
|
||||
var offline = navigator.onLine === false;
|
||||
if (offline) el.classList.add('is-offline');
|
||||
var map = L.map(el, { zoomControl: true, attributionControl: true, scrollWheelZoom: false });
|
||||
var map = L.map(el, mapOptions());
|
||||
map.setView([14.588, 100.455], 11);
|
||||
if (!offline) L.tileLayer(TILES, { maxZoom: 18, minZoom: 8, attribution: ATTRIB }).addTo(map);
|
||||
MAPS.push({ map: map, el: el, bounds: null });
|
||||
return { map: map, offline: offline };
|
||||
}
|
||||
|
||||
/* ถ้าหน้าต่างเปลี่ยนขนาด (หรือหมุนมือถือ) → อัปเดตขนาด + ซูมให้พอดีเส้นทางอีกครั้ง */
|
||||
var resizeTimer = null;
|
||||
window.addEventListener('resize', function () {
|
||||
clearTimeout(resizeTimer);
|
||||
resizeTimer = setTimeout(function () {
|
||||
MAPS.forEach(function (rec) {
|
||||
rec.map.invalidateSize();
|
||||
if (rec.bounds) rec.map.fitBounds(rec.bounds, { padding: [24, 24], maxZoom: 15 });
|
||||
});
|
||||
}, 200);
|
||||
});
|
||||
function pinIcon(kind) {
|
||||
return L.divIcon({ className: 'at-pin-wrap', html: '<span class="at-pin ' + kind + '"></span>', iconSize: [16, 16], iconAnchor: [8, 8] });
|
||||
}
|
||||
@@ -152,13 +238,40 @@ window.ATMap = (function () {
|
||||
var all = [];
|
||||
latlngs.forEach(function (l) { all = all.concat(l); });
|
||||
if (!all.length) return;
|
||||
if (all.length === 1) { map.setView(all[0], 14); return; }
|
||||
map.fitBounds(L.latLngBounds(all), { padding: [24, 24] });
|
||||
var rec = mapsFor(map);
|
||||
if (all.length === 1) {
|
||||
if (rec) rec.bounds = L.latLngBounds(all);
|
||||
map.setView(all[0], 14);
|
||||
return;
|
||||
}
|
||||
var bounds = L.latLngBounds(all);
|
||||
if (rec) rec.bounds = bounds;
|
||||
map.invalidateSize(); /* ให้แน่ใจว่าขนาดถูกก่อนคำนวณซูม */
|
||||
map.fitBounds(bounds, { padding: [24, 24], maxZoom: 15 });
|
||||
}
|
||||
|
||||
function mapsFor(map) {
|
||||
for (var i = 0; i < MAPS.length; i++) if (MAPS[i].map === map) return MAPS[i];
|
||||
return null;
|
||||
}
|
||||
function mapsLink(lat, lng) {
|
||||
return 'https://www.google.com/maps/search/?api=1&query=' + lat + ',' + lng;
|
||||
}
|
||||
|
||||
/* วาดเส้นทาง: ขอบสีครีม (เห็นชัดบนพื้นแผนที่) แล้วทับด้วยเส้นสีจริง 5px ตาม DESIGN.md §5 */
|
||||
function drawLines(group, specs) {
|
||||
specs.forEach(function (sp) {
|
||||
L.polyline(sp.latlngs, {
|
||||
color: '#fffdf6', weight: LINE_W + 4, opacity: 0.95, lineJoin: 'round', lineCap: 'round', smoothFactor: 0.6
|
||||
}).addTo(group);
|
||||
});
|
||||
specs.forEach(function (sp) {
|
||||
L.polyline(sp.latlngs, {
|
||||
color: sp.color, weight: LINE_W, opacity: 1, lineJoin: 'round', lineCap: 'round', smoothFactor: 0.6
|
||||
}).addTo(group);
|
||||
});
|
||||
}
|
||||
|
||||
/* ป้ายหยุดรถ: hover = ข้อมูลย่อ · คลิก = popup (ประเภท/กม./ด้านทาง/สายที่ผ่าน + Google Maps) */
|
||||
function drawShelters(map, hits, group) {
|
||||
hits.forEach(function (h) {
|
||||
@@ -251,13 +364,16 @@ window.ATMap = (function () {
|
||||
if (!list.length) return;
|
||||
list.forEach(function (x) {
|
||||
var li = document.createElement('li');
|
||||
var a = document.createElement('a');
|
||||
a.href = x.href;
|
||||
a.className = 'at-km-row';
|
||||
a.innerHTML = '<span class="at-km-dot" aria-hidden="true"></span>' +
|
||||
var row = document.createElement(x.href ? 'a' : 'div');
|
||||
if (x.href) row.href = x.href;
|
||||
row.className = 'at-km-row' + (x.href ? '' : ' is-plain');
|
||||
if (x.note) row.title = x.note;
|
||||
var val = x.off ? '<span class="is-off">' + esc(t('map.offRoute')) + '</span>'
|
||||
: (x.km === null || x.km === '' ? '–' : x.km + ' ' + esc(t('map.km')));
|
||||
row.innerHTML = '<span class="at-km-dot" aria-hidden="true"></span>' +
|
||||
'<span class="at-km-name">' + esc(x.name) + '</span>' +
|
||||
'<span class="at-km-val">' + x.km + ' ' + esc(t('map.km')) + '</span>';
|
||||
li.appendChild(a);
|
||||
'<span class="at-km-val">' + val + '</span>';
|
||||
li.appendChild(row);
|
||||
host.appendChild(li);
|
||||
});
|
||||
var wrap = host.closest('.at-km-wrap');
|
||||
@@ -282,9 +398,7 @@ window.ATMap = (function () {
|
||||
var m = makeMap(el), map = m.map, group = L.layerGroup().addTo(map);
|
||||
var latlngs = toLatLngs(lines);
|
||||
|
||||
latlngs.forEach(function (l) {
|
||||
L.polyline(l, { color: LINE_MAIN, weight: LINE_W, opacity: 1, lineJoin: 'round', lineCap: 'round' }).addTo(group);
|
||||
});
|
||||
drawLines(group, latlngs.map(function (l) { return { latlngs: l, color: LINE_MAIN }; }));
|
||||
/* ต้นทาง/ปลายทาง */
|
||||
[[latlngs[0][0], t('map.origin')], [latlngs[latlngs.length - 1][latlngs[latlngs.length - 1].length - 1], t('map.destination')]]
|
||||
.forEach(function (e) {
|
||||
@@ -292,23 +406,36 @@ window.ATMap = (function () {
|
||||
.bindTooltip(esc(e[1]), { direction: 'top', offset: [0, -8] }).addTo(group);
|
||||
});
|
||||
|
||||
Promise.all([stopsNear(lines, opts), stationsNear(lines, STATION_NEAR_M, opts)]).then(function (res) {
|
||||
var shelters = res[0], sts = res[1];
|
||||
Promise.all([stopsNear(lines, opts), stationsNear(lines, STATION_NEAR_M, opts),
|
||||
stationList(opts), routeList(opts), otherStopList(opts)]).then(function (res) {
|
||||
var shelters = res[0], sts = res[1], stations = res[2], routesDoc = res[3], others = res[4];
|
||||
drawShelters(map, shelters, group);
|
||||
drawStations(map, sts, opts, group);
|
||||
fitAll(map, latlngs);
|
||||
|
||||
/* รายการสถานี + กม. จากต้นทาง (เรียงตามเส้นทาง) */
|
||||
/* จุดจอดตามเส้นทาง + กม. จากต้นทาง — ใช้ routes.json → station_ids เป็นหลัก
|
||||
(station 8 → จับคู่ route_id ใน 8 other_stop.json) ถ้าหา route ไม่ได้จึงใช้ระยะใกล้เส้นแบบเดิม */
|
||||
var main = longest(lines);
|
||||
var rows = sts.map(function (h) {
|
||||
var pt = pointOf(h.station);
|
||||
var k = kmFromStart(main, pt);
|
||||
return { name: h.station.station_name_th, km: k.km.toFixed(1), href: href(opts, h.station.station_code), _sort: k.km };
|
||||
}).sort(function (a, b) { return a._sort - b._sort; });
|
||||
var route = (routesDoc || []).filter(function (r) { return String(r.route_id) === String(routeId); })[0];
|
||||
var rows;
|
||||
if (route && (route.station_ids || []).length) {
|
||||
rows = routeStopRows(route, stations, others, main, (routesDoc || []).map(function (r) { return String(r.route_id); })).map(function (x) {
|
||||
return { name: x.name, km: x.km, off: x.off, note: x.note, href: x.code ? href(opts, x.code) : null };
|
||||
}).sort(function (a, b) { /* เรียงตาม กม. ตามเส้นทาง (อ่านเป็นเส้นทางเดินรถ) */
|
||||
if (a.km === null || a.km === '') return 1;
|
||||
if (b.km === null || b.km === '') return -1;
|
||||
return parseFloat(a.km) - parseFloat(b.km);
|
||||
});
|
||||
} else {
|
||||
rows = sts.map(function (h) {
|
||||
var k = kmFromStart(main, pointOf(h.station));
|
||||
return { name: h.station.station_name_th, km: k.km.toFixed(1), off: false, href: href(opts, h.station.station_code) };
|
||||
}).sort(function (a, b) { return parseFloat(a.km) - parseFloat(b.km); });
|
||||
}
|
||||
renderKmList('route-map-list', rows);
|
||||
|
||||
var parts = ['<b>' + esc(routeId) + '</b> · ' + esc(t('map.captionRoute', { km: lineLengthKm(lines).toFixed(1), n: shelters.length }))];
|
||||
if (sts.length) parts.push(esc(t('map.stations')) + ' <b>' + sts.length + '</b>');
|
||||
if (rows.length) parts.push(esc(t('map.stations')) + ' <b>' + rows.length + '</b>');
|
||||
if (m.offline) parts.push('<span class="at-offline">' + esc(t('map.offline')) + '</span>');
|
||||
caption(el, parts.join(' · '));
|
||||
});
|
||||
@@ -332,6 +459,9 @@ window.ATMap = (function () {
|
||||
var list = res[0], routes = (res[1] || {}).routes || [];
|
||||
var st = list.filter(function (s) { return s.station_code === code; })[0];
|
||||
var serving = st ? routes.filter(function (r) { return (r.station_ids || []).indexOf(st.station_id) !== -1; }) : [];
|
||||
if (opts.onlyRoutes && opts.onlyRoutes.length) {
|
||||
serving = serving.filter(function (r) { return opts.onlyRoutes.indexOf(String(r.route_id)) !== -1; });
|
||||
}
|
||||
var ids = serving.map(function (r) { return r.route_id; });
|
||||
|
||||
if (!st || !ids.length) {
|
||||
@@ -342,7 +472,7 @@ window.ATMap = (function () {
|
||||
|
||||
Promise.all(ids.map(function (id) { return loadGeo(id, opts); })).then(function (geos) {
|
||||
var m = makeMap(el), map = m.map, group = L.layerGroup().addTo(map);
|
||||
var all = [], allLines = [], legendRows = [], drawn = 0;
|
||||
var all = [], allLines = [], legendRows = [], drawn = 0, specs = [];
|
||||
|
||||
geos.forEach(function (g, idx) {
|
||||
var lines = flatten(g);
|
||||
@@ -351,7 +481,7 @@ window.ATMap = (function () {
|
||||
drawn++;
|
||||
allLines = allLines.concat(lines);
|
||||
toLatLngs(lines).forEach(function (l) {
|
||||
L.polyline(l, { color: color, weight: LINE_W, opacity: 1, lineJoin: 'round', lineCap: 'round' }).addTo(group);
|
||||
specs.push({ latlngs: l, color: color });
|
||||
all.push(l);
|
||||
});
|
||||
legendRows.push({ color: color, label: t('map.route') + ' ' + ids[idx] });
|
||||
@@ -362,13 +492,17 @@ window.ATMap = (function () {
|
||||
caption(el, '<span class="at-offline">' + esc(t('map.empty')) + '</span>');
|
||||
return;
|
||||
}
|
||||
drawLines(group, specs);
|
||||
|
||||
stopsNear(allLines, opts).then(function (shelters) {
|
||||
drawShelters(map, shelters, group);
|
||||
var stPt = pointOf(st);
|
||||
/* opts.focus = จุดจริงของสายที่เลือก (เช่น จุดขึ้นรถประจำทางอื่นๆ → วัดสีบัวทอง) */
|
||||
var stPt = opts.focus ? pointOf(opts.focus) : pointOf(st);
|
||||
var focusFirst = (opts.focus && window.OtherStop && OtherStop.firstName) ? OtherStop.firstName(opts.focus) : null;
|
||||
var pinName = focusFirst || (opts.focus && opts.focus.station_name_th) || st.station_name_th;
|
||||
if (stPt) {
|
||||
L.marker([stPt[1], stPt[0]], { icon: pinIcon('here'), zIndexOffset: 1000 })
|
||||
.bindTooltip('<b>' + esc(st.station_name_th) + '</b><br>' + esc(t('map.thisStop')), { direction: 'top', offset: [0, -11] })
|
||||
.bindTooltip('<b>' + esc(pinName) + '</b><br>' + esc(t('map.thisStop')), { direction: 'top', offset: [0, -11] })
|
||||
.addTo(group);
|
||||
all.push([[stPt[1], stPt[0]]]);
|
||||
}
|
||||
@@ -473,7 +607,7 @@ window.ATMap = (function () {
|
||||
|
||||
function drawNearMap(box, near, me) {
|
||||
var offline = navigator.onLine === false;
|
||||
var map = L.map(box, { zoomControl: true, attributionControl: true, scrollWheelZoom: false });
|
||||
var map = L.map(box, mapOptions());
|
||||
map.setView([me[1], me[0]], 13);
|
||||
if (!offline) L.tileLayer(TILES, { maxZoom: 18, minZoom: 8, attribution: ATTRIB }).addTo(map);
|
||||
else box.classList.add('is-offline');
|
||||
@@ -494,6 +628,7 @@ window.ATMap = (function () {
|
||||
|
||||
return {
|
||||
route: route, forStop: forStop, nearMe: nearMe,
|
||||
NEAR_M: NEAR_M, LINE_MAIN: LINE_MAIN
|
||||
NEAR_M: NEAR_M, LINE_MAIN: LINE_MAIN,
|
||||
maps: MAPS /* ไว้ตรวจสอบ/ทดสอบจากคอนโซล */
|
||||
};
|
||||
})();
|
||||
@@ -86,6 +86,10 @@
|
||||
background: linear-gradient(135deg, #7a4cc0, #b07ce0); color: #fff;
|
||||
}
|
||||
.mu-contact-item .ic-wrap.tone-green { background: linear-gradient(135deg, #1f8765, #51c39c); }
|
||||
.mu-contact-item .ic-wrap.tone-sky { background: linear-gradient(135deg, #1877f2, #4a9bf8); }
|
||||
.mu-contact-item .ic-wrap.tone-purple { background: linear-gradient(135deg, #7a4cc0, #a583e0); }
|
||||
.mu-contact-item .mu-link-go { flex: 0 0 auto; display: flex; align-items: center; color: #7a4cc0; opacity: .8; }
|
||||
.mu-contact-item:hover .mu-link-go { opacity: 1; transform: translateX(2px); }
|
||||
.mu-contact-item .ic-wrap svg { width: 22px; height: 22px; }
|
||||
.mu-contact-item .txt { flex: 1; min-width: 0; }
|
||||
.mu-contact-item .txt strong { display: block; color: #1f2a44; font-size: .98rem; margin-bottom: 2px; }
|
||||
@@ -104,7 +108,8 @@
|
||||
padding: 16px;
|
||||
box-shadow: 0 4px 14px rgba(20, 40, 90, .06);
|
||||
}
|
||||
.mu-map-card svg { width: 100%; height: auto; display: block; }
|
||||
/* (ตัดกฎ .mu-map-card svg เดิมออก — แผนที่ SVG นิ่งถูกแทนด้วย Leaflet
|
||||
และกฎนี้ทำให้ SVG ของ Leaflet ยุบเป็น 0x0 จนเส้นทางไม่แสดง) */
|
||||
|
||||
.mu-summary-grid { gap: 14px; }
|
||||
|
||||
|
||||
@@ -84,17 +84,38 @@
|
||||
}
|
||||
function telHref(p) { return 'tel:' + String(p == null ? '' : p).replace(/[^\d+]/g, ''); }
|
||||
|
||||
/* ---------- การ์ดติดต่อ (LINE + QR + เบอร์โทรทุกเบอร์จาก routes.json) ---------- */
|
||||
/* ---------- ลิงก์ติดต่อ (web_url ใน routes.json) — ไอคอน/ชื่อ/สี เปลี่ยนตามชนิด URL ----------
|
||||
facebook → ไอคอน facebook + โทนฟ้า · line (line.me / lin.ee / linevoom) → LINE + โทนเขียว
|
||||
อื่น ๆ (www) → ไอคอนลูกโลก + โทนม่วง */
|
||||
var LINK_KINDS = [
|
||||
{ key: 'facebook', icon: 'ic-facebook', tone: 'tone-sky', match: /facebook\.com|fb\.(me|com)/i },
|
||||
{ key: 'line', icon: 'ic-message-circle', tone: 'tone-green', match: /line\.me|lin\.ee|linevoom|line\.at/i },
|
||||
{ key: 'www', icon: 'ic-globe', tone: 'tone-purple', match: /^https?:/i }
|
||||
];
|
||||
function linkKind(url) {
|
||||
var u = String(url || '').trim();
|
||||
if (!u) return null;
|
||||
for (var i = 0; i < LINK_KINDS.length; i++) { if (LINK_KINDS[i].match.test(u)) return LINK_KINDS[i]; }
|
||||
return { key: 'www', icon: 'ic-globe', tone: 'tone-purple' };
|
||||
}
|
||||
function prettyUrl(url) {
|
||||
return String(url || '').trim().replace(/^https?:\/\//i, '').replace(/\/+$/, '');
|
||||
}
|
||||
|
||||
/* ---------- การ์ดติดต่อ (LINE + QR + ลิงก์ + เบอร์โทรจาก routes.json) ---------- */
|
||||
function buildContact(rid, route, cap) {
|
||||
var host = $('route-contact');
|
||||
if (!host) return;
|
||||
host.innerHTML = '';
|
||||
|
||||
var kind = linkKind(route.web_url);
|
||||
var line = document.createElement('div');
|
||||
line.className = 'mu-contact-item';
|
||||
line.innerHTML =
|
||||
'<span class="ic-wrap tone-green"><svg class="ic" aria-hidden="true"><use href="#ic-message-circle"/></svg></span>' +
|
||||
'<div class="txt"><strong>LINE Official</strong><span id="route-line-note"></span></div>';
|
||||
'<span class="ic-wrap ' + (kind ? kind.tone : 'tone-green') + '"><svg class="ic" aria-hidden="true">' +
|
||||
'<use href="#' + (kind ? kind.icon : 'ic-message-circle') + '"/></svg></span>' +
|
||||
'<div class="txt"><strong>' + esc(kind ? t('route.link.' + kind.key) : 'LINE Official') + '</strong>' +
|
||||
'<span id="route-line-note"></span></div>';
|
||||
var qr = document.createElement('img');
|
||||
qr.className = 'mu-qr-img';
|
||||
qr.loading = 'lazy';
|
||||
@@ -120,6 +141,21 @@
|
||||
'<div class="txt"><strong>' + esc(t('route.call')) + '</strong><span>' + esc(fmtPhone(p)) + '</span></div>';
|
||||
host.appendChild(a);
|
||||
});
|
||||
|
||||
/* ปุ่ม "เปิดลิงก์" แยกต่างหาก — ชัดเจนบนมือถือ (แสดงเมื่อ routes.json มี web_url) */
|
||||
if (kind) {
|
||||
var open = document.createElement('a');
|
||||
open.className = 'mu-contact-item';
|
||||
open.href = String(route.web_url).trim();
|
||||
open.target = '_blank';
|
||||
open.rel = 'noopener noreferrer';
|
||||
open.innerHTML =
|
||||
'<span class="ic-wrap ' + kind.tone + '"><svg class="ic" aria-hidden="true"><use href="#' + kind.icon + '"/></svg></span>' +
|
||||
'<div class="txt"><strong>' + esc(t('route.openLink')) + '</strong><span>' + esc(prettyUrl(route.web_url)) + '</span></div>' +
|
||||
'<span class="mu-link-go"><svg class="ic" aria-hidden="true"><use href="#ic-arrow-right"/></svg></span>';
|
||||
host.appendChild(open);
|
||||
host.hidden = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- รอบต่อวัน / รอบถัดไป จาก schedules.json ---------- */
|
||||
@@ -137,8 +173,8 @@
|
||||
return uniqTimes[0]; /* หมดรอบของวันนี้ → รอบแรกของวันถัดไป */
|
||||
}
|
||||
function loadTrips(rid) {
|
||||
return fetchJSON(DATA + 'schedules.json').then(function (d) {
|
||||
var recs = (d && (d.schedules || d)) || [];
|
||||
return Schedules.load().then(function (sd) { return Schedules.normSub(sd); }).then(function (d) {
|
||||
var recs = window.Schedules ? Schedules.records(d) : ((d && (d.schedules || d)) || []);
|
||||
var out = [];
|
||||
recs.forEach(function (r) {
|
||||
if (String(r.route_id) === String(rid)) out = out.concat(r.departure_times || []);
|
||||
|
||||
@@ -240,7 +240,11 @@
|
||||
}
|
||||
|
||||
.mu-toolbar-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
|
||||
.mu-toolbar-count { margin: 10px 0 0; font-size: .84rem; color: #6f7b95; }
|
||||
.mu-show-more { display: flex; justify-content: center; margin: 14px 0 4px; }
|
||||
.mu-show-more .mu-btn { min-width: 220px; }
|
||||
.mu-stop-card.is-stub { min-height: 120px; background: #faf8ff; border: 1px dashed #ddd2f2; box-shadow: none; }
|
||||
|
||||
.mu-toolbar-count { margin: 10px 0 0; font-size: .84rem; color: #6f7b95; }
|
||||
.mu-toolbar-count b { color: #7a4cc0; font-variant-numeric: tabular-nums; }
|
||||
|
||||
/* ===== การ์ดป้าย ===== */
|
||||
@@ -295,6 +299,10 @@
|
||||
font-weight:700;
|
||||
}
|
||||
.mu-chip.route { background: #f3ecff; color:#6d28d9; border-color: #e0d6f5; }
|
||||
/* ชิปสายที่เป็นลิงก์ → ไปหน้าเช็กเวลาของสายนั้น (หน้าตาเหมือนชิปเดิม + มี hover/focus) */
|
||||
a.mu-chip.route { text-decoration: none; cursor: pointer; }
|
||||
a.mu-chip.route:hover { background:#e9dcff; border-color:#cdb5f2; }
|
||||
a.mu-chip.route:focus-visible { outline: 2px solid #7a4cc0; outline-offset: 2px; }
|
||||
/* รหัสป้าย = ม่วง-ขาว แบบเดียวกับป้ายสายรถ */
|
||||
.mu-chip.count.stop-code {
|
||||
background: linear-gradient(135deg, #7a4cc0, #b07ce0);
|
||||
@@ -449,6 +457,10 @@
|
||||
<div id="near-me-result" class="mu-near-wrap" hidden></div>
|
||||
|
||||
<ul class="mu-stop-grid" id="stops-list"></ul>
|
||||
|
||||
<div class="mu-show-more">
|
||||
<button type="button" class="mu-btn outline" id="stops-show-all" data-i18n="stops.showAll" hidden>แสดงป้ายทั้งหมด</button>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
|
||||
+78
-25
@@ -25,8 +25,10 @@
|
||||
'use strict';
|
||||
|
||||
var DATA_URL = '../resource/data/busstop_list.json';
|
||||
var IMG_DIR = '../.image/stops/';
|
||||
var IMG_EXT = '.jpg';
|
||||
var ROUTES_URL = '../resource/data/routes.json'; /* ใช้ยืนยันว่าสายมีอยู่จริง ก่อนทำชิปเป็นลิงก์ */
|
||||
var IMG_DIR = '../.image/stops/'; /* รูปป้ายริมทาง: pad5(กม.) เช่น 36020.jpg (ชุดเดิม) */
|
||||
var STATION_IMG_DIR = '../.image/stations/'; /* รูปสถานี (ตัวอาคาร): <station_id>.jpg ตาม stations.json */
|
||||
var IMG_EXTS = ['jpg', 'jpeg', 'webp', 'png']; /* ไล่ลองนามสกุล (รองรับ .jpeg) */
|
||||
var PLACEHOLDER = '../.image/icons/minibus-512x512.png';
|
||||
|
||||
function t(key, vars) {
|
||||
@@ -49,14 +51,32 @@
|
||||
.catch(function () { return null; });
|
||||
}
|
||||
|
||||
/* ---------- รูป: ลองรูปจริงก่อน ถ้าไม่มีค่อยใช้ placeholder ---------- */
|
||||
function resolveImage(km) {
|
||||
var code = pad5(km);
|
||||
if (!code) return Promise.resolve(PLACEHOLDER);
|
||||
var url = IMG_DIR + code + IMG_EXT;
|
||||
/* ---------- รูป: รูปสถานี (<station_id>.jpg) ก่อน → รูปป้ายริมทาง (pad5 กม.) → placeholder ---------- */
|
||||
function exists(url) {
|
||||
return fetch(url, { method: 'HEAD', cache: 'no-store' })
|
||||
.then(function (r) { return r.ok ? url : PLACEHOLDER; })
|
||||
.catch(function () { return PLACEHOLDER; });
|
||||
.then(function (r) { return r.ok ? url : null; })
|
||||
.catch(function () { return null; });
|
||||
}
|
||||
/* ไล่ลองนามสกุลทีละตัว (.jpg → .jpeg → .webp → .png) — ไม่มีเลย = null */
|
||||
function firstExisting(base) {
|
||||
var i = 0;
|
||||
function next() {
|
||||
if (i >= IMG_EXTS.length) return Promise.resolve(null);
|
||||
var url = base + '.' + IMG_EXTS[i++];
|
||||
return exists(url).then(function (u) { return u || next(); });
|
||||
}
|
||||
return next();
|
||||
}
|
||||
function resolveImage(stop) {
|
||||
var sid = stop && stop.station_id;
|
||||
var code = pad5(stop && stop.kilometer);
|
||||
var chain = sid ? firstExisting(STATION_IMG_DIR + sid) : Promise.resolve(null);
|
||||
return chain.then(function (u) { return u ? exists(u) : null; })
|
||||
.then(function (u) {
|
||||
if (u) return u;
|
||||
return code ? firstExisting(IMG_DIR + code) : null;
|
||||
})
|
||||
.then(function (u) { return u || PLACEHOLDER; });
|
||||
}
|
||||
|
||||
/* ---------- KPI (คำนวณจากข้อมูลจริง) ---------- */
|
||||
@@ -107,7 +127,7 @@
|
||||
}
|
||||
|
||||
/* ---------- การ์ดป้าย ---------- */
|
||||
function buildCard(stop, imgUrl, idx) {
|
||||
function buildCard(stop, imgUrl, idx, routeIds) {
|
||||
var li = document.createElement('li');
|
||||
li.setAttribute('data-idx', String(idx));
|
||||
|
||||
@@ -157,11 +177,17 @@
|
||||
row.className = 'mu-chip-row';
|
||||
|
||||
// ★ สายรถประจำทางที่ผ่านป้ายนี้ (buses-line)
|
||||
// สายที่มีใน routes.json → ทำเป็นลิงก์ไปหน้ารายละเอียดสายนั้น (#/routes/<รหัส>)
|
||||
var buses = stop['buses-line'] || [];
|
||||
if (buses.length) {
|
||||
buses.forEach(function (n) {
|
||||
var b = document.createElement('span');
|
||||
var known = routeIds.indexOf(String(n)) !== -1;
|
||||
var b = document.createElement(known ? 'a' : 'span');
|
||||
b.className = 'mu-chip route';
|
||||
if (known) {
|
||||
b.href = '#/routes/' + encodeURIComponent(n);
|
||||
b.title = t('stops.viewRoute', { n: n });
|
||||
}
|
||||
b.textContent = t('stops.busPrefix') + ' ' + n;
|
||||
row.appendChild(b);
|
||||
});
|
||||
@@ -193,44 +219,67 @@
|
||||
return li;
|
||||
}
|
||||
|
||||
function renderStops(stops, host) {
|
||||
/* ---------- สร้างการ์ดแบบทยอย (lazy) ----------
|
||||
- สร้าง "ทุกใบ" เป็น <li> เปล่า (มี data-idx) เพื่อให้ตัวกรอง/นับผลทำงานถูกต้องทันที
|
||||
- โหลดรูป + เนื้อหา "เฉพาะใบที่มองเห็น" → เปิดหน้าเร็ว (ไม่ยิง 154 รูปพร้อมกัน)
|
||||
- ใบที่ยังไม่โหลด: ใส่ที่กันที่ว่างชั่วคราว แล้วโหลดเมื่อถูกเรียก (แสดงทั้งหมด / ค้นหาเจอ) */
|
||||
var CARD_STUB = '<div class="mu-stop-card is-stub" aria-hidden="true"></div>';
|
||||
|
||||
function renderStops(stops, host, routeIds) {
|
||||
host.innerHTML = '';
|
||||
if (!stops.length) {
|
||||
var empty = document.createElement('li');
|
||||
empty.className = 'mu-stop-empty';
|
||||
empty.textContent = t('stops.noResult');
|
||||
host.appendChild(empty);
|
||||
return;
|
||||
return Promise.resolve();
|
||||
}
|
||||
// โหลดรูปทีละใบ แล้วค่อยต่อการ์ด (รักษาลำดับ)
|
||||
var chain = Promise.resolve();
|
||||
stops.forEach(function (stop, idx) {
|
||||
chain = chain.then(function () {
|
||||
return resolveImage(stop.kilometer).then(function (url) {
|
||||
host.appendChild(buildCard(stop, url, idx));
|
||||
});
|
||||
});
|
||||
var li = document.createElement('li');
|
||||
li.setAttribute('data-idx', String(idx));
|
||||
li.innerHTML = CARD_STUB;
|
||||
host.appendChild(li);
|
||||
});
|
||||
return chain;
|
||||
if (window.StopsSearch && window.StopsSearch.apply) window.StopsSearch.apply(); /* ให้ตัวกรองนับ/แสดงผลทันที */
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
/* โหลดเนื้อหาการ์ดจริงของใบนั้น (เรียกครั้งเดียวต่อใบ) */
|
||||
function hydrateCard(li, stops, routeIds) {
|
||||
if (!li || li.getAttribute('data-loaded')) return Promise.resolve();
|
||||
var idx = parseInt(li.getAttribute('data-idx'), 10);
|
||||
if (isNaN(idx) || !stops[idx]) return Promise.resolve();
|
||||
li.setAttribute('data-loaded', '1');
|
||||
return resolveImage(stops[idx]).then(function (url) {
|
||||
var built = buildCard(stops[idx], url, idx, routeIds); /* buildCard คืน <li> ของมันเอง */
|
||||
li.innerHTML = '';
|
||||
while (built.firstChild) li.appendChild(built.firstChild); /* ย้ายเนื้อหาเข้ามา — ห้ามซ้อน <li> */
|
||||
});
|
||||
}
|
||||
|
||||
var STATE = { stops: [], routeIds: [] }; /* ให้โมดูลอื่น (search) เรียก hydrateCard ได้ */
|
||||
|
||||
/* ---------- init ---------- */
|
||||
function init() {
|
||||
var host = document.getElementById('stops-list');
|
||||
if (!host) return;
|
||||
|
||||
fetchJSON(DATA_URL).then(function (data) {
|
||||
Promise.all([fetchJSON(DATA_URL), fetchJSON(ROUTES_URL)]).then(function (res) {
|
||||
var data = res[0], routesDoc = res[1] || {};
|
||||
var stops = Array.isArray(data) ? data : (data && data.stops) || [];
|
||||
var routeIds = (routesDoc.routes || []).map(function (r) { return String(r.route_id); });
|
||||
if (!stops.length) {
|
||||
host.innerHTML = '<li class="mu-stop-empty">' + t('stops.noResult') + '</li>';
|
||||
return;
|
||||
}
|
||||
renderKpi(stops);
|
||||
STATE.stops = stops;
|
||||
STATE.routeIds = routeIds;
|
||||
// ผูก event ก่อน render การ์ด — กันเคสที่ render ค้างแล้วปุ่มไม่ตอบสนอง
|
||||
if (window.StopsSearch) window.StopsSearch.init(stops);
|
||||
renderStops(stops, host).then(function () {
|
||||
// การ์ดพร้อมแล้ว → ให้ search module กรองซ้ำครั้งแรก
|
||||
renderStops(stops, host, routeIds).then(function () {
|
||||
if (window.StopsSearch) window.StopsSearch.init(stops);
|
||||
if (window.StopsSearch && window.StopsSearch.hydrateVisible) window.StopsSearch.hydrateVisible();
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -242,5 +291,9 @@
|
||||
}
|
||||
|
||||
// เปิดให้ search module ใช้ helper ร่วมกัน
|
||||
window.StopsRender = { pad5: pad5, PLACEHOLDER: PLACEHOLDER };
|
||||
window.StopsRender = {
|
||||
pad5: pad5,
|
||||
PLACEHOLDER: PLACEHOLDER,
|
||||
hydrate: function (li) { return hydrateCard(li, STATE.stops, STATE.routeIds); }
|
||||
};
|
||||
})();
|
||||
@@ -19,6 +19,7 @@
|
||||
stops: [],
|
||||
codeValue: '',
|
||||
placeQuery: '',
|
||||
showAll: false, /* false = แสดง 6 ใบแรก · true = แสดงป้ายทั้งหมด */
|
||||
bound: false
|
||||
};
|
||||
|
||||
@@ -36,6 +37,7 @@
|
||||
ช่องที่ยังไม่กรอก → ถือเป็น 0 (เช่น "3" + "_" → "03+000")
|
||||
เก็บเป็น digits[] ความยาว 5 เสมอ */
|
||||
|
||||
var PREVIEW_LIMIT = 6; /* แสดง 6 ใบแรก (กดปุ่มเพื่อดูทั้งหมด) */
|
||||
var CODE_CELLS = 5; // 2 หน้า + 3 หลัง
|
||||
|
||||
/* digits[] (5 หลัก) → "03+000" */
|
||||
@@ -148,15 +150,19 @@
|
||||
var f = currentFilter();
|
||||
var filtered = state.stops.filter(function (s) { return f.fn(s, f.value); });
|
||||
|
||||
// อัปเดตการ์ดที่มีอยู่แล้วใน DOM (ไม่ยิง network ซ้ำ)
|
||||
var cards = host.querySelectorAll('li');
|
||||
/* จำกัด 6 ใบเมื่อ "ไม่ได้กรองอะไร" (เปิดหน้าปกติ) · ค้นหา/กรอง = แสดงผลทั้งหมดที่เจอ */
|
||||
var searching = !!f.value;
|
||||
var limit = (searching || state.showAll) ? filtered.length : PREVIEW_LIMIT;
|
||||
|
||||
var cards = [].filter.call(host.children, function (el) { return el.tagName === 'LI' && el.hasAttribute('data-idx'); });
|
||||
var shown = 0;
|
||||
Array.prototype.forEach.call(cards, function (li) {
|
||||
var idx = parseInt(li.getAttribute('data-idx'), 10);
|
||||
if (isNaN(idx)) return;
|
||||
var visible = filtered.indexOf(state.stops[idx]) !== -1;
|
||||
var pos = filtered.indexOf(state.stops[idx]);
|
||||
var visible = pos !== -1 && pos < limit;
|
||||
li.hidden = !visible;
|
||||
if (visible) shown++;
|
||||
if (visible) { shown++; if (window.StopsRender) window.StopsRender.hydrate(li); } /* โหลดรูปเฉพาะใบที่แสดง */
|
||||
});
|
||||
|
||||
// empty state
|
||||
@@ -173,12 +179,29 @@
|
||||
empty.hidden = true;
|
||||
}
|
||||
|
||||
// จำนวนผลลัพธ์
|
||||
// จำนวนผลลัพธ์ + ปุ่ม "แสดงป้ายทั้งหมด"
|
||||
var count = document.getElementById('stops-count');
|
||||
if (count) {
|
||||
count.textContent = t('stops.showing', { a: shown, b: state.stops.length });
|
||||
count.textContent = searching
|
||||
? t('stops.showing', { a: shown, b: filtered.length })
|
||||
: t('stops.showing', { a: shown, b: state.stops.length });
|
||||
count.hidden = false;
|
||||
}
|
||||
var more = document.getElementById('stops-show-all');
|
||||
if (more) {
|
||||
var left = filtered.length - shown;
|
||||
more.hidden = searching || state.showAll || left <= 0; /* กรองอยู่/แสดงครบแล้ว = ไม่ต้องมีปุ่ม */
|
||||
more.textContent = t('stops.showAll') + ' (' + filtered.length + ')';
|
||||
}
|
||||
}
|
||||
|
||||
/* โหลดเนื้อหาการ์ดของใบที่มองเห็น (เรียกหลัง render/กรอง) */
|
||||
function hydrateVisible() {
|
||||
var host = document.getElementById('stops-list');
|
||||
if (!host) return;
|
||||
[].forEach.call(host.children, function (li) {
|
||||
if (li.tagName === 'LI' && li.hasAttribute('data-idx') && !li.hidden && window.StopsRender) window.StopsRender.hydrate(li);
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------- สลับโหมด (หัวใจของการกันชน) ---------- */
|
||||
@@ -389,6 +412,16 @@
|
||||
// ช่องรหัส: 6-box → เด้งช่อง + เติม 0
|
||||
initCodeCells();
|
||||
|
||||
// ปุ่ม "แสดงป้ายทั้งหมด" — กดแล้วเลิกจำกัด 6 ใบ (ไม่กรองอะไรอยู่)
|
||||
var more = document.getElementById('stops-show-all');
|
||||
if (more) {
|
||||
more.addEventListener('click', function () {
|
||||
state.showAll = true;
|
||||
apply();
|
||||
hydrateVisible();
|
||||
});
|
||||
}
|
||||
|
||||
// ช่องชื่อ: debounce + suggest
|
||||
if (placeInput) {
|
||||
var timer = null;
|
||||
@@ -399,6 +432,7 @@
|
||||
state.placeQuery = v;
|
||||
renderSuggest();
|
||||
apply();
|
||||
hydrateVisible();
|
||||
}, 180);
|
||||
});
|
||||
placeInput.addEventListener('focus', renderSuggest);
|
||||
@@ -423,6 +457,7 @@
|
||||
var resetBtn = document.getElementById('stops-reset-btn');
|
||||
if (resetBtn) {
|
||||
resetBtn.addEventListener('click', function () {
|
||||
state.showAll = false; /* ล้างการค้นหา → กลับไปแสดง 6 ใบแรก */
|
||||
var cells = codeCells();
|
||||
Array.prototype.forEach.call(cells, function (c) { c.value = ''; });
|
||||
if (placeInput) placeInput.value = '';
|
||||
@@ -450,7 +485,7 @@
|
||||
setMode(MODE_CODE); // เริ่มที่โหมดรหัส
|
||||
}
|
||||
|
||||
window.StopsSearch = { init: init, setMode: setMode, formatCode: formatCode };
|
||||
window.StopsSearch = { init: init, setMode: setMode, formatCode: formatCode , hydrateVisible: hydrateVisible };
|
||||
|
||||
// ให้ i18n เรียก render ใหม่ได้ (ไม่บังคับ)
|
||||
window.addEventListener('langchange', function () {
|
||||
|
||||
@@ -94,11 +94,16 @@
|
||||
body.appendChild(none);
|
||||
}
|
||||
|
||||
/* มีอย่างน้อย 1 ทิศที่มีตารางจริงไหม — ถ้ามี ห้ามขึ้น "ยังไม่มีข้อมูล" ของทิศที่ว่าง
|
||||
(จุดเดียวมีได้หลายทิศ · ทิศว่างไม่ควรทำให้การ์ดที่ตารางขึ้นแล้วดูเหมือนไม่มีข้อมูล) */
|
||||
var hasAny = g.recs.some(function (x) { return (x.departure_times || []).length > 0; });
|
||||
|
||||
g.recs.forEach(function (r) {
|
||||
var times = (r.departure_times || []).slice();
|
||||
|
||||
/* ไม่มีเวลาเลย (เช่น สาย 999: departure_times = []) → บอกว่าไม่มีข้อมูล ไม่ต้องมีบรรทัดลอย */
|
||||
/* ทิศนี้ยังไม่มีเวลา → ข้ามไปเลยถ้าทิศอื่นมีการ์ดข้อมูลอยู่แล้ว */
|
||||
if (!times.length) {
|
||||
if (hasAny) return;
|
||||
var empty = document.createElement('p');
|
||||
empty.className = 'mu-stop-sub';
|
||||
empty.textContent = t('route.empty');
|
||||
@@ -106,15 +111,22 @@
|
||||
return;
|
||||
}
|
||||
|
||||
/* หัวแถว = ชื่อทิศ (dir_label) → ไม่มีค่อยใช้ dir_note → ไม่มีอีกค่อยบอกว่าอยู่ที่จุดนี้
|
||||
ทิศที่ไปคนละทางจากจุดเดียวกัน (ป่าโมกไปอ่างทอง / ป่าโมกไปอยุธยา) จึงแยกให้เห็นชัด */
|
||||
var sub = document.createElement('p');
|
||||
sub.className = 'mu-stop-sub';
|
||||
sub.innerHTML = r.direction_note
|
||||
? esc(r.direction_note) + ' <span class="mu-direction-tag">' + esc(t('check.direction')) + '</span>'
|
||||
: esc(t('check.atStop')) + ' ' + esc(g.name);
|
||||
if (r.dir_label) {
|
||||
sub.innerHTML = esc(r.dir_label) +
|
||||
(r.direction_note ? ' <span class="mu-direction-tag">' + esc(r.direction_note) + '</span>' : '');
|
||||
} else if (r.direction_note) {
|
||||
sub.innerHTML = esc(r.direction_note) + ' <span class="mu-direction-tag">' + esc(t('check.direction')) + '</span>';
|
||||
} else {
|
||||
sub.textContent = t('check.atStop') + ' ' + g.name;
|
||||
}
|
||||
body.appendChild(sub);
|
||||
|
||||
var grid = document.createElement('div');
|
||||
grid.className = 'mu-time-grid';
|
||||
grid.className = 'mu-time-grid' + (r.estimated ? ' is-est' : ''); /* เวลาที่คำนวณจากต้นทาง */
|
||||
var chips = [];
|
||||
times.forEach(function (tm) {
|
||||
var c = document.createElement('div');
|
||||
@@ -124,6 +136,18 @@
|
||||
chips.push(c);
|
||||
});
|
||||
body.appendChild(grid);
|
||||
if (r.estimated) {
|
||||
var est = document.createElement('p');
|
||||
est.className = 'mu-est-note';
|
||||
/* มาจากกฎ "จุดนี้ = เวลาจุดอ้างอิง ± n นาที" → บอกจุดอ้างอิง + เตือนเรื่องการจราจร */
|
||||
est.textContent = r.estimateFrom && window.Schedules.offsetLabel
|
||||
? t('time.derived', {
|
||||
base: r.estimateFrom.name || ('#' + r.estimateFrom.station_id),
|
||||
n: Schedules.offsetLabel(r.estimateFrom.offsetMin)
|
||||
})
|
||||
: t('time.estimated');
|
||||
body.appendChild(est);
|
||||
}
|
||||
sections.push({ chips: chips, times: times, station: g.name });
|
||||
|
||||
if (r.schedule_note) {
|
||||
@@ -188,11 +212,12 @@
|
||||
Promise.all([
|
||||
fetchJSON(DATA + 'routes.json'),
|
||||
fetchJSON(DATA + 'stations.json'),
|
||||
fetchJSON(DATA + 'schedules.json')
|
||||
Schedules.load().then(function (sd) { return Schedules.normSub(sd); })
|
||||
]).then(function (res) {
|
||||
var routes = (res[0] || {}).routes || [];
|
||||
var sts = (res[1] || {}).stations || [];
|
||||
var recs = (res[2] || {}).schedules || res[2] || [];
|
||||
if (window.Schedules && Schedules.setStationNames) Schedules.setStationNames(sts); /* ให้ข้อความ "คำนวณจาก ..." มีชื่อจุด */
|
||||
var recs = window.Schedules ? Schedules.records(res[2]) : ((res[2] || {}).schedules || res[2] || []);
|
||||
if (!routes.length) return;
|
||||
|
||||
var route = routes.filter(function (r) { return String(r.route_id) === want; })[0] ||
|
||||
@@ -225,6 +250,9 @@
|
||||
|
||||
/* จัดกลุ่มตามลำดับจุดจอดของสาย แล้วต่อด้วยจุดที่เหลือ (ถ้ามีข้อมูล) */
|
||||
var order = (route.station_ids || []).slice();
|
||||
/* schema 2: ใช้ station_order ที่ตรวจทิศทางมาแล้วจากไฟล์ (ถ้ามี) */
|
||||
var sched = window.Schedules ? Schedules.route(res[2], rid) : null;
|
||||
if (sched && sched.station_order.length) order = sched.station_order.slice();
|
||||
recs.forEach(function (r) {
|
||||
if (String(r.route_id) === rid && order.indexOf(r.station_id) === -1) order.push(r.station_id);
|
||||
});
|
||||
@@ -249,9 +277,28 @@
|
||||
var desc = $('check-zone-desc');
|
||||
if (desc) {
|
||||
var names = groups.map(function (g) { return g.name; });
|
||||
/* บอกว่า "ตารางวันนี้" เป็นของวันไหน — เฉพาะสายที่มีการแยกตารางตามวัน (service) เท่านั้น
|
||||
สายอื่นข้อความเหมือนเดิมทุกตัวอักษร */
|
||||
/* ป้ายบอกว่า "ตารางที่เห็นอยู่นี้เป็นของวันไหน" — ใช้ผลตรวจวันจากตัวอ่านกลาง (ไม่คำนวณเองในหน้านี้) */
|
||||
var dayLine = '';
|
||||
if (window.Schedules && Schedules.dayInfo && Schedules.directions) {
|
||||
var di = Schedules.dayInfo();
|
||||
var infos = (Schedules.directions(res[2], rid) || []).map(function (d) { return d.service || { from: 'ไม่ระบุ' }; });
|
||||
var conflict = infos.some(function (x) { return x.conflict; }); /* ทิศเดียวมีทั้งวันทำงาน+วันหยุด */
|
||||
var unknown = infos.some(function (x) { return x.unknown; }); /* ยังไม่ระบุวันเลย */
|
||||
var selectedByDay = infos.some(function (x) { return x.from === 'service' || x.from === 'ระบุตรง' || x.from === 'คำในโน้ต'; });
|
||||
if (unknown) {
|
||||
dayLine = ' · ' + t('check.dayUnknown');
|
||||
} else if (conflict) {
|
||||
dayLine = ' · ' + t('check.dayMixed');
|
||||
} else if (selectedByDay) {
|
||||
dayLine = ' · ' + t(di.dayType === 'holiday' ? 'check.dayHoliday' : 'check.dayWeekday') +
|
||||
' (' + t('check.dayOfWeek') + ' ' + di.weekday_th + ')';
|
||||
}
|
||||
}
|
||||
desc.textContent = 'สาย ' + rid + ' · ' +
|
||||
(names.length > 1 ? names[0] + ' \u2192 ' + names[names.length - 1] + ' · ' : '') +
|
||||
groups.length + ' ' + t('check.stopsCount');
|
||||
groups.length + ' ' + t('check.stopsCount') + dayLine;
|
||||
}
|
||||
|
||||
/* KPI */
|
||||
|
||||
@@ -51,57 +51,10 @@
|
||||
<p class="src">ใบอนุญาต: Leaflet <a href="https://github.com/Leaflet/Leaflet/blob/main/LICENSE" rel="noopener">BSD-2-Clause</a> · ชุดแผนที่ (tiles): <a href="https://www.openstreetmap.org/copyright" rel="noopener">OpenStreetMap © ผู้มีส่วนร่วม (ODbL)</a></p>
|
||||
<ul>
|
||||
<li>Leaflet — ไลบรารีแผนที่แบบ open-source</li>
|
||||
<li>OpenStreetMap — ข้อมูลแผนที่และภาพ tiles</li>
|
||||
<li>ในเวอร์ชัน mockup นี้ใช้ภาพแผนที่จำลอง (mock map) เพื่อการแสดงผลก่อนเชื่อมต่อข้อมูลจริง</li>
|
||||
<li>OpenStreetMap — ภาพ tiles และข้อมูลแผนที่ที่ใช้แสดงผล</li>
|
||||
<li>เส้นทางเดินรถ จุดจอด และหมุดสถานี วาดจากข้อมูล GIS ของทีม (<code>GeoJSON</code>) ทับบนแผนที่</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section class="mu-credit-section">
|
||||
<h2><span data-i18n="credits.images">รูปภาพประกอบ</span></h2>
|
||||
<p class="src">โฟลเดอร์ <code>.image/</code> — ภาพตัวอย่าง (placeholder) สำหรับพัฒนา mockup</p>
|
||||
<ul>
|
||||
<li><strong>ภาพเส้นทาง/รถ</strong> (<code>routes/</code>) — ภาพตัวอย่างสำหรับแสดงการ์ดสายรถ รอแทนที่ด้วยภาพจริง</li>
|
||||
<li><strong>ภาพจุดสังเกต</strong> (<code>landmarks/</code>) — วัด ตลาด ริมน้ำ ฯลฯ ใช้เป็นภาพตัวอย่าง</li>
|
||||
<li><strong>ภาพแผนที่เครือข่าย</strong> (<code>network/overview-map.png</code>) — แผนที่ตัวอย่าง</li>
|
||||
<li><strong>QR code</strong> (<code>qrcode/</code>) — รหัส QR ของสายรถแต่ละสาย</li>
|
||||
<li><strong>โลโก้ minibus</strong> (<code>icons/</code>) — โลโก้และ favicon ของเว็บ</li>
|
||||
<li><strong>maintheme.png</strong> — ภาพดีไซน์ต้นแบบ (theme reference) ของโปรเจกต์</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section class="mu-credit-section">
|
||||
<h2><span data-i18n="credits.logos">โลโก้ผู้สนับสนุนและพาร์ทเนอร์</span></h2>
|
||||
<p class="src">โฟลเดอร์ <code>.image/partners/</code> — โลโก้เป็นเครื่องหมายการค้าของบริษัทเจ้าของแต่ละราย</p>
|
||||
<ul>
|
||||
<li>7-Eleven, Shopee, Lazada, airasia MOVE, busonlineticket, Trip.com, truck2hand, ทีซีแอล 999 อ่างทอง, รถบัสปิ่นเกล้า</li>
|
||||
<li>โลโก้เหล่านี้ใช้เพื่อแสดงรายชื่อผู้สนับสนุน/พันธมิตรเท่านั้น สิทธิ์ทั้งหมดเป็นของเจ้าของ</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section class="mu-credit-section">
|
||||
<h2><span data-i18n="credits.data">ข้อมูลการเดินรถ</span></h2>
|
||||
<ul>
|
||||
<li>ข้อมูลเส้นทาง ตารางเวลา และจุดจอด อ้างอิงจากข้อมูลผู้ประกอบการรถโดยสารและสถานีขนส่งผู้โดยสาร (บขส.)</li>
|
||||
<li>ข้อมูลใน mockup นี้เป็น <strong>ข้อมูลตัวอย่าง</strong> (<code>resource/data/*.json</code>) สำหรับการพัฒนา — ยังไม่ใช่ข้อมูลจริงที่อัปเดตล่าสุด</li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section class="mu-credit-section">
|
||||
<h2><span data-i18n="credits.pwa">โหมดออฟไลน์ (PWA / Service Worker)</span></h2>
|
||||
<p class="src">พัฒนาโดยทีม Atroute — ไม่ใช้ไลบรารีภายนอก</p>
|
||||
<ul>
|
||||
<li>เว็บนี้เป็น Progressive Web App — ติดตั้งได้ (Add to Home Screen) และเปิดใช้งานได้เมื่อไม่มีอินเทอร์เน็ต</li>
|
||||
<li>อัปเดตเนื้อหาอัตโนมัติ: เมื่อเปิดเว็บ ระบบจะตรวจสอบเวอร์ชันใหม่และโหลดให้เอง — ผู้ใช้ไม่ต้องล้างแคช</li>
|
||||
<li>ไฟล์ที่เกี่ยวข้อง: <code>ui/sw.js</code>, <code>ui/pwa.js</code>, <code>ui/manifest.json</code></li>
|
||||
</ul>
|
||||
</section>
|
||||
|
||||
<section class="mu-credit-section">
|
||||
<h2><span data-i18n="credits.notes">หมายเหตุ</span></h2>
|
||||
<ul>
|
||||
<li>เว็บนี้เป็นต้นแบบ (prototype) สำหรับพัฒนาเว็บข้อมูลการเดินรถของสถานีขนส่งผู้โดยสารจังหวัดอ่างทอง</li>
|
||||
<li>หากใช้ทรัพยากรใดผิดข้อกำหนดของเจ้าของ กรุณาแจ้งทีมพัฒนาเพื่อแก้ไขทันที</li>
|
||||
</ul>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
+10
-11
@@ -86,12 +86,6 @@
|
||||
stationSelect.innerHTML = '';
|
||||
var list = stationsFor(provinceId);
|
||||
|
||||
/* ตัวเลือกแรก = ทุกสถานีในจังหวัด (ค่าเริ่มต้น → แสดงทุกสาย) */
|
||||
var all = document.createElement('option');
|
||||
all.value = '';
|
||||
all.textContent = tr('home.allStations');
|
||||
stationSelect.appendChild(all);
|
||||
|
||||
list.forEach(function (st) {
|
||||
var opt = document.createElement('option');
|
||||
opt.value = st.station_code; /* ใช้รหัสสถานี = ลิงก์สั้น อ่านง่าย */
|
||||
@@ -100,8 +94,11 @@
|
||||
});
|
||||
|
||||
if (!list.length) {
|
||||
all.textContent = tr('home.stationEmpty');
|
||||
all.disabled = true;
|
||||
var none = document.createElement('option'); /* ไม่มีสถานีในจังหวัดนี้ → บอกด้วยตัวเลือกว่าง */
|
||||
none.value = '';
|
||||
none.textContent = tr('home.stationEmpty');
|
||||
none.disabled = true;
|
||||
stationSelect.appendChild(none);
|
||||
if (stationHint) stationHint.textContent = tr('home.stationEmptyHint') + ' ' + provinceName(provinceId);
|
||||
} else if (stationHint) {
|
||||
stationHint.innerHTML = tr('home.stationCount', { n: list.length }) + ' ' + provinceName(provinceId);
|
||||
@@ -109,7 +106,9 @@
|
||||
|
||||
/* คืนค่าที่เลือกไว้ (จากลิงก์) ถ้ามีในจังหวัดนี้ */
|
||||
if (preferredCode && list.some(function (s) { return s.station_code === preferredCode; })) {
|
||||
stationSelect.value = preferredCode;
|
||||
stationSelect.value = preferredCode; /* จากลิงก์แชร์ (?s=) */
|
||||
} else if (list.length) {
|
||||
stationSelect.value = list[0].station_code; /* ไม่มีตัวเลือก "ทุกสถานี" แล้ว → เลือกสถานีแรก */
|
||||
} else {
|
||||
stationSelect.value = '';
|
||||
}
|
||||
@@ -200,12 +199,12 @@
|
||||
fetchJSON(DATA_URL.routeGroups),
|
||||
fetchJSON(DATA_URL.routes),
|
||||
fetchJSON(DATA_URL.routesMunicipal),
|
||||
fetchJSON(DATA_URL.schedules)
|
||||
(window.Schedules ? Schedules.load().then(function (sd) { return Schedules.normSub(sd); }) : fetchJSON(DATA_URL.schedules))
|
||||
]).then(function (res) {
|
||||
var groups = ((res[0] || {}).route_groups) || [];
|
||||
var routes = ((res[1] || {}).routes) || [];
|
||||
var municipal = ((res[2] || {}).routes) || [];
|
||||
var recs = (res[3] || {}).schedules || res[3] || [];
|
||||
var recs = window.Schedules ? Schedules.records(res[3]) : ((res[3] || {}).schedules || res[3] || []);
|
||||
if (!groups.length || !routes.length) return;
|
||||
|
||||
/* รวมเส้นทางหมวดเทศบาลจากไฟล์แยก (ข้ามแถวที่ยังไม่ได้กรอก) */
|
||||
|
||||
@@ -0,0 +1,151 @@
|
||||
/* ============================================================
|
||||
otherStop.js — ตัวอ่าน '8 other_stop.json' (ใช้ร่วมทุกหน้า)
|
||||
|
||||
ทำไมต้องมี: จุดจอด station_id 8 คือ "จุดขึ้นรถประจำทางอื่นๆ" ซึ่งเป็นชื่อรวม ๆ
|
||||
ของทุกสาย — ตัวจริงของแต่ละสายอยู่ใน '8 other_stop.json' เช่น
|
||||
|
||||
{ "route_id": "1101", "station_name_th": "วัดสีบัวทอง", ... } ← 1101 คือสาย 1011
|
||||
|
||||
ไฟล์นี้จึงต้อง "จับคู่ route id" ก่อน แล้วค่อยเอาชื่อ/พิกัดจริงของสายนั้นไปแสดง
|
||||
(เช่น หน้าป้ายต้องขึ้น "จุดขึ้นรถประจำทางอื่นๆ · วัดสีบัวทอง")
|
||||
|
||||
API:
|
||||
OtherStop.load() → Promise<entry[]> (โหลดครั้งเดียวแล้ว cache)
|
||||
OtherStop.fileRouteId(entry) → รหัสสายตามที่เขียนในไฟล์
|
||||
OtherStop.resolve(fileRouteId, validIds) → { id, alias } | null
|
||||
OtherStop.forRoute(entries, routeId, validIds) → entry | null
|
||||
OtherStop.forStation(entries, station, routeId, validIds) → entry | null
|
||||
OtherStop.stopsOf(entry) → [{ name, lat, lng, hasCoord, city_th, province_th, index }]
|
||||
OtherStop.firstName(entry) → ชื่อจุดแรก (ใช้เป็นชื่อย่อของสาย)
|
||||
OtherStop.allStops(entries, routeId, validIds) → รายการจุดจริง "ทุกจุด" ของสายนั้น
|
||||
· แต่ละจุดมี offsetMin = นาทีจากจุดแรก (ถ้าไฟล์ใส่ "offsets_min") → ใช้คำนวณเวลาของจุดนั้นได้
|
||||
· ฟิลด์ในไฟล์: station_name_th[], latitude[], longitude[], offsets_min[] (จับคู่ตามลำดับ)
|
||||
============================================================ */
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var URL = '../resource/data/8%20other_stop.json';
|
||||
var cache = null;
|
||||
|
||||
/* โหลดครั้งเดียว — คืน promise เดิมซ้ำ (ไม่ยิง fetch ซ้ำทุกหน้า) */
|
||||
function load() {
|
||||
if (cache) return cache;
|
||||
cache = fetch(URL, { cache: 'no-store' })
|
||||
.then(function (r) { return r.ok ? r.json() : null; })
|
||||
.then(function (d) { return (d && d.other_stop) || []; })
|
||||
.catch(function () { return []; });
|
||||
return cache;
|
||||
}
|
||||
|
||||
function fileRouteId(entry) {
|
||||
return String((entry && entry.route_id) != null ? entry.route_id : '');
|
||||
}
|
||||
|
||||
/* เทียบรหัสสายแบบ "ทนรหัสเพี้ยน": 1101 → 1011 (ตัวเลขชุดเดียวกัน สลับตำแหน่ง)
|
||||
ใช้เฉพาะเมื่อรหัสในไฟล์ "ไม่มีจริง" ใน routes.json และหาคู่ได้ไม่กำกวม (1 ตัวเท่านั้น) */
|
||||
function sameDigits(a, b) {
|
||||
var na = String(a).replace(/\D/g, ''), nb = String(b).replace(/\D/g, '');
|
||||
if (!na || na.length !== nb.length) return false;
|
||||
return na.split('').sort().join('') === nb.split('').sort().join('');
|
||||
}
|
||||
|
||||
function resolve(fid, validIds) {
|
||||
var want = String(fid);
|
||||
var valid = (validIds || []).map(String);
|
||||
if (valid.indexOf(want) !== -1) return { id: want, alias: false };
|
||||
/* เทียบแบบสลับตำแหน่ง (1101 → 1011) เฉพาะรหัสยาว ≥3 หลัก
|
||||
— รหัสสั้นอย่าง "51"/"15" มีโอกาสสลับกันได้จริง → ไม่เดา */
|
||||
var digits = want.replace(/\D/g, '');
|
||||
if (digits.length < 3) return null;
|
||||
var cands = valid.filter(function (v) { return sameDigits(v, want); });
|
||||
if (cands.length === 1) return { id: cands[0], alias: true };
|
||||
return null; /* ไม่รู้จัก หรือกำกวม → ไม่เดา */
|
||||
}
|
||||
|
||||
function forRoute(entries, routeId, validIds) {
|
||||
var want = String(routeId);
|
||||
var hit = (entries || []).filter(function (e) { return fileRouteId(e) === want; })[0];
|
||||
if (hit) return hit;
|
||||
/* ถ้ายังไม่เจอ → หา entry ที่รหัสในไฟล์หมายถึงสายนี้ (เช่น 1101 → 1011) */
|
||||
var found = null;
|
||||
(entries || []).forEach(function (e) {
|
||||
if (found) return;
|
||||
var r = resolve(fileRouteId(e), validIds);
|
||||
if (r && r.id === want) found = e;
|
||||
});
|
||||
return found;
|
||||
}
|
||||
|
||||
/* ทุก entry ที่หมายถึงสายนี้ (สายเดียวมีได้หลายจุดจริง) */
|
||||
function forRouteAll(entries, routeId, validIds) {
|
||||
var want = String(routeId);
|
||||
return (entries || []).filter(function (e) {
|
||||
if (fileRouteId(e) === want) return true;
|
||||
var r = resolve(fileRouteId(e), validIds);
|
||||
return !!(r && r.id === want);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/* ---------- แตก entry → รายการ "จุดจริง" ของสายนั้น ----------
|
||||
กติกาข้อมูล (เจ้าของข้อมูลกำหนด):
|
||||
· station_name_th เป็นได้ทั้งข้อความเดียว หรือรายการหลายชื่อ (เช่น 954 = 4 จุด)
|
||||
· latitude/longitude เป็นได้ทั้งตัวเลขเดียว หรือรายการ — จับคู่กับชื่อ "ตามลำดับ"
|
||||
· "พิกัดเป็นของชื่อแรก" → ถ้ามีพิกัดเดียว ชื่อที่ 2 เป็นต้นไป = ยังไม่มีพิกัด (ไม่เดา) */
|
||||
function num(v) { var n = parseFloat(v); return isNaN(n) ? null : n; }
|
||||
function stopsOf(entry) {
|
||||
if (!entry) return [];
|
||||
var names = [].concat(entry.station_name_th == null ? [] : entry.station_name_th)
|
||||
.map(function (x) { return String(x == null ? '' : x).trim(); })
|
||||
.filter(Boolean);
|
||||
var lats = [].concat(entry.latitude == null ? [] : entry.latitude);
|
||||
var lngs = [].concat(entry.longitude == null ? [] : entry.longitude);
|
||||
var offs = [].concat(entry.offsets_min == null ? [] : entry.offsets_min); /* นาทีจากจุดแรก (0 = จุดแรกเอง) */
|
||||
return names.map(function (name, i) {
|
||||
var lat = num(lats[i]), lng = num(lngs[i]);
|
||||
return {
|
||||
index: i,
|
||||
name: name,
|
||||
/* city/province ในไฟล์อธิบาย "จุดแรก" — จุดอื่นไม่ทราบ ไม่เดา */
|
||||
city_th: i === 0 ? (entry.city_th || null) : null,
|
||||
province_th: i === 0 ? (entry.province_th || null) : null,
|
||||
station_type: entry.station_type || null,
|
||||
note: entry.note || null,
|
||||
lat: lat, lng: lng,
|
||||
offsetMin: num(offs[i]), /* ระยะเวลาจากจุดแรก (นาที) — ไม่ใส่ = ไม่ทราบ */
|
||||
hasCoord: lat != null && lng != null,
|
||||
entry: entry
|
||||
};
|
||||
});
|
||||
}
|
||||
function firstName(entry) { var st = stopsOf(entry)[0]; return st ? st.name : null; }
|
||||
function allStops(entries, routeId, validIds) {
|
||||
var out = [];
|
||||
forRouteAll(entries, routeId, validIds).forEach(function (e) { out = out.concat(stopsOf(e)); });
|
||||
return out;
|
||||
}
|
||||
|
||||
/* ใช้กับ "สถานี 8" (จุดขึ้นรถประจำทางอื่นๆ) เท่านั้น */
|
||||
function isOtherStop(station) {
|
||||
if (!station) return false;
|
||||
return String(station.station_code) === 'other_stop' || Number(station.station_id) === 8;
|
||||
}
|
||||
|
||||
function forStation(entries, station, routeId, validIds) {
|
||||
if (!isOtherStop(station)) return null;
|
||||
return forRoute(entries, routeId, validIds);
|
||||
}
|
||||
|
||||
window.OtherStop = {
|
||||
load: load,
|
||||
fileRouteId: fileRouteId,
|
||||
resolve: resolve,
|
||||
forRoute: forRoute,
|
||||
forRouteAll: forRouteAll,
|
||||
isOtherStop: isOtherStop,
|
||||
forStation: forStation,
|
||||
stopsOf: stopsOf,
|
||||
firstName: firstName,
|
||||
allStops: allStops
|
||||
};
|
||||
})();
|
||||
@@ -0,0 +1,618 @@
|
||||
/* ============================================================
|
||||
schedules.js — ตัวอ่านข้อมูลตารางเวลา (ใช้ร่วมทุกหน้า)
|
||||
|
||||
***APIs นี้ไม่เปลี่ยนชื่อ/รูปเดิม*** — หน้า check/busDetail/home/stopDetail เรียกเหมือนเดิม
|
||||
ที่เพิ่มเข้ามาคือ "สมองเรื่องวันทำงาน/วันหยุด" ซึ่งทำงานอยู่ในไฟล์นี้ที่เดียว
|
||||
|
||||
รองรับ schedules.json 2 รูปแบบ:
|
||||
schema 1 (เดิม): { "schedules": [ { route_id, station_id, direction_note, departure_times[], schedule_note } ] }
|
||||
schema 2 (ใหม่): { "schema": 2, "routes": [ { route_id, station_order[], directions: [
|
||||
{ dir_id, dir_label, service?, stops: [ { station_id, times[], dir_note?, note?, groups? } ] } ] } ] }
|
||||
|
||||
── เรื่องวันทำงาน / วันหยุด (ไม่ต้องแก้โค้ดหน้าไหนเลย) ────────────────
|
||||
เพิ่มฟิลด์ "ไม่บังคับ" 2 ระดับ:
|
||||
1) ระดับทิศทาง: "service": "all" | "weekday" | "holiday"
|
||||
- ทั้งทิศทางใช้เฉพาะวันนั้น (เช่น ทิศ 'ตารางวันหยุด' → service: "holiday")
|
||||
- ไม่ใส่ = "all" (ทุกวัน) → ไฟล์เดิมไม่ต้องแก้อะไร พฤติกรรมเหมือนเดิมเป๊ะ
|
||||
2) ระดับจุดจอด: "groups": [ { "label": "วันหยุด", "dayType": "holiday", "times": ["10:00"] } ]
|
||||
- เวลาที่ "เพิ่มเข้ามาเฉพาะบางวัน" (ตรงกับโน้ตเดิม เช่น "10:00 มีเฉพาะวันหยุด")
|
||||
- times[] ยังเป็นตารางพื้นฐานที่ใช้ทุกวัน
|
||||
|
||||
ค่าเริ่มต้น: ตรวจจากวันที่ของเครื่องเอง (เสาร์–อาทิตย์ = วันหยุด + วันนักขัตฤกษ์จาก holidays.json)
|
||||
ความปลอดภัย: ถ้ากรองตามวันแล้วไม่เหลือทิศทางใดเลย → ถอยไปใช้ทั้งหมด + ติดธง fallback (หน้าเว็บไม่ว่าง)
|
||||
|
||||
API:
|
||||
Schedules.records(doc, opts) → record แบน (schema เดิม) สำหรับโค้ดเดิม
|
||||
Schedules.route(doc, routeId, opts) → { route_id, station_order[], directions[], entries[] }
|
||||
Schedules.directions(doc, routeId, opts) → [{ dir_id, dir_label, service, dayType, fallback, stops[] }]
|
||||
Schedules.times(doc, routeId, opts) → เวลาทั้งหมดของสาย (เรียงแล้ว)
|
||||
Schedules.countTrips(doc, routeId, opts) → จำนวนเที่ยวของสาย
|
||||
Schedules.todayType() → 'weekday' | 'holiday'
|
||||
Schedules.dayInfo(date) → { dayType, label_th, date }
|
||||
Schedules.ready → promise (โหลด holidays.json เสร็จ)
|
||||
opts ที่รับได้: { dayType: 'all' | 'weekday' | 'holiday' } (ไม่ส่ง = ตรวจจากวันนี้)
|
||||
============================================================ */
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var DATA_URL = '../resource/data/';
|
||||
var HOLIDAYS = [];
|
||||
var ALIAS = { weekend: 'holiday', 'sat-sun': 'holiday', saturday: 'holiday', sunday: 'holiday', workday: 'weekday', weekday: 'weekday', holiday: 'holiday', all: 'all' };
|
||||
|
||||
/* ความเร็วเฉลี่ยตั้งต้นสำหรับคำนวณเวลาจุดที่ไม่มีตาราง (ปรับต่อทิศได้ด้วย "speedKmh") */
|
||||
var DEFAULT_SPEED_KMH = 40;
|
||||
|
||||
function pad2(n) { return (n < 10 ? '0' : '') + n; }
|
||||
function toMin(hhmm) {
|
||||
var a = String(hhmm).split(':');
|
||||
var h = parseInt(a[0], 10), m = parseInt(a[1], 10);
|
||||
return (isNaN(h) ? 0 : h) * 60 + (isNaN(m) ? 0 : m);
|
||||
}
|
||||
|
||||
/* คำนวณเวลาของจุดที่ไม่มีตาราง จากจุดที่มีเวลาแล้วซึ่งอยู่ใกล้ที่สุดตามระยะทาง (กม.)
|
||||
คืน null เมื่อคำนวณไม่ได้ (ไม่มี กม. หรือไม่มีจุดอ้างอิง) */
|
||||
function computeTimes(stop, siblings, opts) {
|
||||
var o = (typeof opts === 'number') ? { speedKmh: opts } : (opts || {});
|
||||
var speed = Number(o.speedKmh) > 0 ? Number(o.speedKmh) : DEFAULT_SPEED_KMH;
|
||||
if (!stop || typeof stop.km !== 'number') return null;
|
||||
var cands = siblings.filter(function (s) {
|
||||
return s !== stop && typeof s.km === 'number' && (s.times || []).length;
|
||||
});
|
||||
if (!cands.length) return null;
|
||||
var base = null;
|
||||
if (o.baseSid != null) { /* ผู้ใช้เลือกจุดอ้างอิงเอง (จากเครื่องมือแก้ไข) */
|
||||
base = cands.filter(function (s) { return String(s.station_id) === String(o.baseSid); })[0] || null;
|
||||
}
|
||||
if (!base && o.baseEnd === 'first') { /* ใช้เวลาจริงจากจุดต้นทาง (กม. น้อยสุด) */
|
||||
base = cands.reduce(function (a, b) { return a.km <= b.km ? a : b; });
|
||||
} else if (!base && o.baseEnd === 'last') { /* ใช้เวลาจริงจากจุดปลายทาง (กม. มากสุด) */
|
||||
base = cands.reduce(function (a, b) { return a.km >= b.km ? a : b; });
|
||||
} else if (!base) { /* อัตโนมัติ: จุดที่มีเวลาซึ่งใกล้ที่สุด */
|
||||
base = cands.reduce(function (a, b) { return Math.abs(b.km - stop.km) < Math.abs(a.km - stop.km) ? b : a; });
|
||||
}
|
||||
var delta = (stop.km - base.km) / speed * 60; /* นาที (+ ไปข้างหน้า, - ย้อนหลัง) */
|
||||
return base.times.map(function (t) {
|
||||
var tot = Math.round(toMin(t) + delta);
|
||||
tot = ((tot % 1440) + 1440) % 1440;
|
||||
return pad2(Math.floor(tot / 60)) + ':' + pad2(tot % 60);
|
||||
});
|
||||
}
|
||||
|
||||
/* ความเร็วที่ใช้จริงของทิศหนึ่ง ๆ: มาจาก travelMin (เวลาเดินทางทั้งเส้น) ถ้ามี ไม่งั้นใช้ speedKmh/ค่าตั้งต้น */
|
||||
function speedOf(dir) {
|
||||
if (Number(dir.travelMin) > 0) {
|
||||
var kms = (dir.stops || []).map(function (s) { return s.km; }).filter(function (x) { return typeof x === 'number'; });
|
||||
if (kms.length > 1) {
|
||||
var span = Math.max.apply(null, kms) - Math.min.apply(null, kms);
|
||||
if (span > 0) return { kmh: span / Number(dir.travelMin) * 60, span: span, source: 'travelMin' };
|
||||
}
|
||||
}
|
||||
return { kmh: Number(dir.speedKmh) > 0 ? Number(dir.speedKmh) : DEFAULT_SPEED_KMH, span: null, source: 'speedKmh' };
|
||||
}
|
||||
|
||||
function hasSchema2(doc) {
|
||||
return !!(doc && doc.schema === 2 && Array.isArray(doc.routes));
|
||||
}
|
||||
function normSub(doc) { /* เตรียมไฟล์ย่อยให้อยู่ในรูป { routes: [...] } */
|
||||
if (!doc) return null;
|
||||
if (doc.route_id != null && !Array.isArray(doc.routes)) {
|
||||
var dirs = isSchema3(doc) ? directionsFromSchema3(doc) : (doc.directions || []);
|
||||
return { schema: 2, routes: [{ route_id: doc.route_id, station_order: doc.station_order || [], directions: dirs }] };
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
|
||||
/* ---------- schema 3: { weekday:{directions:{...}}, holiday:{directions:{...}} } ----------
|
||||
โครงอ่านง่ายสำหรับเจ้าของข้อมูล (กลุ่มวัน → ทิศทาง) · แปลงเป็นทิศภายในให้ทุกหน้าใช้ต่อได้เหมือนเดิม
|
||||
กติกา: จุดที่ระบุเวลามา = จุดตั้งต้นของทิศนั้น · จุดอื่นใน station_order คำนวณจาก กม.+ความเร็ว (ถ้าเปิด autoTimes) */
|
||||
var DAYGROUP = { weekday: 'weekday', holiday: 'holiday' };
|
||||
function isSchema3(doc) { return !!(doc && doc.schema === 3 && (doc.weekday || doc.holiday)); }
|
||||
function directionsFromSchema3(doc) {
|
||||
var out = [];
|
||||
['weekday', 'holiday'].forEach(function (kind) {
|
||||
var grp = doc[kind];
|
||||
if (!grp || !grp.directions) return;
|
||||
Object.keys(grp.directions).forEach(function (name) {
|
||||
var src = grp.directions[name] || {};
|
||||
var times = (src.departures || src.times || []).slice();
|
||||
var from = (src.from_station_id != null) ? Number(src.from_station_id) : null;
|
||||
var stops = [];
|
||||
if (from != null && times.length) {
|
||||
stops.push({ station_id: from, times: times, dir_note: grp.label || null });
|
||||
} else if (from != null) {
|
||||
stops.push({ station_id: from, times: [], dir_note: grp.label || null });
|
||||
}
|
||||
out.push({
|
||||
dir_id: kind + ':' + name,
|
||||
dir_label: name,
|
||||
service: { day: kind, from: 'schema 3', matches: kind === todayType() },
|
||||
station_order: doc.station_order || [],
|
||||
stops: stops,
|
||||
/* จุดตั้งต้นมีเวลาแล้ว → ให้จุดอื่นคำนวณต่อจาก กม. เฉพาะเมื่อเปิด autoTimes */
|
||||
autoTimes: !!doc.autoTimes
|
||||
});
|
||||
});
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
/* ---------- ชื่อจุดจอด (สำหรับข้อความ "คำนวณจาก ...") ----------
|
||||
โหลดเบื้องหลังครั้งเดียว — ถ้ายังไม่ทัน ก็ถอยไปใช้รหัสจุดในข้อความ (ไม่พัง) */
|
||||
var STATION_NAMES = {};
|
||||
var namesWarmed = false;
|
||||
function warmStations() {
|
||||
if (namesWarmed) return;
|
||||
namesWarmed = true;
|
||||
fetch(DATA_URL + 'stations.json', { cache: 'no-store' })
|
||||
.then(function (r) { return r.ok ? r.json() : null; })
|
||||
.then(function (d) {
|
||||
((d && d.stations) || []).forEach(function (st) { STATION_NAMES[String(st.station_id)] = st.station_name_th; });
|
||||
})
|
||||
.catch(function () {});
|
||||
}
|
||||
function stationNameOf(id) { return STATION_NAMES[String(id)] || null; }
|
||||
/* หน้าเว็บที่โหลด stations.json อยู่แล้วส่งชื่อเข้ามาได้ → ข้อความหมายเหตุมีชื่อทันที (ไม่ต้องรอ fetch) */
|
||||
function setStationNames(list) {
|
||||
((list && list.stations) || list || []).forEach(function (st) {
|
||||
if (st && st.station_id != null) STATION_NAMES[String(st.station_id)] = st.station_name_th;
|
||||
});
|
||||
}
|
||||
/* เรียกทันทีตอนไฟล์ถูกโหลด — จะทันรอบเรนเดอร์แรก (ชื่อจุดอ้างอิงในข้อความ "คำนวณจาก ...") */
|
||||
warmStations();
|
||||
|
||||
/* ---------- เลื่อนเวลาเป็นนาที (กฎ derive: จุดนี้ = เวลาจุดอ้างอิง ± offset) ----------
|
||||
คืน HH:MM เรียงใหม่ · เกินเที่ยงคืน = วนกลับ (ไม่พัง) */
|
||||
function shiftTimes(times, offsetMin) {
|
||||
var off = Number(offsetMin) || 0;
|
||||
return (times || []).map(function (t) {
|
||||
var a = String(t).split(':');
|
||||
var m = (parseInt(a[0], 10) || 0) * 60 + (parseInt(a[1], 10) || 0) + off;
|
||||
m = ((m % 1440) + 1440) % 1440;
|
||||
var hh = Math.floor(m / 60), mm = m % 60;
|
||||
return (hh < 10 ? '0' : '') + hh + ':' + (mm < 10 ? '0' : '') + mm;
|
||||
}).sort();
|
||||
}
|
||||
/* ป้ายผลต่างเวลา เช่น +30 / −15 (ใช้ในข้อความหมายเหตุ) */
|
||||
function offsetLabel(min) {
|
||||
var n = Number(min) || 0;
|
||||
var sign = n < 0 ? '\u2212' : '+';
|
||||
return sign + Math.abs(n);
|
||||
}
|
||||
|
||||
/* ---------- เครื่องยนต์ตรวจวัน (จันทร์–อาทิตย์) ----------
|
||||
ทำงานที่ท่อกลางนี้ที่เดียว → ทุกหน้าได้ผลเหมือนกัน ไม่ต้องแก้โค้ดหน้าไหน
|
||||
ลำดับการตัดสิน:
|
||||
1) ถ้าทิศมี "days" ระบุตรง ๆ (อา จ อ พ พฤ ศ ส) → ใช้ตามนั้น (แม่นสุด)
|
||||
2) ถ้ามี service = weekday/holiday → เทียบกับวันนี้
|
||||
3) ถ้าไม่มีอะไรระบุ → อ่านคำใน dir_label / dir_note / note ของสายนั้น (ตรวจคำอัตโนมัติ)
|
||||
4) ตัดสินไม่ได้ → แสดงทุกวัน (ไม่ซ่อนข้อมูล) พร้อมป้ายว่า "ยังไม่ระบุวัน" */
|
||||
var DAYS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat']; /* ตรงกับ Date.getDay() */
|
||||
var DAY_TH = { sun: 'อาทิตย์', mon: 'จันทร์', tue: 'อังคาร', wed: 'พุธ', thu: 'พฤหัสบดี', fri: 'ศุกร์', sat: 'เสาร์' };
|
||||
var DAY_ABBR = { sun: 'อา', mon: 'จ', tue: 'อ', wed: 'พ', thu: 'พฤ', fri: 'ศ', sat: 'ส' };
|
||||
var DAY_ALIAS = { /* รับได้หลายชื่อ */
|
||||
weekday: 'weekday', workday: 'weekday', 'วันทำงาน': 'weekday', 'จ-ศ': 'weekday', 'จ–ศ': 'weekday',
|
||||
holiday: 'holiday', weekend: 'holiday', 'วันหยุด': 'holiday', 'ส-อา': 'holiday', 'ส–อา': 'holiday', 'เสาร์-อาทิตย์': 'holiday',
|
||||
all: 'all', ทุกวัน: 'all', daily: 'all'
|
||||
};
|
||||
var DAY_WORDS_HOLIDAY = ['วันหยุด', 'นักขัตฤกษ์', 'เสาร์-อาทิตย์', 'เสาร์–อาทิตย์', 'ส-อา', 'ส–อา', 'weekend', 'holiday'];
|
||||
var DAY_WORDS_WEEKDAY = ['วันทำงาน', 'วันธรรมดา', 'จ-ศ', 'จ–ศ', 'จันทร์ถึงศุกร์', 'weekday', 'workday'];
|
||||
|
||||
function ymd(d) {
|
||||
var m = d.getMonth() + 1, day = d.getDate();
|
||||
return d.getFullYear() + '-' + (m < 10 ? '0' : '') + m + '-' + (day < 10 ? '0' : '') + day;
|
||||
}
|
||||
function dayKey(date) { return DAYS[(date || new Date()).getDay()]; }
|
||||
function isHolidayDate(date, list) {
|
||||
var list_ = list || HOLIDAYS;
|
||||
if (list_.indexOf(ymd(date)) !== -1) return true; /* นักขัตฤกษ์ */
|
||||
var wd = (date.getDay() + 6) % 7; /* 0 = จันทร์ */
|
||||
return wd >= 5; /* เสาร์–อาทิตย์ = วันหยุด */
|
||||
}
|
||||
function dayTypeOf(date, list) { return isHolidayDate(date || new Date(), list) ? 'holiday' : 'weekday'; }
|
||||
function todayType(date) { return dayTypeOf(date); }
|
||||
function dayInfo(date) {
|
||||
var d = date || new Date();
|
||||
var t = dayTypeOf(d);
|
||||
return { dayType: t, weekday: DAYS[d.getDay()], weekday_th: DAY_TH[DAYS[d.getDay()]], date: ymd(d),
|
||||
label_th: t === 'holiday' ? 'วันหยุด (ส–อา/นักขัตฤกษ์)' : 'วันทำงาน (จ–ศ)' };
|
||||
}
|
||||
/* ตรวจคำในข้อความ (dir_label / dir_note / note) ว่าหมายถึงวันไหน */
|
||||
function detectDay(text) {
|
||||
var t = String(text == null ? '' : text).trim();
|
||||
if (!t) return null;
|
||||
var low = t.toLowerCase();
|
||||
var hitH = DAY_WORDS_HOLIDAY.filter(function (w) { return low.indexOf(w.toLowerCase()) !== -1; })[0];
|
||||
var hitW = DAY_WORDS_WEEKDAY.filter(function (w) { return low.indexOf(w.toLowerCase()) !== -1; })[0];
|
||||
if (hitH && !hitW) return { day: 'holiday', from: 'คำ', text: t };
|
||||
if (hitW && !hitH) return { day: 'weekday', from: 'คำ', text: t };
|
||||
return null; /* เจอทั้งคู่/ไม่เจอ = ไม่เดา */
|
||||
}
|
||||
/* รวบข้อความทั้งหมดของทิศ (label + โน้ตของทุกจุด) แล้วตรวจหา "วัน" ให้สอดคล้องกันทั้งทิศ
|
||||
คืน { day, from, text } หรือ null (ยังไม่ระบุ) */
|
||||
function detectDayOfDir(d) {
|
||||
var texts = [];
|
||||
if (d && d.dir_label) texts.push(d.dir_label);
|
||||
((d && d.stops) || []).forEach(function (s) {
|
||||
if (s.dir_note) texts.push(s.dir_note);
|
||||
if (s.note) texts.push(s.note);
|
||||
});
|
||||
var verdicts = [], conflicts = false, hasHol = false, hasWk = false, sample = null;
|
||||
texts.forEach(function (t) {
|
||||
var v = detectDay(t);
|
||||
if (!v) { return; }
|
||||
if (v.day === 'holiday') { hasHol = true; } else { hasWk = true; }
|
||||
verdicts.push(v); if (!sample) sample = v;
|
||||
});
|
||||
if (!verdicts.length) return null;
|
||||
if (hasHol && hasWk) { /* ทิศเดียวมีทั้งสองวัน */
|
||||
return { day: 'all', from: 'ปนกัน', text: sample.text, conflict: true };
|
||||
}
|
||||
return { day: verdicts[0].day, from: 'คำในโน้ต', text: sample.text };
|
||||
}
|
||||
/* วันนี้ตรงกับทิศนี้ไหม + บอกเหตุผล (ใช้แสดงบนหน้าเว็บได้) */
|
||||
function serviceOf(obj, dirForDetect) {
|
||||
if (obj && obj.days && obj.days.length) { /* ระบุวันตรง ๆ มาก่อน */
|
||||
return { day: 'custom', days: obj.days.map(String), from: 'ระบุตรง', matches: obj.days.map(String).indexOf(dayKey()) !== -1 };
|
||||
}
|
||||
var s = (obj && obj.service) ? String(obj.service).toLowerCase() : '';
|
||||
var alias = DAY_ALIAS[s] || (DAY_ALIAS[String(obj && obj.service)] || '');
|
||||
if (alias === 'weekday' || alias === 'holiday') {
|
||||
return { day: alias, from: 'service', matches: alias === todayType() };
|
||||
}
|
||||
if (alias === 'all') return { day: 'all', from: 'service', matches: true };
|
||||
var det = detectDayOfDir(dirForDetect || obj); /* ไม่ระบุ → ตรวจจากคำ */
|
||||
if (det) {
|
||||
if (det.day === 'all') return { day: 'all', from: det.from + ' (ปนกัน)', text: det.text, conflict: true, matches: true };
|
||||
return { day: det.day, from: det.from, text: det.text, matches: det.day === todayType() };
|
||||
}
|
||||
return { day: 'all', from: 'ไม่ระบุ', unknown: true, matches: true }; /* ไม่รู้ = แสดง (ไม่ซ่อนข้อมูล) */
|
||||
}
|
||||
function normDay(opts) {
|
||||
if (opts && opts.dayType) return DAY_ALIAS[String(opts.dayType).toLowerCase()] || 'all';
|
||||
return todayType();
|
||||
}
|
||||
|
||||
/* ตัดสินว่าทิศนี้ใช้กับวันที่กำลังดูอยู่ไหม
|
||||
service = ผลจาก serviceOf() → { day, matches, conflict?, unknown? } */
|
||||
function applies(info, day) {
|
||||
if (!day || day === 'all') return true; /* ไม่ระบุวัน = ดูทุกวัน */
|
||||
if (!info || typeof info !== 'object') return true;
|
||||
if (info.unknown) return true; /* ยังไม่ระบุวัน → แสดง (ไม่ซ่อนข้อมูล) */
|
||||
if (info.conflict) return true; /* ทิศเดียวมีทั้ง 2 ตาราง → ซ่อนไม่ได้ (จะหายข้อมูล) */
|
||||
if (info.day === 'custom') { /* ระบุวันตรง ๆ (days[]) */
|
||||
return !info.days || info.days.indexOf(dayKey(dayDate(day))) !== -1;
|
||||
}
|
||||
return info.day === 'all' || info.day === day; /* เทียบกับวันที่กำลังดู ไม่ใช่ค่าของวันนี้ */
|
||||
}
|
||||
/* 'weekday' / 'holiday' → วันที่สมมติขึ้นมา (ใช้ตรวจ days[] ให้ตรงกับวันที่ขอ) */
|
||||
function dayDate(day) {
|
||||
var d = new Date();
|
||||
if (day === 'weekday') { var wd = (d.getDay() + 6) % 7; d.setDate(d.getDate() - wd); }
|
||||
else if (day === 'holiday') { var wd2 = (d.getDay() + 6) % 7; d.setDate(d.getDate() + (5 - wd2)); }
|
||||
return d;
|
||||
}
|
||||
function normDay(opts) {
|
||||
if (opts && opts.dayType) return ALIAS[String(opts.dayType).toLowerCase()] || 'all';
|
||||
return todayType(); /* ค่าเริ่มต้น: ตรวจจากวันนี้ */
|
||||
}
|
||||
|
||||
/* เวลาของจุดจอด ณ วันหนึ่ง ๆ = times พื้นฐาน + groups ที่ตรงกับวันนั้น */
|
||||
/* timesFor(stop, day) — day ที่ส่งมา (weekday/holiday) = "วันเป้าหมาย" ที่ต้องการดู
|
||||
ทิศที่ผ่านการกรองวันมาแล้วจะส่ง day='all' → คืน times ตรง ๆ · ส่วนที่ยังไม่แยกวันใช้ groups แยกเอง */
|
||||
function timesFor(stop, day) {
|
||||
var groups = (stop && stop.groups) || [];
|
||||
if (!groups.length) return (stop && stop.times ? stop.times : []).slice();
|
||||
var out = ((stop && stop.times) || []).slice(); /* เวลาที่ไม่ผูกวัน = ใช้ทุกวัน */
|
||||
groups.forEach(function (g) {
|
||||
var gt = g.dayType ? (ALIAS[String(g.dayType).toLowerCase()] || 'all') : 'all';
|
||||
if (gt !== 'all' && day && day !== 'all' && gt !== day) return;
|
||||
out = out.concat(g.times || []);
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
/* ---------- โหลดข้อมูล: schedules.json เป็นได้ทั้ง "ไฟล์รวม" และ "สารบัญ" ----------
|
||||
- สารบัญ (index: true): routes[] มี { route_id, file } → โหลดเฉพาะไฟล์ของสายที่ขอ (lazy + cache)
|
||||
- ไฟล์รวม (schema 2 เดิม): มี routes[] พร้อม directions ในตัว → ใช้ได้เหมือนเดิมไม่ต้องแก้โค้ดเก่า
|
||||
- schema 1 เดิม: { schedules: [...] } → ใช้ได้เหมือนเดิม */
|
||||
var SUBS = {}; /* cache ไฟล์ย่อยต่อสาย */
|
||||
var subsReady = null;
|
||||
function loadSubs() {
|
||||
if (subsReady) return subsReady;
|
||||
subsReady = fetch(DATA_URL + 'schedules.json', { cache: 'no-store' })
|
||||
.then(function (r) { return r.ok ? r.json() : null; })
|
||||
.then(function (d) {
|
||||
if (!d || !d.index) return d; /* ไฟล์รวม → คืนทั้งไฟล์ */
|
||||
var rows = d.routes || [];
|
||||
return Promise.all(rows.map(function (row) {
|
||||
var file = row.file || ('schedules' + row.route_id + '.json');
|
||||
return fetch(DATA_URL + 'scheduleslist/' + file, { cache: 'no-store' })
|
||||
.then(function (x) { return x.ok ? x.json() : null; })
|
||||
.then(function (sub) {
|
||||
if (!sub) return null;
|
||||
var dirs = isSchema3(sub) ? directionsFromSchema3(sub) : (sub.directions || []);
|
||||
SUBS[String(sub.route_id)] = { route_id: sub.route_id, station_order: sub.station_order || [],
|
||||
directions: dirs, schema3: isSchema3(sub) };
|
||||
return SUBS[String(sub.route_id)];
|
||||
}).catch(function () { return null; });
|
||||
})).then(function (list) {
|
||||
var routes = list.filter(Boolean);
|
||||
return { schema: 2, index: true, routes: routes };
|
||||
});
|
||||
})
|
||||
.catch(function () { return null; });
|
||||
return subsReady;
|
||||
}
|
||||
/* โหลดสายเดียว (เร็ว — ใช้ตอนเปิดหน้า check/routes ของสายนั้น) */
|
||||
function loadRoute(rid) {
|
||||
var key = String(rid);
|
||||
if (SUBS[key]) return Promise.resolve({ schema: 2, routes: [SUBS[key]] });
|
||||
if (!subsReady) return loadSubs().then(function () { return SUBS[key] ? { schema: 2, routes: [SUBS[key]] } : null; });
|
||||
return Promise.resolve(SUBS[key] ? { schema: 2, routes: [SUBS[key]] } : null);
|
||||
}
|
||||
|
||||
/* ---------- ระยะทาง กม. (ไฟล์แยก resource/data/stop-km.json — สร้างโดย resource/tools/stop-km.py) ----------
|
||||
แยกไฟล์เพราะ schedules.json เป็นไฟล์ที่คนแก้มือ ถ้าเอาค่าคำนวณไปฝังไว้ พอบันทึกทับจากสำเนาเก่าจะหายทั้งชุด */
|
||||
var KM = {};
|
||||
var kmReady = null;
|
||||
function loadKm() {
|
||||
if (kmReady) return kmReady;
|
||||
kmReady = fetch(DATA_URL + 'stop-km.json', { cache: 'no-store' })
|
||||
.then(function (r) { return r.ok ? r.json() : null; })
|
||||
.then(function (d) {
|
||||
KM = (d && typeof d === 'object') ? d : {};
|
||||
try { window.dispatchEvent(new CustomEvent('schedules:km', { detail: { routes: Object.keys(KM).length } })); } catch (e) { }
|
||||
return KM;
|
||||
})
|
||||
.catch(function () { KM = {}; return KM; });
|
||||
return kmReady;
|
||||
}
|
||||
function absKm(rid, sid) {
|
||||
var r = KM[String(rid)];
|
||||
if (!r) return null;
|
||||
var v = r[String(sid)];
|
||||
return (typeof v === 'number') ? v : null;
|
||||
}
|
||||
/* km ของจุดในทิศนั้น — พลิกให้ "เพิ่มขึ้นตามทางที่รถวิ่ง" เพื่อให้ผลต่างมีเครื่องหมายถูกต้องเอง
|
||||
(ลำดับจุดในทิศ + กม.จริงบนเส้น เป็นตัวบอกทิศ) */
|
||||
function relKms(rid, stops) {
|
||||
var abs = (stops || []).map(function (s, i) {
|
||||
var k = (s && typeof s.km === 'number') ? s.km : (s ? absKm(rid, s.station_id) : null);
|
||||
return (typeof k === 'number') ? { i: i, k: k } : null;
|
||||
});
|
||||
var known = abs.filter(Boolean);
|
||||
if (known.length < 2) {
|
||||
return (stops || []).map(function (s) {
|
||||
if (s && typeof s.km === 'number') return s.km;
|
||||
return s ? absKm(rid, s.station_id) : null;
|
||||
});
|
||||
}
|
||||
var forward = known[known.length - 1].k >= known[0].k; /* ทิศนี้วิ่งจาก กม. น้อย → มาก ใช่ไหม */
|
||||
var max = known.reduce(function (a, b) { return b.k > a ? b.k : a; }, known[0].k);
|
||||
return abs.map(function (x) { if (!x) return null; return forward ? x.k : (max - x.k); });
|
||||
}
|
||||
|
||||
/* โหลด holidays.json ครั้งเดียว (ถ้าไม่มีไฟล์ → ใช้กฎเสาร์–อาทิตย์) */
|
||||
var ready = null;
|
||||
function loadHolidays() {
|
||||
if (ready) return ready;
|
||||
ready = fetch(DATA_URL + 'holidays.json', { cache: 'no-store' })
|
||||
.then(function (r) { return r.ok ? r.json() : null; })
|
||||
.then(function (d) {
|
||||
HOLIDAYS = (d && Array.isArray(d.holidays)) ? d.holidays.slice() : [];
|
||||
try { window.dispatchEvent(new CustomEvent('schedules:ready', { detail: { holidays: HOLIDAYS.length } })); } catch (e) { }
|
||||
return HOLIDAYS;
|
||||
})
|
||||
.catch(function () { HOLIDAYS = []; return HOLIDAYS; });
|
||||
return ready;
|
||||
}
|
||||
|
||||
/* ---------- ทิศทางของสาย (กรองตามวัน + ถอยกลับถ้าว่าง) ---------- */
|
||||
function directions(doc, routeId, opts) {
|
||||
var rid = String(routeId);
|
||||
var list = [];
|
||||
if (hasSchema2(doc)) {
|
||||
var r = (doc.routes || []).filter(function (x) { return String(x.route_id) === rid; })[0];
|
||||
if (!r) return [];
|
||||
list = (r.directions || []).map(function (d) {
|
||||
return {
|
||||
dir_id: d.dir_id,
|
||||
dir_label: d.dir_label,
|
||||
days: Array.isArray(d.days) ? d.days.map(String) : null, /* ระบุวันตรง ๆ (อา จ อ พ พฤ ศ ส) */
|
||||
service: serviceOf(d, d), /* ตรวจวัน + เหตุผล (จากคำ/service/days) */
|
||||
autoTimes: !!d.autoTimes, /* true = คำนวณจุดที่ไม่มีตารางให้ */
|
||||
autoFor: Array.isArray(d.autoFor) ? d.autoFor.slice() : null, /* จำกัดเฉพาะจุดเหล่านี้ (ไม่ใส่ = ทุกจุดที่ว่าง) */
|
||||
travelMin: Number(d.travelMin) > 0 ? Number(d.travelMin) : null, /* เวลาเดินทางทั้งเส้น (นาที) */
|
||||
baseEnd: (d.baseEnd === 'first' || d.baseEnd === 'last') ? d.baseEnd : null, /* มีเวลาจริงที่ปลายไหน */
|
||||
baseSid: (d.baseSid != null ? d.baseSid : null), /* หรือระบุจุดอ้างอิงตรง ๆ */
|
||||
speedKmh: Number(d.speedKmh) > 0 ? Number(d.speedKmh) : DEFAULT_SPEED_KMH,
|
||||
stops: (d.stops || []).map(function (s) {
|
||||
return {
|
||||
station_id: s.station_id,
|
||||
times: s.times || [],
|
||||
km: (typeof s.km === 'number') ? s.km : null, /* กม. จากต้นทาง (วัดโดย resource/tools/stop-km.py) */
|
||||
dir_note: s.dir_note || null,
|
||||
note: s.note || null,
|
||||
groups: s.groups || null,
|
||||
derive: s.derive || null /* กฎ "จุดนี้ = เวลาจุดอ้างอิง ± n นาที" */
|
||||
};
|
||||
})
|
||||
};
|
||||
});
|
||||
} else {
|
||||
/* schema 1 → ยังใช้ได้เหมือนเดิม (ไม่แยกวัน) */
|
||||
list = [{ dir_id: 'all', dir_label: null, service: 'all', stops: (doc && doc.schedules ? doc.schedules : []).filter(function (r) {
|
||||
return String(r.route_id) === rid;
|
||||
}).map(function (r) {
|
||||
return { station_id: r.station_id, times: r.departure_times || [], dir_note: r.direction_note || null, note: r.schedule_note || null, groups: null };
|
||||
}) }];
|
||||
}
|
||||
|
||||
var day = normDay(opts);
|
||||
var kept = list.filter(function (d) { return applies(d.service, day); }); /* service = ผลตรวจวันของทิศนั้น */
|
||||
var fallback = false;
|
||||
if (!kept.length && list.length) { kept = list.slice(); fallback = true; } /* ห้ามปล่อยว่าง */
|
||||
|
||||
warmStations(); /* เพื่อให้ข้อความ "คำนวณจาก ..." มีชื่อจุด */
|
||||
/* เวลาจริงรายจุดของ "ทั้งสาย" — กฎ derive อ้างจุดข้ามทิศได้ (เช่น 902: จุด 15 ← จุด 6 คนละทิศ) */
|
||||
var realByStation = {};
|
||||
(kept.length ? kept : list).forEach(function (d) {
|
||||
(d.stops || []).forEach(function (s) {
|
||||
var t0 = timesFor(s, day === 'all' ? 'all' : day);
|
||||
if (t0.length && !realByStation[String(s.station_id)]) realByStation[String(s.station_id)] = t0;
|
||||
});
|
||||
});
|
||||
|
||||
return kept.map(function (d) {
|
||||
var kms = relKms(rid, d.stops); /* km ตามทางที่รถวิ่ง (จากไฟล์ stop-km.json) */
|
||||
/* ใส่ km ให้ "ทุกจุด" ก่อน — ต้องมีครบทั้งชุด ระบบหาจุดอ้างอิง/คำนวณความเร็วถึงจะทำงานได้ */
|
||||
var withKm = d.stops.map(function (s, si) {
|
||||
var c = {};
|
||||
for (var k in s) c[k] = s[k];
|
||||
if (typeof c.km !== 'number' && typeof kms[si] === 'number') c.km = kms[si];
|
||||
return c;
|
||||
});
|
||||
var speed = speedOf({ travelMin: d.travelMin, speedKmh: d.speedKmh, stops: withKm });
|
||||
var stops = withKm.map(function (s) {
|
||||
var t = timesFor(s, day === 'all' ? 'all' : day);
|
||||
var est = false;
|
||||
var estFrom = null; /* ถ้าเป็นเวลาที่คำนวณ → ข้อมูลจุดอ้างอิง */
|
||||
/* ★ กฎของเจ้าของข้อมูล: "จุดนี้ = เวลาจุดอ้างอิง ± n นาที" (เขียนครั้งเดียวในไฟล์สาย) */
|
||||
if (s.derive && s.derive.from_station_id != null) {
|
||||
var src = realByStation[String(s.derive.from_station_id)];
|
||||
if (src && src.length) {
|
||||
t = shiftTimes(src, s.derive.offset_min);
|
||||
est = true;
|
||||
estFrom = { station_id: Number(s.derive.from_station_id),
|
||||
name: stationNameOf(s.derive.from_station_id),
|
||||
offsetMin: Number(s.derive.offset_min) || 0,
|
||||
overrode: (timesFor(s, 'all').length > 0) };
|
||||
}
|
||||
}
|
||||
if (!est && d.autoTimes && !t.length) { /* ไม่มีตารางจริง → คำนวณจากจุดที่มีเวลา + กม. */
|
||||
var only = d.autoFor && d.autoFor.length
|
||||
? d.autoFor.map(String).indexOf(String(s.station_id)) !== -1
|
||||
: true; /* ไม่ระบุ autoFor = ทุกจุดที่ว่าง */
|
||||
if (only) {
|
||||
var calc = computeTimes(s, withKm, { speedKmh: speed.kmh, baseEnd: d.baseEnd, baseSid: d.baseSid });
|
||||
if (calc && calc.length) { t = calc; est = true; }
|
||||
}
|
||||
}
|
||||
return { station_id: s.station_id, times: t, km: s.km, dir_note: s.dir_note, note: s.note,
|
||||
groups: s.groups, estimated: est, estimateFrom: estFrom, derive: s.derive || null };
|
||||
});
|
||||
return { dir_id: d.dir_id, dir_label: d.dir_label, service: d.service, days: d.days, autoTimes: d.autoTimes,
|
||||
travelMin: d.travelMin, baseEnd: d.baseEnd, baseSid: d.baseSid, autoFor: d.autoFor,
|
||||
speedKmh: Math.round(speed.kmh * 10) / 10,
|
||||
speedFrom: speed.source, dayType: day, fallback: fallback, stops: stops };
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------- schema 2 → record แบน (คง API เดิม) ---------- */
|
||||
function records(doc, opts) {
|
||||
if (!doc) return [];
|
||||
if (!hasSchema2(doc)) return doc.schedules || (Array.isArray(doc) ? doc : []);
|
||||
var out = [];
|
||||
(doc.routes || []).forEach(function (r) {
|
||||
directions(doc, r.route_id, opts).forEach(function (d) {
|
||||
(d.stops || []).forEach(function (s) {
|
||||
out.push({
|
||||
route_id: r.route_id,
|
||||
station_id: s.station_id,
|
||||
direction_note: s.dir_note || null,
|
||||
dir_label: d.dir_label || null, /* ชื่อทิศ (ป่าโมกไปอยุธยา ฯลฯ) — ใช้เป็นหัวแถว */
|
||||
departure_times: s.times || [],
|
||||
schedule_note: s.note || null,
|
||||
estimated: !!s.estimated, /* true = เวลาคำนวณ ไม่ใช่ตารางจริง */
|
||||
estimateFrom: s.estimateFrom || null, /* { station_id, name, offsetMin } เมื่อคำนวณ */
|
||||
km: s.km,
|
||||
dir_id: d.dir_id,
|
||||
service: d.service,
|
||||
days: d.days,
|
||||
dayType: d.dayType,
|
||||
fallback: d.fallback
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
return out;
|
||||
}
|
||||
|
||||
/* ---------- ข้อมูลของสายเดียว ---------- */
|
||||
function route(doc, routeId, opts) {
|
||||
var rid = String(routeId);
|
||||
var entries = records(doc, opts).filter(function (r) { return String(r.route_id) === rid; });
|
||||
var dirs = directions(doc, rid, opts);
|
||||
var order = [];
|
||||
if (hasSchema2(doc)) {
|
||||
var r = (doc.routes || []).filter(function (x) { return String(x.route_id) === rid; })[0];
|
||||
if (r && r.station_order) order = r.station_order.slice();
|
||||
}
|
||||
if (!order.length) {
|
||||
entries.forEach(function (r) { if (order.indexOf(r.station_id) === -1) order.push(r.station_id); });
|
||||
order.sort(function (a, b) { return a - b; });
|
||||
}
|
||||
return { route_id: rid, station_order: order, directions: dirs, entries: entries };
|
||||
}
|
||||
|
||||
/* ---------- เวลาทั้งหมดของสาย (ไม่ซ้ำ + เรียง) ---------- */
|
||||
function times(doc, routeId, opts) {
|
||||
var seen = {};
|
||||
records(doc, opts).forEach(function (r) {
|
||||
if (String(r.route_id) !== String(routeId)) return;
|
||||
(r.departure_times || []).forEach(function (t) { seen[t] = true; });
|
||||
});
|
||||
return Object.keys(seen).sort();
|
||||
}
|
||||
|
||||
/* ---------- จำนวนเที่ยวของสาย ---------- */
|
||||
function countTrips(doc, routeId, opts) {
|
||||
var n = 0;
|
||||
records(doc, opts).forEach(function (r) {
|
||||
if (String(r.route_id) === String(routeId)) n += (r.departure_times || []).length;
|
||||
});
|
||||
return n;
|
||||
}
|
||||
|
||||
loadHolidays(); /* เริ่มโหลดทันที (ไม่บล็อกการอ่าน) */
|
||||
loadKm();
|
||||
|
||||
window.Schedules = {
|
||||
hasSchema2: hasSchema2,
|
||||
load: loadSubs, /* โหลดทุกสาย (จากสารบัญหรือไฟล์รวม) */
|
||||
loadRoute: loadRoute, /* โหลดสายเดียว + ไฟล์ย่อยที่ยังไม่เคยโหลด */
|
||||
normSub: normSub,
|
||||
get subs() { return SUBS; },
|
||||
records: records,
|
||||
route: route,
|
||||
directions: directions,
|
||||
times: times,
|
||||
countTrips: countTrips,
|
||||
/* ส่วนของวันทำงาน/วันหยุด */
|
||||
todayType: todayType,
|
||||
dayTypeOf: dayTypeOf,
|
||||
dayInfo: dayInfo,
|
||||
dayKey: dayKey,
|
||||
DAYS: DAYS,
|
||||
DAY_TH: DAY_TH,
|
||||
DAY_ABBR: DAY_ABBR,
|
||||
detectDay: detectDay,
|
||||
detectDayOfDir: detectDayOfDir,
|
||||
offsetLabel: offsetLabel,
|
||||
stationNameOf: stationNameOf,
|
||||
setStationNames: setStationNames,
|
||||
shiftTimes: shiftTimes,
|
||||
serviceOf: serviceOf,
|
||||
timesFor: timesFor,
|
||||
computeTimes: computeTimes,
|
||||
speedOf: speedOf,
|
||||
absKm: absKm,
|
||||
relKms: relKms,
|
||||
loadKm: loadKm,
|
||||
get km() { return KM; },
|
||||
DEFAULT_SPEED_KMH: DEFAULT_SPEED_KMH,
|
||||
loadHolidays: loadHolidays,
|
||||
get holidays() { return HOLIDAYS.slice(); },
|
||||
ready: ready
|
||||
};
|
||||
})();
|
||||
+42
-405
@@ -1,4 +1,18 @@
|
||||
<style>
|
||||
.mu-other-stops { margin: 16px 0 6px; }
|
||||
.mu-other-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
|
||||
.mu-other-item { display: block; padding: 10px 12px; background: #fff;
|
||||
border: 1px solid #eef0f6; border-radius: 12px; min-width: 0; }
|
||||
.mu-other-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
|
||||
.mu-other-item .mu-time-grid { margin-top: 8px; }
|
||||
.mu-other-item .mu-est-note { margin-top: 4px; }
|
||||
.mu-other-idx { flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%; background: #f1e9ff;
|
||||
color: #7a4cc0; font-size: .78rem; font-weight: 700; display: flex; align-items: center; justify-content: center; }
|
||||
.mu-other-txt { flex: 1; min-width: 0; }
|
||||
.mu-other-txt strong { display: block; color: #1f2a44; font-size: .94rem; }
|
||||
.mu-other-txt span { display: block; color: #6f7b95; font-size: .8rem; }
|
||||
.mu-other-item .mu-chip { flex: 0 0 auto; font-family: ui-monospace, Consolas, monospace; font-size: .72rem; }
|
||||
.mu-other-item .mu-chip.warn { background: #fff5e6; color: #9a6b00; border-color: #f2d9a8; }
|
||||
:root {
|
||||
--mu-accent: #7a4cc0;
|
||||
--mu-accent-soft: #f3eafe;
|
||||
@@ -55,8 +69,10 @@
|
||||
.mu-stop-hero > * {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
min-width: 0; /* กัน grid track บวมตาม min-content (ไม่งั้นเนื้อหาถูก overflow:hidden ตัดที่จอแคบ) */
|
||||
}
|
||||
.mu-stop-hero-title {
|
||||
overflow-wrap: anywhere;
|
||||
margin: 0;
|
||||
font-size: 1.72rem;
|
||||
color: var(--mu-ink);
|
||||
@@ -68,7 +84,7 @@
|
||||
font-size: .9rem;
|
||||
}
|
||||
.mu-meta-row { display:flex; flex-wrap:wrap; gap:8px; margin: 12px 0 0; }
|
||||
.mu-meta-pill { background:linear-gradient(135deg, #ffffff, #f7f9ff); border:1px solid rgba(231, 224, 246, 0.9); color:#5b3b71; padding:6px 14px; border-radius:999px; font-size:.85rem; font-weight:600; box-shadow: 0 4px 10px rgba(122, 76, 192, 0.08); }
|
||||
.mu-meta-pill { max-width: 100%; overflow-wrap: anywhere; background:linear-gradient(135deg, #ffffff, #f7f9ff); border:1px solid rgba(231, 224, 246, 0.9); color:#5b3b71; padding:6px 14px; border-radius:999px; font-size:.85rem; font-weight:600; box-shadow: 0 4px 10px rgba(122, 76, 192, 0.08); }
|
||||
.mu-meta-pill.purple { background:linear-gradient(135deg, #f5eeff, #fce7f3); color:#7a4cc0; border-color:#e8d9f0; }
|
||||
.mu-meta-pill.sky { background:linear-gradient(135deg, #ebf5ff, #eff6ff); color:#3071b8; border-color:#d7e7fb; }
|
||||
.mu-meta-pill.mint { background:linear-gradient(135deg, #eafaf4, #ecfeff); color:#1f8765; border-color:#d1efdf; }
|
||||
@@ -86,6 +102,8 @@
|
||||
padding: 10px;
|
||||
background: #fff;
|
||||
box-shadow: 0 6px 14px rgba(122, 76, 192, 0.08);
|
||||
min-width: 0;
|
||||
overflow-wrap: anywhere;
|
||||
}
|
||||
.mu-hero-metric:nth-child(1) { background: linear-gradient(135deg, #f5efff, #fdf2f8); }
|
||||
.mu-hero-metric:nth-child(2) { background: linear-gradient(135deg, #ecfeff, #eef6ff); }
|
||||
@@ -338,6 +356,8 @@
|
||||
}
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
.mu-hero-metric-grid { grid-template-columns: 1fr; }
|
||||
.mu-hero-metric { min-width: 0; overflow-wrap: anywhere; }
|
||||
.mu-stop-summary-rail {
|
||||
gap: 6px;
|
||||
}
|
||||
@@ -390,438 +410,55 @@
|
||||
|
||||
<main class="mu-page">
|
||||
<div class="mu-container">
|
||||
<p class="mu-breadcrumb"><a href="#/">หน้าแรก</a>/ <a href="#/stops">ป้ายหยุดรถ</a>/ บขส.อ่างทอง</p>
|
||||
<p class="mu-breadcrumb" id="stop-breadcrumb"></p>
|
||||
|
||||
<section class="mu-stop-hero">
|
||||
<div>
|
||||
<h1 class="mu-stop-hero-title"><svg class="ic" aria-hidden="true"><use href="#ic-map-pin"/></svg> บขส.อ่างทอง</h1>
|
||||
<p class="mu-stop-hero-sub">ศูนย์รวมรถโดยสารหลักของจังหวัดอ่างทอง พร้อมข้อมูลเวลารถแบบอ่านง่ายและหาเที่ยวถัดไปได้ทันที</p>
|
||||
<div class="mu-meta-row">
|
||||
<span class="mu-meta-pill purple"><span data-i18n="type.terminal">สถานีขนส่งหลัก</span></span>
|
||||
<span class="mu-meta-pill sky">รหัส: at_main_terminal</span>
|
||||
<span class="mu-meta-pill mint">เมืองอ่างทอง · จังหวัดอ่างทอง</span>
|
||||
</div>
|
||||
<div class="mu-hero-metric-grid">
|
||||
<div class="mu-hero-metric">
|
||||
<p class="mu-hero-metric-label">จำนวนสายรถ</p>
|
||||
<p class="mu-hero-metric-value">8 สายหลัก</p>
|
||||
</div>
|
||||
<div class="mu-hero-metric">
|
||||
<p class="mu-hero-metric-label">เวลาบริการ</p>
|
||||
<p class="mu-hero-metric-value">04:30 - 21:00</p>
|
||||
</div>
|
||||
<div class="mu-hero-metric">
|
||||
<p class="mu-hero-metric-label">เที่ยวเร็วสุดถัดไป</p>
|
||||
<p class="mu-hero-metric-value">คำนวณอัตโนมัติ</p>
|
||||
</div>
|
||||
<div class="mu-hero-metric">
|
||||
<p class="mu-hero-metric-label">สิ่งอำนวยความสะดวก</p>
|
||||
<p class="mu-hero-metric-value">ห้องน้ำ · ที่พักคอย · ร้านอาหาร</p>
|
||||
</div>
|
||||
</div>
|
||||
<h1 class="mu-stop-hero-title"><svg class="ic" aria-hidden="true"><use href="#ic-map-pin"/></svg> <span id="stop-title"></span></h1>
|
||||
<p class="mu-stop-hero-sub" id="stop-sub"></p>
|
||||
<div class="mu-meta-row" id="stop-meta"></div>
|
||||
<div class="mu-hero-metric-grid" id="stop-metrics"></div>
|
||||
</div>
|
||||
<div>
|
||||
<img class="mu-stop-hero-photo" src="../.image/stops/54950.jpg" alt="ผังป้าย บขส.อ่างทอง" fetchpriority="high" decoding="async">
|
||||
<img class="mu-stop-hero-photo" id="stop-photo" alt="" fetchpriority="high" decoding="async" hidden>
|
||||
<div class="mu-live-clock-card" id="mu-live-clock-card">
|
||||
<div>
|
||||
<p class="mu-live-clock-title">เวลาปัจจุบัน ณ ป้ายนี้</p>
|
||||
<p class="mu-live-clock-title" data-i18n="stop.nowAtStop">เวลาปัจจุบัน ณ ป้ายนี้</p>
|
||||
<p class="mu-live-clock-time" id="mu-current-time">--:--</p>
|
||||
</div>
|
||||
<p class="mu-live-clock-note"><span class="mu-live-dot"></span>กำลังคำนวณเที่ยวถัดไปอัตโนมัติ</p>
|
||||
<p class="mu-live-clock-note"><span class="mu-live-dot"></span><span data-i18n="stop.autoNext">กำลังคำนวณเที่ยวถัดไปอัตโนมัติ</span></p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="mu-nearby" aria-label="สถานที่ใกล้เคียง">
|
||||
<section class="mu-nearby" id="stop-nearby" aria-label="สถานที่ใกล้เคียง" hidden>
|
||||
<h2><span data-i18n="stop.nearby">ใกล้เคียงป้าย</span></h2>
|
||||
<p class="sub">สถานที่น่าสนใจและจุดแวะระหว่างรอรถได้สะดวก · เดินถึงได้ภายใน 5–10 นาที</p>
|
||||
<div class="mu-nearby-grid">
|
||||
<div class="mu-nearby-card"><img src="../.image/landmarks/riverbank.jpg" alt="ริมแม่น้ำเจ้าพระยา" loading="lazy" decoding="async"><p class="cap">ริมแม่น้ำเจ้าพระยา<small>จุดพักผ่อน · เดิน 6 นาที</small></p></div>
|
||||
<div class="mu-nearby-card"><img src="../.image/landmarks/waterpark.png" alt="สวนน้ำอ่างทอง" loading="lazy" decoding="async"><p class="cap">สวนน้ำอ่างทอง<small>สวนสนุก · เดิน 8 นาที</small></p></div>
|
||||
<div class="mu-nearby-card"><img src="../.image/landmarks/temple.png" alt="วัดใกล้สถานี" loading="lazy" decoding="async"><p class="cap">วัดสำคัญใกล้ป้าย<small>จุดแวะสักการะ · เดิน 5 นาที</small></p></div>
|
||||
<div class="mu-nearby-card"><img src="../.image/landmarks/market.png" alt="ตลาดใกล้สถานี" loading="lazy" decoding="async"><p class="cap">ตลาดชุมชน<small>อาหาร · ติดป้าย</small></p></div>
|
||||
</div> </section>
|
||||
<div class="mu-toolbar">
|
||||
<a class="mu-btn primary" href="#/routes/101&origin=at_main_terminal">ดูตารางเวลาสายรถ 101</a>
|
||||
<a class="mu-back-btn" href="#/stops"><span data-i18n="common.backStops">← กลับไปยังรายการป้าย</span></a>
|
||||
</div>
|
||||
|
||||
<section class="mu-info-grid" aria-label="stop highlights">
|
||||
<article class="mu-info-card" style="background:linear-gradient(135deg, #f7f1ff, #f2e8ff);">
|
||||
<p class="label">จำนวนสายรถ</p>
|
||||
<p class="value">8 สาย</p>
|
||||
</article>
|
||||
<article class="mu-info-card" style="background:linear-gradient(135deg, #edf6ff, #e8f3ff); border-color:#d7e7fb;">
|
||||
<p class="label">เวลาบริการ</p>
|
||||
<p class="value">04:30 - 21:00</p>
|
||||
</article>
|
||||
<article class="mu-info-card" style="background:linear-gradient(135deg, #eefdf6, #e7f9f1); border-color:#d1efdf;">
|
||||
<p class="label">ประเภท</p>
|
||||
<p class="value">สถานีหลัก</p>
|
||||
</article>
|
||||
<article class="mu-info-card" style="background:linear-gradient(135deg, #fff5fa, #ffeef6); border-color:#f7d6e5;">
|
||||
<p class="label">สิ่งอำนวยความสะดวก</p>
|
||||
<p class="value">ครบครัน</p>
|
||||
</article>
|
||||
<p class="sub" id="stop-nearby-sub"></p>
|
||||
<div class="mu-nearby-grid" id="stop-nearby-grid"></div>
|
||||
</section>
|
||||
|
||||
<div class="mu-toolbar" id="stop-toolbar"></div>
|
||||
|
||||
<section class="mu-info-grid" id="stop-info" aria-label="stop highlights"></section>
|
||||
|
||||
<section class="mu-layout-grid">
|
||||
<div class="mu-card-panel">
|
||||
<h2><span data-i18n="stop.routes">สายรถที่ผ่านจุดนี้</span></h2>
|
||||
<div class="mu-route-tools">
|
||||
<input id="mu-route-filter" class="mu-route-filter" type="text" placeholder="ค้นหาสายรถหรือปลายทาง" data-i18n-attr="placeholder:stop.searchRoute,aria-label:stop.searchRoute" data-i18n-attr="placeholder:stop.searchRoute,aria-label:stop.searchRoute">
|
||||
<span class="mu-route-count" id="mu-route-count">แสดง 8 จาก 8 สาย</span>
|
||||
<input id="mu-route-filter" class="mu-route-filter" type="text" placeholder="ค้นหาสายรถหรือปลายทาง" data-i18n-attr="placeholder:stop.searchRoute,aria-label:stop.searchRoute">
|
||||
<span class="mu-route-count" id="mu-route-count"></span>
|
||||
</div>
|
||||
<ul class="mu-list mu-stop-list">
|
||||
<li>
|
||||
<details class="mu-stop-expander">
|
||||
<summary>
|
||||
<span class="mu-route-chip">902</span>
|
||||
<span class="mu-route-type-badge"><svg class="ic" aria-hidden="true"><use href="#ic-bus-front"/></svg> รถบัส</span>
|
||||
<span class="mu-stop-summary-main">
|
||||
<strong>กรุงเทพ-อ่างทอง สายเอเซีย</strong>
|
||||
<span class="mu-stop-summary-meta">เที่ยวกลับเข้า บขส.อ่างทอง</span>
|
||||
</span>
|
||||
<span class="mu-stop-summary-rail">
|
||||
<span class="mu-status-pill info">18 รอบ/วัน</span>
|
||||
<span class="mu-stop-chevron">⌄</span>
|
||||
</span>
|
||||
</summary>
|
||||
<div class="mu-stop-expander-body">
|
||||
<div class="mu-time-grid">
|
||||
<div class="mu-time-chip">04:00</div><div class="mu-time-chip">04:30</div>
|
||||
<div class="mu-time-chip">05:00</div><div class="mu-time-chip">05:30</div>
|
||||
<div class="mu-time-chip">06:00</div><div class="mu-time-chip">06:30</div>
|
||||
<div class="mu-time-chip">07:00</div><div class="mu-time-chip">07:30</div>
|
||||
<div class="mu-time-chip">08:00</div><div class="mu-time-chip">08:30</div>
|
||||
<div class="mu-time-chip">09:00</div><div class="mu-time-chip">09:30</div>
|
||||
<div class="mu-time-chip">10:00</div><div class="mu-time-chip">10:30</div>
|
||||
<div class="mu-time-chip">11:00</div><div class="mu-time-chip">11:30</div>
|
||||
<div class="mu-time-chip">12:00</div><div class="mu-time-chip">12:30</div>
|
||||
<div class="mu-time-chip">13:00</div><div class="mu-time-chip">13:30</div>
|
||||
<div class="mu-time-chip">14:00</div><div class="mu-time-chip">14:30</div>
|
||||
<div class="mu-time-chip">15:00</div><div class="mu-time-chip">15:30</div>
|
||||
<div class="mu-time-chip">16:00</div><div class="mu-time-chip">16:30</div>
|
||||
<div class="mu-time-chip">17:00</div><div class="mu-time-chip">17:30</div>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details class="mu-stop-expander">
|
||||
<summary>
|
||||
<span class="mu-route-chip">15</span>
|
||||
<span class="mu-route-type-badge"><svg class="ic" aria-hidden="true"><use href="#ic-bus-front"/></svg> รถบัส</span>
|
||||
<span class="mu-stop-summary-main">
|
||||
<strong>กรุงเทพ-อ่างทอง สายใน</strong>
|
||||
<span class="mu-stop-summary-meta">เที่ยวกลับเข้า บขส.อ่างทอง</span>
|
||||
</span>
|
||||
<span class="mu-stop-summary-rail">
|
||||
<span class="mu-status-pill info">4 รอบ/วัน</span>
|
||||
<span class="mu-stop-chevron">⌄</span>
|
||||
</span>
|
||||
</summary>
|
||||
<div class="mu-stop-expander-body">
|
||||
<div class="mu-time-grid">
|
||||
<div class="mu-time-chip">05:00</div><div class="mu-time-chip">05:45</div>
|
||||
<div class="mu-time-chip">06:30</div><div class="mu-time-chip">07:30</div>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details class="mu-stop-expander">
|
||||
<summary>
|
||||
<span class="mu-route-chip">101</span>
|
||||
<span class="mu-route-type-badge"><svg class="ic" aria-hidden="true"><use href="#ic-bus-front"/></svg> รถบัส</span>
|
||||
<span class="mu-stop-summary-main">
|
||||
<strong>อ่างทอง-ป่าโมก-อยุธยา</strong>
|
||||
<span class="mu-stop-summary-meta">เที่ยวออกจาก บขส.อ่างทอง</span>
|
||||
</span>
|
||||
<span class="mu-stop-summary-rail">
|
||||
<span class="mu-status-pill info">9 รอบ/วัน</span>
|
||||
<span class="mu-stop-chevron">⌄</span>
|
||||
</span>
|
||||
</summary>
|
||||
<div class="mu-stop-expander-body">
|
||||
<div class="mu-time-grid">
|
||||
<div class="mu-time-chip next">07:30</div><div class="mu-time-chip">08:20</div>
|
||||
<div class="mu-time-chip">09:10</div><div class="mu-time-chip">10:00</div>
|
||||
<div class="mu-time-chip">10:50</div><div class="mu-time-chip">11:50</div>
|
||||
<div class="mu-time-chip">13:00</div><div class="mu-time-chip">14:00</div>
|
||||
<div class="mu-time-chip">15:00</div>
|
||||
</div>
|
||||
<p class="mu-schedule-note">flow mock: เปิด route detail ที่ <strong>?route=101&origin=at_main_terminal</strong></p>
|
||||
<div class="mu-contact-row" style="margin-top:10px;">
|
||||
<a href="#/routes/101&origin=at_main_terminal"><span data-i18n="stop.openRoute">เปิดหน้ารายละเอียดสายรถนี้</span></a>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details class="mu-stop-expander">
|
||||
<summary>
|
||||
<span class="mu-route-chip">464</span>
|
||||
<span class="mu-route-type-badge"><svg class="ic" aria-hidden="true"><use href="#ic-bus-front"/></svg> รถบัส</span>
|
||||
<span class="mu-stop-summary-main">
|
||||
<strong>สุพรรณ-อ่างทอง-สระบุรี</strong>
|
||||
<span class="mu-stop-summary-meta">เที่ยวผ่านจุดนี้</span>
|
||||
</span>
|
||||
<span class="mu-stop-summary-rail">
|
||||
<span class="mu-status-pill info">20 รอบ/วัน</span>
|
||||
<span class="mu-stop-chevron">⌄</span>
|
||||
</span>
|
||||
</summary>
|
||||
<div class="mu-stop-expander-body">
|
||||
<div class="mu-time-grid">
|
||||
<div class="mu-time-chip">06:30</div><div class="mu-time-chip">07:10</div>
|
||||
<div class="mu-time-chip">07:50</div><div class="mu-time-chip">08:40</div>
|
||||
<div class="mu-time-chip">09:30</div><div class="mu-time-chip">10:10</div>
|
||||
<div class="mu-time-chip">10:50</div><div class="mu-time-chip">11:30</div>
|
||||
<div class="mu-time-chip">12:10</div><div class="mu-time-chip">12:50</div>
|
||||
<div class="mu-time-chip">13:30</div><div class="mu-time-chip">14:10</div>
|
||||
<div class="mu-time-chip">14:50</div><div class="mu-time-chip">15:30</div>
|
||||
<div class="mu-time-chip">16:10</div><div class="mu-time-chip">16:50</div>
|
||||
<div class="mu-time-chip">17:30</div><div class="mu-time-chip">18:10</div>
|
||||
<div class="mu-time-chip">18:50</div><div class="mu-time-chip">19:30</div>
|
||||
</div>
|
||||
<p class="mu-schedule-note"><svg class="ic" aria-hidden="true"><use href="#ic-triangle-alert"/></svg> เวลารถเปลี่ยนทุกวัน</p>
|
||||
</div>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details class="mu-stop-expander">
|
||||
<summary>
|
||||
<span class="mu-route-chip">641</span>
|
||||
<span class="mu-route-type-badge"><svg class="ic" aria-hidden="true"><use href="#ic-bus-front"/></svg> รถบัส</span>
|
||||
<span class="mu-stop-summary-main">
|
||||
<strong>อ่างทอง-บ้านแพรก-ลพบุรี</strong>
|
||||
<span class="mu-stop-summary-meta">เที่ยวออกจาก บขส.อ่างทอง</span>
|
||||
</span>
|
||||
<span class="mu-stop-summary-rail">
|
||||
<span class="mu-status-pill info">9 รอบ/วัน</span>
|
||||
<span class="mu-stop-chevron">⌄</span>
|
||||
</span>
|
||||
</summary>
|
||||
<div class="mu-stop-expander-body">
|
||||
<div class="mu-time-grid">
|
||||
<div class="mu-time-chip">07:00</div><div class="mu-time-chip">08:00</div>
|
||||
<div class="mu-time-chip">09:00</div><div class="mu-time-chip">10:00</div>
|
||||
<div class="mu-time-chip">11:00</div><div class="mu-time-chip">12:00</div>
|
||||
<div class="mu-time-chip">13:30</div><div class="mu-time-chip">14:30</div>
|
||||
<div class="mu-time-chip">16:30</div>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details class="mu-stop-expander">
|
||||
<summary>
|
||||
<span class="mu-route-chip">324</span>
|
||||
<span class="mu-route-type-badge"><svg class="ic" aria-hidden="true"><use href="#ic-bus-front"/></svg> รถบัส</span>
|
||||
<span class="mu-stop-summary-main">
|
||||
<strong>อ่างทอง-วัดพิกุลทอง</strong>
|
||||
<span class="mu-stop-summary-meta">เที่ยวผ่านจุดนี้</span>
|
||||
</span>
|
||||
<span class="mu-stop-summary-rail">
|
||||
<span class="mu-status-pill info">1 รอบ/วัน</span>
|
||||
<span class="mu-stop-chevron">⌄</span>
|
||||
</span>
|
||||
</summary>
|
||||
<div class="mu-stop-expander-body">
|
||||
<div class="mu-time-grid">
|
||||
<div class="mu-time-chip">10:00</div>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details class="mu-stop-expander">
|
||||
<summary>
|
||||
<span class="mu-route-chip">1011</span>
|
||||
<span class="mu-route-type-badge"><svg class="ic" aria-hidden="true"><use href="#ic-bus-front"/></svg> รถบัส</span>
|
||||
<span class="mu-stop-summary-main">
|
||||
<strong>อ่างทอง-สีบัวทอง</strong>
|
||||
<span class="mu-stop-summary-meta">เที่ยวผ่านจุดนี้</span>
|
||||
</span>
|
||||
<span class="mu-stop-summary-rail">
|
||||
<span class="mu-status-pill info">3 รอบ/วัน</span>
|
||||
<span class="mu-stop-chevron">⌄</span>
|
||||
</span>
|
||||
</summary>
|
||||
<div class="mu-stop-expander-body">
|
||||
<div class="mu-time-grid">
|
||||
<div class="mu-time-chip">12:00</div><div class="mu-time-chip">16:00</div>
|
||||
<div class="mu-time-chip">17:00</div>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details class="mu-stop-expander">
|
||||
<summary>
|
||||
<span class="mu-route-chip">2231</span>
|
||||
<span class="mu-route-type-badge"><svg class="ic" aria-hidden="true"><use href="#ic-bus-front"/></svg> รถบัส</span>
|
||||
<span class="mu-stop-summary-main">
|
||||
<strong>อ่างทอง-มหานาม</strong>
|
||||
<span class="mu-stop-summary-meta">เที่ยวผ่านจุดนี้</span>
|
||||
</span>
|
||||
<span class="mu-stop-summary-rail">
|
||||
<span class="mu-status-pill info">1 รอบ/วัน</span>
|
||||
<span class="mu-stop-chevron">⌄</span>
|
||||
</span>
|
||||
</summary>
|
||||
<div class="mu-stop-expander-body">
|
||||
<div class="mu-time-grid">
|
||||
<div class="mu-time-chip">16:00</div>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="mu-list mu-stop-list" id="stop-routes"></ul>
|
||||
</div>
|
||||
|
||||
<aside class="mu-card-panel">
|
||||
<h2><span data-i18n="stop.mapInfo">แผนที่และข้อมูลป้าย</span></h2>
|
||||
<div class="at-map" id="stop-map" role="region" aria-label="แผนที่เส้นทางที่ผ่านป้ายนี้"></div>
|
||||
<p class="at-map-caption" id="stop-map-caption"></p>
|
||||
<div style="display:flex; flex-wrap:wrap; gap:8px; margin-top:14px;">
|
||||
<span class="mu-chip" style="background: rgba(255,255,255,.9); border:1px solid rgba(231, 224, 246, 0.95); color:#5b3b71;">เปิด 04:30</span>
|
||||
<span class="mu-chip" style="background: rgba(255,255,255,.9); border:1px solid rgba(231, 224, 246, 0.95); color:#5b3b71;">ปิด 21:00</span>
|
||||
<span class="mu-chip" style="background: rgba(31, 135, 101, 0.08); color:#1f8765; border:1px solid rgba(31,135,101,.15);">มีห้องน้ำ</span>
|
||||
<span class="mu-chip" style="background: rgba(31, 135, 101, 0.08); color:#1f8765; border:1px solid rgba(31,135,101,.15);">ที่พักคอย</span>
|
||||
<span class="mu-chip" style="background: rgba(31, 135, 101, 0.08); color:#1f8765; border:1px solid rgba(31,135,101,.15);">ร้านอาหาร</span>
|
||||
</div>
|
||||
<div id="stop-chips" style="display:flex; flex-wrap:wrap; gap:8px; margin-top:14px;"></div>
|
||||
</aside>
|
||||
</section>
|
||||
</div>
|
||||
</main>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
function pad2(num) {
|
||||
return String(num).padStart(2, "0");
|
||||
}
|
||||
|
||||
function timeToMinutes(timeText) {
|
||||
var match = /^([01]?\d|2[0-3]):([0-5]\d)$/.exec(timeText.trim());
|
||||
if (!match) {
|
||||
return null;
|
||||
}
|
||||
return Number(match[1]) * 60 + Number(match[2]);
|
||||
}
|
||||
|
||||
function renderCurrentTime(now) {
|
||||
var currentTimeEl = document.getElementById("mu-current-time");
|
||||
if (!currentTimeEl) {
|
||||
return;
|
||||
}
|
||||
currentTimeEl.textContent = pad2(now.getHours()) + ":" + pad2(now.getMinutes());
|
||||
}
|
||||
|
||||
function updateNextArrivalForRow(detailEl, nowMinutes) {
|
||||
var chips = Array.from(detailEl.querySelectorAll(".mu-time-chip"));
|
||||
if (!chips.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
chips.forEach(function (chip) {
|
||||
chip.classList.remove("next");
|
||||
chip.classList.remove("next-live");
|
||||
});
|
||||
|
||||
var times = chips
|
||||
.map(function (chip, idx) {
|
||||
return { chip: chip, idx: idx, minutes: timeToMinutes(chip.textContent) };
|
||||
})
|
||||
.filter(function (item) {
|
||||
return item.minutes !== null;
|
||||
})
|
||||
.sort(function (a, b) {
|
||||
return a.minutes - b.minutes;
|
||||
});
|
||||
|
||||
if (!times.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
var next = times.find(function (item) {
|
||||
return item.minutes >= nowMinutes;
|
||||
});
|
||||
var wrapsToTomorrow = false;
|
||||
if (!next) {
|
||||
next = times[0];
|
||||
wrapsToTomorrow = true;
|
||||
}
|
||||
|
||||
next.chip.classList.add("next-live");
|
||||
|
||||
var rail = detailEl.querySelector(".mu-stop-summary-rail");
|
||||
if (!rail) {
|
||||
return;
|
||||
}
|
||||
|
||||
var nextEl = rail.querySelector(".mu-next-arrival");
|
||||
if (!nextEl) {
|
||||
nextEl = document.createElement("span");
|
||||
nextEl.className = "mu-next-arrival";
|
||||
var chevron = rail.querySelector(".mu-stop-chevron");
|
||||
if (chevron) {
|
||||
rail.insertBefore(nextEl, chevron);
|
||||
} else {
|
||||
rail.appendChild(nextEl);
|
||||
}
|
||||
}
|
||||
|
||||
nextEl.textContent = (wrapsToTomorrow ? "พรุ่งนี้ " : "ถัดไป ") + next.chip.textContent.trim();
|
||||
}
|
||||
|
||||
function setupRouteFilter() {
|
||||
var inputEl = document.getElementById("mu-route-filter");
|
||||
var countEl = document.getElementById("mu-route-count");
|
||||
var items = Array.from(document.querySelectorAll(".mu-stop-list > li"));
|
||||
if (!inputEl || !countEl || !items.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
function applyFilter() {
|
||||
var keyword = inputEl.value.trim().toLowerCase();
|
||||
var visibleCount = 0;
|
||||
|
||||
items.forEach(function (li) {
|
||||
var summaryText = li.textContent.toLowerCase();
|
||||
var matched = !keyword || summaryText.indexOf(keyword) !== -1;
|
||||
li.style.display = matched ? "block" : "none";
|
||||
if (matched) {
|
||||
visibleCount += 1;
|
||||
}
|
||||
});
|
||||
|
||||
countEl.textContent = "แสดง " + visibleCount + " จาก " + items.length + " สาย";
|
||||
}
|
||||
|
||||
inputEl.addEventListener("input", applyFilter);
|
||||
applyFilter();
|
||||
}
|
||||
|
||||
function tick() {
|
||||
var now = new Date();
|
||||
var nowMinutes = now.getHours() * 60 + now.getMinutes();
|
||||
renderCurrentTime(now);
|
||||
document.querySelectorAll(".mu-stop-expander").forEach(function (detailEl) {
|
||||
updateNextArrivalForRow(detailEl, nowMinutes);
|
||||
});
|
||||
}
|
||||
|
||||
tick();
|
||||
setupRouteFilter();
|
||||
setInterval(tick, 30000);
|
||||
})();
|
||||
</script>
|
||||
|
||||
<script>
|
||||
(function () {
|
||||
var r = window.__route || { params: {} };
|
||||
var el = document.getElementById('stop-map');
|
||||
if (el && window.ATMap && r.params.code) ATMap.forStop(el, r.params.code);
|
||||
})();
|
||||
</script>
|
||||
<script src="./partials/stopDetail.init.js"></script>
|
||||
@@ -0,0 +1,573 @@
|
||||
/* ============================================================
|
||||
stopDetail.init.js — หน้ารายละเอียดป้าย (#/stops/<รหัส>)
|
||||
|
||||
เดิม: ข้อมูลทุกอย่างฝังตายใน stopDetail.html (ทุกป้ายแสดงเหมือนกันหมด)
|
||||
ใหม่: เรนเดอร์จาก JSON จริง 100% — เปลี่ยนข้อมูลที่ไหนก็แก้ที่ไฟล์ข้อมูล ไม่ต้องแก้ HTML
|
||||
|
||||
แหล่งข้อมูล:
|
||||
stations.json → ชื่อ/ประเภท/รหัส/จังหวัด/พิกัด (+ ฟิลด์เสริม photo/description/landmarks/facilities ถ้าใส่ไว้)
|
||||
routes.json → สายรถที่ผ่านป้ายนี้ (station_ids) + ชื่อสาย
|
||||
schedules.json → เวลารถของแต่ละสายที่ป้ายนี้ (schema 2 ผ่านตัวอ่านกลาง Schedules)
|
||||
.image/stations/ → รูปสถานี <station_id>.jpg (+ รูปเสริม <station_id>-2.jpg)
|
||||
|
||||
พารามิเตอร์ URL:
|
||||
#/stops/<รหัสป้าย> → แสดงป้ายนั้น
|
||||
#/stops/<รหัสป้าย>?route=<รหัสสาย> → กรอง/เปิดเฉพาะสายนั้นทันที
|
||||
============================================================ */
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
var DATA = '../resource/data/';
|
||||
var PHOTO_DIR = '../.image/stations/'; /* รูปสถานี: <station_id>.<jpg|jpeg|webp|png> (ไล่ลองนามสกุลให้) */
|
||||
var PHOTO_EXTS = ['jpg', 'jpeg', 'webp', 'png'];
|
||||
|
||||
/* ประเภทป้าย → คีย์แปล + โทนสี */
|
||||
var TYPE_KEY = {
|
||||
main_terminal: 'type.terminal', local_terminal: 'type.local', local_stop: 'type.busstop',
|
||||
market: 'type.market', private_stop: 'type.marketOpt'
|
||||
};
|
||||
var TYPE_TONE = {
|
||||
main_terminal: 'purple', local_terminal: 'sky', local_stop: 'mint', market: 'mint', private_stop: 'sky'
|
||||
};
|
||||
|
||||
function $(id) { return document.getElementById(id); }
|
||||
function t(k, v) { return window.I18N ? I18N.t(k, v) : k; }
|
||||
function esc(s) {
|
||||
return String(s == null ? '' : s).replace(/&/g, '&').replace(/</g, '<')
|
||||
.replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
||||
}
|
||||
function fetchJSON(u) {
|
||||
return fetch(u, { cache: 'no-store' }).then(function (r) { return r.ok ? r.json() : null; }).catch(function () { return null; });
|
||||
}
|
||||
function pad2(n) { return (n < 10 ? '0' : '') + n; }
|
||||
function toMin(s) {
|
||||
var m = /^([01]?\d|2[0-3]):([0-5]\d)$/.exec(String(s || '').trim());
|
||||
return m ? Number(m[1]) * 60 + Number(m[2]) : null;
|
||||
}
|
||||
function nowMin() { var d = new Date(); return d.getHours() * 60 + d.getMinutes(); }
|
||||
function point(st) {
|
||||
if (!st || st.latitude === '' || st.longitude === '' || st.latitude == null) return null;
|
||||
return [parseFloat(st.longitude), parseFloat(st.latitude)];
|
||||
}
|
||||
|
||||
/* ---------- หาป้ายของเรา: รหัส URL → stations.json ---------- */
|
||||
function findStation(stations, code) {
|
||||
var want = String(code || '').trim();
|
||||
var hit = stations.filter(function (s) { return String(s.station_code) === want; })[0];
|
||||
if (hit) return hit;
|
||||
hit = stations.filter(function (s) { return String(s.station_code).toLowerCase() === want.toLowerCase(); })[0];
|
||||
if (hit) return hit;
|
||||
if (/^\d+$/.test(want)) {
|
||||
hit = stations.filter(function (s) { return String(s.station_id) === want; })[0];
|
||||
}
|
||||
return hit || null;
|
||||
}
|
||||
|
||||
/* ---------- สายรถที่ผ่านป้ายนี้ + เวลาที่ป้ายนี้ ---------- */
|
||||
function routesAtStation(routes, sched, sid) {
|
||||
var out = [];
|
||||
routes.forEach(function (r) {
|
||||
var ids = r.station_ids || [];
|
||||
if (ids.indexOf(sid) === -1) return;
|
||||
var legs = []; /* แต่ละทิศ = 1 รายการ */
|
||||
Schedules.directions(sched, r.route_id).forEach(function (d) {
|
||||
d.stops.forEach(function (s) {
|
||||
if (s.station_id !== sid) return;
|
||||
legs.push({ dir_id: d.dir_id, label: s.dir_note || d.dir_label || null, times: s.times || [], note: s.note || null, estimated: !!s.estimated, estimateFrom: s.estimateFrom || null });
|
||||
});
|
||||
});
|
||||
var trips = legs.reduce(function (n, l) { return n + l.times.length; }, 0);
|
||||
var pos = ids.indexOf(sid);
|
||||
out.push({
|
||||
route: r, legs: legs, trips: trips,
|
||||
isOrigin: pos === 0, isTerminus: pos === ids.length - 1, index: pos, total: ids.length
|
||||
});
|
||||
});
|
||||
/* เรียงตามลำดับใน routes.json (คงที่ — ตรงกับตัวเลือกสายในหน้าอื่น) */
|
||||
return out;
|
||||
}
|
||||
|
||||
/* ---------- รูปสถานี: .image/stations/<station_id>.jpg ----------
|
||||
เลือกตาม station_id ใน stations.json · ไฟล์หาย → ไม่แสดงช่องว่าง (hero ยืดเต็ม) */
|
||||
function findPhoto(station) {
|
||||
if (station.photo) return station.photo; /* ระบุพาธเองได้ใน stations.json (ทับค่าเริ่มต้น) */
|
||||
var n = station.__seq || 1; /* รูปเสริมของสถานีเดียวกัน: 2-2.jpg, 2-3.jpeg … */
|
||||
var base = PHOTO_DIR + station.station_id + (n > 1 ? '-' + n : '');
|
||||
return PHOTO_EXTS.map(function (e) { return base + '.' + e; }); /* เรียง候选ให้ renderHero ไล่ลอง */
|
||||
}
|
||||
|
||||
/* ---------- ตัวเลขสรุป ---------- */
|
||||
var HHMM = /^\d{1,2}:\d{2}$/; /* กันค่าหลอกในไฟล์ (เช่นข้อความ) ไม่ให้เพี้ยน KPI */
|
||||
|
||||
function summarise(rows) {
|
||||
var times = [], trips = 0;
|
||||
rows.forEach(function (x) {
|
||||
trips += x.trips;
|
||||
x.legs.forEach(function (l) {
|
||||
times = times.concat((l.times || []).filter(function (t) { return HHMM.test(String(t)); }));
|
||||
});
|
||||
});
|
||||
times.sort(function (a, b) { return toMin(a) - toMin(b); });
|
||||
return { rows: rows.length, trips: trips, first: times[0] || null, last: times[times.length - 1] || null };
|
||||
}
|
||||
|
||||
/* ---------- เรนเดอร์: หัวป้าย ---------- */
|
||||
function renderHero(st, sum, photo, place) {
|
||||
var baseName = st.station_name_th || ('ป้าย ' + st.station_code);
|
||||
/* จุดขึ้นรถประจำทางอื่นๆ: ต่อท้ายด้วยชื่อสถานที่จริงของสายที่กำลังดูอยู่ */
|
||||
var placeName = (place && window.OtherStop && OtherStop.firstName) ? OtherStop.firstName(place)
|
||||
: (place && place.station_name_th) ? place.station_name_th : null;
|
||||
var name = baseName + (placeName ? ' \u00b7 ' + placeName : '');
|
||||
var city = (place && place.city_th) || st.city_th || '';
|
||||
var prov = (place && place.province_th) || st.province_th || '';
|
||||
|
||||
var crumb = $('stop-breadcrumb');
|
||||
if (crumb) crumb.innerHTML = '<a href="#/">' + esc(t('nav.home')) + '</a>/ <a href="#/stops">' +
|
||||
esc(t('nav.stops')) + '</a>/ ' + esc(name);
|
||||
|
||||
var title = $('stop-title');
|
||||
if (title) title.textContent = name;
|
||||
|
||||
var sub = $('stop-sub');
|
||||
if (sub) {
|
||||
sub.textContent = st.description ||
|
||||
t('stop.subGeneric', { city: city || prov || t('stop.thisStop') });
|
||||
}
|
||||
|
||||
var meta = $('stop-meta');
|
||||
if (meta) {
|
||||
meta.innerHTML =
|
||||
'<span class="mu-meta-pill ' + (TYPE_TONE[st.station_type] || 'purple') + '">' +
|
||||
esc(t(TYPE_KEY[st.station_type] || 'type.busstop')) + '</span>' +
|
||||
'<span class="mu-meta-pill sky">' + esc(t('stop.code')) + ' ' + esc(st.station_code) + '</span>' +
|
||||
(city || prov ? '<span class="mu-meta-pill mint">' + esc([city, prov].filter(Boolean).join(' · ')) + '</span>' : '');
|
||||
}
|
||||
|
||||
var metrics = $('stop-metrics');
|
||||
if (metrics) {
|
||||
metrics.innerHTML =
|
||||
'<div class="mu-hero-metric"><p class="mu-hero-metric-label">' + esc(t('stop.statRoutes')) + '</p>' +
|
||||
'<p class="mu-hero-metric-value">' + sum.rows + '</p></div>' +
|
||||
'<div class="mu-hero-metric"><p class="mu-hero-metric-label">' + esc(t('stop.statTrips')) + '</p>' +
|
||||
'<p class="mu-hero-metric-value">' + sum.trips + '</p></div>' +
|
||||
'<div class="mu-hero-metric"><p class="mu-hero-metric-label">' + esc(t('stop.statHours')) + '</p>' +
|
||||
'<p class="mu-hero-metric-value">' + (sum.first ? esc(sum.first + ' - ' + sum.last) : '–') + '</p></div>' +
|
||||
'<div class="mu-hero-metric"><p class="mu-hero-metric-label">' + esc(t('stop.nextArrival')) + '</p>' +
|
||||
'<p class="mu-hero-metric-value" id="stop-next-trip">–</p></div>';
|
||||
}
|
||||
|
||||
var img = $('stop-photo');
|
||||
if (img) {
|
||||
img.alt = name;
|
||||
img.hidden = true; /* ซ่อนไว้ก่อน — รอผลตรวจว่ามีไฟล์จริง */
|
||||
var cands = [].concat(photo || []).filter(Boolean); /* รองรับทั้งสตริงเดียวและรายการนามสกุล */
|
||||
(function tryNext(i) {
|
||||
if (i >= cands.length) return; /* ไม่มีไฟล์เลย → ไม่แสดงช่องว่าง */
|
||||
var url = cands[i];
|
||||
fetch(url, { method: 'HEAD', cache: 'no-store' })
|
||||
.then(function (r) {
|
||||
if (!r.ok) return tryNext(i + 1); /* ลองนามสกุลถัดไป (.jpg → .jpeg → .webp → .png) */
|
||||
img.src = url;
|
||||
img.hidden = false;
|
||||
})
|
||||
.catch(function () { tryNext(i + 1); });
|
||||
})(0);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- เรนเดอร์: การ์ดสรุป 4 ใบ ---------- */
|
||||
function renderInfo(st, sum) {
|
||||
var box = $('stop-info');
|
||||
if (!box) return;
|
||||
var tones = [
|
||||
'background:linear-gradient(135deg, #f7f1ff, #f2e8ff);',
|
||||
'background:linear-gradient(135deg, #edf6ff, #e8f3ff); border-color:#d7e7fb;',
|
||||
'background:linear-gradient(135deg, #eefdf6, #e7f9f1); border-color:#d1efdf;',
|
||||
'background:linear-gradient(135deg, #fff5fa, #ffeef6); border-color:#f7d6e5;'
|
||||
];
|
||||
var cards = [
|
||||
[t('stop.statRoutes'), sum.rows ? t(sum.rows === 1 ? 'stop.nRoutes1' : 'stop.nRoutes', { n: sum.rows }) : '–'],
|
||||
[t('stop.statTrips'), sum.trips ? String(sum.trips) : '–'],
|
||||
[t('stop.statType'), t(TYPE_KEY[st.station_type] || 'type.busstop')],
|
||||
[t('stop.statHours'), sum.first ? sum.first + ' - ' + sum.last : '–']
|
||||
];
|
||||
box.innerHTML = cards.map(function (c, i) {
|
||||
return '<article class="mu-info-card" style="' + tones[i] + '">' +
|
||||
'<p class="label">' + esc(c[0]) + '</p><p class="value">' + esc(c[1]) + '</p></article>';
|
||||
}).join('');
|
||||
}
|
||||
|
||||
/* ---------- เรนเดอร์: สายรถที่ผ่านป้ายนี้ ---------- */
|
||||
function renderRoutes(rows, placeByRoute) {
|
||||
placeByRoute = placeByRoute || {};
|
||||
var list = $('stop-routes');
|
||||
var filter = $('mu-route-filter');
|
||||
if (!list) return;
|
||||
|
||||
if (!rows.length) {
|
||||
list.innerHTML = '<li><p class="mu-stop-sub">' + esc(t('stop.noRoutes')) + '</p></li>';
|
||||
if (filter) filter.disabled = true;
|
||||
setCount(0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
list.innerHTML = '';
|
||||
rows.forEach(function (x) {
|
||||
var r = x.route;
|
||||
var li = document.createElement('li');
|
||||
var det = document.createElement('details');
|
||||
det.className = 'mu-stop-expander';
|
||||
if (x.isOrigin || x.isTerminus) det.open = true;
|
||||
|
||||
var posLabel = x.isOrigin ? t('route.origin') : (x.isTerminus ? t('route.destination') : t('route.pass'));
|
||||
var place = placeByRoute[String(r.route_id)] || null;
|
||||
/* จุดขึ้นรถประจำทางอื่นๆ → แสดง "ชื่อจุดจริง · อำเภอ" แทนคำว่าจุดจอดที่ N */
|
||||
/* จุดขึ้นรถประจำทางอื่นๆ ที่มีหลายจุด → โชว์จุดแรก + "(+N จุด)" ไม่ยัดชื่อทั้งชุด */
|
||||
var subs = (place && window.OtherStop && OtherStop.stopsOf) ? OtherStop.stopsOf(place) : [];
|
||||
var pName = subs.length ? subs[0].name : (place && place.station_name_th) || '';
|
||||
var pMore = subs.length > 1 ? ' ' + t('stop.otherMore', { n: subs.length - 1 }) : '';
|
||||
var metaText = place
|
||||
? pName + pMore + (place.city_th ? ' \u00b7 ' + place.city_th : '')
|
||||
: posLabel + (x.total > 1 ? ' \u00b7 ' + (x.index + 1) + '/' + x.total : '');
|
||||
var sum = document.createElement('summary');
|
||||
sum.innerHTML =
|
||||
'<span class="mu-route-chip">' + esc(r.route_id) + '</span>' +
|
||||
'<span class="mu-route-type-badge"><svg class="ic" aria-hidden="true"><use href="#ic-bus-front"/></svg> ' +
|
||||
esc(r.vehicle_type_th || t('type.terminal')) + '</span>' +
|
||||
'<span class="mu-stop-summary-main">' +
|
||||
'<strong>' + esc(r.route_name_th || ('สาย ' + r.route_id)) + '</strong>' +
|
||||
'<span class="mu-stop-summary-meta">' + esc(metaText) + '</span>' +
|
||||
'</span>' +
|
||||
'<span class="mu-stop-summary-rail">' +
|
||||
'<span class="mu-status-pill info">' + esc(t(x.trips === 1 ? 'stop.tripsPerDay1' : 'stop.tripsPerDay', { n: x.trips })) + '</span>' +
|
||||
'<span class="mu-stop-chevron">\u2304</span>' +
|
||||
'</span>';
|
||||
det.appendChild(sum);
|
||||
|
||||
var body = document.createElement('div');
|
||||
body.className = 'mu-stop-expander-body';
|
||||
|
||||
if (!x.legs.length || !x.trips) {
|
||||
body.innerHTML = '<p class="mu-stop-sub">' + esc(t('stop.noTimes')) + '</p>';
|
||||
} else {
|
||||
x.legs.forEach(function (leg) {
|
||||
/* ทิศที่ยังไม่มีเวลา → ข้าม (แถวนี้มีการแสดงตารางของทิศอื่นอยู่แล้ว) */
|
||||
if (!(leg.times || []).length) return;
|
||||
if (leg.label) {
|
||||
var lab = document.createElement('p');
|
||||
lab.className = 'mu-stop-sub';
|
||||
lab.textContent = leg.label;
|
||||
body.appendChild(lab);
|
||||
}
|
||||
var grid = document.createElement('div');
|
||||
grid.className = 'mu-time-grid' + (leg.estimated ? ' is-est' : '');
|
||||
leg.times.forEach(function (tm) {
|
||||
var c = document.createElement('div');
|
||||
c.className = 'mu-time-chip';
|
||||
c.textContent = tm;
|
||||
grid.appendChild(c);
|
||||
});
|
||||
body.appendChild(grid);
|
||||
if (leg.estimated) {
|
||||
var estN = document.createElement('p');
|
||||
estN.className = 'mu-est-note';
|
||||
/* กฎ "จุดนี้ = เวลาจุดอ้างอิง ± n นาที" → บอกจุดอ้างอิง + เตือนเรื่องการจราจร */
|
||||
estN.textContent = leg.estimateFrom && window.Schedules.offsetLabel
|
||||
? t('time.derived', {
|
||||
base: leg.estimateFrom.name || ('#' + leg.estimateFrom.station_id),
|
||||
n: Schedules.offsetLabel(leg.estimateFrom.offsetMin)
|
||||
})
|
||||
: t('time.estimated');
|
||||
body.appendChild(estN);
|
||||
}
|
||||
if (leg.note) {
|
||||
var n = document.createElement('p');
|
||||
n.className = 'mu-schedule-note';
|
||||
n.innerHTML = '<svg class="ic" aria-hidden="true"><use href="#ic-triangle-alert"/></svg> ' + esc(leg.note);
|
||||
body.appendChild(n);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* ลิงก์ไปตารางเวลาเต็มของสายนั้น */
|
||||
var act = document.createElement('div');
|
||||
act.className = 'mu-inline-actions';
|
||||
act.innerHTML = '<a class="mu-btn ghost" href="#/check/' + encodeURIComponent(r.route_id) + '">' +
|
||||
esc(t('stop.viewScheduleN', { n: r.route_id })) + '</a>';
|
||||
body.appendChild(act);
|
||||
|
||||
det.appendChild(body);
|
||||
li.appendChild(det);
|
||||
list.appendChild(li);
|
||||
});
|
||||
|
||||
setupFilter();
|
||||
}
|
||||
|
||||
function setCount(shown, total) {
|
||||
var el = $('mu-route-count');
|
||||
if (el) el.textContent = total ? t('stop.showing', { a: shown, b: total }) : '';
|
||||
}
|
||||
|
||||
/* ---------- กรองสายรถ (ค้นหา) ---------- */
|
||||
function applyFilter() {
|
||||
var input = $('mu-route-filter');
|
||||
var items = Array.prototype.slice.call(document.querySelectorAll('#stop-routes > li'));
|
||||
if (!items.length) return;
|
||||
var kw = (input ? input.value : '').trim().toLowerCase();
|
||||
var shown = 0;
|
||||
items.forEach(function (li) {
|
||||
var ok = !kw || li.textContent.toLowerCase().indexOf(kw) !== -1;
|
||||
li.style.display = ok ? '' : 'none';
|
||||
if (ok) shown++;
|
||||
});
|
||||
setCount(shown, items.length);
|
||||
}
|
||||
function setupFilter() {
|
||||
var input = $('mu-route-filter');
|
||||
if (input && !input.dataset.bound) {
|
||||
input.dataset.bound = '1';
|
||||
input.addEventListener('input', applyFilter);
|
||||
}
|
||||
}
|
||||
|
||||
/* ---------- ไฮไลต์เที่ยวถัดไป + นาฬิกา (เดิมอยู่ใน partial) ---------- */
|
||||
function tick() {
|
||||
var clock = $('mu-current-time');
|
||||
var now = new Date();
|
||||
if (clock) clock.textContent = pad2(now.getHours()) + ':' + pad2(now.getMinutes());
|
||||
var nowm = nowMin();
|
||||
|
||||
var soonest = null;
|
||||
document.querySelectorAll('.mu-stop-expander').forEach(function (det) {
|
||||
var chips = Array.prototype.slice.call(det.querySelectorAll('.mu-time-chip'));
|
||||
chips.forEach(function (c) { c.classList.remove('next-live'); });
|
||||
var times = chips.map(function (c) { return { c: c, m: toMin(c.textContent) }; })
|
||||
.filter(function (x) { return x.m !== null; })
|
||||
.sort(function (a, b) { return a.m - b.m; });
|
||||
if (!times.length) return;
|
||||
|
||||
var next = times.filter(function (x) { return x.m >= nowm; })[0];
|
||||
var tomorrow = false;
|
||||
if (!next) { next = times[0]; tomorrow = true; }
|
||||
next.c.classList.add('next-live');
|
||||
if (!soonest || next.m < soonest.m) soonest = { m: next.m, time: next.c.textContent.trim(), tomorrow: tomorrow };
|
||||
|
||||
var rail = det.querySelector('.mu-stop-summary-rail');
|
||||
if (!rail) return;
|
||||
var el = rail.querySelector('.mu-next-arrival');
|
||||
if (!el) {
|
||||
el = document.createElement('span');
|
||||
el.className = 'mu-next-arrival';
|
||||
var chev = rail.querySelector('.mu-stop-chevron');
|
||||
chev ? rail.insertBefore(el, chev) : rail.appendChild(el);
|
||||
}
|
||||
var routeId = (det.querySelector('.mu-route-chip') || {}).textContent || '';
|
||||
el.textContent = (tomorrow ? t('stop.tomorrow') : t('stop.nextAt')) + ' ' + next.c.textContent.trim();
|
||||
el.dataset.route = routeId;
|
||||
});
|
||||
|
||||
var hero = $('stop-next-trip');
|
||||
if (hero) hero.textContent = soonest ? (soonest.tomorrow ? t('stop.tomorrow') + ' ' : '') + soonest.time : '–';
|
||||
}
|
||||
|
||||
/* ---------- ป้ายที่ไม่พบข้อมูล ---------- */
|
||||
function renderNotFound(code) {
|
||||
var main = document.querySelector('#view .mu-container') || document.querySelector('#view');
|
||||
if (!main) return;
|
||||
main.innerHTML =
|
||||
'<p class="mu-breadcrumb"><a href="#/stops">' + esc(t('common.backStops')) + '</a></p>' +
|
||||
'<h1 class="mu-stop-hero-title">' + esc(t('stop.notFound')) + '</h1>' +
|
||||
'<p class="mu-stop-hero-sub">' + esc(t('stop.notFoundSub', { code: code })) + '</p>';
|
||||
}
|
||||
|
||||
/* ---------- เริ่มทำงาน ---------- */
|
||||
function init() {
|
||||
var route = window.__route || { params: {}, query: {} };
|
||||
var code = (route.params && route.params.code) || '';
|
||||
var wantRoute = (route.query && route.query.route) || '';
|
||||
|
||||
Promise.all([
|
||||
fetchJSON(DATA + 'stations.json'),
|
||||
fetchJSON(DATA + 'routes.json'),
|
||||
Schedules.load().then(function (sd) { return Schedules.normSub(sd); }),
|
||||
(window.OtherStop ? OtherStop.load() : Promise.resolve([]))
|
||||
]).then(function (res) {
|
||||
var stations = (res[0] || {}).stations || [];
|
||||
if (window.Schedules && Schedules.setStationNames) Schedules.setStationNames(stations); /* ให้ข้อความ "คำนวณจาก ..." มีชื่อจุด */
|
||||
var routes = (res[1] || {}).routes || [];
|
||||
var sched = res[2] || {};
|
||||
var others = res[3] || [];
|
||||
|
||||
var st = findStation(stations, code);
|
||||
if (!st) { renderNotFound(code); return; }
|
||||
|
||||
var rows = routesAtStation(routes, sched, st.station_id);
|
||||
var sum = summarise(rows);
|
||||
|
||||
/* สถานี 8 "จุดขึ้นรถประจำทางอื่นๆ" = ชื่อรวมของทุกสาย
|
||||
→ จับคู่ route id เพื่อเอาชื่อสถานที่จริงของสายนั้น (เช่น 1011 → วัดสีบัวทอง / 1101 ในไฟล์) */
|
||||
var validIds = routes.map(function (r) { return String(r.route_id); });
|
||||
var isOther = !!(window.OtherStop && OtherStop.isOtherStop(st));
|
||||
var placeByRoute = {};
|
||||
if (isOther) {
|
||||
routes.forEach(function (r) {
|
||||
var e = OtherStop.forRoute(others, r.route_id, validIds);
|
||||
if (e) placeByRoute[String(r.route_id)] = e;
|
||||
});
|
||||
}
|
||||
var focusPlace = (isOther && wantRoute) ? (placeByRoute[String(wantRoute)] || null) : null;
|
||||
|
||||
renderOtherStops(isOther, routes, others, validIds, wantRoute, sched);
|
||||
renderHero(st, sum, findPhoto(st), focusPlace);
|
||||
renderInfo(st, sum);
|
||||
renderToolbar(st, rows, wantRoute);
|
||||
renderNearby(st);
|
||||
renderChips(st, sum);
|
||||
renderRoutes(rows, placeByRoute);
|
||||
|
||||
var filter = $('mu-route-filter');
|
||||
if (filter && wantRoute) { filter.value = wantRoute; applyFilter(); }
|
||||
|
||||
tick();
|
||||
setInterval(tick, 30000);
|
||||
|
||||
/* แผนที่: ใช้เส้นทางของสายที่ผ่านป้ายนี้ */
|
||||
var mapEl = $('stop-map');
|
||||
if (mapEl && window.ATMap) {
|
||||
var mapOpts = {};
|
||||
if (isOther && wantRoute) mapOpts.onlyRoutes = [String(wantRoute)];
|
||||
if (focusPlace) mapOpts.focus = focusPlace;
|
||||
try { ATMap.forStop(mapEl, st.station_code, mapOpts); } catch (e) { /* แผนที่พังไม่ควรทำให้หน้าเจ๊ง */ }
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------- จุดขึ้นรถประจำทางอื่นๆ: แสดง "ทุกจุด" ของสายนั้น ----------
|
||||
สายเดียวผ่านได้หลายจุด (เช่น 954 = ตลาดท่าช้าง · สามโก้ · วิเศษชัยชาญ · อ่างทอง)
|
||||
จุดที่ยังไม่มีพิกัด → แสดงชื่อพร้อมป้าย "ยังไม่มีพิกัด" (ไม่ซ่อนข้อมูล) */
|
||||
function renderOtherStops(isOther, routes, others, validIds, wantRoute, sched) {
|
||||
var host = $('stop-other-stops');
|
||||
if (!host) {
|
||||
if (!isOther) return;
|
||||
host = document.createElement('section');
|
||||
host.className = 'mu-other-stops';
|
||||
host.id = 'stop-other-stops';
|
||||
var bar = $('stop-toolbar');
|
||||
if (bar && bar.parentNode) bar.parentNode.insertBefore(host, bar);
|
||||
else return;
|
||||
}
|
||||
if (!isOther) { host.hidden = true; return; }
|
||||
|
||||
var list = []; /* { route_id, stop } */
|
||||
routes.forEach(function (r) {
|
||||
if (wantRoute && String(r.route_id) !== String(wantRoute)) return;
|
||||
OtherStop.allStops(others, r.route_id, validIds).forEach(function (st) {
|
||||
list.push({ route_id: String(r.route_id), stop: st });
|
||||
});
|
||||
});
|
||||
if (!list.length) { host.hidden = true; return; }
|
||||
|
||||
var one = !!wantRoute && routes.filter(function (r) { return String(r.route_id) === String(wantRoute); }).length === 1;
|
||||
|
||||
/* เวลาของ "จุดแรก" ของแต่ละสาย (แถว station 8 ในตารางเวลา) = ฐานสำหรับคำนวณจุดถัดไป
|
||||
offsets_min ใน 8 other_stop.json บอกว่าแต่ละจุดห่างจากจุดแรกกี่นาที */
|
||||
var baseByRoute = {};
|
||||
if (window.Schedules && sched && Schedules.records) {
|
||||
(Schedules.records(sched) || []).forEach(function (r) {
|
||||
if (String(r.station_id) !== '8') return;
|
||||
var rid = String(r.route_id), t2 = r.departure_times || [];
|
||||
if (t2.length && (!baseByRoute[rid] || t2.length > baseByRoute[rid].length)) baseByRoute[rid] = t2;
|
||||
});
|
||||
}
|
||||
var canShift = !!(window.Schedules && Schedules.shiftTimes && Schedules.offsetLabel);
|
||||
|
||||
host.hidden = false;
|
||||
host.innerHTML =
|
||||
'<h2 class="sect">' + esc(one
|
||||
? t('stop.otherStopsTitle', { n: wantRoute, m: list.length })
|
||||
: t('stop.otherStopsAll', { m: list.length })) + '</h2>' +
|
||||
'<ul class="mu-list mu-other-list">' + list.map(function (x) {
|
||||
var st = x.stop;
|
||||
var where = [st.city_th, st.province_th].filter(Boolean).join(' · ');
|
||||
var base = baseByRoute[String(x.route_id)] || null;
|
||||
var hasOff = (st.offsetMin != null);
|
||||
var times = (hasOff && base && canShift) ? Schedules.shiftTimes(base, st.offsetMin) : null;
|
||||
var first = (hasOff && base) ? list.filter(function (y) { return String(y.route_id) === String(x.route_id); })[0] : null;
|
||||
return '<li class="mu-other-item">' +
|
||||
'<div class="mu-other-row">' +
|
||||
'<span class="mu-other-idx">' + (st.index + 1) + '</span>' +
|
||||
'<div class="mu-other-txt"><strong>' + esc(st.name) + '</strong>' +
|
||||
(where ? '<span>' + esc(where) + '</span>' : '') +
|
||||
(one ? '' : '<span>' + esc(t('stops.busPrefix')) + ' ' + esc(x.route_id) + '</span>') +
|
||||
'</div>' +
|
||||
'<span class="mu-chip ' + (st.hasCoord ? 'count' : 'warn') + '">' +
|
||||
esc(st.hasCoord ? (Number(st.lat).toFixed(4) + ', ' + Number(st.lng).toFixed(4)) : t('stop.noCoord')) +
|
||||
'</span>' +
|
||||
'</div>' +
|
||||
(times && times.length
|
||||
? '<div class="mu-time-grid is-est">' + times.map(function (tm) {
|
||||
return '<div class="mu-time-chip">' + esc(tm) + '</div>';
|
||||
}).join('') + '</div>' +
|
||||
(st.offsetMin !== 0 && first
|
||||
? '<p class="mu-est-note">' + esc(t('time.derived', {
|
||||
base: first.stop.name, n: Schedules.offsetLabel(st.offsetMin)
|
||||
})) + '</p>'
|
||||
: '')
|
||||
: '') +
|
||||
'</li>';
|
||||
}).join('') + '</ul>';
|
||||
}
|
||||
|
||||
/* ---------- ปุ่ม/ทางลัด ---------- */
|
||||
function renderToolbar(st, rows, preferRoute) {
|
||||
var bar = $('stop-toolbar');
|
||||
if (!bar || !rows.length) return;
|
||||
/* ถ้ามี ?route= ให้ปุ่มอ้างสายนั้นก่อน ไม่งั้นใช้สายแรก */
|
||||
var top = rows[0].route;
|
||||
if (preferRoute) {
|
||||
var hit = rows.filter(function (x) { return String(x.route.route_id) === String(preferRoute); })[0];
|
||||
if (hit) top = hit.route;
|
||||
}
|
||||
bar.innerHTML =
|
||||
'<a class="mu-btn primary" href="#/check/' + encodeURIComponent(top.route_id) + '">' +
|
||||
esc(t('stop.viewScheduleN', { n: top.route_id })) + '</a>' +
|
||||
'<a class="mu-back-btn" href="#/stops">' + esc(t('common.backStops')) + '</a>';
|
||||
}
|
||||
|
||||
/* ---------- สถานที่ใกล้เคียง (ต้องมีข้อมูลใน stations.json → landmarks[]) ---------- */
|
||||
function renderNearby(st) {
|
||||
var sec = $('stop-nearby');
|
||||
var grid = $('stop-nearby-grid');
|
||||
if (!sec || !grid) return;
|
||||
var marks = st.landmarks || [];
|
||||
if (!marks.length) { sec.hidden = true; return; }
|
||||
sec.hidden = false;
|
||||
var sub = $('stop-nearby-sub');
|
||||
if (sub) sub.textContent = st.landmarks_note || t('stop.nearbySub');
|
||||
grid.innerHTML = marks.map(function (m) {
|
||||
return '<div class="mu-nearby-card">' +
|
||||
'<img src="' + esc(m.img || '') + '" alt="' + esc(m.caption || '') + '" loading="lazy" decoding="async">' +
|
||||
'<p class="cap">' + esc(m.caption || '') + (m.sub ? '<small>' + esc(m.sub) + '</small>' : '') + '</p></div>';
|
||||
}).join('');
|
||||
}
|
||||
|
||||
/* ---------- ชิป: เวลาเปิด–ปิด + สิ่งอำนวยความสะดวก (ถ้ามีใน stations.json) ---------- */
|
||||
function renderChips(st, sum) {
|
||||
var box = $('stop-chips');
|
||||
if (!box) return;
|
||||
var html = '';
|
||||
if (sum.first) html += '<span class="mu-chip">' + esc(t('stop.open')) + ' ' + esc(sum.first) + '</span>';
|
||||
if (sum.last) html += '<span class="mu-chip">' + esc(t('stop.close')) + ' ' + esc(sum.last) + '</span>';
|
||||
(st.facilities || []).forEach(function (f) {
|
||||
html += '<span class="mu-chip ok">' + esc(f) + '</span>';
|
||||
});
|
||||
box.innerHTML = html;
|
||||
}
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
document.addEventListener('DOMContentLoaded', init);
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
})();
|
||||
@@ -254,3 +254,16 @@ main.mu-container { padding-top: 14px; padding-bottom: 14px; }
|
||||
#view .mu-photo-strip { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
|
||||
#view .mu-stop-grid { grid-template-columns: repeat(4, 1fr); }
|
||||
}
|
||||
|
||||
/* เวลาที่ "คำนวณจากต้นทาง" (ไม่ใช่ตารางจริงของผู้ประกอบการ) — ทำเครื่องหมายให้ผู้ใช้รู้ ไม่ให้เข้าใจผิด */
|
||||
.mu-time-grid.is-est .mu-time-chip {
|
||||
border: 1px dashed #a892d4;
|
||||
background: #faf7ff;
|
||||
color: #6b5a8e;
|
||||
font-style: italic;
|
||||
}
|
||||
.mu-est-note {
|
||||
margin: 6px 0 0;
|
||||
font-size: .78rem;
|
||||
color: #6b5a8e;
|
||||
}
|
||||
@@ -13,7 +13,7 @@
|
||||
- ขั้นตอนอัปเดต: ดู AGENTS.md หัวข้อ PWA
|
||||
============================================================ */
|
||||
|
||||
const VERSION = "2026.09.22.5"; // ← bump ทุกครั้งที่แก้ SW เอง
|
||||
const VERSION = "2026.09.27.15"; // ← bump ทุกครั้งที่แก้ SW เอง
|
||||
const CACHE = `at-transit-${VERSION}`;
|
||||
|
||||
const PRECACHE = [
|
||||
@@ -38,6 +38,7 @@ const PRECACHE = [
|
||||
"./partials/busDetailExpanded.html",
|
||||
"./partials/checkSchedule.html",
|
||||
"./partials/stopDetail.html",
|
||||
"./partials/stopDetail.init.js",
|
||||
"./partials/credits.html",
|
||||
"./partials/about.html",
|
||||
"./partials/about.init.js",
|
||||
@@ -45,6 +46,9 @@ const PRECACHE = [
|
||||
"./partials/blog.init.js",
|
||||
"./partials/busDetail.init.js",
|
||||
"./partials/checkSchedule.init.js",
|
||||
"./partials/schedules.js",
|
||||
"../resource/data/holidays.json",
|
||||
"./partials/otherStop.js",
|
||||
"./vendor/leaflet/leaflet.js",
|
||||
"./vendor/leaflet/leaflet.css",
|
||||
"./map.js",
|
||||
|
||||
Reference in new issue
Block a user