feat: Initial commit - WebGIS Smart City Project by Naufal Zaky Ramadhan (D1041231071)

This commit is contained in:
naukyy
2026-06-13 00:00:33 +07:00
commit 2c123f5af2
163 changed files with 13007 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
const getBaseUrl = () => {
const segments = window.location.pathname.split('/');
const targetIndex = segments.findIndex(seg => ['01', '02', '03', 'versi'].includes(seg));
if (targetIndex !== -1) {
return segments.slice(0, targetIndex).join('/');
}
return '';
};
export const BASE_URL = getBaseUrl();
const createService = (endpoint) => ({
getAll: async () => {
const res = await fetch(`${BASE_URL}/${endpoint}`);
const json = await res.json();
return json.data;
},
create: async (data) => {
const res = await fetch(`${BASE_URL}/${endpoint}`, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data)
});
const json = await res.json();
return json.data;
},
delete: async (id) => {
const res = await fetch(`${BASE_URL}/${endpoint}?id=${id}`, {
method: 'DELETE'
});
const json = await res.json();
return json.data;
}
});
// P01
export const spbuService = createService('01/backend/api/spbu.php');
export const jalanService = createService('01/backend/api/jalan.php');
export const kavlingService = createService('01/backend/api/kavling.php');
// P02
export const rumahIbadahService = createService('02/backend/api/rumah_ibadah.php');
export const wargaMiskinService = createService('02/backend/api/warga_miskin.php');
export const haversineService = {
getDalamRadius: async (id, radius) => {
const res = await fetch(`${BASE_URL}/02/backend/api/haversine.php?rumah_ibadah_id=${id}&radius_km=${radius}`);
const json = await res.json();
return json.data;
}
};
@@ -0,0 +1,22 @@
import { CONFIG } from '../config.js';
export const rumahIbadahService = {
getAll: async () => {
const res = await fetch(`${CONFIG.BASE_URL}/rumah_ibadah.php`);
return await res.json();
},
save: async (data) => {
const res = await fetch(`${CONFIG.BASE_URL}/rumah_ibadah.php`, {
method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data)
});
return await res.json();
},
delete: async (id) => {
const res = await fetch(`${CONFIG.BASE_URL}/rumah_ibadah.php?id=${id}`, { method: 'DELETE' });
return await res.json();
},
getJangkauan: async (id, radius = 1) => {
const res = await fetch(`${CONFIG.BASE_URL}/rumah_ibadah.php?action=jangkauan&id=${id}&radius=${radius}`);
return await res.json();
}
};
@@ -0,0 +1,10 @@
export const CONFIG = {
BASE_URL: '/final/backend/api'
};
export const statistikService = {
getKepadatan: async () => {
const res = await fetch(`${CONFIG.BASE_URL}/statistik.php`);
return await res.json();
}
};
@@ -0,0 +1,18 @@
import { CONFIG } from '../config.js';
export const wargaMiskinService = {
getAll: async () => {
const res = await fetch(`${CONFIG.BASE_URL}/warga_miskin.php`);
return await res.json();
},
save: async (data) => {
const res = await fetch(`${CONFIG.BASE_URL}/warga_miskin.php`, {
method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data)
});
return await res.json();
},
delete: async (id) => {
const res = await fetch(`${CONFIG.BASE_URL}/warga_miskin.php?id=${id}`, { method: 'DELETE' });
return await res.json();
}
};