양선아

6/10 updates

......@@ -2,19 +2,35 @@
<html lang="kr">
<head>
<title>RF-Project</title>
<meta charset="utf-8">
<!--BOOTSTRAP 사용 부분-->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<div id="header">
<style>
#header{
color: brown;
text-align: center;
background: #fff7b5;
font-family: "210 자연주의";
}
h1{
font-weight: bold;
}
h3{
font-family: "Dovemayo";
}
</style>
</div>
</head>
<body>
<!--body-->
<div id="bodyWrap">
<div id="header">
<h1><a href="/market_analysis/maplist">Statistics on Return Farm Project</a></h1>
<h1 class="projectname"><a href="/market_analysis/maplist">Statistics on Return Farm Project</a></h1>
<br>
<h3>농산물 시장 유통에 대한 통계분석 입니다.</h3>
<br>
......
......@@ -10,6 +10,9 @@
<!--css 내용 여기에 direct로 넣었다-->
<style>
#mapbase {position:relative; width:40%; height:0; padding-bottom:40%; }
h1 {
font-size: 20px;
}
.info {
padding: 6px 8px;
font: 14px/16px Arial, Helvetica, sans-serif;
......@@ -33,6 +36,7 @@
margin-right: 8px;
opacity: 0.7;
}
</style>
<!--BOOTSTRAP 사용 부분-->
......@@ -128,17 +132,16 @@
<div id="map_design">
<script>
var geojson;
var density_max = 3300;
function getColor(d) {
return d > density_max*0.9 ? '#FF0015' :
d > density_max*0.8 ? '#F20D20' :
d > density_max*0.7 ? '#E6192A' :
d > density_max*0.6 ? '#D92635' :
d > density_max*0.5 ? '#CC3340' :
d > density_max*0.4 ? '#BF404A' :
d > density_max*0.3 ? '#B34D55' :
d > density_max*0.2 ? '#A65960' :
d > density_max*0.1 ? '#99666A' :
return d > parseInt(density_max*0.9) ? '#FF0015' :
d > parseInt(density_max*0.8) ? '#F20D20' :
d > parseInt(density_max*0.7) ? '#E6192A' :
d > parseInt(density_max*0.6) ? '#D92635' :
d > parseInt(density_max*0.5) ? '#CC3340' :
d > parseInt(density_max*0.4) ? '#BF404A' :
d > parseInt(density_max*0.3) ? '#B34D55' :
d > parseInt(density_max*0.2) ? '#A65960' :
d > parseInt(density_max*0.1) ? '#99666A' :
'#8C7375';
}
function style(feature) {
......@@ -214,7 +217,7 @@
legend.onAdd = function (map) {
var div = L.DomUtil.create('div', 'info legend'),
grades = [0, density_max*0.1, density_max*0.2, density_max*0.3, density_max*0.4,density_max*0.5, density_max*0.6, density_max*0.7, density_max*0.8,density_max*0.9],
grades = [0, parseInt(density_max*0.1), parseInt(density_max*0.2), parseInt(density_max*0.3), parseInt(density_max*0.4),parseInt(density_max*0.5), parseInt(density_max*0.6), parseInt(density_max*0.7), parseInt(density_max*0.8),parseInt(density_max*0.9)],
labels = [],
from, to;
......
......@@ -2,6 +2,7 @@
<html lang="kr">
<head>
<title>RF-Project</title>
<meta charset = "utf-8">
<!-- link에 들어가 있는건 지도 데이터를 위한 css 파일 -->
<!-- script에 들어가 있는건 지도 데이터를 위한 js 파일 -->
<!-- 직접 다운받아 넣을 수도 있는데 우선은 그냥 웹에서 불러올 수 있도록 해놨다. -->
......@@ -104,6 +105,9 @@
var statesdata = "{{maps.mapdata}}".replace(/&quot;/g,"\"");
statesdata = JSON.parse(statesdata);
let key = Object.keys(statesdata.features[1].properties);
var density_max = "{{max}}".replace(/&#x27;/g,"\"");
density_max = JSON.parse(density_max);
density_max = Number(density_max.maxx);
</script>
</div>
<!--지도에 밀도 데이터 받는 부분-->
......@@ -136,17 +140,16 @@
<div id="map_design">
<script>
var geojson;
var density_max = 100;
function getColor(d) {
return d > density_max*0.9 ? '#FF0015' :
d > density_max*0.8 ? '#F20D20' :
d > density_max*0.7 ? '#E6192A' :
d > density_max*0.6 ? '#D92635' :
d > density_max*0.5 ? '#CC3340' :
d > density_max*0.4 ? '#BF404A' :
d > density_max*0.3 ? '#B34D55' :
d > density_max*0.2 ? '#A65960' :
d > density_max*0.1 ? '#99666A' :
return d > parseInt(density_max*0.9) ? '#FF0015' :
d > parseInt(density_max*0.8) ? '#F20D20' :
d > parseInt(density_max*0.7) ? '#E6192A' :
d > parseInt(density_max*0.6) ? '#D92635' :
d > parseInt(density_max*0.5) ? '#CC3340' :
d > parseInt(density_max*0.4) ? '#BF404A' :
d > parseInt(density_max*0.3) ? '#B34D55' :
d > parseInt(density_max*0.2) ? '#A65960' :
d > parseInt(density_max*0.1) ? '#99666A' :
'#8C7375';
}
function style(feature) {
......@@ -190,7 +193,6 @@
click: zoomToFeature
});
}
geojson = L.geoJson(statesdata, {
style: style,
onEachFeature: onEachFeature
......@@ -222,7 +224,7 @@
legend.onAdd = function (map) {
var div = L.DomUtil.create('div', 'info legend'),
grades = [0, density_max*0.1, density_max*0.2, density_max*0.3, density_max*0.4,density_max*0.5, density_max*0.6, density_max*0.7, density_max*0.8,density_max*0.9],
grades = [0, parseInt(density_max*0.1), parseInt(density_max*0.2), parseInt(density_max*0.3), parseInt(density_max*0.4),parseInt(density_max*0.5), parseInt(density_max*0.6), parseInt(density_max*0.7), parseInt(density_max*0.8),parseInt(density_max*0.9)],
labels = [],
from, to;
......
......@@ -21,6 +21,7 @@ def returnfarm_dbselect(contenttype, maptype):
myrtrn = RT_edu.objects.values(mapt).annotate(count=Count(mapt))
return myrtrn
# 공공데이터 불러오는 부분
def publicdata():
# 통계청 귀농가구원의 시도별, 시군별, 연령별
......@@ -31,19 +32,25 @@ def publicdata():
def main(request):
return render(request, 'main.html')
# html에 넘겨주는 부분
####### return farm ##########
def returnfarm(request):
try:
maptype = request.GET['maptype']
contenttype = request.GET['contenttype']
mapp = Maps.objects.get(id=int(maptype))
exportdatas = returnfarm_dbselect(contenttype, int(maptype))
maxx = exportdatas.aggregate(maxx=Max('count'))
except:
mapp = Maps.objects.get(id=9)
exportdatas = {}
context = {'exportdata': exportdatas, 'maps':mapp}
maxx = {'maxx' : 100}
context = {'exportdata': exportdatas, 'maps':mapp, 'max':maxx}
return render(request, 'returnfarm.html', context)
######## population ###########
def population(request):
try:
maptype = request.GET['maptype']
......@@ -53,9 +60,9 @@ def population(request):
except:
mapp = Maps.objects.get(id=9)
exportdatas = {}
exportdatas = publicdata()
context = {'exportdata': exportdatas, 'maps':mapp}
return render(request, 'population.html', context)
########### market ##########
def market(request):
return render(request, 'market.html')
\ No newline at end of file
......