demo (#22) - cant get back route on map - please help me (#386) - Message List
I would like to ask you for help me with troublefinding with demo or workshop tutorial FOSS4G from 5.aug.2010. I followed tutorial and finaly map on the web works until I should get back result - route on the map. I tried almost everything and didnt find bug in my source. I think problem is between forwarding parameters to php and result back to javascript because php works separately fine when I put parameters by url (by $_GET). Also javascript work fine becasue when I put in final-routing.html in part of declaration of "store" variable to "url" parameter something like this (geojson): url:{"type":"MultiLineString?","coordinates":[[[2.198332100000000,41.401535400000000],[2.199489200000000,41.402396799999998],[2.200376700000000,41.403057400000002],[2.201798100000000,41.404115500000003],[2.202900900000000,41.404936399999997],[2.203994900000000,41.405750800000000],[2.205156000000000,41.406615000000002],[2.206282500000000,41.407453500000003],[2.207234100000000,41.408161800000002],[2.207496000000000,41.408356800000000],[2.207745100000000,41.408542300000001],[2.208577300000000,41.409190199999998],[2.209733000000000,41.410021899999997],[2.210870300000000,41.410868399999998],[2.211984000000000,41.411697300000000],[2.212533300000000,41.412106100000003],[2.213132800000000,41.412552400000003],[2.214291500000000,41.413414799999998],[2.215261300000000,41.414136599999999],[2.215552400000000,41.414353200000001]]]} the route then was displayed on the map. But if I put back all original methods (&_REQUEST) the system is not working. No route is shown on the map. Please can you help me with this.
here are my codes :
routing-final.html
<html> <head>
<title>A Basic GeoExt? Page</title> <script src="Ext-3.2.1/adapter/ext/ext-base.js" type="text/javascript"></script> <script src="Ext-3.2.1/ext-all.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css" href="Ext-3.2.1/resources/css/ext-all.css" /> <script src="OpenLayers?-2.9.1/lib/OpenLayers.js" type="text/javascript"></script> <script src="GeoExt?-0.7/lib/GeoExt.js" type="text/javascript"></script> <link rel="stylesheet" type="text/css"
href="GeoExt?-0.7/resources/css/geoext-all-debug.css" />
<script src="DrawPoints?.js" type="text/javascript"></script>
<script src="proj4js-1.0.1/lib/proj4js.js" type="text/javascript"></script>
<script type="text/javascript">
// global projection objects (uses the proj4js lib) var epsg_4326 = new OpenLayers?.Projection("EPSG:4326"),
epsg_900913 = new OpenLayers?.Projection("EPSG:900913");
function pgrouting(store, layer, method) {
if (layer.features.length == 2) {
// erase the previous route store.removeAll();
// transform the two geometries from EPSG:900913 to EPSG:4326 var startpoint = layer.features[0].geometry.clone();
startpoint.transform(epsg_900913, epsg_4326);
var finalpoint = layer.features[1].geometry.clone();
finalpoint.transform(epsg_900913, epsg_4326);
// load to route store.load({
params: {
startpoint: startpoint.x + " " + startpoint.y, finalpoint: finalpoint.x + " " + finalpoint.y, method: method
}
});
}
}
Ext.onReady(function() {
// create the map panel var panel = new GeoExt?.MapPanel?({
renderTo: "gxmap", map: {
layers: [new OpenLayers?.Layer.OSM("Simple OSM Map")]
}, center: [245300, 5070600], zoom: 11, height: 400, width: 600, title: "A Simple GeoExt? Map"
}); var map = panel.map;
// create the layer where the route will be drawn var route_layer = new OpenLayers?.Layer.Vector("route", {
styleMap: new OpenLayers?.StyleMap?(new OpenLayers?.Style({
strokeColor: "#ff9933", strokeWidth: 7
}))
});
// create the layer where the start and final points will be drawn var points_layer = new OpenLayers?.Layer.Vector("points");
// when a new point is added to the layer, call the pgrouting function points_layer.events.on({
featureadded: function() {
pgrouting(store, points_layer, method.getValue());
}
});
// add the layers to the map map.addLayers([points_layer, route_layer]);
// create the control to draw the points (see the DrawPoints?.js file) var draw_points = new DrawPoints?(points_layer);
// create the control to move the points var drag_points = new OpenLayers?.Control.DragFeature?(points_layer, {
autoActivate: true
});
// when a point is moved, call the pgrouting function drag_points.onComplete = function() {
pgrouting(store, points_layer, method.getValue());
};
// add the controls to the map map.addControls([draw_points, drag_points]);
// create the store to query the web service var store = new GeoExt?.data.FeatureStore?({
layer: route_layer, fields: [
{name: "length"}
], proxy: new GeoExt?.data.ProtocolProxy?({
protocol: new OpenLayers?.Protocol.HTTP({
url: "/pgrouting/php/pgrouting.php", format: new OpenLayers?.Format.GeoJSON({
internalProjection: epsg_900913, externalProjection: epsg_4326
})
})
})
});
/* var trasa = new OpenLayers?.Layer.GML("My GeoJSON Layer", " http://localhost/pgrouting/trasa.geojson", {format: OpenLayers?.Format.GeoJSON}); map.addLayers([trasa]); */
// create the method combo box var method = new Ext.form.ComboBox?({
renderTo: "method", triggerAction: "all", editable: false, forceSelection: true, store: [
["SPD", "Shortest Path Dijkstra"], ["SPA", "Shortest Path A*"], ["SPS", "Shortest Path Shooting*"]
], listeners: {
select: function() {
pgrouting(store, points_layer, method.getValue());
}
}
}); // default method is Shortest Path Dijkstra method.setValue("SPD");
});
</script> </head> <body> <div id="gxmap"></div> <div id="method"></div> </body> </html>
pgrouting.php <?php
// Database connection settings define("PG_DB" , "routing"); define("PG_HOST", "localhost"); define("PG_USER", "postgres"); define("PG_PORT", "5432"); define("TABLE", "ways");
// Retrieve start point
$start = split(' ',$_REQUESTstartpoint?);
// Retrieve end point $end = split(' ',$_REQUESTfinalpoint?); $endPoint = array($end[0], $end[1]);
// Find the nearest edge $startEdge = findNearestEdge($startPoint); $endEdge = findNearestEdge($endPoint);
// FUNCTION findNearestEdge function findNearestEdge($lonlat) {
// Connect to database $con = pg_connect("dbname=".PG_DB." host=".PG_HOST." user=".PG_USER);
$sql = "SELECT gid, source, target, the_geom,
distance(the_geom, GeometryFromText?(
FROM ".TABLE." WHERE the_geom && setsrid(
'BOX3D(".($lonlat[0]-0.1)."
".($lonlat[1]-0.1).", ".($lonlat[0]+0.1)." ".($lonlat[1]+0.1).")'::box3d, 4326)
ORDER BY dist LIMIT 1";
$query = pg_query($con,$sql);
$edgegid? = pg_fetch_result($query, 0, 0); $edgesource? = pg_fetch_result($query, 0, 1); $edgetarget? = pg_fetch_result($query, 0, 2); $edgethe_geom? = pg_fetch_result($query, 0, 3);
// Close database connection pg_close($con);
return $edge;
}
// Select the routing algorithm switch($_REQUESTmethod?) {
case 'SPD' : // Shortest Path Dijkstra
$sql = "SELECT rt.gid, ST_AsGeoJSON(rt.the_geom) AS geojson,
length(rt.the_geom) AS length, ".TABLE.".gid
FROM ".TABLE.",
(SELECT gid, the_geom
FROM dijkstra_sp_delta(
'".TABLE."', ".$startEdgesource?.", ".$endEdgetarget?.", 0.1)
) as rt
WHERE ".TABLE.".gid=rt.gid;";
break;
case 'SPA' : // Shortest Path A*
$sql = "SELECT rt.gid, ST_AsGeoJSON(rt.the_geom) AS geojson,
length(rt.the_geom) AS length, ".TABLE.".gid
FROM ".TABLE.",
(SELECT gid, the_geom
FROM astar_sp_delta(
'".TABLE."', ".$startEdgesource?.", ".$endEdgetarget?.", 0.1)
) as rt
WHERE ".TABLE.".gid=rt.gid;";
break;
case 'SPS' : // Shortest Path Shooting*
$sql = "SELECT rt.gid, ST_AsGeoJSON(rt.the_geom) AS geojson,
length(rt.the_geom) AS length, ".TABLE.".gid
FROM ".TABLE.",
(SELECT gid, the_geom
FROM shootingstar_sp(
'".TABLE."', ".$startEdgegid?.", ".$endEdgegid?.", 0.1, 'length', true, true)
) as rt
WHERE ".TABLE.".gid=rt.gid;";
break;
} // close switch
// Connect to database $dbcon = pg_connect("dbname=".PG_DB." host=".PG_HOST." user=".PG_USER);
// Perform database query $query = pg_query($dbcon,$sql);
// Return route as GeoJSON $geojson = array(
'type' => 'FeatureCollection?', 'features' => array()
);
/* while ($row = pg_fetch_assoc($query)) {
//echo "GID=" . $rowgid? . "</br>"; echo "GEOJSON=" . $rowgeojson? . "</br>"; //echo "LENGTH=" . $rowlength? . "</br>";
} */
// Add edges to GeoJSON array while($edge=pg_fetch_assoc($query)) {
$feature = array(
'type' => 'Feature', 'geometry' => json_decode($edgegeojson?, true), 'crs' => array(
'type' => 'EPSG', 'properties' => array('code' => '4326')
), 'properties' => array(
)
);
// Add feature array to feature collection array array_push($geojsonfeatures?, $feature);
}
// Close database connection
pg_close($dbcon);
// Return routing result header('Content-type: application/json',true); echo json_encode($geojson);
?>
-
Message #1641
There is a wrong path in the AJAX call of the demo script. You can see that it can't find the PHP file when using a tool like FireBug? for example. Sorry for that.
I edited the script and updated the Ubuntu package, so you could update to the latest version with "sudo apt-get update" or just change the line like:
var store = new GeoExt.data.FeatureStore({ layer: route_layer, fields: [ {name: "length"} ], proxy: new GeoExt.data.ProtocolProxy({ protocol: new OpenLayers.Protocol.HTTP({ url: './php/pgrouting.php', format: new OpenLayers.Format.GeoJSON({ internalProjection: epsg_900913, externalProjection: epsg_4326 }) }) }) });
I just realized that the documentation on http://download.osgeo.org/pgrouting/foss4g2010/workshop/ is still old. I will also upload the latest version.
daniel09/30/10 18:01:02 (7 weeks ago)-
Message #1642
thank you for quuick response for my problem. I changed that code you mentioned but it doesnt helped :(.
Please, rest of my code is ok?
In IE I get javacsript error on page load : OpenLayers?. Format.GML.v3.prototype ha value null or is not object. Row:19, Char:1, Code:0, URI: http://10.20.248.35/pgrouting/OpenLayers-2.9.1/lib/OpenLayers/Format/SOSGetObservation.js and also for SOSGetFeatureOfInterest.js
Even if this error apears in IE I can set up start an end points but route is not shown still.
Dzouzeph09/30/10 19:22:27 (7 weeks ago)-
Message #1643
Could you try your application in some other browser than IE? I have never tested the workshop with IE, because it doesn't install on Linux ;-)
No, honestly, it's better to try some other browser than IE for debugging. I can't open your link btw.. Did you just get the files from OSgeo download server. I replaced them with the newer version and maybe you downloaded files when not everything was uploaded yet. Now it's finished.
daniel09/30/10 20:42:42 (7 weeks ago)-
Message #1644
Yes I already tried it also on firefox :) but still no route was displayed on the map. Just now I downloaded gz archiv with update workshop data and replace my website. Javascript error I mentioned now in IE disapeared :) (maybe cause before gz archive showing unxcpected end of archiv when I extracted it) but display route problem still doesn work even on firefox. Link is not working because it is internal IP what I trying it on virtual server on CentOS. Can you advice me please how can I check if is problem in routing-final.html or in pgrouting.php? Or what should I check in Firebug?
Dzouzeph09/30/10 21:39:39 (7 weeks ago)-
Message #1645
You must make sure that all parts are working.
- Is pgRouting correctly installed and workshop queries work?
- PostgreSQL database extension for PHP loaded?
- Can you make a request passing "start" and "end" parameter manually?
routing-final.html should contain all necessary parts. With FireBug? extension you can check Ajax requests with parameters sent and reply from the script.
daniel10/01/10 04:06:33 (7 weeks ago)-
Message #1646
workshop queries works ok.
connect from php to postgre works ok
I tried to set start and end point manualy in next php file and at the bottom I pasted result from this page.
Im not sure but I think there is something wrong with part of geojson generation... ???
PHP file :
<?php
// Database connection settings
define("PG_DB" , "routing");
define("PG_HOST", "localhost");
define("PG_USER", "postgres");
define("PG_PORT", "5432");
define("TABLE", "ways");
// Retrieve start point
//$start = split(' ',$_REQUESTstartpoint?);
$startPoint = array(2.174728, 41.403317);
// Retrieve end point
//$end = split(' ',$_REQUESTfinalpoint?);
$endPoint = array(2.19807, 41.4007418);
// Find the nearest edge
$startEdge = findNearestEdge($startPoint);
$endEdge = findNearestEdge($endPoint);
// FUNCTION findNearestEdge
function findNearestEdge($lonlat) {
// Connect to database
$con = pg_connect("dbname=".PG_DB." host=".PG_HOST." user=".PG_USER);
$sql = "SELECT gid, source, target, the_geom,
distance(the_geom, GeometryFromText?(
FROM ".TABLE."
WHERE the_geom && setsrid(
'BOX3D(".($lonlat[0]-0.1)."
".($lonlat[1]-0.1).",
".($lonlat[0]+0.1)."
".($lonlat[1]+0.1).")'::box3d, 4326)
ORDER BY dist LIMIT 1";
$query = pg_query($con,$sql);
$edgegid? = pg_fetch_result($query, 0, 0);
$edgesource? = pg_fetch_result($query, 0, 1);
$edgetarget? = pg_fetch_result($query, 0, 2);
$edgethe_geom? = pg_fetch_result($query, 0, 3);
echo "edge=" . $edgegid? . "</br>";
echo "source=" . $edgesource? . "</br>";
echo "target=" . $edgetarget? . "</br>";
echo "thegeom=" . $edgethe_geom? . "</br>";
pg_close($con);
return $edge;
}
echo "startedge=" . $startEdgesource? . "</br>";
echo "endedge=" . $endEdgetarget? . "</br>";
$sql2 = "SELECT rt.gid, ST_AsGeoJSON(rt.the_geom) AS geojson,
length(rt.the_geom) AS length, ".TABLE.".gid
FROM ".TABLE.",
(SELECT gid, the_geom
FROM dijkstra_sp_delta(
'".TABLE."',
".$startEdgesource?.",
".$endEdgetarget?.",
0.1)
) as rt
WHERE ".TABLE.".gid=rt.gid;";
// Connect to database
$con = pg_connect("dbname=".PG_DB." host=".PG_HOST." user=".PG_USER);
// Perform database query
$query2 = pg_query($con,$sql2);
while ($edge = pg_fetch_assoc($query2)) {
echo "GID=" . $edgegid? . "</br>";
echo "GEOJSON=" . $edgegeojson? . "</br>";
echo "LENGTH=" . $edgelength? . "</br>";
}
// Return route as GeoJSON
$geojson = array(
'type' => 'FeatureCollection?',
'features' => array()
);
// Add edges to GeoJSON array
while($edge=pg_fetch_assoc($query2)) {
$feature = array(
'type' => 'Feature',
'geometry' => json_decode($edgegeojson?, true),
'crs' => array(
'type' => 'EPSG',
'properties' => array('code' => '4326')
),
'properties' => array(
)
);
// Add feature array to feature collection array
array_push($geojsonfeatures?, $feature);
}
// Close database connection
pg_close($con);
// Return routing result
header('Content-type: application/json',true);
echo json_encode($geojson);
?>
RESULT on page :
edge=419
source=385
target=386
thegeom=0105000020E6100000010000000102000000050000002A368BBC51600140923B1169C0B34440F84E71C1BE620140EDA06D90A4B34440C687D9CBB6630140EE9D2C1098B344402AE109BDFE640140497C934B88B34440FFB91E3B5E670140705E9CF86AB34440
edge=5279
source=2741
target=2732
thegeom=0105000020E6100000010000000102000000020000008D9944BDE0930140100DE60A4AB34440DCF9D9232F960140D897118365B34440
startedge=385
endedge=2732
GID=419
GEOJSON={"type":"MultiLineString?","coordinates":[[[2.172030900000000,41.404309400000002],[2.173215400000000,41.403459599999998],[2.173688500000000,41.403078100000002],[2.174314000000000,41.402596899999999],[2.175472700000000,41.401702000000000]]]}
LENGTH=0.00431878690966869
GID=420
GEOJSON={"type":"MultiLineString?","coordinates":[[[2.175472700000000,41.401702000000000],[2.176513500000000,41.400889800000002]]]}
LENGTH=0.00132020206029156
GID=940
GEOJSON={"type":"MultiLineString?","coordinates":[[[2.180117800000000,41.401783100000003],[2.180268200000000,41.401668700000002],[2.180416800000000,41.401555799999997]]]}
LENGTH=0.000375587940415142
GID=941
GEOJSON={"type":"MultiLineString?","coordinates":[[[2.180416800000000,41.401555799999997],[2.180468900000000,41.401516100000002],[2.181257400000000,41.400916600000002]]]}
LENGTH=0.00105602323574844
..... and so on ....
GID=5696
GEOJSON={"type":"MultiLineString?","coordinates":[[[2.189371800000000,41.398126800000000],[2.190468700000000,41.397284499999998]]]}
LENGTH=0.00138298911781812
GID=5697
GEOJSON={"type":"MultiLineString?","coordinates":[[[2.190468700000000,41.397284499999998],[2.191560200000000,41.396493200000002]]]}
LENGTH=0.00134815723860168
Dzouzeph10/01/10 19:37:37 (7 weeks ago)-
Message #1647
I think somewhere in this part :
// Add edges to GeoJSON array while($edge=pg_fetch_assoc($query2)) { $feature = array( 'type' => 'Feature', 'geometry' => json_decode($edge['geojson'], true), 'crs' => array( 'type' => 'EPSG', 'properties' => array('code' => '4326') ), 'properties' => array( 'id' => $edge['id'], 'length' => $edge['length'] ) ); // Add feature array to feature collection array array_push($geojson['features'], $feature); }
Dzouzeph10/01/10 20:03:25 (7 weeks ago) -
Message #1648
sorry I forgot to put previous example code in Code block brackets.....
> '''PHP file :'''[[BR]] > > <?php[[BR]] > > // Database connection settings[[BR]] > define("PG_DB" , "routing");[[BR]] > define("PG_HOST", "localhost");[[BR]] > define("PG_USER", "postgres");[[BR]] > define("PG_PORT", "5432"); [[BR]] > define("TABLE", "ways");[[BR]] > > // Retrieve start point[[BR]] > //$start = split(' ',$_REQUEST['startpoint']);[[BR]] > $startPoint = array(2.174728, 41.403317);[[BR]] > > // Retrieve end point[[BR]] > //$end = split(' ',$_REQUEST['finalpoint']);[[BR]] > $endPoint = array(2.19807, 41.4007418);[[BR]] > > // Find the nearest edge[[BR]] > $startEdge = findNearestEdge($startPoint);[[BR]] > $endEdge = findNearestEdge($endPoint);[[BR]] > > // FUNCTION findNearestEdge[[BR]] > function findNearestEdge($lonlat) {[[BR]] > > // Connect to database[[BR]] > $con = pg_connect("dbname=".PG_DB." host=".PG_HOST." user=".PG_USER);[[BR]] > > $sql = "SELECT gid, source, target, the_geom, [[BR]] > distance(the_geom, GeometryFromText([[BR]] > 'POINT(".$lonlat[0]." ".$lonlat[1].")', 4326)) AS dist [[BR]] > FROM ".TABLE." [[BR]] > WHERE the_geom && setsrid([[BR]] > 'BOX3D(".($lonlat[0]-0.1)." [[BR]] > ".($lonlat[1]-0.1).", [[BR]] > ".($lonlat[0]+0.1)." [[BR]] > ".($lonlat[1]+0.1).")'::box3d, 4326) [[BR]] > ORDER BY dist LIMIT 1";[[BR]] > > $query = pg_query($con,$sql); [[BR]] > > $edge['gid'] = pg_fetch_result($query, 0, 0); [[BR]] > $edge['source'] = pg_fetch_result($query, 0, 1); [[BR]] > $edge['target'] = pg_fetch_result($query, 0, 2); [[BR]] > $edge['the_geom'] = pg_fetch_result($query, 0, 3); [[BR]] > > echo "edge=" . $edge['gid'] . "</br>";[[BR]] > echo "source=" . $edge['source'] . "</br>";[[BR]] > echo "target=" . $edge['target'] . "</br>";[[BR]] > echo "thegeom=" . $edge['the_geom'] . "</br>";[[BR]] > > > pg_close($con);[[BR]] > > return $edge;[[BR]] > > }[[BR]] > > > echo "startedge=" . $startEdge['source'] . "</br>";[[BR]] > echo "endedge=" . $endEdge['target'] . "</br>";[[BR]] > > > > > > $sql2 = "SELECT rt.gid, ST_AsGeoJSON(rt.the_geom) AS geojson, [[BR]] > length(rt.the_geom) AS length, ".TABLE.".gid [[BR]] > FROM ".TABLE.", [[BR]] > (SELECT gid, the_geom [[BR]] > FROM dijkstra_sp_delta([[BR]] > '".TABLE."',[[BR]] > ".$startEdge['source'].",[[BR]] > ".$endEdge['target'].",[[BR]] > 0.1)[[BR]] > ) as rt [[BR]] > WHERE ".TABLE.".gid=rt.gid;";[[BR]] > > // Connect to database[[BR]] > $con = pg_connect("dbname=".PG_DB." host=".PG_HOST." user=".PG_USER);[[BR]] > > // Perform database query[[BR]] > $query2 = pg_query($con,$sql2);[[BR]] > > while ($edge = pg_fetch_assoc($query2)) {[[BR]] > echo "GID=" . $edge['gid'] . "</br>";[[BR]] > echo "GEOJSON=" . $edge['geojson'] . "</br>";[[BR]] > echo "LENGTH=" . $edge['length'] . "</br>";[[BR]] > }[[BR]] > > > > // Return route as GeoJSON[[BR]] > $geojson = array([[BR]] > 'type' => 'FeatureCollection',[[BR]] > 'features' => array()[[BR]] > ); [[BR]] > > > > // Add edges to GeoJSON array[[BR]] > while($edge=pg_fetch_assoc($query2)) { [[BR]] > > $feature = array([[BR]] > 'type' => 'Feature',[[BR]] > 'geometry' => json_decode($edge['geojson'], true),[[BR]] > 'crs' => array([[BR]] > 'type' => 'EPSG',[[BR]] > 'properties' => array('code' => '4326')[[BR]] > ),[[BR]] > 'properties' => array([[BR]] > 'id' => $edge['id'],[[BR]] > 'length' => $edge['length'][[BR]] > )[[BR]] > );[[BR]] > > // Add feature array to feature collection array[[BR]] > array_push($geojson['features'], $feature);[[BR]] > }[[BR]] > > > > // Close database connection[[BR]] > pg_close($con);[[BR]] > > // Return routing result[[BR]] > header('Content-type: application/json',true);[[BR]] > echo json_encode($geojson);[[BR]] > > > ?>[[BR]] > > > > '''RESULT on page :'''[[BR]] > > edge=419[[BR]] > source=385[[BR]] > target=386[[BR]] > thegeom=0105000020E6100000010000000102000000050000002A368BBC51600140923B1169C0B34440F84E71C1BE620140EDA06D90A4B34440C687D9CBB6630140EE9D2C1098B344402AE109BDFE640140497C934B88B34440FFB91E3B5E670140705E9CF86AB34440[[BR]] > > edge=5279[[BR]] > source=2741[[BR]] > target=2732[[BR]] > thegeom=0105000020E6100000010000000102000000020000008D9944BDE0930140100DE60A4AB34440DCF9D9232F960140D897118365B34440[[BR]] > > startedge=385[[BR]] > endedge=2732[[BR]] > GID=419[[BR]] > GEOJSON={"type":"MultiLineString","coordinates":[[[2.172030900000000,41.404309400000002],[2.173215400000000,41.403459599999998],[2.173688500000000,41.403078100000002],[2.174314000000000,41.402596899999999],[2.175472700000000,41.401702000000000]]]}[[BR]] > LENGTH=0.00431878690966869[[BR]] > GID=420[[BR]] > GEOJSON={"type":"MultiLineString","coordinates":[[[2.175472700000000,41.401702000000000],[2.176513500000000,41.400889800000002]]]}[[BR]] > LENGTH=0.00132020206029156[[BR]] > GID=940[[BR]] > GEOJSON={"type":"MultiLineString","coordinates":[[[2.180117800000000,41.401783100000003],[2.180268200000000,41.401668700000002],[2.180416800000000,41.401555799999997]]]}[[BR]] > LENGTH=0.000375587940415142[[BR]] > GID=941[[BR]] > GEOJSON={"type":"MultiLineString","coordinates":[[[2.180416800000000,41.401555799999997],[2.180468900000000,41.401516100000002],[2.181257400000000,41.400916600000002]]]}[[BR]] > LENGTH=0.00105602323574844[[BR]] > [[BR]] > > ..... and so on ....[[BR]] > [[BR]] > > GID=5696[[BR]] > GEOJSON={"type":"MultiLineString","coordinates":[[[2.189371800000000,41.398126800000000],[2.190468700000000,41.397284499999998]]]}[[BR]] > LENGTH=0.00138298911781812[[BR]] > GID=5697[[BR]] > GEOJSON={"type":"MultiLineString","coordinates":[[[2.190468700000000,41.397284499999998],[2.191560200000000,41.396493200000002]]]}[[BR]] > LENGTH=0.00134815723860168[[BR]]
Dzouzeph10/01/10 20:06:36 (7 weeks ago)-
Message #1650
You said, you're using CentOS, right? Could you tell me your version of PostGIS/PHP?
If something goes wrong with GeoJSON, could be that there is a problem with PHP function "json_encode()", which isn't available in older version of PHP or GeoJSON support of PostGIS (not available in old versions of PostGIS)
daniel10/01/10 21:15:26 (7 weeks ago)-
Message #1651
Yes I use CentOS.
postgis-1.3.6.-1.rehel5.i386
PHP 5.1.6.-27.el5.i386 should I change some of this to another version?
Dzouzeph10/01/10 23:28:51 (7 weeks ago)-
Message #1652
You need to make sure that your PHP supports "json_encode()" (could be that your PHP version support doesn't this, but there is a workaround as far as I remember).
And PostGIS needs to support GeoJSON as well. Could be this comes with 1.4, but could be also in 1.3 already.I think it's easier for you to just try this with some sample script and test query, or try to look for older documentation of PHP/PostGIS.
daniel10/02/10 03:21:32 (7 weeks ago)-
Message #1686
I have all the requirements mentioned above.(PHP 5.2, GeoJSON support, PostGIS 1.5,...) but I still have this problem. The javascript couldn't call the php script. they both work independently but together they won't.
farid110/11/10 21:54:09 (6 weeks ago)-
Message #1687
Then the path is still wrong and you should update to the latest version of the workshop.
Try it with Firebug, try to call the URL to the PHP script with parameters directly to see what happens. Or if you have your version online, you can send a link.
daniel10/12/10 04:59:39 (6 weeks ago)-
Message #1688
Finally I solved the problem. there wasn't any mistake with the path. When I tried to run the script in "php designer" I got this message:
Warning: Cannot modify header information - headers already sent by (output started at C:\ms4w\Apache\htdocs\web\php\pgrouting.php:20) in C:\ms4w\Apache\htdocs\web\php\pgrouting.php on line 147 ... and the json array
then I commented this line in php script: header('Content-type: application/json',true);
and everythings work fine. :)
Thank you Daniel, your comments helped me a lot.
farid110/12/10 06:26:02 (6 weeks ago)
-
-
-
Message #1654
Daniel great thanks to you ;)
you have right ...my php was missing json extension. I installed it according
steps from http://www.php.net/manual/en/json.installation.php.
PHP = 5.2 and > has it by default.
Dzouzeph10/02/10 07:14:04 (7 weeks ago)
-
-
-
-
-
-
-
-
-