Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jbelien committed Dec 12, 2018
2 parents cb2aea9 + 636945b commit 928362c
Show file tree
Hide file tree
Showing 27 changed files with 7,207 additions and 4,244 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.cache/
.vscode/
node_modules/
vendor/
config.yml
12 changes: 5 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
"type": "project",
"description": "Draw an area and export it using ogr2ogr in several formats",
"license": "GPL-3.0-or-later",
"authors": [
{
"name": "Jonathan Beliën",
"email": "jbe@geo6.be"
}
],
"require": {
"symfony/yaml": "4.1.6"
"symfony/yaml": "4.2.1",
"geo6/php-gdal-wrapper": "1.1.0"
},
"scripts": {
"serve": "php -S localhost:8080 -t public/"
}
}
104 changes: 96 additions & 8 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

47 changes: 7 additions & 40 deletions fn.php
Original file line number Diff line number Diff line change
@@ -1,38 +1,6 @@
<?php
/**
*
*/
function ogr2ogr($format, $dst, $src, $params = NULL, &$stdout = NULL, &$stderr = NULL) {
if (is_array($src)) {
$source = escapeshellarg($src[0]);
$source .= ' ';
$layers = explode(' ', $src[1]); foreach ($layers as $l) $source .= escapeshellarg($l);
} else {
$source = escapeshellarg($src);
}

$descriptorspec = array(
0 => array('pipe', 'r'), // stdin
1 => array('pipe', 'w'), // stdout
2 => array('pipe', 'w') // stderr
);

$process = proc_open('ogr2ogr -f '.escapeshellarg($format).' '.$params.' '.escapeshellarg($dst).' '.$source, $descriptorspec, $pipes);

if (is_resource($process)) {
$stdout = stream_get_contents($pipes[1]);
fclose($pipes[1]);

$stderr = stream_get_contents($pipes[2]) ;
fclose($pipes[2]);

$return_value = proc_close($process);
} else {
return FALSE;
}

return ($return_value === 0);
}
use Geo6\GDAL\ogr2ogr;

/**
*
Expand Down Expand Up @@ -67,16 +35,15 @@ function export($source, $file, $format, $srs = 'EPSG:4326', $params = array())
try {
if (!file_exists($dir) || !is_dir($dir)) { mkdir($dir, 0777, TRUE); }

$params = '';
$ogr2ogr = new ogr2ogr($file, $source);
$ogr2ogr->setOption('f', $format);

if ($srs !== 'EPSG:4326') {
$params .= ' -s_srs EPSG:4326';
$params .= ' -t_srs '.$srs;
$ogr2ogr->setOption('s_srs', 'EPSG:4326');
$ogr2ogr->setOption('t_srs', $srs);
}

$ogr = ogr2ogr($format, $file, $source, $params, $stdout, $stderr);
if ($ogr === FALSE) {
throw new Exception($stderr);
}
$ogr2ogr->run();
} catch (Exception $e) {
$warnings[] = $e->getMessage();
}
Expand Down
121 changes: 0 additions & 121 deletions js/draw.js

This file was deleted.

46 changes: 0 additions & 46 deletions js/export.js

This file was deleted.

Loading

0 comments on commit 928362c

Please sign in to comment.