t push -u origin masterMerge branch 'master' of http://git.eanbo.cn/xieshen/drought

This commit is contained in:
Yin.T430u 2018-12-28 02:09:08 +08:00
commit c3c4f90867
28 changed files with 236 additions and 119 deletions

View File

@ -37,20 +37,10 @@
<div id="wrapper"> <div id="wrapper">
{% include 'dashboard/common/left_menu.html' %} {% include 'dashboard/common/left_menu.html' %}
<div id="page-wrapper" class="gray-bg"> <div id="page-wrapper" class="gray-bg">
<div class="row border-bottom white-bg border-bottom-shadow">
<nav class="navbar navbar-static-top" role="navigation" style="margin-bottom: 0">
<ul class="nav navbar-top-links navbar-right">
<li>
<a href="{% url 'account-logout' %}">
<i class="fa fa-sign-out"></i> 注销
</a>
</li>
</ul>
</nav>
</div>
<div class="row border-bottom white-bg page-heading"> <div class="row border-bottom white-bg page-heading">
<div class="col-lg-9"> <div class="col-lg-9">
<h4> {% block page_head %}首页{% endblock %}</h4> <h4> {% block page_head %}{% endblock %}</h4>
<ol class="breadcrumb"> <ol class="breadcrumb">
{% block breadcrumb %} {% block breadcrumb %}
<li class="active"> <li class="active">

View File

@ -5,12 +5,20 @@
<div class="sidebar-collapse"> <div class="sidebar-collapse">
{% with request.resolver_match.url_name as url_name %} {% with request.resolver_match.url_name as url_name %}
<ul class="nav metismenu" id="side-menu"> <ul class="nav metismenu" id="side-menu">
<li class="nav-header"> <li class="nav-header" style="text-align: center;">
<div class="profile-element"> <div class="profile-element" >
<img alt="image" class="img-circle" src="{% static 'dashboard/img/bjwl.png' %}"> <img alt="image" class="img-circle" src="{% static 'dashboard/img/bjwl.png' %}">
<span class="font-bold m-t-xs" style="color: white"> {% if request.user.is_authenticated %}
{{ request.user.username }} <p style="color: white;margin-top: 30px">欢迎{{ request.user.username }}</p>
</span> <a href="{% url 'account-logout' %}">
<i class="fa fa-sign-out"></i> 注销
</a>
{% else %}
<p class="font-bold m-t-xs" style="color: white;margin-top: 30px">
请您<a href="{% url 'account-login' %}">登录</a>本站
</p>
{% endif %}
</div> </div>
</li> </li>
@ -118,8 +126,8 @@
<li {% if url_name == 'http://{{ request.get_host }}/admin/auth/user/' %}class="active"{% endif %}> <li {% if url_name == 'http://{{ request.get_host }}/admin/auth/user/' %}class="active"{% endif %}>
<a href="http://{{ request.get_host }}/admin/auth/user/"> 用户管理</a> <a href="http://{{ request.get_host }}/admin/auth/user/"> 用户管理</a>
</li> </li>
<li {% if url_name == 'http://{{ request.get_host }}/admin/auth/group/' %}class="active"{% endif %}> <li {% if url_name == 'http://{{ request.get_host }}/admin/' %}class="active"{% endif %}>
<a href="http://{{ request.get_host }}/admin/auth/group/">权限管理</a> <a href="http://{{ request.get_host }}/admin/">权限管理</a>
</li> </li>
<li {% if url_name == '' %}class="active"{% endif %}> <li {% if url_name == '' %}class="active"{% endif %}>
<a href="#">服务器状态</a> <a href="#">服务器状态</a>

View File

@ -9,14 +9,8 @@
<link href="{% static 'dashboard/css/legend.css' %}" rel="stylesheet"> <link href="{% static 'dashboard/css/legend.css' %}" rel="stylesheet">
{% endblock %} {% endblock %}
{% block page_head %}GDP数据管理{% endblock %} {% block page_head %}{% endblock %}
{% block breadcrumb %} {% block breadcrumb %}
<li>
<a href="{% url 'dashboard-index' %}">首页</a>
</li>
<li class="active">
GDP数据管理
</li>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div class="ibox"> <div class="ibox">

View File

@ -7,14 +7,8 @@
<link href="{% static 'graphic/css/leaflet.timedimension.control.min.css' %}" rel="stylesheet"> <link href="{% static 'graphic/css/leaflet.timedimension.control.min.css' %}" rel="stylesheet">
<link href="{% static 'graphic/css/timeline2.css' %}" rel="stylesheet"> <link href="{% static 'graphic/css/timeline2.css' %}" rel="stylesheet">
{% endblock %} {% endblock %}
{% block page_head %}水文数据管理{% endblock %} {% block page_head %}{% endblock %}
{% block breadcrumb %} {% block breadcrumb %}
<li>
<a href="{% url 'dashboard-index' %}">首页</a>
</li>
<li class="active">
水文数据管理
</li>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div class="ibox"> <div class="ibox">

View File

@ -9,14 +9,8 @@
<link href="{% static 'dashboard/css/legend.css' %}" rel="stylesheet"> <link href="{% static 'dashboard/css/legend.css' %}" rel="stylesheet">
{% endblock %} {% endblock %}
{% block page_head %}土地利用数据管理{% endblock %} {% block page_head %}{% endblock %}
{% block breadcrumb %} {% block breadcrumb %}
<li>
<a href="{% url 'dashboard-index' %}">首页</a>
</li>
<li class="active">
土地利用数据管理
</li>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div class="ibox"> <div class="ibox">

View File

@ -72,7 +72,7 @@
</div> </div>
</div> </div>
{% empty %} {% empty %}
<div class="list-group-item" style="text-align: center">暂无数据.</div> <div class="list-group-item" style="text-align: center">暂无数据.请查看您的访问权限</div>
{% endfor %} {% endfor %}
</div> </div>
</div> </div>

View File

@ -9,14 +9,8 @@
<link href="{% static 'dashboard/css/legend.css' %}" rel="stylesheet"> <link href="{% static 'dashboard/css/legend.css' %}" rel="stylesheet">
{% endblock %} {% endblock %}
{% block page_head %}人口数据管理{% endblock %} {% block page_head %}{% endblock %}
{% block breadcrumb %} {% block breadcrumb %}
<li>
<a href="{% url 'dashboard-index' %}">首页</a>
</li>
<li class="active">
人口数据管理
</li>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div class="ibox"> <div class="ibox">

View File

@ -1,16 +1,7 @@
{% extends 'dashboard/base.html' %} {% extends 'dashboard/base.html' %}
{% load static %} {% load static %}
{% load bootstrap3 %} {% load bootstrap3 %}
{% block breadcrumb %}{% endblock %}
{% block page_head %}气象数据管理{% endblock %}
{% block breadcrumb %}
<li>
<a href="{% url 'dashboard-index' %}">首页</a>
</li>
<li class="active">
气象数据管理
</li>
{% endblock %}
{% block content %} {% block content %}
<div class="ibox"> <div class="ibox">
<div class="ibox-title"> <div class="ibox-title">

View File

@ -7,6 +7,7 @@ from django.utils.decorators import method_decorator
from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView, TemplateView from django.views.generic import ListView, DetailView, CreateView, UpdateView, DeleteView, TemplateView
from dashboard.models import Spi, Hydro, Landuse, Finance, Revenue, Population, GDP from dashboard.models import Spi, Hydro, Landuse, Finance, Revenue, Population, GDP
from users.models import YearRange
def index(request): def index(request):
@ -67,7 +68,11 @@ class SpiImportView(TemplateView):
def SpiDataDetailView(request): def SpiDataDetailView(request):
spis = Spi.objects.all()[:100] user = request.user
year_range = YearRange.objects.get(user_id=user.id)
start_year = year_range.start_year
end_year = year_range.end_year
spis = Spi.objects.filter(year__range = (start_year,end_year))[:100]
return render(request, 'dashboard/spi_data_detail.html', {'spis': spis}) return render(request, 'dashboard/spi_data_detail.html', {'spis': spis})
@ -112,7 +117,11 @@ class HydroImportView(TemplateView):
def HydroDataDetailView(request): def HydroDataDetailView(request):
hydros = Hydro.objects.all()[:100] user = request.user
year_range = YearRange.objects.get(user_id=user.id)
start_year = year_range.start_year
end_year = year_range.end_year
hydros = Hydro.objects.filter(date__range = (start_year,end_year))[:100]
return render(request, 'dashboard/hydro_data_detail.html', {'hydros': hydros}) return render(request, 'dashboard/hydro_data_detail.html', {'hydros': hydros})
@ -157,7 +166,11 @@ class LanduseImportView(TemplateView):
def LanduseDataDetailView(request): def LanduseDataDetailView(request):
landuses = Landuse.objects.all()[:100] user = request.user
year_range = YearRange.objects.get(user_id=user.id)
start_year = year_range.start_year
end_year = year_range.end_year
landuses = Landuse.objects.filter(date__range=(start_year,end_year))[:100]
return render(request, 'dashboard/landuse_data_detail.html', {'landuses': landuses}) return render(request, 'dashboard/landuse_data_detail.html', {'landuses': landuses})
@ -254,7 +267,11 @@ class RevenueImportView(TemplateView):
def RevenueDataDetailView(request): def RevenueDataDetailView(request):
revenues = Revenue.objects.all()[:100] user = request.user
year_range = YearRange.objects.get(user_id=user.id)
start_year = year_range.start_year
end_year = year_range.end_year
revenues = Revenue.objects.filter(data__range = (start_year,end_year))[:100]
return render(request, 'dashboard/revenue_data_detail.html', {'revenues': revenues}) return render(request, 'dashboard/revenue_data_detail.html', {'revenues': revenues})
@ -301,7 +318,11 @@ class PopulationImportView(TemplateView):
def PopulationDataDetailView(request): def PopulationDataDetailView(request):
populations = Population.objects.all()[:100] user = request.user
year_range = YearRange.objects.get(user_id = user.id)
start_year = year_range.start_year
end_year = year_range.end_year
populations = Population.objects.filter(date__range = (start_year,end_year))[:100]
return render(request, 'dashboard/population_data_detail.html', {'populations': populations}) return render(request, 'dashboard/population_data_detail.html', {'populations': populations})
@ -352,7 +373,11 @@ class GDPImportView(TemplateView):
def GDPDataDetailView(request): def GDPDataDetailView(request):
gdps = GDP.objects.all() user = request.user
year_range = YearRange.objects.get(user_id=user.id)
start_year = year_range.start_year
end_year = year_range.end_year
gdps = GDP.objects.filter(date__range=(start_year,end_year))
return render(request, 'dashboard/gdp_data_detail.html', {'gdps': gdps}) return render(request, 'dashboard/gdp_data_detail.html', {'gdps': gdps})

View File

@ -130,6 +130,7 @@ def get_spi_dataframe(station_polygon, newdata_path, month):
for i in range(0, month - 1): for i in range(0, month - 1):
spi_month_data.append("1") spi_month_data.append("1")
spei_month_data.append("1;1") spei_month_data.append("1;1")
print(newdata.iloc[index])
spi_month_data.append(str(newdata.iloc[index].rain)) spi_month_data.append(str(newdata.iloc[index].rain))
spei_month_data.append(str(newdata.iloc[index].rain) + ";" + str(newdata.iloc[index].temp)) spei_month_data.append(str(newdata.iloc[index].rain) + ";" + str(newdata.iloc[index].temp))
index += 1 index += 1

View File

@ -4,8 +4,12 @@ from shapely.geometry import Point
import rasterio as rio import rasterio as rio
import rasterio.mask import rasterio.mask
from rasterio.warp import reproject, Resampling from rasterio.warp import reproject, Resampling
import os
import glob
DATA_BASE_PATH = '/home/g214/data_from_chenhao/data_analyse/' DATA_BASE_PATH = '/home/g214/data_from_chenhao/data_analyse/'
# DATA_BASE_PATH = r"D:\7. business\7.baoji\code\drought_analyse\data/" # DATA_BASE_PATH = r"D:\7. business\7.baoji\code\drought_analyse\data/"
def get_buffer_data(gdf, crs={'init': 'epsg:4326', 'no_defs': True}, dis=1): def get_buffer_data(gdf, crs={'init': 'epsg:4326', 'no_defs': True}, dis=1):
@ -25,20 +29,43 @@ def get_buffer_data(gdf, crs={'init': 'epsg:4326', 'no_defs': True}, dis=1):
def read_xzqh(path): def read_xzqh(path):
shp_bjqh = GeoDataFrame.from_file(path) shp_bjqh = GeoDataFrame.from_file(path)
shp_bjqh = shp_bjqh[['geometry', 'county']] shp_bjqh = shp_bjqh[['geometry', 'county']]
# shp_bjqh.rename(columns={'县名称': 'county'}, inplace=True)
shp_bjqh.to_crs(epsg=4326, inplace=True) shp_bjqh.to_crs(epsg=4326, inplace=True)
return shp_bjqh return shp_bjqh
def intersection(gdf1, gdf2): def intersection(gdf1, gdf2):
try: geo_list = []
from geopandas.tools import overlay county = []
data = overlay(gdf1, gdf2, how='intersection', use_sindex=False) index_gdf1 = 0
data.crs = gdf1.crs for geo in gdf1.geometry:
return data index_gdf2 = 0
except Exception as e: for geo2 in gdf2.geometry:
print(str(e)) if geo.intersects(geo2):
return None intersection_geo = geo.intersection(geo2)
geo_list.append(intersection_geo)
if 'county' in gdf1:
county.append(gdf1.iloc[index_gdf1].county)
elif 'county' in gdf2:
county.append(gdf2.iloc[index_gdf2].county)
index_gdf2 += 1
index_gdf1 += 1
gdf = GeoDataFrame(geometry=geo_list, crs=gdf1.crs)
if county and len(county) > 0:
gdf['county'] = county
# print(gdf.head())
return gdf
# def intersection(gdf1, gdf2):
# try:
# from geopandas.tools import overlay
# data = overlay(gdf1, gdf2, how='intersection', use_sindex=False)
# data.crs = gdf1.crs
# return data
# except Exception as e:
# print(str(e))
# return None
def intersection_xzqh(gdf): def intersection_xzqh(gdf):
@ -51,6 +78,33 @@ def join(gdf1, gdf2):
return geopandas.sjoin(gdf1, gdf2, how="inner", op='intersects') return geopandas.sjoin(gdf1, gdf2, how="inner", op='intersects')
def cut_raster_by_geo(path, new_path, geo):
with rio.open(path) as src:
# gdf = geo.to_crs(epsg=src.crs)
feature = [geo.__geo_interface__]
out_image, out_transform = rio.mask.mask(src, feature, crop=True, nodata=src.nodata)
out_meta = src.meta.copy()
out_meta.update({"driver": "GTiff",
"height": out_image.shape[1],
"width": out_image.shape[2],
"transform": out_transform})
dest = rio.open(new_path, "w", **out_meta)
dest.write(out_image)
dest.close()
def get_new_raster_name(path):
return os.path.join(os.path.dirname(path), "region", os.path.basename(path))
def cut_dir_by_shp(dir, shp_path):
shp_data = GeoDataFrame.from_file(shp_path)
region = shp_data.loc[0].geometry
files = filter(os.path.isfile, glob.glob(dir + "*"))
for file in files:
cut_raster_by_geo(file, get_new_raster_name(file), region)
def agg_raster_by_gdf_value(path, gdf): def agg_raster_by_gdf_value(path, gdf):
# crs = '+proj=aea +lat_1=25 +lat_2=47 +lat_0=0 +lon_0=105 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs' # crs = '+proj=aea +lat_1=25 +lat_2=47 +lat_0=0 +lon_0=105 +x_0=0 +y_0=0 +datum=WGS84 +units=m +no_defs'
with rio.open(path) as src: with rio.open(path) as src:
@ -161,12 +215,12 @@ def agg_raster_by_gdf_area_and_aspect_slope(path, path_aspect, path_slope, gdf):
nodata=src1.nodata) nodata=src1.nodata)
out_image_slope, _ = rio.mask.mask(src2, feature, crop=True, nodata=src2.nodata) out_image_slope, _ = rio.mask.mask(src2, feature, crop=True, nodata=src2.nodata)
out_image_aspect_reproject = np.empty(shape=(out_image.shape[0], # same number of bands out_image_aspect_reproject = np.empty(shape=(out_image.shape[0], # same number of bands
round(out_image.shape[1]), round(out_image.shape[1]),
round(out_image.shape[2]))) round(out_image.shape[2])))
out_image_slope_reproject = np.empty(shape=(out_image.shape[0], # same number of bands out_image_slope_reproject = np.empty(shape=(out_image.shape[0], # same number of bands
round(out_image.shape[1]), round(out_image.shape[1]),
round(out_image.shape[2]))) round(out_image.shape[2])))
reproject( reproject(
out_image_aspect, out_image_aspect_reproject, out_image_aspect, out_image_aspect_reproject,
src_transform=out_transform_aspect, src_transform=out_transform_aspect,
@ -181,9 +235,11 @@ def agg_raster_by_gdf_area_and_aspect_slope(path, path_aspect, path_slope, gdf):
# src_crs={'init': 'EPSG:3857'}, # src_crs={'init': 'EPSG:3857'},
# dst_crs={'init': 'EPSG:3857'}, # dst_crs={'init': 'EPSG:3857'},
resampling=Resampling.bilinear) resampling=Resampling.bilinear)
out_image_slope_reproject = np.where(out_image_slope_reproject == src1.nodata, 1000, out_image_slope_reproject) out_image_slope_reproject = np.where(out_image_slope_reproject == src1.nodata, 1000,
out_image_slope_reproject)
out_image_slope_reproject = out_image_slope_reproject.astype(int) out_image_slope_reproject = out_image_slope_reproject.astype(int)
out_image_aspect_reproject = np.where(out_image_aspect_reproject == src2.nodata, 1000, out_image_aspect_reproject) out_image_aspect_reproject = np.where(out_image_aspect_reproject == src2.nodata, 1000,
out_image_aspect_reproject)
out_image_aspect_reproject = out_image_aspect_reproject.astype(int) out_image_aspect_reproject = out_image_aspect_reproject.astype(int)
for i in range(0, out_image.shape[1]): for i in range(0, out_image.shape[1]):
for j in range(0, out_image.shape[2]): for j in range(0, out_image.shape[2]):
@ -204,5 +260,12 @@ def agg_raster_by_gdf_area_and_aspect_slope(path, path_aspect, path_slope, gdf):
print(str(e)) print(str(e))
return (res_flat, res_30, res_more_than_30) return (res_flat, res_30, res_more_than_30)
def merge_gdf_geo_to_geojson(gdf): def merge_gdf_geo_to_geojson(gdf):
return gdf.to_json() return gdf.to_json()
if __name__ == '__main__':
# cut_dir_by_shp('/home/g214/data_from_chenhao/data_analyse/station/interpolation/rain/', '/home/g214/data_from_chenhao/data_analyse/boundary/bj_region/bj_region.shp')
cut_dir_by_shp('/home/g214/data_from_chenhao/data_analyse/station/interpolation/temp/', '/home/g214/data_from_chenhao/data_analyse/boundary/bj_region/bj_region.shp')
# cut_dir_by_shp('../data/', '../bj_region/bj_region.shp')

View File

@ -61,8 +61,8 @@ def get_type_path(type):
@csrf_exempt @csrf_exempt
def calc_hailstones_impact(request): def calc_hailstones_impact(request):
type = request.POST['type'] type = request.POST['type']
county = request.POST['county'] # 是否划分县域 1 or 0 county = request.POST.get('county', '0') # 是否划分县域 1 or 0
calc_dem = request.POST['dem'] # 是否计算dem 1 or 0 calc_dem = request.POST.get('dem', '0') # 是否计算dem 1 or 0
csv_path = handle_uploaded_file(request.FILES['file_path']) # 冰雹雷达数据 csv_path = handle_uploaded_file(request.FILES['file_path']) # 冰雹雷达数据
hailstones_data = get_hailstones(csv_path) hailstones_data = get_hailstones(csv_path)
@ -102,8 +102,6 @@ def calc_prevent_impact(request):
prevent_data_inter = prevent_hailstones_data() prevent_data_inter = prevent_hailstones_data()
hailstones_data_inter = get_hailstones(csv_path) hailstones_data_inter = get_hailstones(csv_path)
print(hailstones_data_inter.head())
print(prevent_data_inter.head())
prevent_intersection_disater_data = intersection(hailstones_data_inter, prevent_data_inter) prevent_intersection_disater_data = intersection(hailstones_data_inter, prevent_data_inter)
# print(prevent_intersection_disater_data.head()) # print(prevent_intersection_disater_data.head())

View File

@ -44,7 +44,8 @@ INSTALLED_APPS = [
'graphic', 'graphic',
'policy', 'policy',
'predict', 'predict',
'disaster' 'disaster',
'users',
] ]
MIDDLEWARE = [ MIDDLEWARE = [
@ -139,9 +140,9 @@ STATICFILES_DIRS = [
STATIC_ROOT = '/var/www/p3/drought/shared/static' STATIC_ROOT = '/var/www/p3/drought/shared/static'
MEDIA_ROOT = '/var/www/p3/drought/shared/static/media/' MEDIA_ROOT = '/var/www/p3/drought/shared/static/media/'
# CORS_ORIGIN_ALLOW_ALL = True
# CORS_URLS_REGEX = r'^//disaster/.*$' # CORS_URLS_REGEX = r'^//disaster/.*$'
#跨域增加忽略
CORS_ALLOW_CREDENTIALS = True CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_ALLOW_ALL = True CORS_ORIGIN_ALLOW_ALL = True
CORS_ORIGIN_WHITELIST = ( CORS_ORIGIN_WHITELIST = (
@ -172,6 +173,8 @@ CORS_ALLOW_HEADERS = (
'Pragma', 'Pragma',
) )
LOGIN_REDIRECT_URL='/'
try: try:
from .local_settings import * from .local_settings import *
except ImportError as e: except ImportError as e:

View File

@ -26,5 +26,6 @@ urlpatterns = [
path('policy/', include('policy.urls')), path('policy/', include('policy.urls')),
path('admin/', admin.site.urls), path('admin/', admin.site.urls),
path('predict/', include('predict.urls')), path('predict/', include('predict.urls')),
path('users/',include('users.urls')),
path('disaster/', include('disaster.urls')) path('disaster/', include('disaster.urls'))
] ]

View File

@ -14,7 +14,8 @@ $(function () {
layers: 'baoji:bj_eco', layers: 'baoji:bj_eco',
transparent: true, transparent: true,
format: 'image/png', format: 'image/png',
styles: 'baoji:gdp' styles: 'baoji:gdp',
tiled:false,
}); });
map.addLayer(countyLayer); map.addLayer(countyLayer);

View File

@ -85,14 +85,6 @@ function initChart(element, code, year_from, year_to) {
name: '气温', name: '气温',
type: 'line', type: 'line',
animation: false, animation: false,
areaStyle: {
normal: {}
},
lineStyle: {
normal: {
width: 1
}
},
data: temperatureData data: temperatureData
}, },

View File

@ -4,7 +4,7 @@ for (var y = 1979; y < 2016; y++) {
for (var m = 1; m < 13; m++) { for (var m = 1; m < 13; m++) {
var year = y.toString(); var year = y.toString();
var month = m.toString(); var month = m.toString();
var result = month.length < 2 ? year + '-' + month + '-rain' : year + month + '-rain'; var result = month.length < 2 ? year + '-' + month : year + month ;
results.push(result); results.push(result);
} }
} }
@ -12,6 +12,12 @@ for (var y = 1979; y < 2016; y++) {
$(function () { $(function () {
var map = L.map('map', { var map = L.map('map', {
timeDimension: true,
timeDimensionControl: true,
timeDimensionOptions: {
timeInterval: "1979-01-01/2018-12-20",
period: "PT1H"
},
center: [34.3632, 107.2377], center: [34.3632, 107.2377],
zoom: 9 zoom: 9
}); });
@ -24,16 +30,10 @@ $(function () {
layers: 'baoji:bj_county_boundary', layers: 'baoji:bj_county_boundary',
transparent: true, transparent: true,
format: 'image/png', format: 'image/png',
styles:'baoji:county_boundary' styles: 'baoji:county_boundary'
}); });
map.addLayer(baojiLayer); map.addLayer(baojiLayer);
var countyLayer = L.tileLayer.wms('http://210.77.68.250:8080/geoserver/baoji/wms', {
layers: 'baoji:1979-1-rain',
transparent: true,
format: 'image/png',
styles: 'baoji:rain'
});
map.addLayer(countyLayer);
var handle = $("#custom-handle"); var handle = $("#custom-handle");
function slideLayer() { function slideLayer() {
@ -48,16 +48,30 @@ $(function () {
removeLayer(currentLayer, 1); removeLayer(currentLayer, 1);
} }
currentLayer = L.tileLayer.wms('http://210.77.68.250:8080/geoserver/baoji/wms', { currentLayer = L.tileLayer.wms('http://210.77.68.250:8080/geoserver/baoji/wms', {
layers: 'baoji:' + results[count], layers: 'baoji:' + results[count] + '-rain',
transparent: true, transparent: true,
format: 'image/png', format: 'image/png',
styles: 'baoji:rain' styles: 'baoji:rain'
}); });
map.addLayer(currentLayer); map.addLayer(currentLayer);
disTimeline(result[count]);
count += 1; count += 1;
if (count > results.length) count = 0; if (count > results.length) count = 0;
} }
function disTimeline(time) {
//2018-1-rain
//2018-10-rain
if (month.length = 2){
var year = time.substring(0,4);
var month = time.substring(4,6);
}else
var year = time.substring(0, 4);
var month = time.substring(4, 6);
var date = new Date(year, month);
map.timeDimension.setCurrentTime(date.getTime());
}
baojiLayer.bringToFront(); baojiLayer.bringToFront();
slideLayer(); slideLayer();

View File

@ -12,6 +12,12 @@ for (var y = 1979; y < 2016; y++) {
$(function () { $(function () {
var map = L.map('map', { var map = L.map('map', {
timeDimension: true,
timeDimensionControl: true,
timeDimensionOptions: {
timeInterval: "1979-01-01/2018-12-20",
period: "PT1H"
},
center: [34.3632, 107.2377], center: [34.3632, 107.2377],
zoom: 9 zoom: 9
}); });
@ -24,16 +30,16 @@ $(function () {
layers: 'baoji:bj_county_boundary', layers: 'baoji:bj_county_boundary',
transparent: true, transparent: true,
format: 'image/png', format: 'image/png',
styles:'baoji:county_boundary' styles: 'baoji:county_boundary'
}); });
map.addLayer(baojiLayer); map.addLayer(baojiLayer);
var countyLayer = L.tileLayer.wms('http://210.77.68.250:8080/geoserver/baoji/wms', { var tempLayer = L.tileLayer.wms('http://210.77.68.250:8080/geoserver/baoji/wms', {
layers: 'baoji:1979-1-temp', layers: 'baoji:1979-1-temp',
transparent: true, transparent: true,
format: 'image/png', format: 'image/png',
styles: 'baoji:temp' styles: 'baoji:temp'
}); });
map.addLayer(countyLayer); map.addLayer(tempLayer);
var handle = $("#custom-handle"); var handle = $("#custom-handle");
function slideLayer() { function slideLayer() {
@ -54,10 +60,18 @@ $(function () {
styles: 'baoji:temp' styles: 'baoji:temp'
}); });
map.addLayer(currentLayer); map.addLayer(currentLayer);
disTimeline(result[count]);
count += 1; count += 1;
if (count > results.length) count = 0; if (count > results.length) count = 0;
} }
function disTimeline(time) {
var year = time.substring(0, 4);
var month = time.substring(4, 6);
var date = new Date(year, month, 1, 20, 0, 0);
map.timeDimension.setCurrentTime(date.getTime());
}
baojiLayer.bringToFront(); baojiLayer.bringToFront();
slideLayer(); slideLayer();

View File

@ -27,13 +27,13 @@ $(function () {
styles:'baoji:county_boundary' styles:'baoji:county_boundary'
}); });
map.addLayer(baojiLayer); map.addLayer(baojiLayer);
var countyLayer = L.tileLayer.wms('http://210.77.68.250:8080/geoserver/baoji/wms', { var spiLayer = L.tileLayer.wms('http://210.77.68.250:8080/geoserver/baoji/wms', {
layers: 'baoji:1979-1-spi', layers: 'baoji:1979-1-spi',
transparent: true, transparent: true,
format: 'image/png', format: 'image/png',
styles: 'baoji:spi' styles: 'baoji:spi'
}); });
map.addLayer(countyLayer); map.addLayer(spiLayer);
var handle = $("#custom-handle"); var handle = $("#custom-handle");
function slideLayer() { function slideLayer() {

View File

@ -27,13 +27,13 @@ $(function () {
styles:'baoji:county_boundary' styles:'baoji:county_boundary'
}); });
map.addLayer(baojiLayer); map.addLayer(baojiLayer);
var countyLayer = L.tileLayer.wms('http://210.77.68.250:8080/geoserver/baoji/wms', { var speiLayer = L.tileLayer.wms('http://210.77.68.250:8080/geoserver/baoji/wms', {
layers: 'baoji:1979-1-spei', layers: 'baoji:1979-1-spei',
transparent: true, transparent: true,
format: 'image/png', format: 'image/png',
styles: 'baoji:spei' styles: 'baoji:spei'
}); });
map.addLayer(countyLayer); map.addLayer(speiLayer);
var handle = $("#custom-handle"); var handle = $("#custom-handle");
function slideLayer() { function slideLayer() {

17
gs.py
View File

@ -120,11 +120,14 @@ if __name__ == '__main__':
gs = GeoServer('http://210.77.68.250:8080/geoserver', 'admin', 'geoserver', 'baoji') gs = GeoServer('http://210.77.68.250:8080/geoserver', 'admin', 'geoserver', 'baoji')
# name = gs.create_and_publish_geotiff('baoji/sample/Baojishi_Cotton_2016_1KM.tif') for y in range(1979, 2018):
# for m in range(1, 13):
# print('coverage storage name :' + name) file_name = "%s-%s-temp.tif" % (y, m)
# print('layer name :' + name) print(file_name)
name = gs.create_and_publish_geotiff('baoji/temp/%s' % (file_name))
print('coverage storage name :' + name)
print('layer name :' + name)
name = gs.create_and_publish_shp('baoji/sample/baoji_grid.shp') # name = gs.create_and_publish_shp('baoji/sample/baoji_grid.shp')
print('data storage name:' + name) # print('data storage name:' + name)
print('layer name:' + name) # print('layer name:' + name)

0
users/__init__.py Normal file
View File

5
users/admin.py Normal file
View File

@ -0,0 +1,5 @@
from django.contrib import admin
from .models import *
# Register your models here.
admin.site.register(YearRange)

5
users/apps.py Normal file
View File

@ -0,0 +1,5 @@
from django.apps import AppConfig
class UsersConfig(AppConfig):
name = 'users'

15
users/models.py Normal file
View File

@ -0,0 +1,15 @@
import uuid
from django.contrib.auth.models import AbstractUser, User
from django.db import models
# Create your models here.
class YearRange(models.Model):
id = models.UUIDField('id',primary_key=True,default=uuid.uuid4)
user = models.ForeignKey(User,blank=False,null=False,on_delete=models.CASCADE)
start_year = models.CharField('起始年份',max_length=256)
end_year = models.CharField('截止年份',max_length=256)
def __str__(self):
return str(self.user)

3
users/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

6
users/urls.py Normal file
View File

@ -0,0 +1,6 @@
from django.urls import path
urlpatterns = [
]

3
users/views.py Normal file
View File

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.