[pgrouting-users] ender the postgresql query into browser by openlayers (GeoJSON output)

hi to all.
I am working on pgrouting project.I am using OSM data to find the best route.
but I want to take a query into postgresql by php server side and returen the result on the browser with GeoJSON format. for example I want bring the result of this query as selected streets on the browser by openlayers.
select * from table where streetname is x or y;
then bring the result by Geojson output to the browser,I would like to display these streets as red color in the browser for clients.
who can help me?
it the simplest example.
danke

Hi Javad

I use geoserver and it's "sql view" feature to do this. I don't return the results in GeoJSON but I believe it can, but you can use a vector layer if you want the raw data to put into a store or do something interactive, or a wms layer if there are large results for better performance.

The way it works is pretty much like you describe. In openlayers you define a layer with a filter and in your app you can let someone enter a street name say, and refresh the layer (using mergeNewParams). The parameters get send to the geoserver sql view which you'd have your select statement use the parameter value, and the layer results go back just like in a static layer.

hth
charles

On Aug 10, 2011, at 12:54 PM, javad sadidi wrote:

hi to all.
I am working on pgrouting project.I am using OSM data to find the best route.
but I want to take a query into postgresql by php server side and returen the result on the browser with GeoJSON format. for example I want bring the result of this query as selected streets on the browser by openlayers.
select * from table where streetname is x or y;
then bring the result by Geojson output to the browser,I would like to display these streets as red color in the browser for clients.
who can help me?
it the simplest example.
danke
_______________________________________________
Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users

hi thanks for your answer.
can you show an example in more details?

On Wed, Aug 10, 2011 at 11:17 PM, Charles Galpin <cgalpin@lhsw.com> wrote:

Hi Javad

I use geoserver and it’s “sql view” feature to do this. I don’t return the results in GeoJSON but I believe it can, but you can use a vector layer if you want the raw data to put into a store or do something interactive, or a wms layer if there are large results for better performance.

The way it works is pretty much like you describe. In openlayers you define a layer with a filter and in your app you can let someone enter a street name say, and refresh the layer (using mergeNewParams). The parameters get send to the geoserver sql view which you’d have your select statement use the parameter value, and the layer results go back just like in a static layer.

hth
charles

On Aug 10, 2011, at 12:54 PM, javad sadidi wrote:

hi to all.
I am working on pgrouting project.I am using OSM data to find the best route.
but I want to take a query into postgresql by php server side and returen the result on the browser with GeoJSON format. for example I want bring the result of this query as selected streets on the browser by openlayers.
select * from table where streetname is x or y;
then bring the result by Geojson output to the browser,I would like to display these streets as red color in the browser for clients.
who can help me?
it the simplest example.
danke


Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users


Pgrouting-users mailing list
Pgrouting-users@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/pgrouting-users

I don’t have a simple example, no. But this is a geoserver/openlayers question, so I suggest you start here

http://docs.geoserver.org/

Install it and give it a try, and ask on the geoserver list if you have any questions. Sql views are documented here:

http://docs.geoserver.org/stable/en/user/data/sqlview.html

But if you want to use php, I’d look into other WMS servers. Perhaps mapserver would suit you better, but I am not familiar with it enough to know.

Also, check the archives for this list for the last few days, but someone asked a similar question and Stephen linked to this demo of his that might be useful to you

http://gis.imaptools.com/routing/leaddog

hth
charles

On Aug 17, 2011, at 4:49 AM, javad sadidi wrote:

hi thanks for your answer.
can you show an example in more details?

On Wed, Aug 10, 2011 at 11:17 PM, Charles Galpin <cgalpin@lhsw.com> wrote: