No worries Ante. GeoTools provides a couple of helper classes for
working with JTS that you might find, well, helpful :)

http://docs.geotools.org/stable/javadocs/org/geotools/geometry/jts/Geometries.html

http://docs.geotools.org/stable/javadocs/org/geotools/geometry/jts/JTS.html

Michael

2011/4/1 ante lakos <[email protected]>:
> hi,
> thanks for your effort Michael.
> Thanks to your post I've figured it out now. I had the wrong Geometry class
> imported:
> org.geotools.geometry.Geometry (which does not have getCoordinates() method)
> instead of:
> com.vividsolutions.jts.geom.Geometry (which indeed has the method)
> I already worked pass the problem as I've used switch-case to type cast the
> geometry attribute read from the feature directly to either Point or
> LineString. As I had these properly imported this worked. At least now I
> understand why it didn't work with Geometry object.
> Thanks!
>
>
> On Fri, Apr 1, 2011 at 8:56 AM, Michael Bedward <[email protected]>
> wrote:
>>
>> 2011/4/1 ante lakos <[email protected]>:
>> > hi,
>> >
>> > i got an error when trying to that saying method could not be found.
>> >
>>
>> Without seeing your code I can't tell what you were doing wrong, but
>> to illustrate that the problem is not the Geometry class I just ran
>> this code snippet:
>>
>> WKTReader reader = new WKTReader();
>> Geometry geom = reader.read("LINESTRING(0 0, 1 2, 3 4, 5 6)");
>>
>> Coordinate[] coords = geom.getCoordinates();
>> for (Coordinate c : coords) {
>>    System.out.printf("%.1f %.1f \n", c.x, c.y);
>> }
>>
>> Which produced this output as expected:
>>
>> 0.0 0.0
>> 1.0 2.0
>> 3.0 4.0
>> 5.0 6.0
>>
>> Michael
>
>
>
> --
> Ante Lakoš
> Ured ovlaštenog inženjera geodezije
> mob. +385 (0)99 6171544
> tel. + 385 (0)1 2226673
> fax. +385 (0)1 3879724
> email. [email protected]
>

------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to