Created At: 2026-06-14T15:49:16Z
Completed At: 2026-06-14T15:49:16Z
File Path: `file:///c:/Users/HP/Downloads/climate-system/climate-system/index.php`
Total Lines: 4761
Total Bytes: 203898
Showing lines 51 to 250
The following code has been modified to include a line number before every line, in the format: <line_number>: <original_line>. Please note that any changes targeting the original code should remove the line number, colon, and leading space.
51:         }
52:         fclose($handle);
53:     }
54:     return $data;
55: }
56: 
57: // Fungsi membuat 4 file CSV simulasi IPCC (historical, ensmean, ensmin, ensmax) jika belum tersedia
58: function ensure_sample_csv_exists_ipcc($location_sanitized, $variable_sanitized) {
59:     $dir = __DIR__ . "/data/{$location_sanitized}/{$variable_sanitized}";
60:     if (!is_dir($dir)) {
61:         mkdir($dir, 0777, true);
62:     }
63: 
64:     $base = 26.5; // default baseline (suhu)
65:     if (stripos($variable_sanitized, 'anomaly') !== false || stripos($variable_sanitized, 'anomali') !== false) {
66:         $base = 0.5; // default baseline (anomali suhu)
67:     } else if (stripos($variable_sanitized, 'precip') !== false || stripos($variable_sanitized, 'hujan') !== false) {
68:         $base = 2300; // default baseline (curah hujan)
69:     } else if (stripos($variable_sanitized, 'kelembaban') !== false || stripos($variable_sanitized, 'humidity') !== false) {
70:         $base = 82.0;
71:     } else if (stripos($variable_sanitized, 'kecepatan') !== false || stripos($variable_sanitized, 'angin') !== false || stripos($variable_sanitized, 'wind') !== false) {
72:         $base = 2.4;
73:     } else if (stripos($variable_sanitized, 'radiasi') !== false || stripos($variable_sanitized, 'matahari') !== false || stripos($variable_sanitized, 'solar') !== false) {
74:         $base = 178.0;
75:     }
76: 
77:     // 1. historical_timeseries.csv (1991 - 2020)
78:     $hist_path = "{$dir}/historical_timeseries.csv";
79:     if (!file_exists($hist_path)) {
80:         $handle = 
<truncated 6787 bytes>
ations (
214:                 id INTEGER PRIMARY KEY AUTOINCREMENT,
215:                 name TEXT UNIQUE NOT NULL,
216:                 created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
217:             );
218: 
219:             CREATE TABLE IF NOT EXISTS variables (
220:                 id INTEGER PRIMARY KEY AUTOINCREMENT,
221:                 name TEXT UNIQUE NOT NULL,
222:                 created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
223:             );
224: 
225:             CREATE TABLE IF NOT EXISTS periods (
226:                 id INTEGER PRIMARY KEY AUTOINCREMENT,
227:                 range TEXT UNIQUE NOT NULL,
228:                 created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
229:             );
230: 
231:             CREATE TABLE IF NOT EXISTS historical_climate (
232:                 id INTEGER PRIMARY KEY AUTOINCREMENT,
233:                 location_id INTEGER NOT NULL,
234:                 variable_id INTEGER NOT NULL,
235:                 description TEXT DEFAULT '',
236:                 image_annual_url TEXT DEFAULT '',
237:                 image_trend_url TEXT DEFAULT '',
238:                 image_time_series_url TEXT DEFAULT '',
239:                 image_monthly_map_url TEXT DEFAULT '',
240:                 image_monthly_graph_url TEXT DEFAULT '',
241:                 created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
242:                 updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
243:                 FOREIGN KEY (location_id) REFERENCES locations(id) ON DELETE CASCADE,
244:                 FOREIGN KEY (variable_id) REFERENCES variables(id) ON DELETE CASCADE,
245:                 UNIQUE (location_id, variable_id)
246:             );
247: 
248:             CREATE TABLE IF NOT EXISTS future_climate (
249:                 id INTEGER PRIMARY KEY AUTOINCREMENT,
250:                 location_id INTEGER NOT NULL,
The above content does NOT show the entire file contents. If you need to view any lines of the file which were not shown to complete your task, call this tool again to view those lines.
