/**
  * Loads geometry data from the ESRI shape file
  *
  * @return boolean|void
  * @see ShapeFile::_loadRecords()
  */
 public function _loadRecords()
 {
     global $eof;
     ImportShp::readFromBuffer(32);
     while (true) {
         $record = new ShapeRecord(-1);
         $record->loadFromFile($this->SHPFile, $this->DBFFile);
         if ($record->lastError != "") {
             return false;
         }
         if ($eof) {
             break;
         }
         $this->records[] = $record;
     }
 }
Esempio n. 2
0
 /**
  * Test for doImport
  *
  * @return void
  *
  * @group medium
  */
 public function testDoImport()
 {
     //$sql_query_disabled will show the import SQL detail
     //$import_notice will show the import detail result
     global $import_notice, $sql_query, $sql_query_disabled;
     $sql_query_disabled = false;
     //Test function called
     $this->object->doImport();
     //asset that all sql are executed
     $this->assertContains('CREATE DATABASE IF NOT EXISTS `SHP_DB` DEFAULT CHARACTER ' . 'SET utf8 COLLATE utf8_general_ci', $sql_query);
     $this->assertContains('CREATE TABLE IF NOT EXISTS `SHP_DB`.`TBL_NAME` ' . '(`SPATIAL` geometry) DEFAULT CHARACTER ' . 'SET utf8 COLLATE utf8_general_ci;', $sql_query);
     $this->assertContains("INSERT INTO `SHP_DB`.`TBL_NAME` (`SPATIAL`) VALUES", $sql_query);
     $this->assertContains("GeomFromText('POINT(1294523.1759236", $sql_query);
     //asset that all databases and tables are imported
     $this->assertContains('The following structures have either been created or altered.', $import_notice);
     $this->assertContains('Go to database: `SHP_DB`', $import_notice);
     $this->assertContains('Edit settings for `SHP_DB`', $import_notice);
     $this->assertContains('Go to table: `TBL_NAME`', $import_notice);
     $this->assertContains('Edit settings for `TBL_NAME`', $import_notice);
     //asset that the import process is finished
     $this->assertEquals(true, $GLOBALS['finished']);
 }
Esempio n. 3
0
 /**
  * Loads data from a polyline record
  *
  * @return void
  * @see ShapeRecord::_loadPolyLineRecord()
  */
 public function _loadPolyLineRecord()
 {
     $this->SHPData = array();
     $this->SHPData["xmin"] = loadData("d", ImportShp::readFromBuffer(8));
     $this->SHPData["ymin"] = loadData("d", ImportShp::readFromBuffer(8));
     $this->SHPData["xmax"] = loadData("d", ImportShp::readFromBuffer(8));
     $this->SHPData["ymax"] = loadData("d", ImportShp::readFromBuffer(8));
     $this->SHPData["numparts"] = loadData("V", ImportShp::readFromBuffer(4));
     $this->SHPData["numpoints"] = loadData("V", ImportShp::readFromBuffer(4));
     for ($i = 0; $i < $this->SHPData["numparts"]; $i++) {
         $this->SHPData["parts"][$i] = loadData("V", ImportShp::readFromBuffer(4));
     }
     $readPoints = 0;
     reset($this->SHPData["parts"]);
     while (list($partIndex, ) = each($this->SHPData["parts"])) {
         if (!isset($this->SHPData["parts"][$partIndex]["points"]) || !is_array($this->SHPData["parts"][$partIndex]["points"])) {
             $this->SHPData["parts"][$partIndex] = array();
             $this->SHPData["parts"][$partIndex]["points"] = array();
         }
         while (!in_array($readPoints, $this->SHPData["parts"]) && $readPoints < $this->SHPData["numpoints"]) {
             $this->SHPData["parts"][$partIndex]["points"][] = $this->_loadPoint();
             $readPoints++;
         }
     }
 }