Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

geocalcmap app #134

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added geocalcmap/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions geocalcmap/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.contrib import admin

# Register your models here.
5 changes: 5 additions & 0 deletions geocalcmap/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from django.apps import AppConfig


class GeocalcmapConfig(AppConfig):
name = 'geocalcmap'
Empty file.
3 changes: 3 additions & 0 deletions geocalcmap/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.db import models

# Create your models here.
44,563 changes: 44,563 additions & 0 deletions geocalcmap/summer.csv

Large diffs are not rendered by default.

187 changes: 187 additions & 0 deletions geocalcmap/templates/base.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
{% load staticfiles %}
{% load i18n %}

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>GeoCalcMap</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="yandex-verification" content="814cc814a6791f9c" />

<!-- css files -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link href="https://stackpath.bootstrapcdn.com/bootswatch/3.3.7/yeti/bootstrap.min.css" rel="stylesheet" integrity="sha384-HzUaiJdCTIY/RL2vDPRGdEQHHahjzwoJJzGUkYjHVzTwXFQ2QN/nVgX7tzoMW3Ov" crossorigin="anonymous">
<link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" />
<link href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.0/css/bootstrap-datepicker3.min.css" rel="stylesheet" />
<link href='https://api.mapbox.com/mapbox-gl-js/v0.44.2/mapbox-gl.css' rel='stylesheet' />
<style>
html {
position: relative;
min-height: 100%;
}

body {
margin-bottom: 50px;
}

/* Remove the navbar's default margin-bottom and rounded borders */
.navbar {
margin-bottom: 0;
border-radius: 0;
}

.logo {
width: 50px;
height: 44px;
}

.logo_old {
width: 120px;
height: 44px;
}

.lang {
min-width: 44px; !important;
}

footer {
position: absolute;
bottom: 0;
width: 100%;
background-color:#dddddd;
color: #000;
font-size: 13px;
padding: 10px;
}

h1{
text-align: center;
}
#container{
display: flex;
justify-content: center;
align-items: center;
}
#form{
flex-direction: row;
}
#form div{
margin-top: 10px;
}
#form div::before{
content: "* ";
}
#map{
flex-direction: row;

margin-left: 50px;
}
</style>


<!-- scripts -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datepicker/1.7.0/js/bootstrap-datepicker.js"></script>
<script src='https://api.mapbox.com/mapbox-gl-js/v0.44.2/mapbox-gl.js'></script>
<script src='https://cdn.plot.ly/plotly-2.18.2.min.js'></script>
</head>
<body>
{% get_current_language as LANGUAGE_CODE %}
{% get_available_languages as LANGUAGES %}
{% get_language_info_list for LANGUAGES as languages %}
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-left" href="{% url 'home' %}">
<img class="logo_old" src="{% static 'lmnad/logo_comp.png' %}" alt="LMNAD">
</a>
<a class="navbar-brand" >
GeoCalcMap
</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
{% if LANGUAGE_CODE == 'ru' %}
<img src="{% static 'lmnad/flag_ru.png' %}" title="Russian">
{% else %}
<img src="{% static 'lmnad/flag_en.png' %}" title="English">
{% endif %}
<span class="caret"></span>
</a>
<ul class="dropdown-menu lang">
<form action="{% url 'set_language' %}" method="post">
{% csrf_token %}
{% for language in languages %}
<li>
<button type="submit"
name="language"
style="border: none; padding: 5px; background: none;"
value="{{ language.code }}"
class="{% if language.code == LANGUAGE_CODE %}selected{% endif %}">
{% if language.code == 'ru' %}
<img src="{% static 'lmnad/flag_ru.png' %}" title="Russian">
{% else %}
<img src="{% static 'lmnad/flag_en.png' %}" title="English">
{% endif %}
</button>
</li>
{% endfor %}
</form>
</ul>
</li>
{% if user.is_authenticated %}
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"> {{ user.username }} <span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="{{ user.get_absolute_url }}">{% trans "My account" %}</a></li>
<li><a href="{% url 'change_password' %}">{% trans "Change password" %}</a></li>
<li role="separator" class="divider"></li>
<li><a href="{% url 'logout' %}">{% trans "Log out" %}</a></li>
</ul>
</li>
{% else %}
<li><a href="{% url 'register' %}">{% trans "Sign up" %}</a></li>
<li><a href="{% url 'login' %}">{% trans "Log in" %}</a></li>
{% endif %}
</ul>
</div>
</div>
</nav>

{% if not user.is_authenticated and project.is_only_user %}
<div class="container">
<div class="row">
<h4>{% trans 'Access denied' %}</h4>
<hr>
<p> {% trans 'Create new user:' %}
<a href="{% url 'register' %}">{% trans "Sign up" %}</a>
{% trans 'or' %}
<a href="{% url 'login' %}">{% trans "Log in" %}</a>
</p>
</div>
</div>
{% else %}
{% block content %}
{% endblock %}
{% endif %}

<!-- FOOTER -->
<footer class="container-fluid text-center">
<p class="pull-left"><a href="{% url 'home' %}">Back to LMNAD</a></p>
<p class="pull-right"><a href="#">Back to top</a></p>
<p>© <a href="{% url 'home' %}">LMNAD</a> 2017-{% now "Y" %} </p>
</footer>
</body>
</html>
82 changes: 82 additions & 0 deletions geocalcmap/templates/default.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@

{% extends './base.html' %}
{% load staticfiles %}
{% load i18n %}

{% block content %}
<h1>{% trans 'Online geographic information system for calculating internal wave parameters' %}</h1>
<div id="container">
<div id="form">
<h3>{% trans 'Selected point' %}:</h3>
<div id="lat">Latitude: </div>
<div id="lon">Longitude: </div>
<div id="alpha">Alpha: </div>
<div id="alpha1">Alpha1: </div>
<div id="beta">Beta: </div>
<div id="c">C: </div>
<div id="depth">Depth: </div>
</div>
<div id='map'></div>
</div>
<script>
const datas = JSON.parse('{{datas|escapejs}}').data
const depths = '0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 125 150 175 200 225 250 275 300 325 350 375 400 425 450 475 500 550 600 650 700 750 800 850 900 950 1000 1050 1100 1150 1200 1250 1300 1350 1400 1450 1500 1550 1600 1650 1700 1750 1800 1850 1900 1950 2000 2100 2200 2300 2400 2500 2600 2700 2800 2900 3000 3100 3200 3300 3400 3500 3600 3700 3800 3900 4000 4100 4200 4300 4400 4500 4600 4700 4800 4900 5000 5100 5200 5300 5400 5500'.split(' ')
console.log(depths)
datas.shift()
console.log(datas)
var data = [{
type:'scattermapbox',
mode: 'markers',
lon: datas.map((row)=>Number(row[0])),
lat: datas.map((row)=>Number(row[1])),
customdata: datas.map((row)=>{
return {alpha: row[2], alpha1: row[3], beta: row[4], c: row[5], depth: row[6]}
}),
marker: {
color: 'rgb(255, 165, 0)',
size: 5
},
}]

var layout = {
autosize: true,
hovermode:'closest',
width: 1000,
height: 800,
mapbox: {
style: "mapbox://styles/tcartamarine/ciq2pv52p000g7mnnwlar0qao",
bearing:0,
center: {
lat:54,
lon:148,
},
pitch:0,
zoom:3
},
}

Plotly.setPlotConfig({
mapboxAccessToken: "pk.eyJ1IjoidGNhcnRhbWFyaW5lIiwiYSI6IjdkMThjZTU4YzdiMDkwMjM0YzlhMDhkNDcyYjMwNjIwIn0.tiKHKvthUQM11YlFXJjPwg"
})

Plotly.newPlot('map', data, layout)
var myPlot = document.getElementById('map')
myPlot.on('plotly_click', function(data){
console.log(data)
let lat = document.getElementById("lat")
lat.innerHTML = "Latitude: " + data.points[0].lat;
let lon = document.getElementById("lon")
lon.innerHTML = "Longitude: " + data.points[0].lon;
let alpha = document.getElementById("alpha")
alpha.innerHTML = "Alpha: " + data.points[0].customdata.alpha;
let alpha1 = document.getElementById("alpha1")
alpha1.innerHTML = "Alpha1: " + data.points[0].customdata.alpha1;
let beta = document.getElementById("beta")
beta.innerHTML = "Beta: " + data.points[0].customdata.beta;
let c = document.getElementById("c")
c.innerHTML = "C: " + data.points[0].customdata.c;
let depth = document.getElementById("depth")
depth.innerHTML = "Depth: " + data.points[0].customdata.depth;
});
</script>
{% endblock %}
3 changes: 3 additions & 0 deletions geocalcmap/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from django.test import TestCase

# Create your tests here.
7 changes: 7 additions & 0 deletions geocalcmap/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from django.urls import path

from . import views

urlpatterns = [
path('geocalcmap', views.index, name='index'),
]
16 changes: 16 additions & 0 deletions geocalcmap/views.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

from django.shortcuts import render
import pandas as pd
import json
import os

def index(request):
#template = loader.get_template('index.html')
names = ['{}'.format(x) for x in range(1, 105)] # максимум 104 записи в одной строке
names[0] = "lat"
names[1] = "lon"
current_file = os.path.abspath(os.path.dirname(__file__))
csv_path = os.path.join(current_file, "summer.csv")
data = pd.read_csv(csv_path, names=names, comment="#")
return render(request, 'default.html', context={"datas": json.dumps(json.loads(data.to_json(orient="split")))})

Binary file modified locale/ru/LC_MESSAGES/django.mo
Binary file not shown.
8 changes: 8 additions & 0 deletions locale/ru/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -944,3 +944,11 @@ msgstr "Сроки"
#: tank/templates/tank/experiments.html:62
msgid "Coming soon..."
msgstr "Проводятся эксперименты"

#: geocalcmap/templates/default.html:7
msgid "Online geographic information system for calculating internal wave parameters"
msgstr "Геоинформационная онлайн система для расчёта параметров внутренних волн"

#: geocalcmap/templates/default.html:10
msgid "Selected point"
msgstr "Выбранная точка"
3 changes: 2 additions & 1 deletion project/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
'igwcoeffs',
'tank',
'publications',
'phenomenon_db'
'phenomenon_db',
'geocalcmap'
]

INSTALLED_APPS = PREREQ_APPS + PROJECT_APPS
Expand Down
1 change: 1 addition & 0 deletions project/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
path('', include('igwcoeffs.urls')),
path('', include('publications.urls')),
path('', include('tank.urls')),
path('', include('geocalcmap.urls')),
path('', include('favicon.urls')),
path('ckeditor/', include('ckeditor_uploader.urls')),
path('select2/', include('django_select2.urls'))
Expand Down