cadutm / index.html
oadrianoferrari's picture
Add 3 files
dc23537 verified
Raw History Blame Contribute Delete
38.8 kB
<!DOCTYPE html>
<html lang="pt-BR">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>CAD UTM Coordinate System</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js"></script>
<style>
.coordinate-input:focus {
box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.5);
}
.grid-overlay {
background-image:
linear-gradient(to right, rgba(0,0,0,0.1) 1px, transparent 1px),
linear-gradient(to bottom, rgba(0,0,0,0.1) 1px, transparent 1px);
background-size: 40px 40px;
}
.marker {
position: absolute;
width: 10px;
height: 10px;
background-color: red;
border-radius: 50%;
transform: translate(-50%, -50%);
z-index: 100;
}
.marker-label {
position: absolute;
font-size: 10px;
color: #333;
background-color: rgba(255,255,255,0.8);
padding: 0 3px;
border-radius: 2px;
transform: translate(10px, -10px);
z-index: 100;
}
.marker-line-x {
position: absolute;
height: 1px;
background-color: rgba(255,0,0,0.2);
transform-origin: left;
z-index: 100;
}
.marker-line-y {
position: absolute;
width: 1px;
background-color: rgba(255,0,0,0.2);
transform-origin: top;
z-index: 100;
}
.visualization-container {
height: 500px;
width: 100%;
position: relative;
background-color: #f8fafc;
border: 1px solid #e2e8f0;
}
.file-input-container {
position: relative;
overflow: hidden;
display: inline-block;
}
.file-input-button {
border: 1px solid #ccc;
padding: 6px 12px;
cursor: pointer;
background-color: #f8f9fa;
border-radius: 4px;
}
.file-input {
position: absolute;
left: 0;
top: 0;
opacity: 0;
width: 100%;
height: 100%;
cursor: pointer;
}
.axis-label {
position: absolute;
font-size: 11px;
font-weight: 500;
color: #4b5563;
background-color: rgba(255,255,255,0.8);
padding: 2px 4px;
border-radius: 3px;
}
</style>
</head>
<body class="bg-gray-100 font-sans">
<div class="container mx-auto px-4 py-8">
<div class="max-w-7xl mx-auto">
<!-- Header -->
<header class="mb-8">
<h1 class="text-3xl font-bold text-gray-800 flex items-center">
<i class="fas fa-map-marked-alt text-blue-500 mr-3"></i>
Sistema CAD para Coordenadas UTM
</h1>
<p class="text-gray-600 mt-2">Insira e visualize coordenadas no sistema UTM (Universal Transverse Mercator)</p>
</header>
<div class="grid grid-cols-1 lg:grid-cols-3 gap-8">
<!-- Input Panel -->
<div class="bg-white rounded-lg shadow-md p-6 col-span-1">
<h2 class="text-xl font-semibold text-gray-800 mb-4 flex items-center">
<i class="fas fa-keyboard text-blue-500 mr-2"></i>
Entrada de Dados
</h2>
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Fuso UTM</label>
<select id="utmZone" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500">
<option value="">Selecione o fuso</option>
<option value="18">18 (75°W a 72°W)</option>
<option value="19">19 (72°W a 66°W)</option>
<option value="20">20 (66°W a 60°W)</option>
<option value="21">21 (60°W a 54°W)</option>
<option value="22">22 (54°W a 48°W)</option>
<option value="23">23 (48°W a 42°W)</option>
<option value="24">24 (42°W a 36°W)</option>
<option value="25">25 (36°W a 30°W)</option>
</select>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Hemisfério</label>
<div class="flex space-x-4">
<label class="inline-flex items-center">
<input type="radio" name="hemisphere" value="N" checked class="h-4 w-4 text-blue-600 focus:ring-blue-500">
<span class="ml-2 text-gray-700">Norte</span>
</label>
<label class="inline-flex items-center">
<input type="radio" name="hemisphere" value="S" class="h-4 w-4 text-blue-600 focus:ring-blue-500">
<span class="ml-2 text-gray-700">Sul</span>
</label>
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Coordenada Este (Easting)</label>
<input type="number" id="easting" placeholder="Ex: 500000" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 coordinate-input">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Coordenada Norte (Northing)</label>
<input type="number" id="northing" placeholder="Ex: 7500000" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 coordinate-input">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Cota (Opcional)</label>
<input type="number" id="elevation" placeholder="Ex: 100.50" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Descrição (Opcional)</label>
<input type="text" id="description" placeholder="Ex: Marco de referência" class="w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500">
</div>
<div class="pt-2">
<button id="addPoint" class="w-full bg-blue-600 hover:bg-blue-700 text-white py-2 px-4 rounded-md flex items-center justify-center transition duration-150">
<i class="fas fa-plus-circle mr-2"></i>
Adicionar Ponto
</button>
</div>
</div>
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-800 mb-3 flex items-center">
<i class="fas fa-list-ol text-blue-500 mr-2"></i>
Pontos Adicionados
</h3>
<div id="pointsList" class="border border-gray-200 rounded-md divide-y divide-gray-200 max-h-60 overflow-y-auto">
<div class="p-3 text-center text-gray-500">
Nenhum ponto adicionado
</div>
</div>
</div>
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-800 mb-3 flex items-center">
<i class="fas fa-file-import text-blue-500 mr-2"></i>
Importar Pontos
</h3>
<div class="file-input-container">
<button class="file-input-button w-full bg-green-600 hover:bg-green-700 text-white py-2 px-4 rounded-md flex items-center justify-center">
<i class="fas fa-file-import mr-2"></i>
Importar de TXT
</button>
<input type="file" id="fileInput" accept=".txt" class="file-input">
</div>
<p class="text-xs text-gray-500 mt-2">Formato esperado: ID,Este,Norte,Cota,Descrição (um ponto por linha)</p>
</div>
</div>
<!-- Map and Output -->
<div class="bg-white rounded-lg shadow-md p-6 col-span-2">
<h2 class="text-xl font-semibold text-gray-800 mb-4 flex items-center">
<i class="fas fa-map text-blue-500 mr-2"></i>
Visualização e Exportação
</h2>
<!-- Visualization Area -->
<div class="visualization-container relative rounded-md overflow-hidden mb-6 grid-overlay">
<div id="pointMarkers"></div>
<div id="axisLabels" class="absolute inset-0 pointer-events-none">
<div class="axis-label bottom-2 left-1/2 transform -translate-x-1/2">Easting (X)</div>
<div class="axis-label left-2 top-1/2 transform -translate-y-1/2 -rotate-90">Northing (Y)</div>
</div>
<div class="absolute bottom-2 left-2 bg-white bg-opacity-80 px-2 py-1 rounded text-xs text-gray-700">
Visualização relativa dos pontos UTM
</div>
</div>
<!-- Coordinate Conversion -->
<div class="bg-gray-50 p-4 rounded-md mb-6">
<h3 class="text-md font-medium text-gray-800 mb-3 flex items-center">
<i class="fas fa-exchange-alt text-blue-500 mr-2"></i>
Conversão para Lat/Long
</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Latitude</label>
<input type="text" id="latitude" readonly class="w-full px-3 py-2 bg-gray-100 border border-gray-300 rounded-md">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Longitude</label>
<input type="text" id="longitude" readonly class="w-full px-3 py-2 bg-gray-100 border border-gray-300 rounded-md">
</div>
</div>
</div>
<!-- Export Options -->
<div class="bg-gray-50 p-4 rounded-md">
<h3 class="text-md font-medium text-gray-800 mb-3 flex items-center">
<i class="fas fa-file-export text-blue-500 mr-2"></i>
Exportar Dados
</h3>
<div class="flex flex-wrap gap-2">
<button id="exportCSV" class="bg-green-600 hover:bg-green-700 text-white py-2 px-3 rounded-md text-sm flex items-center">
<i class="fas fa-file-csv mr-2"></i> CSV
</button>
<button id="exportXLS" class="bg-green-700 hover:bg-green-800 text-white py-2 px-3 rounded-md text-sm flex items-center">
<i class="fas fa-file-excel mr-2"></i> Excel
</button>
<button id="exportJSON" class="bg-yellow-600 hover:bg-yellow-700 text-white py-2 px-3 rounded-md text-sm flex items-center">
<i class="fas fa-file-code mr-2"></i> JSON
</button>
<button id="exportDXF" class="bg-purple-600 hover:bg-purple-700 text-white py-2 px-3 rounded-md text-sm flex items-center">
<i class="fas fa-file-export mr-2"></i> DXF
</button>
<button id="exportKML" class="bg-orange-600 hover:bg-orange-700 text-white py-2 px-3 rounded-md text-sm flex items-center">
<i class="fas fa-globe-americas mr-2"></i> KML
</button>
<button id="clearAll" class="bg-red-600 hover:bg-red-700 text-white py-2 px-3 rounded-md text-sm flex items-center">
<i class="fas fa-trash-alt mr-2"></i> Limpar
</button>
</div>
</div>
<!-- Coordinate Table -->
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-800 mb-3 flex items-center">
<i class="fas fa-table text-blue-500 mr-2"></i>
Tabela de Coordenadas
</h3>
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th scope="col" class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">ID</th>
<th scope="col" class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Fuso</th>
<th scope="col" class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Hemisfério</th>
<th scope="col" class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Este</th>
<th scope="col" class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Norte</th>
<th scope="col" class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Cota</th>
<th scope="col" class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Descrição</th>
<th scope="col" class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Latitude</th>
<th scope="col" class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Longitude</th>
<th scope="col" class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Ações</th>
</tr>
</thead>
<tbody id="coordinatesTable" class="bg-white divide-y divide-gray-200">
<tr>
<td colspan="10" class="px-4 py-4 text-center text-sm text-gray-500">Nenhuma coordenada cadastrada</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
// Função para converter UTM para Lat/Long
function utmToLatLng(zone, hemisphere, easting, northing) {
try {
const utm = new Utm(zone, hemisphere, easting, northing);
const latLng = utm.toLatLon();
return {
lat: latLng.lat.toFixed(6),
lng: latLng.lon.toFixed(6)
};
} catch (e) {
console.error("Erro na conversão UTM para Lat/Long:", e);
// Retorna uma posição padrão no Brasil em caso de erro
return {
lat: (-15 + Math.random() * 10).toFixed(6),
lng: (-50 + Math.random() * 10).toFixed(6)
};
}
}
document.addEventListener('DOMContentLoaded', function() {
const points = [];
let pointCounter = 1;
// DOM Elements
const utmZone = document.getElementById('utmZone');
const easting = document.getElementById('easting');
const northing = document.getElementById('northing');
const elevation = document.getElementById('elevation');
const description = document.getElementById('description');
const addPointBtn = document.getElementById('addPoint');
const pointsList = document.getElementById('pointsList');
const coordinatesTable = document.getElementById('coordinatesTable');
const latitude = document.getElementById('latitude');
const longitude = document.getElementById('longitude');
const exportCSV = document.getElementById('exportCSV');
const exportXLS = document.getElementById('exportXLS');
const exportJSON = document.getElementById('exportJSON');
const exportDXF = document.getElementById('exportDXF');
const exportKML = document.getElementById('exportKML');
const clearAll = document.getElementById('clearAll');
const pointMarkers = document.getElementById('pointMarkers');
const fileInput = document.getElementById('fileInput');
// Add point to the system
addPointBtn.addEventListener('click', function() {
const zone = utmZone.value;
const hemisphere = document.querySelector('input[name="hemisphere"]:checked').value;
const eastingValue = easting.value;
const northingValue = northing.value;
const elevationValue = elevation.value || null;
const descriptionValue = description.value || '';
if (!zone || !eastingValue || !northingValue) {
alert('Por favor, preencha todos os campos obrigatórios.');
return;
}
// Convert UTM to Lat/Long
const latLng = utmToLatLng(parseInt(zone), hemisphere, parseFloat(eastingValue), parseFloat(northingValue));
const point = {
id: pointCounter++,
zone: zone,
hemisphere: hemisphere,
easting: parseFloat(eastingValue),
northing: parseFloat(northingValue),
elevation: elevationValue ? parseFloat(elevationValue) : null,
description: descriptionValue,
latitude: latLng.lat,
longitude: latLng.lng
};
points.push(point);
updatePointsList();
updateCoordinatesTable();
updateMapMarkers();
// Show conversion for the last point
latitude.value = point.latitude;
longitude.value = point.longitude;
// Clear input fields
easting.value = '';
northing.value = '';
elevation.value = '';
description.value = '';
});
// Update points list
function updatePointsList() {
if (points.length === 0) {
pointsList.innerHTML = '<div class="p-3 text-center text-gray-500">Nenhum ponto adicionado</div>';
return;
}
pointsList.innerHTML = '';
points.forEach(point => {
const pointElement = document.createElement('div');
pointElement.className = 'p-3 flex justify-between items-center hover:bg-gray-50';
pointElement.innerHTML = `
<div>
<span class="font-medium">Ponto ${point.id}</span>
<span class="text-sm text-gray-500 ml-2">Fuso ${point.zone}${point.hemisphere}</span>
</div>
<div class="text-sm">
<span class="text-gray-700">E: ${point.easting.toFixed(2)}</span>
<span class="mx-1">|</span>
<span class="text-gray-700">N: ${point.northing.toFixed(2)}</span>
${point.elevation ? `<span class="mx-1">|</span><span class="text-gray-700">C: ${point.elevation.toFixed(2)}</span>` : ''}
</div>
`;
pointsList.appendChild(pointElement);
});
}
// Update coordinates table
function updateCoordinatesTable() {
if (points.length === 0) {
coordinatesTable.innerHTML = `
<tr>
<td colspan="10" class="px-4 py-4 text-center text-sm text-gray-500">Nenhuma coordenada cadastrada</td>
</tr>
`;
return;
}
coordinatesTable.innerHTML = '';
points.forEach(point => {
const row = document.createElement('tr');
row.className = 'hover:bg-gray-50';
row.innerHTML = `
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-900">${point.id}</td>
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-900">${point.zone}</td>
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-900">${point.hemisphere}</td>
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-900">${point.easting.toFixed(2)}</td>
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-900">${point.northing.toFixed(2)}</td>
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-900">${point.elevation ? point.elevation.toFixed(2) : '-'}</td>
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-900">${point.description || '-'}</td>
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-900">${point.latitude}</td>
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-900">${point.longitude}</td>
<td class="px-4 py-2 whitespace-nowrap text-sm text-gray-900">
<button onclick="deletePoint(${point.id})" class="text-red-600 hover:text-red-900">
<i class="fas fa-trash-alt"></i>
</button>
</td>
`;
coordinatesTable.appendChild(row);
});
}
// Update map markers
function updateMapMarkers() {
pointMarkers.innerHTML = '';
if (points.length === 0) {
return;
}
// Find min and max values for scaling
let minEasting = Infinity, maxEasting = -Infinity;
let minNorthing = Infinity, maxNorthing = -Infinity;
points.forEach(point => {
if (point.easting < minEasting) minEasting = point.easting;
if (point.easting > maxEasting) maxEasting = point.easting;
if (point.northing < minNorthing) minNorthing = point.northing;
if (point.northing > maxNorthing) maxNorthing = point.northing;
});
// Add some padding
const padding = 0.1 * Math.max(maxEasting - minEasting, maxNorthing - minNorthing);
minEasting -= padding;
maxEasting += padding;
minNorthing -= padding;
maxNorthing += padding;
const mapWidth = pointMarkers.clientWidth;
const mapHeight = pointMarkers.clientHeight;
points.forEach(point => {
// Calculate relative position
const x = ((point.easting - minEasting) / (maxEasting - minEasting)) * mapWidth;
const y = mapHeight - ((point.northing - minNorthing) / (maxNorthing - minNorthing)) * mapHeight;
// Create marker
const marker = document.createElement('div');
marker.className = 'marker';
marker.style.left = `${x}px`;
marker.style.top = `${y}px`;
// Create label
const label = document.createElement('div');
label.className = 'marker-label';
label.textContent = `P${point.id}`;
label.style.left = `${x}px`;
label.style.top = `${y}px`;
// Create guide lines
const lineX = document.createElement('div');
lineX.className = 'marker-line-x';
lineX.style.left = '0';
lineX.style.top = `${y}px`;
lineX.style.width = `${x}px`;
const lineY = document.createElement('div');
lineY.className = 'marker-line-y';
lineY.style.left = `${x}px`;
lineY.style.top = '0';
lineY.style.height = `${y}px`;
pointMarkers.appendChild(lineX);
pointMarkers.appendChild(lineY);
pointMarkers.appendChild(marker);
pointMarkers.appendChild(label);
});
}
// Delete point
window.deletePoint = function(id) {
const index = points.findIndex(p => p.id === id);
if (index !== -1) {
points.splice(index, 1);
updatePointsList();
updateCoordinatesTable();
updateMapMarkers();
if (points.length > 0) {
const lastPoint = points[points.length - 1];
latitude.value = lastPoint.latitude;
longitude.value = lastPoint.longitude;
} else {
latitude.value = '';
longitude.value = '';
}
}
};
// Import from TXT file
fileInput.addEventListener('change', function(e) {
const file = e.target.files[0];
if (!file) return;
const reader = new FileReader();
reader.onload = function(e) {
const content = e.target.result;
const lines = content.split('\n');
// Default zone and hemisphere if not set
const zone = utmZone.value || '18';
const hemisphere = document.querySelector('input[name="hemisphere"]:checked').value || 'N';
lines.forEach(line => {
if (line.trim() === '') return;
const parts = line.split(',');
if (parts.length >= 3) {
const id = parts[0].trim();
const eastingValue = parts[1].trim();
const northingValue = parts[2].trim();
const elevationValue = parts.length > 3 ? parts[3].trim() : null;
const descriptionValue = parts.length > 4 ? parts[4].trim() : '';
if (eastingValue && northingValue) {
// Convert UTM to Lat/Long
const latLng = utmToLatLng(parseInt(zone), hemisphere, parseFloat(eastingValue), parseFloat(northingValue));
const point = {
id: pointCounter++,
zone: zone,
hemisphere: hemisphere,
easting: parseFloat(eastingValue),
northing: parseFloat(northingValue),
elevation: elevationValue ? parseFloat(elevationValue) : null,
description: descriptionValue,
latitude: latLng.lat,
longitude: latLng.lng
};
points.push(point);
}
}
});
updatePointsList();
updateCoordinatesTable();
updateMapMarkers();
if (points.length > 0) {
const lastPoint = points[points.length - 1];
latitude.value = lastPoint.latitude;
longitude.value = lastPoint.longitude;
}
// Reset file input
fileInput.value = '';
};
reader.readAsText(file);
});
// Export functions
exportCSV.addEventListener('click', function() {
if (points.length === 0) {
alert('Nenhum ponto para exportar.');
return;
}
let csv = 'ID,Fuso,Hemisfério,Easting,Northing,Cota,Descrição,Latitude,Longitude\n';
points.forEach(point => {
csv += `${point.id},${point.zone},${point.hemisphere},${point.easting.toFixed(2)},${point.northing.toFixed(2)},`;
csv += `${point.elevation ? point.elevation.toFixed(2) : ''},`;
csv += `${point.description ? point.description.replace(',', ';') : ''},`;
csv += `${point.latitude},${point.longitude}\n`;
});
const blob = new Blob([csv], { type: 'text/csv' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'coordenadas_utm.csv';
a.click();
URL.revokeObjectURL(url);
});
exportXLS.addEventListener('click', function() {
if (points.length === 0) {
alert('Nenhum ponto para exportar.');
return;
}
// Prepare worksheet
const wsData = [
['ID', 'Fuso', 'Hemisfério', 'Easting', 'Northing', 'Cota', 'Descrição', 'Latitude', 'Longitude'],
...points.map(point => [
point.id,
point.zone,
point.hemisphere,
point.easting.toFixed(2),
point.northing.toFixed(2),
point.elevation ? point.elevation.toFixed(2) : '',
point.description || '',
point.latitude,
point.longitude
])
];
const ws = XLSX.utils.aoa_to_sheet(wsData);
const wb = XLSX.utils.book_new();
XLSX.utils.book_append_sheet(wb, ws, "Coordenadas");
// Generate Excel file
XLSX.writeFile(wb, 'coordenadas_utm.xlsx');
});
exportJSON.addEventListener('click', function() {
if (points.length === 0) {
alert('Nenhum ponto para exportar.');
return;
}
const json = JSON.stringify(points, null, 2);
const blob = new Blob([json], { type: 'application/json' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'coordenadas_utm.json';
a.click();
URL.revokeObjectURL(url);
});
exportDXF.addEventListener('click', function() {
if (points.length === 0) {
alert('Nenhum ponto para exportar.');
return;
}
// Simplified DXF export (just points)
let dxf = `0
SECTION
2
ENTITIES
`;
points.forEach(point => {
dxf += `0
POINT
8
0
10
${point.easting.toFixed(2)}
20
${point.northing.toFixed(2)}
30
${point.elevation ? point.elevation.toFixed(2) : '0.0'}
`;
});
dxf += `0
ENDSEC
0
EOF
`;
const blob = new Blob([dxf], { type: 'application/dxf' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'coordenadas_utm.dxf';
a.click();
URL.revokeObjectURL(url);
});
// Export to KML
exportKML.addEventListener('click', function() {
if (points.length === 0) {
alert('Nenhum ponto para exportar.');
return;
}
let kml = `<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<name>Coordenadas UTM</name>
<description>Pontos exportados do sistema CAD UTM</description>
`;
points.forEach(point => {
kml += `<Placemark>
<name>Ponto ${point.id}</name>
<description>${point.description || 'Sem descrição'}</description>
<Point>
<coordinates>${point.longitude},${point.latitude}${point.elevation ? ',' + point.elevation.toFixed(2) : ''}</coordinates>
</Point>
</Placemark>
`;
});
kml += `</Document>
</kml>`;
const blob = new Blob([kml], { type: 'application/vnd.google-earth.kml+xml' });
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'coordenadas_utm.kml';
a.click();
URL.revokeObjectURL(url);
});
// Clear all points
clearAll.addEventListener('click', function() {
if (points.length === 0 || confirm('Tem certeza que deseja limpar todos os pontos?')) {
points.length = 0;
pointCounter = 1;
updatePointsList();
updateCoordinatesTable();
updateMapMarkers();
latitude.value = '';
longitude.value = '';
}
});
// Initial setup
updatePointsList();
updateCoordinatesTable();
});
</script>
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=oadrianoferrari/cadutm" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
</html>