Compare commits
No commits in common. "4bef36aa6bf81afee7abd5d037e47026f6e2b08c" and "01e9fe7eba2e9368690db8d04f51f5ebf19dcbd6" have entirely different histories.
4bef36aa6b
...
01e9fe7eba
@ -10,6 +10,7 @@
|
||||
|
||||
// Query
|
||||
|
||||
require_once("../config.db.php");
|
||||
require_once ("../config.php");
|
||||
|
||||
|
||||
@ -21,14 +22,13 @@ $coords_array = array ();
|
||||
while ($row = $result->fetch(PDO::FETCH_ASSOC)) {
|
||||
$coords_array[]=$row;
|
||||
}
|
||||
//DEBUG echo "<pre>"; print_r($coords_array); echo "</pre>";
|
||||
|
||||
// If no results are found, echo a message and stop
|
||||
//if ($coords_array == false) { echo "No results"; exit; }
|
||||
|
||||
if (file_exists("shape/ideenmelder.shp")) {unlink ("shape/ideenmelder.shp");}
|
||||
if (file_exists("shape/ideenmelder.dbf")) {unlink ("shape/ideenmelder.dbf");}
|
||||
if (file_exists("shape/ideenmelder.shx")) {unlink ("shape/ideenmelder.shx");}
|
||||
unlink ("shape/ideenmelder.shp");
|
||||
unlink ("shape/ideenmelder.dbf");
|
||||
unlink ("shape/ideenmelder.shx");
|
||||
//unlink ("shape/ideenmelder.dbt");
|
||||
|
||||
require_once('../vendor/Shapefile/ShapefileAutoloader.php');
|
||||
@ -43,9 +43,10 @@ use Shapefile\Geometry\Point;
|
||||
try {
|
||||
// Open Shapefile
|
||||
$Shapefile = new ShapefileWriter('shape/ideenmelder.shp');
|
||||
|
||||
// Set shape type
|
||||
|
||||
$Shapefile->setShapeType(Shapefile::SHAPE_TYPE_POINT);
|
||||
|
||||
// Create field structure
|
||||
$Shapefile->addNumericField('ID', 10);
|
||||
$Shapefile->addCharField('DESC');
|
||||
@ -54,7 +55,7 @@ try {
|
||||
$Shapefile->addCharField('DEFECT',60);
|
||||
|
||||
foreach ($coords_array as $coords) {
|
||||
//DEBUG echo "Coords ".$coords['id'].":";print_r($coords);echo "<hr>";
|
||||
//echo "Coords ".$coords['id'].":";print_r($coords);echo "<hr>";
|
||||
// Create a Point Geometry
|
||||
$lat=$coords['lat'];
|
||||
$lon=$coords['lng'];
|
||||
|
108
vendor/Shapefile/File/FileInterface.php
vendored
108
vendor/Shapefile/File/FileInterface.php
vendored
@ -1,108 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP Shapefile - PHP library to read and write ESRI Shapefiles, compatible with WKT and GeoJSON
|
||||
*
|
||||
* @package Shapefile
|
||||
* @author Gaspare Sganga
|
||||
* @version 4.0.0dev
|
||||
* @license MIT
|
||||
* @link https://gasparesganga.com/labs/php-shapefile/
|
||||
*/
|
||||
|
||||
namespace Shapefile\File;
|
||||
|
||||
/**
|
||||
* Interface to interact with files in binary mode.
|
||||
*/
|
||||
interface FileInterface
|
||||
{
|
||||
/**
|
||||
* Returns true if file is readable.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isReadable();
|
||||
|
||||
|
||||
/**
|
||||
* Returns true if file is writable.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isWritable();
|
||||
|
||||
|
||||
/**
|
||||
* Truncates file to given length.
|
||||
*
|
||||
* @param int $size Size to truncate to.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function truncate($size);
|
||||
|
||||
|
||||
/**
|
||||
* Gets file size in bytes.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getSize();
|
||||
|
||||
|
||||
/**
|
||||
* Gets file current pointer position.
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getPointer();
|
||||
|
||||
|
||||
/**
|
||||
* Sets file pointer to specified position.
|
||||
*
|
||||
* @param int $position The position to set the pointer to.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setPointer($position);
|
||||
|
||||
|
||||
/**
|
||||
* Resets file pointer position to its end.
|
||||
*
|
||||
* @return void.
|
||||
*/
|
||||
public function resetPointer();
|
||||
|
||||
|
||||
/**
|
||||
* Increases file pointer position of specified offset.
|
||||
*
|
||||
* @param int $offset The offset to move the pointer for.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setOffset($offset);
|
||||
|
||||
|
||||
/**
|
||||
* Reads raw binary string packed data from file.
|
||||
*
|
||||
* @param int $length Number of bytes to read.
|
||||
*
|
||||
* @return string|false Returns binary string packed data, or false on failure.
|
||||
*/
|
||||
public function read($length);
|
||||
|
||||
|
||||
/**
|
||||
* Writes raw binary string packed data to file.
|
||||
*
|
||||
* @param string $data Binary string packed data to write.
|
||||
*
|
||||
* @return bool Returns true on success, or false on failure.
|
||||
*/
|
||||
public function write($data);
|
||||
}
|
143
vendor/Shapefile/File/StreamResourceFile.php
vendored
143
vendor/Shapefile/File/StreamResourceFile.php
vendored
@ -1,143 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* PHP Shapefile - PHP library to read and write ESRI Shapefiles, compatible with WKT and GeoJSON
|
||||
*
|
||||
* @package Shapefile
|
||||
* @author Gaspare Sganga
|
||||
* @version 4.0.0dev
|
||||
* @license MIT
|
||||
* @link https://gasparesganga.com/labs/php-shapefile/
|
||||
*/
|
||||
|
||||
namespace Shapefile\File;
|
||||
|
||||
use Shapefile\Shapefile;
|
||||
use Shapefile\ShapefileException;
|
||||
|
||||
/**
|
||||
* Default FileInterface implementation.
|
||||
* It allows reading/writing of files in binary mode.
|
||||
* It accepts both filepaths and stream resource handles.
|
||||
*/
|
||||
class StreamResourceFile implements FileInterface
|
||||
{
|
||||
/////////////////////////////// PRIVATE VARIABLES ///////////////////////////////
|
||||
/**
|
||||
* @var resource File resource handle.
|
||||
*/
|
||||
private $handle = null;
|
||||
|
||||
/**
|
||||
* @var bool Flag to store whether file was passed as resource handle or not.
|
||||
*/
|
||||
private $flag_resource = false;
|
||||
|
||||
|
||||
|
||||
/////////////////////////////// PUBLIC ///////////////////////////////
|
||||
/**
|
||||
* Constructor.
|
||||
* Opens file with binary read or write access.
|
||||
*
|
||||
* @param string|resource $file Path to file or resource handle.
|
||||
* @param bool $write_access Access type: false = read; true = write.
|
||||
*/
|
||||
public function __construct($file, $write_access)
|
||||
{
|
||||
$this->flag_resource = is_resource($file);
|
||||
|
||||
if ($this->flag_resource) {
|
||||
$this->handle = $file;
|
||||
if (get_resource_type($this->handle) !== 'stream' || !stream_get_meta_data($this->handle)['seekable']) {
|
||||
throw new ShapefileException(Shapefile::ERR_FILE_RESOURCE_NOT_VALID);
|
||||
}
|
||||
if ((!$write_access && !$this->isReadable()) || ($write_access && !$this->isWritable())) {
|
||||
throw new ShapefileException(Shapefile::ERR_FILE_PERMISSIONS);
|
||||
}
|
||||
} else {
|
||||
$this->handle = @fopen($file, $write_access ? 'c+b' : 'rb');
|
||||
if ($this->handle === false) {
|
||||
throw new ShapefileException(Shapefile::ERR_FILE_OPEN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Destructor.
|
||||
*
|
||||
* Closes file if it was NOT passed as resource handle.
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
if (!$this->flag_resource) {
|
||||
fclose($this->handle);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets canonicalized absolute pathname.
|
||||
*/
|
||||
public function getFilepath()
|
||||
{
|
||||
return realpath(stream_get_meta_data($this->handle)['uri']);
|
||||
}
|
||||
|
||||
|
||||
public function isReadable()
|
||||
{
|
||||
return in_array(stream_get_meta_data($this->handle)['mode'], ['rb', 'r+b', 'w+b', 'x+b', 'c+b']);
|
||||
}
|
||||
|
||||
public function isWritable()
|
||||
{
|
||||
return in_array(stream_get_meta_data($this->handle)['mode'], ['r+b', 'wb', 'w+b', 'xb', 'x+b', 'cb', 'c+b']);
|
||||
}
|
||||
|
||||
|
||||
public function truncate($size)
|
||||
{
|
||||
ftruncate($this->handle, $size);
|
||||
}
|
||||
|
||||
public function getSize()
|
||||
{
|
||||
return fstat($this->handle)['size'];
|
||||
}
|
||||
|
||||
|
||||
public function getPointer()
|
||||
{
|
||||
return ftell($this->handle);
|
||||
}
|
||||
|
||||
public function setPointer($position)
|
||||
{
|
||||
fseek($this->handle, $position, SEEK_SET);
|
||||
}
|
||||
|
||||
public function resetPointer()
|
||||
{
|
||||
fseek($this->handle, 0, SEEK_END);
|
||||
}
|
||||
|
||||
public function setOffset($offset)
|
||||
{
|
||||
fseek($this->handle, $offset, SEEK_CUR);
|
||||
}
|
||||
|
||||
|
||||
public function read($length)
|
||||
{
|
||||
return @fread($this->handle, $length);
|
||||
}
|
||||
|
||||
public function write($data)
|
||||
{
|
||||
if (@fwrite($this->handle, $data) === false) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user