Php buffer

From DreamsteepWiki

Jump to: navigation, search

<?php
  $GEOMTAB  = 'taxlot_polygons';  //the name of the postgis table
  $ID_TABLE = 'gid';             //the name of the index field
  $DBNAME   = 'keith';           //the name of the database
  $USER     = 'postgres';
  $PASSWORD = 'password';
  $HOST     = '127.0.0.1';
  /////
  $BUFFERDIST  = 51.1;           //distance of buffer

  $INDEX_TO_GET =  trim(stripslashes($_GET['indexnum']));;

  $dbconn = pg_connect("host=$HOST dbname=$DBNAME user=$USER password=$PASSWORD")
  or die('Could not connect: ' . pg_last_error());

  $query = 'SELECT  ST_asText(buffer(the_geom, '.$BUFFERDIST.' )) FROM '.$GEOMTAB.' WHERE '.$ID_TABLE.' = '.$INDEX_TO_GET.' ;';
  
  $result = pg_query($query) or die('Query failed: ' . pg_last_error());
  $arr    = pg_fetch_array($result, 0, PGSQL_NUM);

  echo $arr[0] ;

  pg_free_result($result);
  pg_close($dbconn);

?>



Personal tools