Commit 8ecf5493 authored by Muhamad's avatar Muhamad

Merge branch 'master' of http://git.khansia.co.id/Nahrowi/oku-gis

parents 592304dd e68cf74c
...@@ -21,6 +21,9 @@ urlpatterns = [ ...@@ -21,6 +21,9 @@ urlpatterns = [
path('editkependudukan/', views.editkependudukan, name='kependudukan'), path('editkependudukan/', views.editkependudukan, name='kependudukan'),
path('valideditkependudukan', views.valideditkependudukan, name='valideditkependudukan'), path('valideditkependudukan', views.valideditkependudukan, name='valideditkependudukan'),
path('editspo', views.editpointsearch, name='editspo'),
path('editkantor', views.editpointka, name='editkantor'), path('editkantor', views.editpointka, name='editkantor'),
path('editlakes', views.editpointlk, name='editlakes'), path('editlakes', views.editpointlk, name='editlakes'),
path('editpks', views.editpointpks, name='editpks'), path('editpks', views.editpointpks, name='editpks'),
...@@ -33,6 +36,7 @@ urlpatterns = [ ...@@ -33,6 +36,7 @@ urlpatterns = [
path('edittr', views.editpointtr, name='edittr'), path('edittr', views.editpointtr, name='edittr'),
path('editcb', views.editpointcb, name='editcb'), path('editcb', views.editpointcb, name='editcb'),
path('saveeditspo', views.editsearchpoint, name='saveeditspo'),
path('rumahsakit', views.editrumahsakit, name='rumahsakit'), path('rumahsakit', views.editrumahsakit, name='rumahsakit'),
path('cagarbudaya', views.editcagarbudaya, name='cagarbudaya'), path('cagarbudaya', views.editcagarbudaya, name='cagarbudaya'),
path('kantor', views.editkantoradmin, name='kantor'), path('kantor', views.editkantoradmin, name='kantor'),
......
...@@ -272,6 +272,50 @@ def editpoly(request): ...@@ -272,6 +272,50 @@ def editpoly(request):
return Response(build[0][0]) return Response(build[0][0])
@api_view(('GET',))
@renderer_classes((TemplateHTMLRenderer, JSONRenderer))
def editpointsearch(request):
if request.method == 'GET':
id_point = request.GET.get("id_point")
db_point = request.GET.get("db_point")
if (db_point == "geo_cagar_budaya" or db_point == "geo_terminal_bus"):
l = "a.luas"
else:
l = "a.luas_tanah"
print(id_point, db_point, l)
with conn.cursor() as buldings:
buldings.execute("""SELECT
json_build_object (
'type',
'Feature',
'administrasi',
(
a.id,
A.namobj,
A.remark,
A.alamat,
A.gambar,
A.perangkat,
A.tipe_gambar,
b.kabupaten,
c.kecamatan,
d.desa,
%s
),
'geometry',
ST_AsGeoJSON ( A.geom :: geometry ) :: json
)
FROM
%s A
JOIN geo_prov_kab b ON st_intersects ( A.geom, b.geom )
JOIN geo_data_kecamatan c ON st_intersects(A.geom, c.geom)
join geo_data_kelurahan d on st_intersects(A.geom, d.geom)
WHERE a.is_deleted = 0 and a.id = %s"""% (l, db_point, int(id_point)))
build = buldings.fetchall()
return Response(build[0][0])
@api_view(('GET',)) @api_view(('GET',))
@renderer_classes((TemplateHTMLRenderer, JSONRenderer)) @renderer_classes((TemplateHTMLRenderer, JSONRenderer))
def editpointka(request): def editpointka(request):
...@@ -1644,7 +1688,67 @@ def valideditkependudukan(request): ...@@ -1644,7 +1688,67 @@ def valideditkependudukan(request):
data = data_kependuduk[0] data = data_kependuduk[0]
return Response(respon) return Response(respon)
@api_view(('POST',))
def editsearchpoint(request):
idsave = request.POST.get('idspo')
dbsave = request.POST.get('dbspo')
namobj = request.POST.get('namobj')
luas = request.POST.get('luas')
remark = request.POST.get('remark')
gambar = request.POST.get('gambar')
alamat = request.POST.get('alamat')
if (dbsave == "geo_cagar_budaya" or dbsave == "geo_terminal_bus"):
l = "luas"
else:
l = "luas_tanah"
if alamat is None:
alamat = 'alamat'
elif alamat == '':
alamat = 'alamat'
else:
alamat = request.POST.get('alamat')
perangkat = request.POST.get('perangkat')
if perangkat is None:
perangkat = 'bpk'
elif perangkat == '':
perangkat = 'bpk'
else:
perangkat = request.POST.get('perangkat')
point = request.POST.get("point")
cood_edit = json.loads(point)
co_edit = cood_edit['geometry']['coordinates']
file = request.FILES.get('file')
fss = FileSystemStorage(location='/var/www/django/oku.khansia.co.id/static/img/image/')
try:
format = (file.name).split(".")
num = random.randrange(1, 10000000000000)
namafile = f"{namobj}_{num}.{format[-1:][0]}"
filename = fss.save(namafile, file)
# print(file.name)
url = fss.url(filename)
except:
namafile = gambar
print(dbsave, co_edit, namobj, alamat, remark, l, luas, perangkat, namafile, idsave)
with conn.cursor() as editspo:
editspo.execute("""update %s set geom = st_geomfromgeojson('{"type":"Point", "coordinates":%s, "crs":{"type":"name","properties":{"name":"EPSG:4326"}}}'), namobj = '%s', alamat = '%s', remark = '%s', %s = '%s', perangkat = '%s', gambar = '%s' where id = %s"""% (dbsave, co_edit, namobj, alamat, remark, l, luas, perangkat, namafile, idsave))
conn.commit()
with conn.cursor() as hasiledit:
hasiledit.execute("""select namobj, alamat, remark, %s, gambar, perangkat from %s where id = %s"""% (l, dbsave, idsave))
hasileditspo = hasiledit.fetchall()
data = hasileditspo[0]
data = {'status':'Success'}
data = 'SUCCESS'
info = 'data telah diperbaharui'
status = 0
respon={'data':data, 'info': info, 'status':status}
return Response(respon)
@api_view(('POST',)) @api_view(('POST',))
def editrumahsakit(request): def editrumahsakit(request):
......
...@@ -4789,6 +4789,7 @@ ...@@ -4789,6 +4789,7 @@
var gardu_listrik = "{{ gardu_listrik }}".replace(/'/g, '"'); var gardu_listrik = "{{ gardu_listrik }}".replace(/'/g, '"');
var result_gardu_listrik = JSON.parse("" + gardu_listrik + "") var result_gardu_listrik = JSON.parse("" + gardu_listrik + "")
console.log(result_gardu_listrik)
var geo_po_gardu_listrik = L.geoJson(null, { var geo_po_gardu_listrik = L.geoJson(null, {
pointToLayer: function(feature, latlng) { pointToLayer: function(feature, latlng) {
...@@ -8391,7 +8392,7 @@ ...@@ -8391,7 +8392,7 @@
var map_bang = new L.map('map-insert-renov-bang', { var map_bang = new L.map('map-insert-renov-bang', {
editable: false, editable: false,
zoomControl: false, zoomControl: false,
drawControl: true drawControl: false
}).setView([-2, 118], 5); }).setView([-2, 118], 5);
mapssx = L.tileLayer('https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}', { mapssx = L.tileLayer('https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}', {
......
...@@ -1195,6 +1195,18 @@ ...@@ -1195,6 +1195,18 @@
polygon_edit_tuplah = L.polygon(list_poly_edit).addTo(map_edit_tuplah) polygon_edit_tuplah = L.polygon(list_poly_edit).addTo(map_edit_tuplah)
polygon_edit_tuplah.enableEdit(); polygon_edit_tuplah.enableEdit();
$('#btn_ceklwas').click(function() {
var hasil = (JSON.stringify(polygon_edit_tuplah.toGeoJSON()))
var seeArea = L.GeometryUtil.geodesicArea(polygon_edit_tuplah.getLatLngs()[0]);
var fixarea = seeArea.toFixed(3)
var separ = fixarea.toString().split(".");
var areacom = separ.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
separ.join(".");
$("#luas_tuplah_edit").val(fixarea);
})
$('#btnsavetuplah').click(function() { $('#btnsavetuplah').click(function() {
var hasil = (JSON.stringify(polygon_edit_tuplah.toGeoJSON())) var hasil = (JSON.stringify(polygon_edit_tuplah.toGeoJSON()))
$("#coordinatetuplah").val(hasil); $("#coordinatetuplah").val(hasil);
...@@ -1211,10 +1223,11 @@ ...@@ -1211,10 +1223,11 @@
} }
}, },
}) })
});
// $(document).on("click", "#btnsavetuplah", function() {
// });
});
$(document).on("click", "#btnsavetuplah", function() { $(document).on("click", "#btnsavetuplah", function() {
var id_poly = $('#idtuplah').val(); var id_poly = $('#idtuplah').val();
...@@ -3745,6 +3758,53 @@ ...@@ -3745,6 +3758,53 @@
Poly = lay; Poly = lay;
}); });
$("#tipe_point_b").change(function() {
var tipe = $(this).val();
$.ajax({
url: "{% url 'api:change-tipe' %}",
data: {
'tipe': tipe
},
dataType: 'json',
success: function(data) {
var data_all_kab = []
for (var i = 0; i < data['result'].length; i++) {
var data_k = data['result'][i][0];
console.log(data_k)
var data_kab = `<option value="` + data_k + `">` + data_k + `</option>`;
data_all_kab.push(data_kab)
};
$('#tipe_point_2_b').html(`<option value="null" selected disabled>-- Pilih Tipe Point --</option>` + data_all_kab);
$('#tipe_point_3_b').html(`<option value="null" selected disabled>-- Pilih Point --</option>`);
}
});
});
$("#tipe_point_2_b").change(function() {
var jenis = $(this).val();
var tipx = $("#tipe_point_b").val();
$.ajax({
url: "{% url 'api:change-jenis' %}",
data: {
'tipe': tipx,
'jenis': jenis
},
dataType: 'json',
success: function(data) {
console.log(data)
var data_all_kab = []
for (var i = 0; i < data['result'].length; i++) {
var data_id = data['result'][i][0];
var data_po = data['result'][i][1];
var data_kab = `<option value="` + data_id + `">` + data_po + `</option>`;
data_all_kab.push(data_kab)
};
$('#tipe_point_3_b').html(`<option value="null" selected disabled>-- Pilih Point --</option>` + data_all_kab);
}
});
});
$("#map-create-all > div.leaflet-control-container > div.leaflet-top.leaflet-left > div").css("display", "none") $("#map-create-all > div.leaflet-control-container > div.leaflet-top.leaflet-left > div").css("display", "none")
}); });
...@@ -4078,6 +4138,33 @@ ...@@ -4078,6 +4138,33 @@
$("#modal_point").modal() $("#modal_point").modal()
map.closePopup(); map.closePopup();
}); });
$("#tipe_point").change(function() {
var tipe = $(this).val();
$.ajax({
url: "{% url 'api:change-tipe' %}",
data: {
'tipe': tipe
},
dataType: 'json',
success: function(data) {
console.log(data)
var data_all_kab = []
for (var i = 0; i < data['result'].length; i++) {
var data_k = data['result'][i][0];
var data_kab = `<option value="` +
data_k +
`">` +
data_k +
`</option>`;
data_all_kab.push(data_kab)
};
$('#tipe_point_2').html(`<option value="null" selected disabled>-- Pilih Tipe Point --</option>` + data_all_kab);
}
});
});
$("#map-create-all > div.leaflet-control-container > div.leaflet-top.leaflet-left > div:nth-child(2) > div > div").css("display", "none") $("#map-create-all > div.leaflet-control-container > div.leaflet-top.leaflet-left > div:nth-child(2) > div > div").css("display", "none")
$(".leaflet-draw-draw-marker").css("padding", "0px!important") $(".leaflet-draw-draw-marker").css("padding", "0px!important")
$(".leaflet-draw-draw-marker").css("width", "100%!important") $(".leaflet-draw-draw-marker").css("width", "100%!important")
...@@ -4087,79 +4174,6 @@ ...@@ -4087,79 +4174,6 @@
}) })
$("#tipe_point").change(function() {
var tipe = $(this).val();
$.ajax({
url: "{% url 'api:change-tipe' %}",
data: {
'tipe': tipe
},
dataType: 'json',
success: function(data) {
console.log(data)
var data_all_kab = []
for (var i = 0; i < data['result'].length; i++) {
var data_k = data['result'][i][0];
var data_kab = `<option value="` +
data_k +
`">` +
data_k +
`</option>`;
data_all_kab.push(data_kab)
};
$('#tipe_point_2').html(`<option value="null" selected disabled>-- Pilih Tipe Point --</option>` + data_all_kab);
}
});
});
$("#tipe_point_b").change(function() {
var tipe = $(this).val();
$.ajax({
url: "{% url 'api:change-tipe' %}",
data: {
'tipe': tipe
},
dataType: 'json',
success: function(data) {
var data_all_kab = []
for (var i = 0; i < data['result'].length; i++) {
var data_k = data['result'][i][0];
console.log(data_k)
var data_kab = `<option value="` + data_k + `">` + data_k + `</option>`;
data_all_kab.push(data_kab)
};
$('#tipe_point_2_b').html(`<option value="null" selected disabled>-- Pilih Tipe Point --</option>` + data_all_kab);
}
});
});
$("#tipe_point_2_b").change(function() {
var jenis = $(this).val();
var tipx = $("#tipe_point_b").val();
$.ajax({
url: "{% url 'api:change-jenis' %}",
data: {
'tipe': tipx,
'jenis': jenis
},
dataType: 'json',
success: function(data) {
console.log(data)
var data_all_kab = []
for (var i = 0; i < data['result'].length; i++) {
var data_id = data['result'][i][0];
var data_po = data['result'][i][1];
var data_kab = `<option value="` + data_id + `">` + data_po + `</option>`;
data_all_kab.push(data_kab)
};
$('#tipe_point_3_b').html(`<option value="null" selected disabled>-- Pilih Point --</option>` + data_all_kab);
}
});
});
$(".btn_cek_KDBKLB").click(function() { $(".btn_cek_KDBKLB").click(function() {
$("#koordinatjalan").addClass("active") $("#koordinatjalan").addClass("active")
$("#informasi_create").removeClass("active") $("#informasi_create").removeClass("active")
......
...@@ -298,7 +298,14 @@ ...@@ -298,7 +298,14 @@
Luas &nbsp; Luas &nbsp;
</th> </th>
<td> <td>
<input id="luas_tuplah_edit" type="text" class="form-control" value="" style="width:fit-content;" disabled> <input id="luas_tuplah_edit" type="text" class="form-control" value="" disabled>
</td>
<td>
<button type="submit" id="btn_ceklwas" class="btn btn-primary" title="Check Luas" style="border-radius: 0px 10px 10px 0px;
outline: none;
background: linear-gradient(
201.55deg
, #72BBFF -24.21%, #3D5CCA 130.65%);"><i class="icon-search4 text-muted text-size-base" style="color: white;"></i></button>
</td> </td>
</tr> </tr>
<tr> <tr>
......
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