Пример #1
0
 function updateCartoMobileSettings($data, $_key_)
 {
     $table = new table("settings.geometry_columns_join");
     $data = $table->makeArray($data);
     $cartomobileArr = (array) json_decode($this->getValueFromKey($_key_, "cartomobile"));
     foreach ($data as $value) {
         $safeColumn = $table->toAscii($value->column, array(), "_");
         if ($value->id != $value->column && $value->column && $value->id) {
             unset($cartomobileArr[$value->id]);
         }
         $cartomobileArr[$safeColumn] = $value;
     }
     $conf['cartomobile'] = json_encode($cartomobileArr);
     $conf['_key_'] = $_key_;
     $table->updateRecord(json_decode(json_encode($conf)), "_key_");
     $this->execQuery($sql, "PDO", "transaction");
     if (!$this->PDOerror || !$sql) {
         $response['success'] = true;
         $response['message'] = "Column renamed";
     } else {
         $response['success'] = false;
         $response['message'] = $this->PDOerror[0];
     }
     return $response;
 }
Пример #2
0
 public function store($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->class = $data;
     $obj->_key_ = $this->table;
     $tableObj->updateRecord($obj, "_key_");
     if (!$tableObj->PDOerror) {
         $response['success'] = true;
         $response['message'] = "Class updated";
     } else {
         $response['success'] = false;
         $response['message'] = $tableObj->PDOerror[0];
     }
     return $response;
 }
Пример #3
0
 function deleteColumn($data, $whereClause = NULL)
 {
     $data = $this->makeArray($data);
     $fieldconfArr = (array) json_decode($this->getGeometryColumns($this->table, "fieldconf"));
     foreach ($data as $value) {
         $sql .= "ALTER TABLE {$this->table} DROP COLUMN {$value};";
         unset($fieldconfArr[$value]);
     }
     $this->execQuery($sql, "PDO", "transaction");
     if (!$this->PDOerror || !$sql) {
         $conf['fieldconf'] = json_encode($fieldconfArr);
         $conf['f_table_name'] = $this->table;
         $geometryColumnsObj = new table("settings.geometry_columns_join");
         $geometryColumnsObj->updateRecord(json_decode(json_encode($conf)), "f_table_name", $whereClause);
         $response['success'] = true;
         $response['message'] = "Column deleted";
     } else {
         $response['success'] = false;
         $response['message'] = $this->PDOerror[0];
     }
     return $response;
 }
Пример #4
0
<?php

include "../server_header.inc";
$table = new table(NULL);
$response = $table->create($_REQUEST['name'], $_REQUEST['type'], $_REQUEST['srid']);
$table = new table('settings.geometry_columns_join');
$obj = json_decode('{"data":{"f_table_name":"' . $response['tableName'] . '","f_table_title":""}}');
$response2 = $table->updateRecord($obj->data, 'f_table_name', "f_table_schema='{$postgisschema}'");
// If layer is new (inserted) then insert a new class for it
if ($response2['operation'] == "inserted") {
    $class = new _class($_REQUEST['name'], $postgisschema);
    $class->insert();
}
makeMapFile($_SESSION['screen_name']);
include_once "../server_footer.inc";
Пример #5
0
 public function copyClasses($to, $from)
 {
     $query = "SELECT class FROM settings.geometry_columns_join WHERE _key_ =:from";
     $res = $this->prepare($query);
     try {
         $res->execute(array("from" => $from));
     } catch (\PDOException $e) {
         $response['success'] = false;
         $response['message'] = $e->getMessage();
         $response['code'] = 400;
         return $response;
     }
     $row = $this->fetchRow($res);
     $conf['class'] = $row["class"];
     $conf['_key_'] = $to;
     $geometryColumnsObj = new table("settings.geometry_columns_join");
     $res = $geometryColumnsObj->updateRecord(json_decode(json_encode($conf)), "_key_");
     if (!$res["success"]) {
         $response['success'] = false;
         $response['message'] = $res["message"];
         $response['code'] = "406";
         return $response;
     }
     return $res;
 }
Пример #6
0
 public function copyMeta($to, $from)
 {
     $query = "SELECT * FROM settings.geometry_columns_join WHERE _key_ =:from";
     $res = $this->prepare($query);
     try {
         $res->execute(array("from" => $from));
     } catch (\PDOException $e) {
         $response['success'] = false;
         $response['message'] = $e->getMessage();
         $response['code'] = 400;
         return $response;
     }
     $booleanFields = array("editable", "baselayer", "tilecache", "not_querable", "single_tile", "enablesqlfilter", "skipconflict");
     $row = $this->fetchRow($res);
     foreach ($row as $k => $v) {
         if (in_array($k, $booleanFields)) {
             $conf[$k] = $v ?: "0";
         } else {
             $conf[$k] = $v;
         }
     }
     //print_r($conf);
     //die();
     $conf['_key_'] = $to;
     $geometryColumnsObj = new table("settings.geometry_columns_join");
     $res = $geometryColumnsObj->updateRecord(json_decode(json_encode($conf)), "_key_");
     if (!$res["success"]) {
         $response['success'] = false;
         $response['message'] = $res["message"];
         $response['code'] = "406";
         return $response;
     }
     return $res;
 }
Пример #7
0
 public function loadInDb()
 {
     $this->connect("PDO");
     $table = new table($this->safeFile);
     if ($this->pdo) {
         $cmd = "shp2pgsql -g 'the_geom' -W 'WINDOWS-1252' -I -c -s {$this->srid} {$this->file}.shp {$this->safeFile}";
         $result = exec($cmd, $output);
         $sql_total = implode("", $output);
         // Create block begin
         $this->begin();
         if ($table->exits) {
             $table->destroy();
         }
         $this->execQuery($sql_total, "PDO", "transaction");
         //Create block end
         if (!$this->PDOerror) {
             $this->commit();
             if (!$table->exits) {
                 // no need to re-init table object if table exits
                 $table = new table($this->safeFile);
             } else {
                 $overWriteTxt = " An exiting layer was overwriten";
             }
             //$table->point2multipoint();
             $response['success'] = true;
             $response['message'] = "Your shape file was uploaded and processed. You can find new layer in your geocloud." . $overWriteTxt;
         } else {
             $response['success'] = false;
             $response['message'] = $this->PDOerror;
             $this->rollback();
         }
     } else {
         // The psql way
         // Create block begin
         $this->begin();
         if ($table->exits) {
             $table->destroy();
         }
         $cmd = "shp2pgsql -W -g 'the_geom' 'WINDOWS-1252' -I -D -c -s {$this->srid} {$this->file}.shp {$this->safeFile}|psql {$this->postgisdb} postgres";
         $result = exec($cmd);
         if ($result == "COMMIT") {
             if (!$table->exits) {
                 // no need to re-init table object if table exits
                 $table = new table($this->safeFile);
             } else {
                 $overWriteTxt = " An exiting layer was overwriten";
             }
             //$table->point2multipoint();
             $this->commit();
             // rename column 'state' if such exits
             $this->connect("PDO");
             // Must re-connect after commit
             $this->begin();
             $sql = "ALTER TABLE {$this->safeFile} RENAME state to _state";
             $this->execQuery($sql);
             $this->commit();
             $response['success'] = true;
             $response['message'] = "Your shape file was uploaded and processed. You can find new layer in your geocloud." . $overWriteTxt;
         } else {
             $this->rollback();
             $response['success'] = false;
             $response['message'] = "Something went wrong!";
         }
         $table = new table('settings.geometry_columns_join');
         $obj = json_decode('{"data":{"f_table_name":"' . $this->safeFile . '","f_table_title":""}}');
         $response2 = $table->updateRecord($obj->data, 'f_table_name');
         // If layer is new (inserted) then insert a new class for it
         if ($response2['operation'] == "inserted") {
             //$class = new _class();
             //$class->insert($this->safeFile, array(), "_");
         }
         $response['cmd'] = $cmd;
     }
     return $response;
 }
Пример #8
0
     break;
 case "getgeojson":
     // only geometrycolumns table
     $response = $table->getGeoJson();
     break;
 case "getallrecords":
     // All tables
     $response = $table->getRecords(false, "gid,plannr,plannavn,distrikt,anvendelsegenerel,zonestatus,doklink", null);
     break;
 case "getgroupby":
     // All tables
     $response = $table->getGroupBy($parts[6]);
     break;
 case "updaterecord":
     // All tables
     $response = $table->updateRecord($obj->data, $parts[6]);
     makeMapFile($_SESSION['screen_name']);
     break;
 case "destroyrecord":
     // Geometry columns
     $response = $table->destroyRecord($obj->data, $parts[6]);
     makeMapFile($_SESSION['screen_name']);
     break;
 case "destroy":
     // Geometry columns
     $response = $table->destroy();
     makeMapFile($_SESSION['screen_name']);
     break;
 case 'getcolumns':
     // All tables
     $response = $table->getColumnsForExtGridAndStore();