to('auth'); // } return view('kewilayahan/peta/peta'); } public function defaultCentroidOld() { $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 defaultCentroid() { $db = \Config\Database::connect(); $geom = $db->table('KPDL_ZP_NAS_DIFF A')->select("A.WKB_GEOMETRY")->where('KD_KANWIL', session('kwladm'))->limit(1); $data = $db->newQuery()->fromSubquery($geom, "A") ->select("SDO_UTIL.TO_WKTGEOMETRY(SDO_GEOM.SDO_CENTROID(SDO_AGGR_UNION(SDOAGGRTYPE(A.WKB_GEOMETRY, 0.05)),0.05)) GEOJSON"); $sql = $data->getCompiledSelect(); // print_r($sql); // exit; $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(); } 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(); if ($data) { return $this->respond(array_change_key_case($data), 200); } else { return $this->respond([], 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, to_number(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)->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_WKTGEOMETRY(SDO_AGGR_UNION(SDOAGGRTYPE(A.WKB_GEOMETRY,0.05))) GEOJSON") ->whereIn('OGC_FID', $id_poly_zona); $sql = $data->getCompiledSelect(); // print_r($sql); // exit; $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(); } } public function kelurahanpoly_ori() { 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_WKTGEOMETRY(SDO_AGGR_UNION(SDOAGGRTYPE(A.WKB_GEOMETRY,0.05))) GEOJSON") ->whereIn('ADM4_PCODE', $adm4_pcode); $sql = $data->getCompiledSelect(); // print_r($sql); // exit; $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"; } } 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_WKTGEOMETRY(SDO_AGGR_UNION(SDOAGGRTYPE(A.WKB_GEOMETRY,0.05))) GEOJSON") ->whereIn('ADM4_PCODE', $adm4_pcode); $sql = $data->getCompiledSelect(); // print_r($sql); // exit; // $sql = "SELECT SDO_UTIL.TO_WKTGEOMETRY(SDO_UTIL.EXTRACT(a.wkb_geometry, 1)) GEOJSON // FROM KPDL_V_BATAS_DESA a // WHERE ADM4_PCODE IN ('31.73.07.1004','31.73.07.1005','31.73.07.1006','31.73.07.1003','31.73.07.1001','31.73.07.1002')"; $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"); // $polyArray = ''; while ($row = oci_fetch_assoc($stmt)) { // Call the load() method to get the contents of the LOB // array_push($polyArray, str_replace(" 0.0", "", $row['GEOJSON']->load())); $polyArray = str_replace(" 0.0", "", $row['GEOJSON']->load()); // $polyArray = $row['GEOJSON']->load(); // print $row['GEOJSON']->load(); } // $poly = null; // if (count($polyArray)) { // $gE = new GeometryEngine(); // $poly = Polygon::fromText($polyArray[0]); // for ($i = 1; $i <= count($polyArray); $i++) { // $poly = $gE->union($poly, Polygon::fromText($polyArray[$i])); // // $poly->union(Polygon::fromText($polyArray[$i])); // } // echo $poly; // } // $poly->union() return $this->respond($polyArray, 200); // echo $polyArray; } }