function run_test in geoPHP 7
Same name in this branch
- 7 geoPHP/tests/test.php \run_test()
- 7 geoPHP/tests/postgis.php \run_test()
Same name and namespace in other branches
- 8 geoPHP/tests/test.php \run_test()
File
- geoPHP/
tests/ postgis.php, line 5
Code
function run_test() {
header("Content-type: text");
include_once '../geoPHP.inc';
// Your database test table should contain 3 columns: name (text), type (text), geom (geometry)
$host = 'localhost';
$database = 'phayes';
$table = 'test';
$column = 'geom';
$user = 'phayes';
$pass = 'supersecret';
$connection = pg_connect("host={$host} dbname={$database} user={$user} password={$pass}");
// Truncate
pg_query($connection, "DELETE FROM {$table}");
// Working with PostGIS and EWKB
// ----------------------------
foreach (scandir('./input') as $file) {
$parts = explode('.', $file);
if ($parts[0]) {
$name = $parts[0];
$format = $parts[1];
$value = file_get_contents('./input/' . $file);
print '---- Testing ' . $file . "\n";
flush();
$geometry = geoPHP::load($value, $format);
test_postgis($name, $format, $geometry, $connection, 'wkb');
$geometry
->setSRID(4326);
test_postgis($name, $format, $geometry, $connection, 'ewkb');
}
}
print "Testing Done!";
}