Example #1
0
 /**
  * Prepare geometry
  */
 public function __toString()
 {
     // ST_TRANSFORM(ST_GEOMFROMTEXT('$geom'), $srid)
     if ($this->isWKT()) {
         return 'GeomFromText(' . SpatialiteBaseDriver::escapeValue($this->getValue()) . ',' . SpatialiteBaseDriver::escapeValue($this->getSrid()) . '
        )';
     }
     if ($this->type == self::TYPE_WKB) {
         return 'x' . $this->getValue();
     }
     return $this->getValue();
 }
 /**
  * Spatialite constructor.
  *
  * @param string $dbPath  Database file path.
  * @param string $libPath mod_spatialite path. Optional.
  * @param string $binPath sqlite binary path. Optional.
  */
 public function __construct($dbPath, $libPath = null, $binPath = null)
 {
     $osAlias = strtoupper(substr(PHP_OS, 0, 3));
     $isWin = $osAlias == 'CYG' || $osAlias == 'WIN';
     $path = __DIR__ . "/../../";
     if ($isWin) {
         $path .= 'bin/x32';
         $binPath = $binPath ? $binPath : $path . '/spatialite.exe';
     } else {
         $path .= 'bin/x64';
         $binPath = $binPath ? $binPath : $path . '/sqlite3';
         $libPath = $libPath ? $libPath : $path . '/mod_spatialite';
     }
     $this->cmd = escapeshellarg($binPath) . ' -separator ' . escapeshellarg(self::SPLIT_CELL_CHAR) . ' -nullvalue ' . escapeshellarg(self::NULL_CHAR) . ' -header ' . escapeshellarg($dbPath);
     if ($libPath) {
         $this->_libLoad = escapeshellarg('SELECT load_extension(\'' . $libPath . '\');');
     }
     parent::__construct($dbPath);
 }