Commit 4092eb5a authored by Manggar Mahardhika's avatar Manggar Mahardhika

push

parent 87e39c3b
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -5,5 +5,13 @@ from . import views
app_name = 'api'
urlpatterns = [
path('search_auto', views.search_auto, name='search')
path('search_auto', views.search_auto, name='search'),
path('tuplah', views.tuplah, name='tuplah'),
path('building', views.building, name='building'),
path('jalan', views.jalan, name='jalan'),
path('sungai', views.sungai, name='sungai'),
path('edit', views.editpoly, name='edit'),
path('validatedit', views.validatedit, name='validatedit'),
path('hapus', views.hapus, name='hapus'),
path('hasilsearch', views.hasilsearch, name='ressearch')
]
\ No newline at end of file
......@@ -17,3 +17,144 @@ def search_auto(request):
data = {'nama_des':all}
return Response(data)
@api_view(('GET',))
@renderer_classes((TemplateHTMLRenderer, JSONRenderer))
def tuplah(request):
with conn.cursor() as desa:
desa.execute(f"SELECT json_build_object('type', 'Feature', 'legend', a.legenda,'geometry', ST_AsGeoJSON( st_intersection(a.geom, b.geom):: geometry) :: json) from geo_tuplah a, geo_prov_kab b")
all = desa.fetchall()
data = {'tuplah':all}
return Response(data)
@api_view(('GET',))
@renderer_classes((TemplateHTMLRenderer, JSONRenderer))
def building(request):
if request.method == 'GET':
wetan = request.GET.get("wetan")
kulon = request.GET.get("kulon")
lor = request.GET.get("lor")
kidul = request.GET.get("kidul")
# lat = request.GET.get("lat")
# lng = request.GET.get("lng")
# kulon lor, wetan lor, wetan kidul, kulon kidul, kulon lor
with conn.cursor() as buldings:
buldings.execute("SELECT json_build_object('type', 'Feature', 'properties', (id, name, information, 'gen'), 'administrasi',(address_1, address_2, address_3, provinsi, 'no'), 'geometry', ST_AsGeoJSON(geom :: geometry) :: json) FROM geo_bangunan WHERE st_intersects(geom,'SRID=0;POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))')"% (kulon, lor, wetan, lor, wetan, kidul, kulon, kidul, kulon, lor))
prov_res = buldings.fetchall()
polbang = []
for i in prov_res:
i[0]['properties']['f2'] = i[0]['properties']['f2'].replace("'"," ")
polbang.append(i[0])
data = {'gen':prov_res}
return Response(data)
@api_view(('GET',))
@renderer_classes((TemplateHTMLRenderer, JSONRenderer))
def jalan(request):
if request.method == 'GET':
wetan = request.GET.get("wetan")
kulon = request.GET.get("kulon")
lor = request.GET.get("lor")
kidul = request.GET.get("kidul")
# lat = request.GET.get("lat")
# lng = request.GET.get("lng")
# kulon lor, wetan lor, wetan kidul, kulon kidul, kulon lor
with conn.cursor() as jalan:
jalan.execute("SELECT json_build_object ('type', 'Feature', 'properties', ( id, namrjl ), 'geometry', ST_AsGeoJSON ( st_intersection(geom, 'SRID=4326;POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))') :: geometry ) :: json ) FROM geo_jalan WHERE st_intersects(geom,'SRID=4326;POLYGON((%s %s, %s %s, %s %s, %s %s, %s %s))')"% (kulon, lor, wetan, lor, wetan, kidul, kulon, kidul, kulon, lor, kulon, lor, wetan, lor, wetan, kidul, kulon, kidul, kulon, lor))
prov_res = jalan.fetchall()
data = {'gen':prov_res}
return Response(data)
@api_view(('GET',))
@renderer_classes((TemplateHTMLRenderer, JSONRenderer))
def sungai(request):
if request.method == 'GET':
wetan = request.GET.get("wetan")
kulon = request.GET.get("kulon")
lor = request.GET.get("lor")
kidul = request.GET.get("kidul")
# lat = request.GET.get("lat")
# lng = request.GET.get("lng")
# kulon lor, wetan lor, wetan kidul, kulon kidul, kulon lor
with conn.cursor() as sungai:
sungai.execute("SELECT json_build_object ('type', 'Feature', 'properties', ( a.id, a.namobj ), 'geometry', ST_AsGeoJSON ( st_intersection(a.geom, b.geom) :: geometry ) :: json ) FROM geo_sungai a, geo_prov_kab b")
prov_res = sungai.fetchall()
data = {'gen':prov_res}
return Response(data)
@api_view(('GET',))
@renderer_classes((TemplateHTMLRenderer, JSONRenderer))
def editpoly(request):
if request.method == 'GET':
id_poly = request.GET.get("id_poly")
with conn.cursor() as buldings:
buldings.execute("SELECT json_build_object('type', 'Feature', 'properties', (id, name, information, 'osm'), 'administrasi',(address_1, address_2, address_3, provinsi, 'no'), 'geometry', ST_AsGeoJSON(geom :: geometry) :: json) FROM geo_bangunan WHERE id = %s"% int(id_poly))
build = buldings.fetchall()
return Response(build[0][0])
import json
@api_view(('POST',))
@renderer_classes((TemplateHTMLRenderer, JSONRenderer))
def validatedit(request):
if request.method == 'POST':
name_b = request.POST.get("name_b")
info_b = request.POST.get("info_b")
desa_b = request.POST.get("desa_b")
kec_b = request.POST.get("kec_b")
kab_b = request.POST.get("kab_b")
pro_b = request.POST.get("pro_b")
id_poly = request.POST.get("id_poly")
polygon = request.POST.get("polygon")
cood_edit = json.loads(polygon)
co_edit = cood_edit['geometry']['coordinates']
print(id_poly, name_b, info_b, polygon)
with conn.cursor() as buldings:
buldings.execute("""UPDATE geo_bangunan set geom = st_geomfromgeojson('{"type":"MultiPolygon", "coordinates":[%s]}'),name='%s',information='%s',address_1='%s', address_2 = '%s', address_3 = '%s', provinsi='%s' WHERE id = %s"""% (co_edit,name_b, info_b, desa_b, kec_b, kab_b, pro_b, int(id_poly)))
conn.commit()
data = {'status':'Success'}
return Response(data)
@api_view(('POST',))
@renderer_classes((TemplateHTMLRenderer, JSONRenderer))
def hapus(request):
if request.method == 'POST':
id_poly = request.POST.get("id_poly")
with conn.cursor() as buldings:
buldings.execute("""DELETE from geo_bangunan where id = %s"""% int(id_poly))
conn.commit()
data = {'status':'Success'}
return Response(data)
@api_view(('GET',))
@renderer_classes((TemplateHTMLRenderer, JSONRenderer))
def hasilsearch(request):
if request.method == 'GET':
id_desa = request.GET.get("id_desa_search")
with conn.cursor() as kel:
kel.execute("SELECT json_build_object('type', 'Feature', 'administrasi', (kode_desa, desa, kecamatan, kab_kota, provinsi, jumlah_pen, jumlah_kk, luas_desa),'penduduk', (pria, wanita, belum_kawin, kawin, cerai_hidup, cerai_mati, wajib_ktp, islam, kristen, khatolik, hindu, budha, konghucu, kepercayaan_lain, u0, u5, u10, u15, u20, u25, u30, u35, u40, u45, u50, u55, u60, u65, u70, u75),'pekerjaan_pendidikan', (tidak_sekolah, belum_tamat, tamat_sd, sltp, slta, diploma_i, diploma_ii, diploma_iv, strata_ii, strata_iii, tidak_bekerja, aparatur_pemerintah, tenaga_pendidik, wiraswasta, pertanian, tenaga_kesehatan, pensiunan, pegawai, tentara, kepolisian, pedagang, petani, peternak, nelayan, karyawan, buruh, pembantu, tukang, pendeta, pastor, ustadz, dosen, guru, pilot, pengacara, notaris, arsitek, akuntan, konsultan, dokter, bidan, perawat, psikiater, sopir, lainnya),'geometry', ST_AsGeoJSON(geom :: geometry) :: json) from geo_data_kelurahan where id = %s"% int(id_desa))
kel_res_ = kel.fetchall()
kel_res = []
for i in kel_res_:
kel_res.append(i[0])
data = {'result':kel_res}
return Response(data)
\ No newline at end of file
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -19,9 +19,13 @@ class Dashboard(generic.TemplateView):
kel_res_ = kel.fetchall()
with conn.cursor() as kec:
kec.execute("SELECT kecamatan, json_build_object('type', 'Feature','geometry', ST_AsGeoJSON(geom :: geometry) :: json) from geo_data_kecamatan")
kec.execute("SELECT kecamatan, json_build_object('type', 'Feature', 'administrasi', (id, kecamatan),'geometry', ST_AsGeoJSON(geom :: geometry) :: json) from geo_data_kecamatan")
kec_res_ = kec.fetchall()
with conn.cursor() as knt:
knt.execute("SELECT json_build_object('type', 'Feature', 'administrasi', (a.namobj, a.remark),'geometry', ST_AsGeoJSON(a.geom :: geometry) :: json) from geo_kantor_administrasi a join geo_prov_kab b on st_intersects(a.geom,b.geom)")
knt_res = knt.fetchall()
kec_res = []
for i in kec_res_:
kec_res.append(i[1])
......@@ -30,12 +34,120 @@ class Dashboard(generic.TemplateView):
for i in kel_res_:
kel_res.append(i[0])
kntl = []
for i in knt_res:
kntl.append(i[0])
with conn.cursor() as kantor_administrasi:
kantor_administrasi.execute("SELECT json_build_object('type', 'Feature', 'administrasi', (a.namobj, a.remark),'geometry', ST_AsGeoJSON(a.geom :: geometry) :: json) from geo_kantor_administrasi a join geo_prov_kab b on st_intersects(a.geom,b.geom)")
kantor_administrasi_res = kantor_administrasi.fetchall()
kantor_administrasi_result = []
for i in kantor_administrasi_res:
kantor_administrasi_result.append(i[0])
with conn.cursor() as layanan_kesehatan:
layanan_kesehatan.execute("SELECT json_build_object('type', 'Feature', 'administrasi', (a.namobj, a.remark), 'geometry', ST_AsGeoJSON(a.geom :: geometry) :: json) from geo_layanan_kesehatan a join geo_prov_kab b on st_intersects(a.geom,b.geom)")
layanan_kesehatan_res = layanan_kesehatan.fetchall()
layanan_kesehatan_result = []
for i in layanan_kesehatan_res:
layanan_kesehatan_result.append(i[0])
with conn.cursor() as puskesmas:
puskesmas.execute("SELECT json_build_object('type', 'Feature', 'administrasi', (a.namobj, a.remark), 'geometry', ST_AsGeoJSON(a.geom :: geometry) :: json) from geo_puskesmas a join geo_prov_kab b on st_intersects(a.geom,b.geom)")
puskesmas_res = puskesmas.fetchall()
puskesmas_result = []
for i in puskesmas_res:
puskesmas_result.append(i[0])
with conn.cursor() as rumah_sakit:
rumah_sakit.execute("SELECT json_build_object('type', 'Feature', 'administrasi', (a.namobj, a.remark), 'geometry', ST_AsGeoJSON(a.geom :: geometry) :: json) from geo_rumah_sakit a join geo_prov_kab b on st_intersects(a.geom,b.geom)")
rumah_sakit_res = rumah_sakit.fetchall()
rumah_sakit_result = []
for i in rumah_sakit_res:
rumah_sakit_result.append(i[0])
with conn.cursor() as sarana_ibadah:
sarana_ibadah.execute("SELECT json_build_object('type', 'Feature', 'administrasi', (a.namobj, a.remark), 'geometry', ST_AsGeoJSON(a.geom :: geometry) :: json) from geo_sarana_ibadah a join geo_prov_kab b on st_intersects(a.geom,b.geom)")
sarana_ibadah_res = sarana_ibadah.fetchall()
sarana_ibadah_result = []
for i in sarana_ibadah_res:
if i[0]["administrasi"]['f1'] == None:
i[0]["administrasi"]['f1'] = "None"
sarana_ibadah_result.append(i[0])
with conn.cursor() as sarana_pendidikan:
sarana_pendidikan.execute("SELECT json_build_object('type', 'Feature', 'administrasi', (a.namobj, a.remark), 'geometry', ST_AsGeoJSON(a.geom :: geometry) :: json) from geo_sarana_pendidikan a join geo_prov_kab b on st_intersects(a.geom,b.geom)")
sarana_pendidikan_res = sarana_pendidikan.fetchall()
sarana_pendidikan_result = []
for i in sarana_pendidikan_res:
if i[0]["administrasi"]['f1'] == None:
i[0]["administrasi"]['f1'] = "None"
sarana_pendidikan_result.append(i[0])
with conn.cursor() as spbu:
spbu.execute("SELECT json_build_object('type', 'Feature', 'administrasi', (a.namobj, a.remark), 'geometry', ST_AsGeoJSON(a.geom :: geometry) :: json) from geo_spbu a join geo_prov_kab b on st_intersects(a.geom,b.geom)")
spbu_res = spbu.fetchall()
spbu_result = []
for i in spbu_res:
spbu_result.append(i[0])
with conn.cursor() as stasiun:
stasiun.execute("SELECT json_build_object('type', 'Feature', 'administrasi', (a.namobj, a.remark), 'geometry', ST_AsGeoJSON(a.geom :: geometry) :: json) from geo_stasiun a join geo_prov_kab b on st_intersects(a.geom,b.geom)")
stasiun_res = stasiun.fetchall()
stasiun_result = []
for i in stasiun_res:
stasiun_result.append(i[0])
with conn.cursor() as terminal:
terminal.execute("SELECT json_build_object('type', 'Feature', 'administrasi', (a.namobj, a.remark), 'geometry', ST_AsGeoJSON(a.geom :: geometry) :: json) from geo_terminal_bus a join geo_prov_kab b on st_intersects(a.geom,b.geom)")
terminal_res = terminal.fetchall()
terminal_result = []
for i in terminal_res:
terminal_result.append(i[0])
with conn.cursor() as cagar_budaya:
cagar_budaya.execute("SELECT json_build_object('type', 'Feature', 'administrasi', (a.namobj, a.remark), 'geometry', ST_AsGeoJSON(a.geom :: geometry) :: json) from geo_cagar_budaya a join geo_prov_kab b on st_intersects(a.geom,b.geom)")
cagar_budaya_res = cagar_budaya.fetchall()
cagar_budaya_result = []
for i in cagar_budaya_res:
cagar_budaya_result.append(i[0])
with conn.cursor() as gardu_listrik:
gardu_listrik.execute("SELECT json_build_object('type', 'Feature', 'administrasi', (a.namobj, a.remark), 'geometry', ST_AsGeoJSON(a.geom :: geometry) :: json) from geo_gardu_listrik a join geo_prov_kab b on st_intersects(a.geom,b.geom)")
gardu_listrik_res = gardu_listrik.fetchall()
gardu_listrik_result = []
for i in gardu_listrik_res:
gardu_listrik_result.append(i[0])
print(all)
context = {
'title':'NA - Dashboard',
'kelurahan':kel_res,
'kecamatan':kec_res,
'global':all[0]
'kantor_administrasi':kantor_administrasi_result,
'layanan_kesehatan':layanan_kesehatan_result,
'puskesmas':puskesmas_result,
'rumah_sakit':rumah_sakit_result,
'sarana_ibadah':sarana_ibadah_result,
'sarana_pendidikan':sarana_pendidikan_result,
'spbu':spbu_result,
'stasiun':stasiun_result,
'terminal':terminal_result,
'cagar_budaya':cagar_budaya_result,
'gardu_listrik':gardu_listrik_result,
'global':all[0],
'kntl':kntl
}
return render (request, self.template_name, context)
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
static/img/flags/ad.png

643 Bytes

static/img/flags/ae.png

408 Bytes

static/img/flags/af.png

604 Bytes

static/img/flags/ag.png

591 Bytes

static/img/flags/ai.png

643 Bytes

static/img/flags/al.png

600 Bytes

static/img/flags/am.png

497 Bytes

static/img/flags/an.png

488 Bytes

static/img/flags/ao.png

428 Bytes

static/img/flags/ar.png

506 Bytes

static/img/flags/as.png

647 Bytes

static/img/flags/at.png

403 Bytes

static/img/flags/au.png

673 Bytes

static/img/flags/aw.png

524 Bytes

static/img/flags/ax.png

663 Bytes

static/img/flags/az.png

589 Bytes

static/img/flags/ba.png

593 Bytes

static/img/flags/bb.png

585 Bytes

static/img/flags/bd.png

504 Bytes

static/img/flags/be.png

449 Bytes

static/img/flags/bf.png

497 Bytes

static/img/flags/bg.png

462 Bytes

static/img/flags/bh.png

457 Bytes

static/img/flags/bi.png

675 Bytes

static/img/flags/bj.png

486 Bytes

static/img/flags/bm.png

611 Bytes

static/img/flags/bn.png

639 Bytes

static/img/flags/bo.png

500 Bytes

static/img/flags/br.png

593 Bytes

static/img/flags/bs.png

526 Bytes

static/img/flags/bt.png

631 Bytes

static/img/flags/bv.png

512 Bytes

static/img/flags/bw.png

443 Bytes

static/img/flags/by.png

514 Bytes

static/img/flags/bz.png

600 Bytes

static/img/flags/ca.png

628 Bytes

static/img/flags/catalonia.png

398 Bytes

static/img/flags/cc.png

625 Bytes

static/img/flags/cd.png

528 Bytes

static/img/flags/cf.png

614 Bytes

static/img/flags/cg.png

521 Bytes

static/img/flags/ch.png

367 Bytes

static/img/flags/ci.png

453 Bytes

static/img/flags/ck.png

586 Bytes

static/img/flags/cl.png

450 Bytes

static/img/flags/cm.png

525 Bytes

static/img/flags/cn.png

472 Bytes

static/img/flags/co.png

483 Bytes

static/img/flags/cr.png

477 Bytes

static/img/flags/cs.png

439 Bytes

static/img/flags/cu.png

563 Bytes

static/img/flags/cv.png

529 Bytes

static/img/flags/cx.png

608 Bytes

static/img/flags/cy.png

428 Bytes

static/img/flags/cz.png

476 Bytes

static/img/flags/de.png

545 Bytes

static/img/flags/dj.png

572 Bytes

static/img/flags/dk.png

495 Bytes

static/img/flags/dm.png

620 Bytes

static/img/flags/do.png

508 Bytes

static/img/flags/dz.png

582 Bytes

static/img/flags/ec.png

500 Bytes

static/img/flags/ee.png

429 Bytes

static/img/flags/eg.png

465 Bytes

static/img/flags/eh.png

508 Bytes

static/img/flags/england.png

496 Bytes

static/img/flags/er.png

653 Bytes

static/img/flags/es.png

469 Bytes

static/img/flags/et.png

592 Bytes

static/img/flags/europeanunion.png

479 Bytes

static/img/flags/fam.png

532 Bytes

static/img/flags/fi.png

489 Bytes

static/img/flags/fj.png

610 Bytes

static/img/flags/fk.png

648 Bytes

static/img/flags/fm.png

552 Bytes

static/img/flags/fo.png

474 Bytes

static/img/flags/fr.png

545 Bytes

static/img/flags/ga.png

489 Bytes

This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment