Ver Mensaje Individual
  #1 (permalink)  
Antiguo 11/03/2014, 08:34
morocho1979
 
Fecha de Ingreso: agosto-2012
Ubicación: Caracas
Mensajes: 14
Antigüedad: 11 años, 9 meses
Puntos: 0
adaptar de sqllite to postgres db2text.php

Saludos tengo este codigo de esta pagina [URL="http://harrywood.co.uk/maps/examples/openlayers/db/db2text.view.php"]http://harrywood.co.uk/maps/examples/openlayers/db/db2text.view.php[/URL]el cual trate de modificar para generar el mismo resulado pero con base de datos postgres el cual falle voy adjuntar el codigo que modifique a ver si alguien da porque en verdad mis destresas no dan mas , el trabaja con sqlite

Gracias por su ayuda


Codigo ********************

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<?php
/*
* This PHP script reads points from a database and outputs a text formatted
* as expected by the OpenLayers text parser (actually tab seperated variables)
* In the absence of bbox param it reads all points from the database.
*
* You can point OpenLayers directly at this php script. Optionally you can then
* use a BBOX strategy. This tells OpenLayers to add on a 'bbox' parameter,
* which this script can use to limit the number of points returned.
*/

$bbox = isset($_GET['bbox']) ? $_GET['bbox'] : "";

define('DBHOST', 'xxxxx');
define('DBNAME', 'xxxx');
define('DBUSER', 'app');
define('DBPASSWD', '12345678');
define('DBPORT', '5432');

$cadena_conexion = "host=".DBHOST . " port=" . DBPORT . " user=" . DBUSER . " password=" . DBPASSWD . " dbname=" . DBNAME;

if((pg_connect($cadena_conexion)) == true){


$query = 'SELECT * FROM marcadores.points ';
if ($bbox!="") {
//splir out the comma sperated min/max lat/lon values
$bbox_vars = explode(",", $bbox);
$minlon = $bbox_vars[0];
$minlat = $bbox_vars[1];
$maxlon = $bbox_vars[2];
$maxlat = $bbox_vars[3];

//DB deals with integers
$minx = round($minlon * 10000000);
$miny = round($minlat * 10000000);
$maxx = round($maxlon * 10000000);
$maxy = round($maxlat * 10000000);

$query .= "WHERE x>".$minx." AND x<".$maxx." AND y>".$miny." AND y<".$maxy;
echo($query);
error_log("query=" .$query);

sleep(3); //Artificial 3 second pause, to help see how the bboxes work
}

//Icon offset. For some reason this doesn't default to a sensible value for
//the default marker graphic, so we output it in the text file.
$icon_offset = "-10,-25";

$result = pg_query($query);
if ($result === false) {
die("Error de Conexion:". $err);
} else {

print "lat lon title description iconOffset\n";

$count = 0;
while ($result->valid()) {
$count++;

// fetch current row
$row = $result->current();

$id = $row[0];
$name = $row[1];
$x = $row[2];
$y = $row[3];

$lon = $x / 10000000;
$lat = $y / 10000000;

//output text file row which OpenLayers can understand
print $lat."\t".$lon."\t".$name."\t".$name."\t".$icon_of fset."\n";


// proceed to next row
$result->next();
}

error_log("Returning " .$count. " points in a text file");

}

} else {
die($err);
}
pg_close($cadena_conexion);
?>
<body>
</body>
</html>