Commit 0ee76cde authored by Manggar Mahardhika's avatar Manggar Mahardhika

push fix search point

parent b0cc89be
......@@ -21,6 +21,9 @@ urlpatterns = [
path('editkependudukan/', views.editkependudukan, name='kependudukan'),
path('valideditkependudukan', views.valideditkependudukan, name='valideditkependudukan'),
path('editspo', views.editpointsearch, name='editspo'),
path('editkantor', views.editpointka, name='editkantor'),
path('editlakes', views.editpointlk, name='editlakes'),
path('editpks', views.editpointpks, name='editpks'),
......@@ -33,6 +36,7 @@ urlpatterns = [
path('edittr', views.editpointtr, name='edittr'),
path('editcb', views.editpointcb, name='editcb'),
path('saveeditspo', views.editsearchpoint, name='saveeditspo'),
path('rumahsakit', views.editrumahsakit, name='rumahsakit'),
path('cagarbudaya', views.editcagarbudaya, name='cagarbudaya'),
path('kantor', views.editkantoradmin, name='kantor'),
......
......@@ -272,6 +272,50 @@ def editpoly(request):
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',))
@renderer_classes((TemplateHTMLRenderer, JSONRenderer))
def editpointka(request):
......@@ -1644,7 +1688,67 @@ def valideditkependudukan(request):
data = data_kependuduk[0]
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',))
def editrumahsakit(request):
......
......@@ -4448,6 +4448,7 @@
var gardu_listrik = "{{ gardu_listrik }}".replace(/'/g, '"');
var result_gardu_listrik = JSON.parse("" + gardu_listrik + "")
console.log(result_gardu_listrik)
var geo_po_gardu_listrik = L.geoJson(null, {
pointToLayer: function(feature, latlng) {
......@@ -8023,7 +8024,7 @@
var map_bang = new L.map('map-insert-renov-bang', {
editable: false,
zoomControl: false,
drawControl: true
drawControl: false
}).setView([-2, 118], 5);
mapssx = L.tileLayer('https://mt1.google.com/vt/lyrs=s&x={x}&y={y}&z={z}', {
......
......@@ -1313,6 +1313,18 @@
polygon_edit_tuplah = L.polygon(list_poly_edit).addTo(map_edit_tuplah)
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() {
var hasil = (JSON.stringify(polygon_edit_tuplah.toGeoJSON()))
$("#coordinatetuplah").val(hasil);
......@@ -1329,10 +1341,11 @@
}
},
})
});
// $(document).on("click", "#btnsavetuplah", function() {
});
// });
$(document).on("click", "#btnsavetuplah", function() {
var id_poly = $('#idtuplah').val();
......@@ -3850,6 +3863,53 @@
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")
});
......@@ -4181,6 +4241,33 @@
$("#modal_point").modal()
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-right").css("display", "none")
......@@ -4189,81 +4276,6 @@
$("#map-create-all > div.leaflet-control-container > div.leaflet-top.leaflet-left > div:nth-child(2) > div > div > a.leaflet-draw-draw-marker").css("display", "block!important")
})
$("#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);
}
});
});
});
$(document).on("click", "#create_save_jalan", function(e) {
......
......@@ -298,7 +298,14 @@
Luas &nbsp;
</th>
<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>
</tr>
<tr>
......@@ -645,7 +652,7 @@
<div class="col-md-4 text-center">
<a href="#" class="btn btn_create_lahan">
<div>
<img src="{% static 'img/icon-1/Vectorpoint.svg' %}" alt="" style="width: 35px;
<img src="{% static 'img/icon-1/SquareHalflahan.svg' %}" alt="" style="width: 35px;
height: 35px;">
</div>
<div style="margin-top: 10px;">
......
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