Your are in luck; we just finished up a bit of a discussion on the use of the
graph module (I need to ask the author of the example if we can use it for the
user guide).
PaulCrease wrote:
> H Mounir, I have recently done something similar and managed to do part of
> what you require, I can take an origin and destination and calculate a route
> between them and return a feature (representing the route) based on the Path
> object returned. I have a blog where I save useful stuff that I otherwise
> might forget. Here is the link
> (http://usefulpracticalgeoblog.blogspot.com/search?updated-min=2011-01-01T00:00:00-08:00&updated-max=2012-01-01T00:00:00-08:00&max-results=1).
> The code is heavily commented to help you hopefully understand what is going
> on and can be downloaded, along with example shapefiles, from my GooglePages
> website The code does the following :- - finds closest graph node to
> coordinate tuples representing destination and origin - calculates route -
> generates a feature with a geometry representing the route, a cost
> representing the distance and also an objectID - feeds all the routes (if
> multiple there are destinations) into a featurecollection that can then be
> drawn
As for your coloring, I suggest you take the featurecollection returned and
apply a style to it that is different from your road network and then draw it
on top. That is how I have tackled that problem anyway :-) I hope it helps you.
Kind Regards, Paul
Some additional comments inline:
> 1. Starting parameters are two adresses
Finding the location for an address can be tricky. When you do a web search the
problem is called geocoding and reverse geocoding.
Martin Davis recently did a good round up geocoders here:
- http://lin-ear-th-inking.blogspot.com/2010/03/open-source-geocoders.html
- http://lin-ear-th-inking.blogspot.com/2010/03/more-open-source-geocoders.html
Generally a geocoder is written for a specific dataset; often making all kind
of fun indexes and summary tables to find stuff quickly. Have a look at the
above, they are open source and can probably be adapted to your data set.
> 2. Find the shortest route between these two and return traveltime and
> traveldistance
You can adjust the "weight" it costs to traverse a graph edge to be based on
distance or travel time (as long as you know the road speed for that edge).
> 3. The base for the calculation is a shapefile of switzerland.
>
Sounds fine. You may (or may not) want to look at the shapefile to see if it
tells you if roads are one way; or what way you can turn at intersections. You
would need to look at this information when constructing your graph.
> 4. No graphical stuff like a gui
>
> I’ve now been fiddeling around for some hours, and i think i didn’t got the
> idea of how to make it the best way.
> I would be very happy if someone could give me some tips.
>
>
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users