Изменил отображение слоя
This commit is contained in:
parent
628bf9bdf5
commit
563dc5ab29
@ -3,6 +3,7 @@ import os.path
|
||||
import subprocess
|
||||
import sys
|
||||
import traceback
|
||||
import uuid
|
||||
from typing import Any
|
||||
|
||||
from apps.main.models.model_ortho import Ortho, orthos_path
|
||||
@ -67,22 +68,22 @@ class OrthoCreateView(CreateView):
|
||||
path = temp_file.temporary_file_path()
|
||||
rst = GDALRaster(path, write=True)
|
||||
extent = self.get_extent(rst)
|
||||
ortho_obj = Ortho.objects.create(
|
||||
ortho_obj = Ortho(
|
||||
name=name,
|
||||
min_lon=extent[0],
|
||||
min_lat=extent[1],
|
||||
max_lon=extent[2],
|
||||
max_lat=extent[3],
|
||||
)
|
||||
|
||||
save_path = os.path.join(orthos_path, str(ortho_obj.id))
|
||||
ortho_uuid = str(uuid.uuid4())
|
||||
save_path = os.path.join(orthos_path, ortho_uuid)
|
||||
if not os.path.exists(save_path):
|
||||
os.makedirs(save_path)
|
||||
|
||||
self.generate_tiles(path, save_path)
|
||||
|
||||
ortho_obj.tiles_path = (
|
||||
f"{settings.MEDIA_URL}orthos/{ortho_obj.id}/{{z}}/{{x}}/{{y}}.png"
|
||||
f"{settings.MEDIA_URL}orthos/{ortho_uuid}/{{z}}/{{x}}/{{y}}.png"
|
||||
)
|
||||
ortho_obj.save()
|
||||
return redirect("management:street_pos:ortho-list")
|
||||
|
||||
@ -90,16 +90,7 @@ class CreatedLayersManager {
|
||||
if (layer.layer_type === 'Tile') {
|
||||
newLayer = new ol.layer.Tile({
|
||||
source: new ol.source.XYZ({
|
||||
tileUrlFunction: function (tileCoord) {
|
||||
const z = tileCoord[0];
|
||||
const x = tileCoord[1];
|
||||
const y = tileCoord[2];
|
||||
|
||||
// Инвертируем Y для TMS → XYZ
|
||||
const tmsY = (1 << z) - y - 1;
|
||||
|
||||
return `/media/orthos/${layer.id}/${z}/${x}/${y}.png`;
|
||||
},
|
||||
url: layer.path
|
||||
}),
|
||||
extent: ol.proj.transformExtent(layer.extent,
|
||||
'EPSG:4326', 'EPSG:3857'
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user