CREATE DATABASE IF NOT EXISTS webgis_jalan_tanah_p2;
USE webgis_jalan_tanah_p2;

DROP TABLE IF EXISTS data_spasial;
CREATE TABLE data_spasial (
    id INT AUTO_INCREMENT PRIMARY KEY,
    nama VARCHAR(150) NOT NULL,
    jenis_objek ENUM('Jalan', 'Tanah') NOT NULL,
    status VARCHAR(100) NOT NULL,
    ukuran DOUBLE NOT NULL DEFAULT 0,
    geojson LONGTEXT NOT NULL,
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
);

INSERT INTO data_spasial (nama, jenis_objek, status, ukuran, geojson) VALUES
('Contoh Jalan Ahmad Yani', 'Jalan', 'Jalan Nasional', 1250.00, '{"type":"LineString","coordinates":[[109.334,-0.055],[109.342,-0.047],[109.351,-0.043]]}'),
('Contoh Tanah Kavling A', 'Tanah', 'SHM', 8500.00, '{"type":"Polygon","coordinates":[[[109.337,-0.032],[109.342,-0.032],[109.342,-0.028],[109.337,-0.028],[109.337,-0.032]]]}');
