| 1 |
<?php // $Id: geo.inc,v 1.14 2009/06/10 20:52:03 vauxia Exp $ |
<?php // $Id: geo.inc,v 1.15 2009/06/18 01:24:11 vauxia Exp $ |
| 2 |
|
|
| 3 |
/** |
/** |
| 4 |
* Return the geo backend database type. |
* Return the geo backend database type. |
| 13 |
switch ($GLOBALS['db_type']) { |
switch ($GLOBALS['db_type']) { |
| 14 |
case 'pgsql': |
case 'pgsql': |
| 15 |
// use the postgis backend if installed |
// use the postgis backend if installed |
| 16 |
if (db_result(db_query("SELECT 1 FROM pg_catalog.pg_proc |
if (db_result(db_query("SELECT 1 FROM pg_catalog.pg_proc |
| 17 |
WHERE proname = 'postgis_version'"))) { |
WHERE proname = 'postgis_version'"))) { |
| 18 |
$backend = 'postgis'; |
$backend = 'postgis'; |
| 19 |
} |
} |
| 64 |
$alias = str_replace('.', '_', $field); |
$alias = str_replace('.', '_', $field); |
| 65 |
$alias = preg_replace('/_geo$/', '', $alias); |
$alias = preg_replace('/_geo$/', '', $alias); |
| 66 |
|
|
| 67 |
return " SRID($field) as {$alias}_srid, |
return " SRID($field) as {$alias}_srid, |
| 68 |
AsBinary($field) AS {$alias}_wkb, |
AsBinary($field) AS {$alias}_wkb, |
| 69 |
AsBinary(Envelope($field)) AS {$alias}_bbox, |
AsBinary(Envelope($field)) AS {$alias}_bbox, |
| 70 |
AsBinary(Centroid($field)) AS $alias}_centroid"; |
AsBinary(Centroid($field)) AS $alias}_centroid"; |
| 261 |
return $form; |
return $form; |
| 262 |
} |
} |
| 263 |
|
|
| 264 |
function geo_wkt_validate($wkt, $geo_type = NULL, $srid = GEO_DEFAULT_SRID) { |
function geo_wkt_validate($wkt, $geo_type = NULL, $srid = GEO_SRID_DEFAULT) { |
| 265 |
|
|
| 266 |
// TODO this should probabaly be moved into db-specific backend files. |
// TODO this should probabaly be moved into db-specific backend files. |
| 267 |
$type = db_result(@db_query("SELECT GeometryType(GeomFromText('%s'))", $wkt)); |
$type = db_result(@db_query("SELECT GeometryType(GeomFromText('%s'))", $wkt)); |