public function get_index() { $safeName = \app\inc\Model::toAscii($_REQUEST['name'], array(), "_"); if (is_numeric($safeName[0])) { $safeName = "_" . $safeName; } $srid = $_REQUEST['srid'] ?: "4326"; $file = $_REQUEST['file']; $key = Connection::$param["postgisschema"] . "." . $safeName . ".rast"; // Create new table $table = new Table($safeName); $res = $table->createAsRasterTable($srid); // Set bitmapsource $join = new Table("settings.geometry_columns_join"); $json = '{"data":{"bitmapsource":"' . $file . '","_key_":"' . $key . '"}}'; $data = (array) json_decode(urldecode($json)); $join->updateRecord($data, "_key_"); if ($res["success"]) { $response['success'] = true; $response['message'] = "Layer <b>{$safeName}</b> is created"; } else { $response['success'] = false; $response['message'] = "Some thing went wrong. Check the log."; Session::createLog(array($res['message']), $_REQUEST['file']); } return Response::json($response); }
public function get_index() { $dir = App::$param['path'] . "app/tmp/" . Connection::$param["postgisdb"] . "/__bitmaps"; $safeName = \app\inc\Model::toAscii($_REQUEST['name'], array(), "_"); if (is_numeric($safeName[0])) { $safeName = "_" . $safeName; } $srid = $_REQUEST['srid'] ?: "4326"; $cmd = "raster2pgsql " . "-s " . $srid . " -I -C -M -d " . $dir . "/" . $_REQUEST['file'] . " -F" . " -t 100x100 " . Connection::$param["postgisschema"] . "." . $safeName . " | PGPASSWORD="******"postgispw"] . " psql " . Connection::$param["postgisdb"] . " -U " . Connection::$param["postgisuser"] . " -h " . Connection::$param["postgishost"] . " -p " . Connection::$param["postgisport"]; exec($cmd . ' 2>&1', $out); $err = false; // This is a HACK. raster2pgsql doesn't return the error to stdout or stderr. if (!isset($out[0])) { $out[0] = "ERROR: Unable to read raster file"; } foreach ($out as $line) { if (strpos($line, 'ERROR') !== false) { $err = true; break; } } if (!$err) { $response['success'] = true; $response['cmd'] = $cmd; $response['message'] = "Raster layer <b>{$safeName}</b> is created"; $key = Connection::$param["postgisschema"] . "." . $safeName . ".rast"; $class = new \app\models\Classification($key); $arr = $class->getAll(); if (empty($arr['data'])) { $class->insert(); $class->update("0", \app\models\Classification::createClass("POLYGON")); } if ($_REQUEST['displayfile']) { $join = new Table("settings.geometry_columns_join"); $json = '{"data":{"bitmapsource":"' . $_REQUEST['file'] . '","_key_":"' . $key . '"}}'; $data = (array) json_decode(urldecode($json)); $join->updateRecord($data, "_key_"); } } else { $response['success'] = false; $response['message'] = "Some thing went wrong. Check the log."; Session::createLog($out, $_REQUEST['file']); } $response['cmd'] = $cmd; return Response::json($response); }
private function storeWizard($data) { // First we replace unicode escape sequence //$data = preg_replace_callback('/\\\\u([0-9a-f]{4})/i', 'replace_unicode_escape_sequence', $data); $tableObj = new Table("settings.geometry_columns_join"); $obj = new \stdClass(); $obj->classwizard = $data; $obj->_key_ = $this->layer; $tableObj->updateRecord($obj, "_key_"); if (!$tableObj->PDOerror) { $response = true; } else { $response = false; } return $response; }
public function updateRoles($data) { $data = (array) $data; $table = new Table("settings.geometry_columns_join"); $role = (array) json_decode($this->getValueFromKey($data['_key_'], "roles")); $role[$data['subuser']] = $data['roles']; $roles['roles'] = json_encode($role); $roles['_key_'] = $data['_key_']; $res = $table->updateRecord(json_decode(json_encode($roles)), "_key_"); if ($res['success'] == true) { $response['success'] = true; $response['message'] = "Roles updates"; } else { $response['success'] = false; $response['message'] = $res['message']; $response['code'] = 403; } return $response; }