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: Pete <peteballack@go...>  20090224 08:57:19
Attachments:
Message as HTML

i'm trying to find the right function for a while now, but i am stuck.... i have a linestring in wgs84 and i want to find the coordinates along the linestring lets say every 50m... I know i can find the distance between two coordinates in meter (JTS.orthodromicDistance) but thats not the one i am looking for hopefully somebody has a solution... thanks 
From: Michael Bedward <michael.bedward@gm...>  20090224 09:46:37

LengthIndexedLine is your friend... http://tsusiatsoftware.net/jts/javadoc/com/vividsolutions/jts/linearref/LengthIndexedLine.html Michael 
From: Pete <peteballack@go...>  20090224 12:45:09
Attachments:
Message as HTML

Hi Michael, thanks for your reply. I think you are referring to the "extractPoint" function. But the function selects the Point between in a fraction between [0,1] and i like to have something like "find the lat/lon position with the distance of 50meter from the beginning" I belive i have to convert my wgs84linestring to use the extractPoint function the way i want it... but i don't really know how... I found the following code. But even a simple test where i compare the lenght of each linestring fails :( MathTransform convert = CRS.findMathTransform( DefaultGeographicCRS.WGS84, DefaultGeocentricCRS.CARTESIAN,false ); Geometry lineStringNew = JTS.transform( lineStringOrig, convert ); 2009/2/24 Michael Bedward <michael.bedward@...> > LengthIndexedLine is your friend... > > > http://tsusiatsoftware.net/jts/javadoc/com/vividsolutions/jts/linearref/LengthIndexedLine.html > > Michael > 
From: Michael Bedward <michael.bedward@gm...>  20090224 23:11:41

Hello Pete, > I think you are referring to the "extractPoint" function. But the function > selects the Point between in a fraction between [0,1] No, it takes a distance in whatever units you are using for your geometries. For example, assuming a Cartesian space (and without checking line direction here)... double interval = 50d; double distance = interval; double end = myLine.getEndPoint().x; LengthIndexedLine lil = new LengthIndexedLine(myLine); List<Coordinate> points = new ArrayList<Coordinate>(); while (true) { p = lil.extractPoint(distance); if (p.x > end) break; points.add(p); distance += interval; } > and i like to have > something like "find the lat/lon position with the distance of 50meter from > the beginning" JTS doesn't know about nonCartesian geometries like latlong. You can use latlong coords and if the distances involved are very small it will be ok, but as they get larger the calculations will become more inaccurate. > I belive i have to convert my wgs84linestring to use the extractPoint > function the way i want it... but i don't really know how... You are probably best reprojecting your coords into a system that is relevant to the area that you are dealing with for accuracy. Select a projection (e.g. UTM Zone 55S for me here in Sydney) and find it's EPSG code (http://www.epsgregistry.org/). Then one way to reproject your geometry (someone else here will surely point out a more elegant way !) // not showing exception handling here... CoordinateReferenceSystem inCRS = DefaultGeographicCRS.WGS84; // you are using this ? CoordinateReferenceSystem outCRS = CRS.decode( someEPSGCode ); MathTransform in2out = CRS.findMathTransform(inCRS, outCRS); MathTransform out2in = in2out.inverse(); LineString trLine = JTS.transform( latLongLine, in2out ); Hope this helps Michael 
Sign up for the SourceForge newsletter:
No, thanks