diff --git a/apps/main/templates/main_index.html b/apps/main/templates/main_index.html
index d8b064a..0807378 100644
--- a/apps/main/templates/main_index.html
+++ b/apps/main/templates/main_index.html
@@ -72,7 +72,12 @@
let centerLon = '{{lat}}'
const getGTOMarkerText = function (feature) {
- return feature.get('statenum');
+ const statemum = feature.get('statenum')
+ console.log(statemum)
+ if (statemum) {
+ return statemum;
+ }
+ return feature.get('name')
};
const createGTOStateNumTextStyle = function (feature, resolution) {
@@ -99,8 +104,8 @@
return new ol.style.Style({
image: new ol.style.Icon({
src: '/static/img/belaz.png',
- width: 40,
- height: 25
+ width: 30,
+ height: 20
}),
text: createGTOStateNumTextStyle(feature, resolution)
})
@@ -318,7 +323,7 @@
mineBorderLayer = new ol.layer.Vector({
source: new ol.source.Vector({
- url: '/static/border.kml/',
+ url: '{{ kml_path }}',
format: new ol.format.KML({extractStyles: false}),
}),
@@ -326,33 +331,29 @@
});
mineBorderLayer.set('name', 'Границы ПРГР')
- // const imageExtent = ol.proj.transformExtent(
- // [86.639393, 53.959368, 86.698046, 54.004628], // [minLon, minLat, maxLon, maxLat]
- // 'EPSG:4326', // Исходная проекция
- // 'EPSG:3857' // Целевая проекция
- // );
+ scanLayer = new ol.layer.Tile({
+ source: new ol.source.XYZ({
+ url: '/static/img/tiles/{z}/{x}/{y}.png/',
+ }),
+ extent: ol.proj.transformExtent(
+ [86.639393, 53.959368, 86.698046, 54.004628], // [minLon, minLat, maxLon, maxLat]
+ 'EPSG:4326', // Исходная проекция
+ 'EPSG:3857' // Целевая проекция
+ )
+ });
+ scanLayer.set('name', 'Ортофотоплан')
- // const scanSource = new ol.source.ImageStatic({
- // url: '/static/img/mine.png',
- // imageExtent: imageExtent // Преобразованные координаты
- // });
-
- // const scanLayer = new ol.layer.Image({
- // source: scanSource
- // });
// Создание карты
map = new ol.Map({
target: 'map', // ID элемента, куда встроится карта
controls: [
- {#new ol.control.Zoom(),#}
- new ol.control.FullScreen(),
new LayerSwitcherControl(),
new ol.control.ScaleLine(),
new ol.control.ZoomSlider()
],
layers: [
OSM,
- // scanLayer,
+ {#scanLayer,#}
mineBorderLayer,
GTOLayer,
SPLayer,
diff --git a/apps/main/views/views_main.py b/apps/main/views/views_main.py
index 37af19f..179a040 100644
--- a/apps/main/views/views_main.py
+++ b/apps/main/views/views_main.py
@@ -26,14 +26,16 @@ def mainindex(request):
try:
if request.method == "GET":
lon = str(float(settingsmodule.get_settings('longitude',
- '86.10111978605353'))) # долгота центра
+ '86.10111978605353'))) # долгота центра
lat = str(float(settingsmodule.get_settings('latitude',
- '55.344251210827814'))) # широта
+ '55.344251210827814'))) # широта
+ kml_path = settingsmodule.get_settings('kml_path', '')
context = generalmodule.get_context_template()
context.update({
'lon': lon.replace(',', '.'),
'lat': lat.replace(',', '.'),
+ 'kml_path': kml_path,
'updatepage': True,
})
return render(request, 'main_index.html', context)
diff --git a/apps/seismicproc/views/views_main.py b/apps/seismicproc/views/views_main.py
index 6c662fb..958d332 100644
--- a/apps/seismicproc/views/views_main.py
+++ b/apps/seismicproc/views/views_main.py
@@ -137,25 +137,25 @@ def main_index(request):
def earthquake_list(request):
- two_days_ago = datetime.datetime.now() - datetime.timedelta(days=2)
- earthquakes = (Earthquake.objects.
- filter(date_time__gt=two_days_ago).
- order_by("-date_time").
- all())
- res = []
- for earthquake in earthquakes:
- # Формула для вычисления радиуса землетрясения
- power = 0.5 * earthquake.magnitude - math.log10(earthquake.depth) - 1.2
- radius = 10 ** power
- res.append({
- 'id': earthquake.id,
- 'time': earthquake.date_time,
- 'lat': earthquake.latitude,
- 'lon': earthquake.longitude,
- 'depth': earthquake.depth,
- 'magnitude': earthquake.magnitude,
- 'region': earthquake.region,
- 'source': earthquake.source,
- 'radius': radius
- })
- return JsonResponse(res, safe=False)
+ try:
+ two_days_ago = datetime.datetime.now() - datetime.timedelta(days=2)
+ earthquakes = (Earthquake.objects.
+ filter(date_time__gt=two_days_ago).
+ order_by("-date_time").
+ all())
+ res = []
+ for earthquake in earthquakes:
+ # Формула для вычисления радиуса землетрясения
+ res.append({
+ 'id': earthquake.id,
+ 'time': earthquake.date_time,
+ 'lat': earthquake.latitude,
+ 'lon': earthquake.longitude,
+ 'depth': earthquake.depth,
+ 'magnitude': earthquake.magnitude,
+ 'region': earthquake.region,
+ 'source': earthquake.source,
+ })
+ return JsonResponse(res, safe=False)
+ except Exception as err:
+ logging.error(traceback.format_exc())
\ No newline at end of file