You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

170 lines
5.8 KiB

<?php
namespace App\Controllers\Kewilayahan;
use App\Libraries\AldLibrary;
use CodeIgniter\API\ResponseTrait;
use CodeIgniter\Controller;
class Peta extends Controller
{
use ResponseTrait;
public function index()
{
// $db = \Config\Database::connect();
// $data = [];
// if (session('isLogin')) {
// echo view('inc/head');
// echo view('inc/navbar');
// echo view('inc/sidebar');
// echo view('kewilayahan/kytp/kpdl', $data);
// echo view('inc/footer');
// } else {
// return redirect()->to('auth');
// }
return view('kewilayahan/peta/peta');
}
public function defaultCentroid()
{
$db = \Config\Database::connect();
$data = $db->table("KPDL_ZP_NAS_DIFF A")
->select(" SDO_UTIL.TO_GEOJSON(SDO_GEOM.SDO_CENTROID(SDO_AGGR_UNION(SDOAGGRTYPE(A.WKB_GEOMETRY, 0.05)),0.05)) GEOJSON")
->where('KD_KANWIL', session('kwladm'));
$sql = $data->getCompiledSelect();
$db2 = new \Config\Database();
$db_def = $db2->default;
$conn = oci_connect($db_def['username'], $db_def['password'], $db_def['hostname']);
$stmt = oci_parse($conn, $sql);
oci_execute($stmt)
or die("Unable to execute query\n");
while ($row = oci_fetch_assoc($stmt)) {
if ($row['GEOJSON']) {
print $row['GEOJSON']->load() . "\n";
}
else {
print null;
}
}
}
public function matoaLokasi()
{
if (!$this->validate([
'uuid' => 'required',
])) {
return $this->respond($this->validator->getErrors(), 422);
}
$uuid = $this->request->getPost('uuid');
$db = \Config\Database::connect();
$data = $db->table('KPDL_MV_LOKASI_SUBJEK A')
->select("A.NPWP, ALAMAT, NM_KPP_ZONA, NM_KANTOR_PENGAMPU, NM_PEREKAM, NM_KPP_PEREKAM,NAMA_AR_MFWP,
JNS_WP_MFWP,STATUS_WP_MFWP, WARNA_PEMBAYARAN_THN_TERAKHIR,STATUS_SPT_TAHUNAN_TERAKHIR,
MERK_USAHA, NO_TELP, TO_CHAR(CREATION_DATE,'YYYY-MM-DD HH24:MI:SS') CREATION_DATE, B.NAMA NAMA_AR_ZONA")
->join('PEGAWAI B', 'A.NIP_AR_ZONA=B.NIP9', 'left')
->where('UUID', $uuid)->get()->getRowArray();
return $this->respond(array_change_key_case($data), 200);
}
public function poiGoogle()
{
if (!$this->validate([
'id_data' => 'required',
])) {
return $this->respond($this->validator->getErrors(), 422);
}
$id_data = $this->request->getPost('id_data');
$db = \Config\Database::connect();
$data = $db->table('KPDL_MV_POI_GOOGLE A')
->select("ID_DATA, NAMA, ALAMAT, CATEGORY, NM_AR_ZONA, B.NM_KANTOR,
TOP_IMAGE_URL, ADM1_EN, ADM2_EN, ADM3_EN, ADM4_EN,
(regexp_replace(RATING , ',' , '.')) RATING,
to_number(regexp_replace(REVIEWS , '[^[:digit:]]', '')) REVIEW")
->join('REF_KPP B', 'A.KD_KPP_ZONA =B.KD_KPP', 'left')
->where('ID_DATA', $id_data);
// print_r($data->getCompiledSelect());
//exit;
$data = $data->get()->getRowArray();
return $this->respond(array_change_key_case($data), 200);
}
public function zonapoly()
{
if (!$this->validate([
'id_poly_zona' => ['required'],
])) {
return $this->respond($this->validator->getErrors(), 422);
}
$Ald = new AldLibrary;
$username = session('nip');
$id_poly_zona = [];
foreach ($this->request->getPost('id_poly_zona') ?? [1, 2, 3] as $key => $value) {
$id_poly_zona[] = $Ald->decryptMe($value, $username);
}
$db = \Config\Database::connect();
$data = $db->table("KPDL_ZP_NAS_DIFF A")
->select("SDO_UTIL.to_geojson(SDO_AGGR_UNION(SDOAGGRTYPE(A.WKB_GEOMETRY,0.05))) GEOJSON")
->whereIn('OGC_FID', $id_poly_zona);
$sql = $data->getCompiledSelect();
$db2 = new \Config\Database();
$db_def = $db2->default;
$conn = oci_connect($db_def['username'], $db_def['password'], $db_def['hostname']);
$stmt = oci_parse($conn, $sql);
oci_execute($stmt)
or die("Unable to execute query\n");
while ($row = oci_fetch_assoc($stmt)) {
print $row['GEOJSON']->load() . "\n";
}
}
public function kelurahanpoly()
{
if (!$this->validate([
'adm4_pcode' => ['required'],
])) {
return $this->respond($this->validator->getErrors(), 422);
}
$Ald = new AldLibrary;
$username = session('nip');
$opsiWilZona = $Ald->decryptMe($this->request->getPost('opsiWilZona'), $username);
$adm4_pcode = [];
foreach ($this->request->getPost('adm4_pcode') ?? [1, 2, 3] as $key => $value) {
$adm4_pcode[] = $Ald->decryptKpdl($value, $username);
}
$db = \Config\Database::connect();
$data = $db->table("KPDL_V_BATAS_DESA A")
->select("SDO_UTIL.to_geojson(SDO_AGGR_UNION(SDOAGGRTYPE(A.WKB_GEOMETRY,0.05))) GEOJSON")
->whereIn('ADM4_PCODE', $adm4_pcode);
$sql = $data->getCompiledSelect();
$db2 = new \Config\Database();
$db_def = $db2->default;
$conn = oci_connect($db_def['username'], $db_def['password'], $db_def['hostname']);
$stmt = oci_parse($conn, $sql);
oci_execute($stmt)
or die("Unable to execute query\n");
while ($row = oci_fetch_assoc($stmt)) {
// Call the load() method to get the contents of the LOB
print $row['GEOJSON']->load() . "\n";
}
}
}