Забил статически пулково 1942
This commit is contained in:
parent
6c501a74be
commit
e997599716
@ -23,16 +23,30 @@
|
||||
</style>
|
||||
{% endblock %}
|
||||
{% block content %}
|
||||
<section class="content text-sm p-1">
|
||||
<div class="card h-100">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Создание слоя</h3>
|
||||
<section class="content-header">
|
||||
<div class="container-fluid">
|
||||
<div class="row mb-2">
|
||||
<div class="col-sm-6">
|
||||
<h1 class="mb-2">Создание слоя</h1>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item"><a href="{% url 'mainindex' %}">Главная</a>
|
||||
</li>
|
||||
<li class="breadcrumb-item active">Создание слоя</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.container-fluid -->
|
||||
</section>
|
||||
|
||||
<section class="content text-sm p-1">
|
||||
<div class="card" style="height: 90%;">
|
||||
|
||||
<!-- /.card-header -->
|
||||
<form enctype="multipart/form-data" method="post" class="card-body">
|
||||
<div class="row h-100">
|
||||
<div class="col-md-6 col-sm-12">
|
||||
<div class="col-md-4 col-sm-12">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Общие данные</h3>
|
||||
@ -70,7 +84,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 col-sm-12">
|
||||
<div class="col-md-8 col-sm-12">
|
||||
<div class="card h-100">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">Предпросмотр</h3>
|
||||
@ -101,6 +115,7 @@
|
||||
<script src="{% static 'js/ol/lib/OpenLayers.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
||||
<script src="{% static 'js/ol/ol-ext/ol-ext.min.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
||||
<script src="{% static 'js/ol/dxf-parser.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/proj4js/2.15.0/proj4-src.js"></script>
|
||||
|
||||
<script src="{% static 'js/ol/layersStyles.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
||||
<script src="{% static 'js/ol/mapCommonFuncs.js' %}?ver={% settings_value 'APP_VER' %}"></script>
|
||||
@ -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',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user