/** * * * @return unknown */ public function loadInDb() { $this->connect("PDO"); $table = new table($this->safeFile); if ($this->pdo) { $cmd = "shp2pgsql -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 i 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 '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 i 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(), "_"); } makeMapFile($_SESSION['screen_name']); $response['cmd'] = $cmd; } return $response; }
<?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";
<?php include "../server_header.inc"; //include("../../inc/oauthcheck.php"); if ($HTTP_RAW_POST_DATA) { $obj = json_decode($HTTP_RAW_POST_DATA); } $class = new _class($parts[5]); //print_r($obj); switch ($parts[4]) { case "getall": $response = $class->getAll(); break; case "get": $response = $class->get($parts[6]); break; case "update": $response = $class->update($parts[6], $obj->data); makeMapFile($_SESSION['screen_name']); break; case "insert": $response = $class->insert(); makeMapFile($_SESSION['screen_name']); break; case "destroy": $response = $class->destroy($obj->data); makeMapFile($_SESSION['screen_name']); break; } include_once "../server_footer.inc";