pastebin - collaborative debugging

pastebin is a collaborative debugging tool allowing you to share and modify code snippets while chatting on IRC, IM or a message board.

This site is developed to XHTML and CSS2 W3C standards. If you see this paragraph, your browser does not support those standards and you need to upgrade. Visit WaSP for a variety of options.

yancho private pastebin - collaborative debugging tool What's a private pastebin?


Posted by Yancho on Fri 7 Dec 15:54
report spam | download | new post

  1. <?
  2.  
  3. include 'db.php';
  4.  
  5.  
  6.  
  7. $ep = $_REQUEST['finalpoint'];
  8. $choice = $_REQUEST['method'];
  9.  
  10. // print_r ($_REQUEST);
  11.  
  12. $end = "'POINT(".$ep.")'" ;
  13.  
  14. $start = "select near_accident ($end,'$choice')";
  15.        
  16.  //echo $start;
  17.  
  18.        
  19. $con = pg_connect("dbname=".$db." host=".$dbhost." user=".$dbuser." password=".$dbpass)
  20.       or die ("PostgreSQL Error --> " . pg_last_error($con));
  21.  
  22. $query = pg_query($con, $start);
  23.  
  24. //echo $query;
  25.  
  26.     while ($row = pg_fetch_row($query)) {
  27.           $source = $row[0];
  28. }
  29. // echo $source;
  30.  
  31.  
  32.        $target = "select give_source('$source',1000,200)";
  33.        $source = "select give_target('POINT(".$ep.")',1000,200)" ;
  34.        $sql = "
  35.  
  36.              SELECT gid, astext(the_geom) as wkt, length(the_geom) AS length
  37.              FROM shootingstar_sp
  38.              ('streets',
  39.                (
  40.                select gid from streets where
  41.                source = ( $source )
  42.                limit 1
  43.                )
  44.              ,
  45.              
  46.                (
  47.                select gid from streets where
  48.                target = ( $target )
  49.                limit 1
  50.      
  51.                )
  52.              ,
  53.              5000,
  54.              'length',
  55.              true,
  56.              true
  57.              );
  58.       ";
  59.  
  60.  
  61.  
  62.   $xml  = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>'."\n";
  63.   $xml .= "<route>\n";
  64.  
  65.   $query2 = pg_query($sql);
  66.     // Add edges to XML file
  67.   while($edge=pg_fetch_assoc($query2)) {
  68.  
  69.     $pathlength += $edge['length'];
  70.  
  71.     $xml .= "\t<edge id='".++$counter."'>\n";
  72.     $xml .= "\t\t<id>".$edge['gid']."</id>\n";
  73.     $xml .= "\t\t<wkt>".$edge['wkt']."</wkt>\n";
  74.     $xml .= "\t\t<length>".round(($pathlength/1000),3)."</length>\n";
  75.     $xml .= "\t</edge>\n";
  76.   }
  77.  
  78.   $xml .= "</route>\n";
  79.  
  80.   pg_close($con);
  81.  
  82.   // Return routing result
  83.  header('Content-type: text/xml',true);
  84.   echo $xml;
  85. ?>

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


Remember me