diff --git a/apps/main/templates/create_layer.html b/apps/main/templates/create_layer.html index 0966e9b..ebcbbf9 100644 --- a/apps/main/templates/create_layer.html +++ b/apps/main/templates/create_layer.html @@ -23,16 +23,30 @@ {% endblock %} {% block content %} -
-
-
-

Создание слоя

+
+
+
+
+

Создание слоя

+
+
+ +
+
+
+ +
+
-
+

Общие данные

@@ -70,7 +84,7 @@
-
+

Предпросмотр

@@ -101,6 +115,7 @@ + @@ -122,8 +137,6 @@ let centerLat = parseFloat('{{lat}}') let centerLon = parseFloat('{{lon}}') - let zeroLon = parseFloat("{{ zeroLon }}") ? parseFloat("{{ zeroLon }}") : centerLon - let zeroLat = parseFloat("{{ zeroLat }}") ? parseFloat("{{ zeroLat }}") : centerLat let transformInteraction = {} let translateInteraction = {} @@ -334,8 +347,10 @@ let minY = dxfHeader.$EXTMIN.y; return entities.map(entity => { const coords = getCoordinates(entity).map(([x, y]) => { - const normalizedX = x - minX; - const normalizedY = y - minY; + const normalizedX = x + // - minX; + const normalizedY = y + // - minY; return convertToLonLat([normalizedX, normalizedY]); }); return {...entity, normalizedCoords: coords}; @@ -366,9 +381,6 @@ } return null; }).filter(f => f !== null); - features.push( - createFeature('Point', [zeroLat, zeroLon], {zeroPoint: true}) - ) console.log(features) return {type: 'FeatureCollection', features: features}; } @@ -474,16 +486,19 @@ } function convertToLonLat([x, y]) { + proj4.defs( + "EPSG:28415", + "+proj=tmerc +lat_0=0 +lon_0=87 +k=1 +x_0=15500000 +y_0=0 +ellps=krass +towgs84=23.57,-140.95,-79.8,0,0.35,0.79,-0.22 +units=m +no_defs" + ); - const kx = 1.676; - const ky = 1.001; + // Определение проекции WGS84 (EPSG:4326) + proj4.defs("EPSG:4326", "+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"); - let res = ol.proj.transform([x, y], 'EPSG:3857', 'EPSG:4326') - res[0] = kx * res[0] - + zeroLat // ДОЛГОТА - res[1] = ky * res[1] - + zeroLon // ШИРОТА - return res; + // Преобразование координат + const transformedCoords = proj4("EPSG:28415", "EPSG:4326", [x, y]); + + // Возвращаем результат (долгота, широта) + return [transformedCoords[0], transformedCoords[1]]; } function downloadGeoJSON(geojson) { @@ -508,16 +523,13 @@ const formData = new FormData(); formData.append('file', new Blob([geojson], {type: 'application/json'}), 'export.geojson'); - formData.append('name', name.value) - - const zeroPointFeatures = features.filter((feature) => feature.get('zeroPoint')) - if (zeroPointFeatures.length > 0) { - console.log(zeroPointFeatures) - const zeroCoords = getCoordsByFeature(zeroPointFeatures[0]) - formData.append('zeroLat', zeroCoords.lat) - formData.append('zeroLon', zeroCoords.lon) + if (!name.value) { + formData.append("name", fileField.files[0].name) + } else { + formData.append('name', name.value) } + // Отправляем данные на сервер fetch(window.location.href, { method: 'POST',