แผนที่จาก GPKG + บทความ 6 ชิ้น + ลดความหนา footer
== แผนที่ / GIS ==
- qgis-to-web.py: อ่าน GPKG ได้ (--from gpkg) + เพิ่ม dream-Watcharapol
- เพิ่ม dream-*.geojson 6 ไฟล์ (เส้นทางที่เสนอ: บ้านภาชี · ชานเมืองอยุธยา · HSR · เมืองทองธานี · ปากเกร็ด · วัชรพล)
- map.js: ATMap.proposal() วาดเส้นจริงจาก geojson (ไม่ใช่เส้นตรง) · smoothFactor 0.5
· coordOf() รับ coords=[lat,lng] · fitAll รับได้ทั้งจุดเดี่ยวและเส้น · setStyle บน featureGroup
== บทความ (blog) ==
- text3: ถ้าผมได้ออกแบบสายเดินรถเอง (จาก mydream.html) TH+EN
- text4: วิธีเดินทางไปสถานีรถไฟ และสนามบิน (จาก train-airplane.html) TH+EN
- text5/text6: โครงเปล่ารอเติมเนื้อหา (แสวงหา-โพธิ์ทอง · อำเภอเข้าเมือง)
- แผนที่ความฝัน: map.groups 3 กลุ่ม · คลิกเส้น/หมุด/แถวได้ · ป้ายที่มา
- ย่อหน้า: ระยะห่าง 20px + ย่อหน้าหน้าบรรทัด 1.5em
== ตารางเดินรถ ==
- เปลี่ยนชื่อคีย์ dir_* -> direction_* ทุกไฟล์ (backward-compat ในโค้ด)
- 1011: จุดย่อย 2 ทิศ + offsets [0,25,55]
- 954/2194: จุดย่อย station 8 + offsets
- refreshHighlights: วนข้ามวันเมื่อเลยเที่ยวสุดท้าย + ไฮเทลต์ชิปทุกจุด
- 8 other_stop.md: อัปเดตตรงข้อมูลจริง 8 รายการ
== i18n ==
- แยกไฟล์ต่อภาษา ui/locales/{th,en}.json + i18n.js = loader (ลด 28KB -> 6.5KB)
- resource/tools/check-i18n.py ตรวจคีย์ขาด/ซ้ำ
- ข้อความผู้สนับสนุนหน้าแรก + คำแปล EN
== UI ==
- ฝังฟอนต์ K2D (ui/vendor/fonts/) ออฟไลน์ 100%
- cache busting ?v=<SW VERSION> ทุกรูป (ui/imageurl.js)
- footer: ลดความหนา 468 -> 349px + line-height 1.5 กันสระ/วรรณยุกต์ซ้อน
- QR modal + ปุ่มคัดลอกลิงก์ · หน้าอัปเดตล่าสุดใน #/check
- credits: ขอขอบคุณภาพรถ 3 สาย
== เครื่องมือ ==
- bump-version.py · stamp-schedules.py · derive-times.py (จุดอ้างอิง ± นาที)
This commit is contained in:
1 parent
1cfaeb1526
commit
656f65b41c
109 files changed
+3335
-1225
No files matched your search
+31
-22
@@ -7,7 +7,7 @@
|
||||
รองรับ 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? } ] } ] } ] }
|
||||
{ direction_id, direction_label, service?, stops: [ { station_id, times[], direction_note?, note?, groups? } ] } ] } ] }
|
||||
|
||||
── เรื่องวันทำงาน / วันหยุด (ไม่ต้องแก้โค้ดหน้าไหนเลย) ────────────────
|
||||
เพิ่มฟิลด์ "ไม่บังคับ" 2 ระดับ:
|
||||
@@ -24,7 +24,7 @@
|
||||
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.directions(doc, routeId, opts) → [{ direction_id, direction_label, service, dayType, fallback, stops[] }]
|
||||
Schedules.times(doc, routeId, opts) → เวลาทั้งหมดของสาย (เรียงแล้ว)
|
||||
Schedules.countTrips(doc, routeId, opts) → จำนวนเที่ยวของสาย
|
||||
Schedules.todayType() → 'weekday' | 'holiday'
|
||||
@@ -118,13 +118,13 @@
|
||||
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 });
|
||||
stops.push({ station_id: from, times: times, direction_note: grp.label || null });
|
||||
} else if (from != null) {
|
||||
stops.push({ station_id: from, times: [], dir_note: grp.label || null });
|
||||
stops.push({ station_id: from, times: [], direction_note: grp.label || null });
|
||||
}
|
||||
out.push({
|
||||
dir_id: kind + ':' + name,
|
||||
dir_label: name,
|
||||
direction_id: kind + ':' + name,
|
||||
direction_label: name,
|
||||
service: { day: kind, from: 'schema 3', matches: kind === todayType() },
|
||||
station_order: doc.station_order || [],
|
||||
stops: stops,
|
||||
@@ -184,7 +184,7 @@
|
||||
ลำดับการตัดสิน:
|
||||
1) ถ้าทิศมี "days" ระบุตรง ๆ (อา จ อ พ พฤ ศ ส) → ใช้ตามนั้น (แม่นสุด)
|
||||
2) ถ้ามี service = weekday/holiday → เทียบกับวันนี้
|
||||
3) ถ้าไม่มีอะไรระบุ → อ่านคำใน dir_label / dir_note / note ของสายนั้น (ตรวจคำอัตโนมัติ)
|
||||
3) ถ้าไม่มีอะไรระบุ → อ่านคำใน direction_label / direction_note / note ของสายนั้น (ตรวจคำอัตโนมัติ)
|
||||
4) ตัดสินไม่ได้ → แสดงทุกวัน (ไม่ซ่อนข้อมูล) พร้อมป้ายว่า "ยังไม่ระบุวัน" */
|
||||
var DAYS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat']; /* ตรงกับ Date.getDay() */
|
||||
var DAY_TH = { sun: 'อาทิตย์', mon: 'จันทร์', tue: 'อังคาร', wed: 'พุธ', thu: 'พฤหัสบดี', fri: 'ศุกร์', sat: 'เสาร์' };
|
||||
@@ -216,7 +216,7 @@
|
||||
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) ว่าหมายถึงวันไหน */
|
||||
/* ตรวจคำในข้อความ (direction_label / direction_note / note) ว่าหมายถึงวันไหน */
|
||||
function detectDay(text) {
|
||||
var t = String(text == null ? '' : text).trim();
|
||||
if (!t) return null;
|
||||
@@ -231,9 +231,9 @@
|
||||
คืน { day, from, text } หรือ null (ยังไม่ระบุ) */
|
||||
function detectDayOfDir(d) {
|
||||
var texts = [];
|
||||
if (d && d.dir_label) texts.push(d.dir_label);
|
||||
if (d && (d.direction_label || d.dir_label)) texts.push((d.direction_label || d.dir_label));
|
||||
((d && d.stops) || []).forEach(function (s) {
|
||||
if (s.dir_note) texts.push(s.dir_note);
|
||||
if ((s.direction_note || s.dir_note)) texts.push((s.direction_note || s.dir_note));
|
||||
if (s.note) texts.push(s.note);
|
||||
});
|
||||
var verdicts = [], conflicts = false, hasHol = false, hasWk = false, sample = null;
|
||||
@@ -332,7 +332,8 @@
|
||||
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) };
|
||||
directions: dirs, schema3: isSchema3(sub),
|
||||
updated: sub.updated || null };
|
||||
return SUBS[String(sub.route_id)];
|
||||
}).catch(function () { return null; });
|
||||
})).then(function (list) {
|
||||
@@ -344,7 +345,14 @@
|
||||
return subsReady;
|
||||
}
|
||||
/* โหลดสายเดียว (เร็ว — ใช้ตอนเปิดหน้า check/routes ของสายนั้น) */
|
||||
function loadRoute(rid) {
|
||||
/* วันที่อัปเดตไฟล์ตารางของสาย (ฟิลด์ "updated" ใน scheduleslist/schedules<id>.json)
|
||||
— ค่ามาจาก mtime ของไฟล์จริง (เติมโดย resource/tools/stamp-schedules.py) */
|
||||
function updatedOf(rid) {
|
||||
var s = SUBS[String(rid)];
|
||||
return (s && s.updated) ? String(s.updated) : null;
|
||||
}
|
||||
|
||||
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; });
|
||||
@@ -416,8 +424,8 @@
|
||||
if (!r) return [];
|
||||
list = (r.directions || []).map(function (d) {
|
||||
return {
|
||||
dir_id: d.dir_id,
|
||||
dir_label: d.dir_label,
|
||||
direction_id: (d.direction_id || d.dir_id),
|
||||
direction_label: (d.direction_label || d.dir_label),
|
||||
days: Array.isArray(d.days) ? d.days.map(String) : null, /* ระบุวันตรง ๆ (อา จ อ พ พฤ ศ ส) */
|
||||
service: serviceOf(d, d), /* ตรวจวัน + เหตุผล (จากคำ/service/days) */
|
||||
autoTimes: !!d.autoTimes, /* true = คำนวณจุดที่ไม่มีตารางให้ */
|
||||
@@ -431,7 +439,7 @@
|
||||
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,
|
||||
direction_note: (s.direction_note || s.dir_note) || null,
|
||||
note: s.note || null,
|
||||
groups: s.groups || null,
|
||||
derive: s.derive || null /* กฎ "จุดนี้ = เวลาจุดอ้างอิง ± n นาที" */
|
||||
@@ -441,10 +449,10 @@
|
||||
});
|
||||
} else {
|
||||
/* schema 1 → ยังใช้ได้เหมือนเดิม (ไม่แยกวัน) */
|
||||
list = [{ dir_id: 'all', dir_label: null, service: 'all', stops: (doc && doc.schedules ? doc.schedules : []).filter(function (r) {
|
||||
list = [{ direction_id: 'all', direction_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 };
|
||||
return { station_id: r.station_id, times: r.departure_times || [], direction_note: r.direction_note || null, note: r.schedule_note || null, groups: null };
|
||||
}) }];
|
||||
}
|
||||
|
||||
@@ -498,10 +506,10 @@
|
||||
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,
|
||||
return { station_id: s.station_id, times: t, km: s.km, direction_note: (s.direction_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,
|
||||
return { direction_id: (d.direction_id || d.dir_id), direction_label: (d.direction_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 };
|
||||
@@ -519,14 +527,14 @@
|
||||
out.push({
|
||||
route_id: r.route_id,
|
||||
station_id: s.station_id,
|
||||
direction_note: s.dir_note || null,
|
||||
dir_label: d.dir_label || null, /* ชื่อทิศ (ป่าโมกไปอยุธยา ฯลฯ) — ใช้เป็นหัวแถว */
|
||||
direction_note: (s.direction_note || s.dir_note) || null,
|
||||
direction_label: (d.direction_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,
|
||||
direction_id: (d.direction_id || d.dir_id),
|
||||
service: d.service,
|
||||
days: d.days,
|
||||
dayType: d.dayType,
|
||||
@@ -605,6 +613,7 @@
|
||||
serviceOf: serviceOf,
|
||||
timesFor: timesFor,
|
||||
computeTimes: computeTimes,
|
||||
updatedOf: updatedOf, /* วันที่อัปเดตไฟล์ตารางของสาย (ISO) — ใช้แสดง "อัปเดตล่าสุด ..." */
|
||||
speedOf: speedOf,
|
||||
absKm: absKm,
|
||||
relKms: relKms,
|
||||
|
||||
Reference in new issue
Block a user