Hi Jody,
I have posted the solution - the construction required a precision model 
to be set, it could not work with a null one. I think the error comes 
from tha part of the code that you indicated because it was not able to 
print an empty array of coordinates. What is a bit more of a worry is 
that the default precision model was not selected in the construction if 
null was specified. I am not sure whether it is a bug or not, I will 
post on the JTS list.
Thank again,
Martin

Jody Garnett wrote:
> Hi Martin:
>
> I am not sure we have much to say on this one; the JTS library is
> pretty solid (and has its own user list). Try stepping through the
> code using a debugger and see what is going on ...
>
> The line number you are failing on makes no sense to me:
>
>   public static String stringOfChar(char ch, int count) {
>     StringBuffer buf = new StringBuffer();
>     for (int i = 0; i < count; i++) {
>       buf.append(ch);
>     }
>     return buf.toString();  <--- you are failing here (this is line 125)
>   }
>
>
> On Fri, May 15, 2009 at 11:07 PM, Martin Tomko <[email protected]> 
> wrote:
>   
>> Dear all,
>> I seem to have problems to build a JTS geometry using Geotools
>> 2.5.-snapshot.
>> I have an array of coordinates (printout below) that I extracted from a
>> GML polygon exterior ring position list.Running the code below I am
>> getting an invalid geometry. I tried to print out the geometry toText,
>> and am getting the followng error from the toText method:
>> java.lang.NullPointerException
>>    at
>> com.vividsolutions.jts.io.WKTWriter.createFormatter(WKTWriter.java:125)
>>    at
>> com.vividsolutions.jts.io.WKTWriter.writeFormatted(WKTWriter.java:290)
>>    at com.vividsolutions.jts.io.WKTWriter.write(WKTWriter.java:226)
>>    at com.vividsolutions.jts.geom.Geometry.toText(Geometry.java:961)
>>
>> Same thing happens on the linearring, which meant that the construction
>> of the LinearRing is somehow incorrect. What could be the problem?
>> Thanks
>> Martin
>>
>>
>> GeometryFactory gf = new GeometryFactory(null,3035);
>> ArrayList<String> splitPos = splitString(poslist," ",2,",");
>> Coordinate[] coords = toCoordArray(splitPos, ",");
>> LinearRing shell = gf.createLinearRing(coords);
>> Polygon p = gf.createPolygon(shell, null);
>> p.setSRID(3035);
>> System.out.println("new pol: "+p.toText());
>>
>> (4100527.55, 2546443.706, NaN)
>> (4101669.813, 2551297.031, NaN)
>> (4102440.967, 2551063.104, NaN)
>> (4103305.401, 2550601.054, NaN)
>> (4104063.084, 2549979.24, NaN)
>> (4104684.898, 2549221.557, NaN)
>> (4105146.948, 2548357.123, NaN)
>> (4105380.875, 2547585.969, NaN)
>> (4100527.55, 2546443.706, NaN)
>>
>> --
>> 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
>>
>>
>> ------------------------------------------------------------------------------
>> Crystal Reports - New Free Runtime and 30 Day Trial
>> Check out the new simplified licensing option that enables
>> unlimited royalty-free distribution of the report engine
>> for externally facing server and web deployment.
>> http://p.sf.net/sfu/businessobjects
>> _______________________________________________
>> Geotools-gt2-users mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>>
>>     
>
>
>   


-- 
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


------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables 
unlimited royalty-free distribution of the report engine 
for externally facing server and web deployment. 
http://p.sf.net/sfu/businessobjects
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to