Dear Justin,
thanks, that's exactly what I needed - I know that the JTS geometry will be in whatever the native units are , that's fine with me. Would it be possible to update the javadoc to say tha the Object is actually the geometry? I was suspecting that, but was not sure whether it is the original feature or the geometry.

Is there any equivalent method to get back to the generating feature (so that one could get some of the other attributes, maybe containing other values for weights?)

Thanks
Martin

On 9/1/2010 5:20 PM, Justin Deoliveira wrote:
Hi Martin,

Yeah you should be able to get at the underlying LineString by calling e.getObject(). Something like:

DijkstraIterator.EdgeWeigter weighter =new DijkstraIterator.EdgeWeighter() {
   public  double  getWeight(Edge e) {
      LineString l = (LineString) e.getObject();
      return l.getLength();
   }
}

However the linestring has no notion of units. That will depend on whatever coordinate system your data is in.

On Wed, Sep 1, 2010 at 10:55 AM, Martin Tomko <[email protected] <mailto:[email protected]>> wrote:

    Dear All,
    I am using the Graph api to construct a graph based on lineStrings -
    that works perfectly. I would like to do a shortest path computation
    based on geographical distance, and need to implement a Weighter.

    the docs show this snippet:

    DijkstraIterator.EdgeWeigter weighter =new
     DijkstraIterator.EdgeWeighter() {
       public  double  getWeight(Edge e) {
          return  1.0;//constant
       }
    }

    which results in a constant weight for an edge of 1.

    How do I get the actual length of an edge, in the original
    feature's units...

    I need the values also for other purposes, so really neend to
    access the edge length property.
    Is it possible?
    Thanks
    Martin



    
------------------------------------------------------------------------------
    This SF.net Dev2Dev email is sponsored by:

    Show off your parallel programming skills.
    Enter the Intel(R) Threading Challenge 2010.
    http://p.sf.net/sfu/intel-thread-sfd
    _______________________________________________
    Geotools-gt2-users mailing list
    [email protected]
    <mailto:[email protected]>
    https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users




--
Justin Deoliveira
OpenGeo - http://opengeo.org
Enterprise support for open source geospatial.



--
Martin Tomko
Postdoctoral Research Assistant

Geographic Information Systems Division
Department of Geography
University of Zurich - Irchel
Winterthurerstr. 190
CH-8057 Zurich, Switzerland

email:  [email protected]
site:   http://www.geo.uzh.ch/~mtomko
mob:    +41-788 629 558
tel:    +41-44-6355256
fax:    +41-44-6356848

------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:

Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to