Screenshot instructions:
Windows
Mac
Red Hat Linux
Ubuntu
Click URL instructions:
Rightclick on ad, choose "Copy Link", then paste here →
(This may not be possible with some types of ads)
From: Martin Tomko <martin.tomko@ge...>  20091104 10:24:57

Dear All, I started playing around with the graph package, that I did not use before. I am trying to read in a line shapefile and create a graph, and then read in a point shapefile and calculate the shortest path from a given point to another one. As the points may not lay directly on the edges, I need to: * add nodes to the graph based on a point feature and the nearest edge in the graph (split the edge, if needed), I think I should manage to compose the graph based on a feature collection as follows: FeatureCollection<SimpleFeatureType, SimpleFeature> fc ... LineStringGraphGenerator lsgg = new LineStringGraphGenerator(); FeatureGraphGenerator fgg = new FeatureGraphGenerator(lsgg); FeatureIterator<SimpleFeature> f = fc.features(); while(f.hasNext()){ Feature ft = f.next(); fgg.add(ft); } // lgb is loaded Graph g = fgg.getGraph(); return g; And use the DijkstraShortestPathFinder to find the paths. I found a function *nearestColinearPoint* (from org.geotools.math.Line), but it seems like I have to convert from Features to JTS geometries, then to java.awt.geom.Line2D and java.awt.geom.Point2D and back to use this. Is there a better way to generate a colinear point feature? Furthermore, what is the best way to add the node to an edge, splitting it into two edges? Thanks heaps, Martin 
From: John Graham <jgraham@ra...>  20091104 19:47:09

>There is now a new ShapeLab example for GeoTools 2.6.0 that avoids >deprecated methods: >http://geotools.org/examples/stylelab.html Thanks  that example really helps. I was able to get rid of all of the deprecated methods, and I also have a greater understanding of how things work now. >> What I would like to do is find an easy and supported way of filling >> individual shapes in the shapefile with a different fill color. >> Is there an easy way to do what I am trying to accomplish? ?The ideal end >> state would be the ability to initialize (programmatically) each >> SimpleFeature within a shapefile with a different fill color, then be >> able to dynamically change those individual fill colors as needed. >I've just written an example of using a filter function to create a >lookup table that matches unique values of some feature attribute to >colours. The function can then be used to set fill and stroke >properties of a rendering style. > >The example is here: > >http://svn.osgeo.org/geotools/branches/2.6.x/demo/example/src/main/java/o rg>/geotools/demo/StyleFunctionLab.java > >I'm not sure if it's exactly what you were looking for but hopefully >it's close enough to be useful. I'm also not sure if the way that >I've coded the example, with a custom filter function class, is the >best way to do it. Someone else here may be able to suggest an easier >approach. This does pretty much exactly what I wanted to do, and it is simple enough for me. I really appreciate your help. I am now able to display a shape layer in WW and dynamically change the styling of the features based on the HASC codes in the shapefile. Cool stuff. 
From: Michael Bedward <michael.bedward@gm...>  20091104 22:17:06

Hi John > This does pretty much exactly what I wanted to do, and it is simple enough > for me. I really appreciate your help. I am now able to display a shape > layer in WW and dynamically change the styling of the features based on > the HASC codes in the shapefile. Cool stuff. > That's great to hear :) Michael 
From: Martin Tomko <martin.tomko@ge...>  20091127 10:40:46

I am bringing this thread back up, as I did not get any response and I was hoping that at least someone is playing around with the Graph package... Any help is welcome! Cheers Martin Martin Tomko wrote: > Dear All, > I started playing around with the graph package, that I did not use > before. I am trying to read in a line shapefile and create a graph, > and then read in a point shapefile and calculate the shortest path > from a given point to another one. As the points may not lay directly > on the edges, I need to: > * add nodes to the graph based on a point feature and the nearest > edge in the graph (split the edge, if needed), > > I think I should manage to compose the graph based on a feature > collection as follows: > FeatureCollection<SimpleFeatureType, SimpleFeature> fc ... > > LineStringGraphGenerator lsgg = new LineStringGraphGenerator(); > FeatureGraphGenerator fgg = new FeatureGraphGenerator(lsgg); > > FeatureIterator<SimpleFeature> f = fc.features(); > while(f.hasNext()){ > Feature ft = f.next(); > fgg.add(ft); > } > // lgb is loaded > Graph g = fgg.getGraph(); > return g; > > > And use the DijkstraShortestPathFinder to find the paths. I found a > function *nearestColinearPoint* (from org.geotools.math.Line), but it > seems like I have to convert from Features to JTS geometries, then to > java.awt.geom.Line2D and java.awt.geom.Point2D and back to use this. > Is there a better way to generate a colinear point feature? > > Furthermore, what is the best way to add the node to an edge, > splitting it into two edges? > > Thanks heaps, > Martin > 
Sign up for the SourceForge newsletter:
No, thanks