Hello Martin,

> But the api doc isn`t what informative for me!

It is a bit minimal

> So can i count that the result is valid? Do you have examples using this
> class?

import com.vividsolutions.jts.geom.Coordinate;
import com.vividsolutions.jts.geom.Geometry;
import com.vividsolutions.jts.io.WKTReader;
import com.vividsolutions.jts.linearref.LengthIndexedLine;

public class Foo {
    public static void main(String[] args) throws Exception {
        WKTReader reader = new WKTReader();
        Geometry line = reader.read("LINESTRING(0 0, 2 2, 4 0, 6 2, 8 0)");
        final double LENGTH = line.getLength();

        LengthIndexedLine lil = new LengthIndexedLine(line);
        System.out.println("Distance        x        y");
        final double STEP = 3.0;

        for (double d = -1.0; d <= LENGTH + STEP; d += STEP) {
            if (lil.isValidIndex(d)) {
                Coordinate c = lil.extractPoint(d);
                System.out.printf("%8.1f %8.4f %8.4f\n", d, c.x, c.y);
            } else {
                System.out.printf("%8.1f   (out of range)\n", d);
            }
        }
    }
}


> And if i have a collection of linestring representing the movementpath
> should i combine the linestrings to a "big" one and then use this algorithm
> or is there an more easier way?

It's up to you :-)

LengthIndexedLine will work with MultiLineString.  If the component
LineStrings are discontinuous the movement will appear to jump from
the end of one to the start of the next, but the calculations will
still be correct in terms of 'length travelled along line'.

> I also wanted to ask you what classes do you use for computing shourtes
> paths? or what classes do you use for buldig a route graph from linestrings!

Spend some time studying the gt-graph module which contains classes
such as this:
file:///Users/michael/coding/geotools/geotools-2.6.0/apidocs/org/geotools/graph/path/DijkstraShortestPathFinder.html

Michael

------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to