Hi Alberto
I don't know if there is a build-in function to calc a route!? But I
have an other suggestion.
Which database do you us?
There is a dijkstra implementation for postgres and postgis named as
pgdijkstra. I used this implementation for my degree dissertation.
- http://www.cartoweb.org/contribs.html
- http://www.postlbs.org/postlbs-cms (includes pgdijkstra)
My suggestion: Use pgdijkstra to calculate a route. Save it in a table
with the session identifier. Show the calculate route with mapbuilder
or openlayers with help of a styled layer descriptor (sld) and an ogc
filter.
An example for a plpgsql function:
-- Function createRoute(SessionID, fromEdge, toEdge)
CREATE OR REPLACE FUNCTION createRoute(VARCHAR, INTEGER, INTEGER)
RETURNS INTEGER AS $$
DECLARE
rec RECORD;
BEGIN
DELETE FROM shortestpathroute
WHERE sessionid = $1;
FOR rec IN EXECUTE
'SELECT gid, the_geom
FROM shortest_path_as_geometry(''basegeometrypgdijkstra'', '
|| $2 || ', ' || $3 ||')'
LOOP
INSERT INTO ShortestPathRoute (sessionId, seggid, the_geom)
VALUES ($1, rec.gid, GeomFromText(astext(force_2d(rec.the_geom)), 21781));
END LOOP;
RETURN 1;
END;
$$ LANGUAGE plpgsql;
An example of a SLD file:
<?xml version="1.0" encoding="UTF-8"?>
<sld:StyledLayerDescriptor xmlns:sld="http://www.opengis.net/sld"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:gml="http://www.opengis.net/gml" version="1.0.0">
<sld:NamedLayer>
<sld:Name>hikeroute</sld:Name>
<sld:UserStyle>
<sld:Name>hikeroute_style</sld:Name>
<sld:Title>geoserver style</sld:Title>
<sld:Abstract>Generated by GeoServer</sld:Abstract>
<sld:FeatureTypeStyle>
<sld:Rule>
<ogc:Filter>
<ogc:PropertyIsEqualTo>
<ogc:PropertyName>sessionid</ogc:PropertyName>
<ogc:Literal>116AB1907F907E0</ogc:Literal>
</ogc:PropertyIsEqualTo>
</ogc:Filter>
<sld:LineSymbolizer>
<sld:Stroke>
<sld:CssParameter name="stroke">#EE0000</sld:CssParameter>
<sld:CssParameter name="stroke-opacity">0.5</sld:CssParameter>
<sld:CssParameter name="stroke-width">3</sld:CssParameter>
</sld:Stroke>
</sld:LineSymbolizer>
</sld:Rule>
</sld:FeatureTypeStyle>
</sld:UserStyle>
</sld:NamedLayer>
</sld:StyledLayerDescriptor>
I hope that helps. Let me know.
Regards,
Thomas
Am 14.03.07 schrieb kaifa.ab@anonymised.com <kaifa.ab@anonymised.com>:
Hi all,
I'm using geoserver in a project with mapbuilder. I'm not a hard
user of both but I'm getting great results with little effort. Does
anybodyhas got quick advice on resources avaiable on the shortest path
finder djikstra algo and geoserver?I've seen that geoserver implements common spatial functions and
I'm asking for djikstra "function".Thanks in advance.
Alberto.
--
Thomas Zuberbuehler
http://www.zubi.li