[postgis-users] Exception in Poligonizer

Leticia lgomez at itba.edu.ar
Sat Apr 7 19:40:43 PDT 2007


Hi Community,

 

            I have to make polygons from linestrings. When I run the
following code (I extracted the affected source code) I obtain the following
runtime error:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1

      at
com.vividsolutions.jts.operation.polygonize.PolygonizeGraph.addEdge(Polygoni
zeGraph.java:120)

      at
com.vividsolutions.jts.operation.polygonize.Polygonizer.add(Polygonizer.java
:133)

      at
com.vividsolutions.jts.operation.polygonize.Polygonizer.access$000(Polygoniz
er.java:58)

      at
com.vividsolutions.jts.operation.polygonize.Polygonizer$LineStringAdder.filt
er(Polygonizer.java:69)

      at com.vividsolutions.jts.geom.LineString.apply(LineString.java:248)

      at
com.vividsolutions.jts.operation.polygonize.Polygonizer.add(Polygonizer.java
:120)

      at
com.vividsolutions.jts.operation.polygonize.Polygonizer.add(Polygonizer.java
:106)

      at Proof.main(Proof.java:100)

 

 

 

import java.util.*;

import com.vividsolutions.jts.geom.*;

import com.vividsolutions.jts.io.*;

import com.vividsolutions.jts.operation.polygonize.*;

 

public class Proof 

{

      

  public static void main(String[] argv) throws ParseException 

  {

        String wktB[] = 

        {           

                    "LINESTRING (59.5 71.5, 59.5 74)", "LINESTRING (59.5 74,
59.5 87.3)",

                    "LINESTRING (59.5 87.3, 59.5 96.6)", "LINESTRING (59.5
96.6, 59.5 118)",

                    "LINESTRING (59.5 118, 59.5 131.5)", "LINESTRING (59.5
131.5, 59.5 147.6)",

                    "LINESTRING (59.5 147.6, 59.5 148.7)", "LINESTRING (59.5
148.7, 59.5 149.7)",

                    "LINESTRING (59.5 149.7, 59.5 152.4)", "LINESTRING (59.5
152.4, 59.5 155.9)",

                    "LINESTRING (59.5 155.9, 59.5 171.7)", "LINESTRING (59.5
171.7, 59.5 172.2)",

                    "LINESTRING (59.5 172.2, 59.5 173)", "LINESTRING (59.5
173, 59.5 174.7)",

                    "LINESTRING (59.5 174.7, 59.5 180.6)", "LINESTRING (59.5
180.6, 59.5 190.2)",

                    "LINESTRING (59.5 190.2, 59.5 210.9)", "LINESTRING (59.5
210.9, 59.5 211.4)",

                    "LINESTRING (59.5 211.4, 59.5 223)", "LINESTRING (59.5
223, 59.5 240)",

                    "LINESTRING (59.5 240, 59.5 242.9)", "LINESTRING (59.5
242.9, 59.5 246.7)",

                    "LINESTRING (59.5 246.7, 59.5 249.9)", "LINESTRING (59.5
249.9, 59.5 257.5)",

                    "LINESTRING (59.5 257.5, 59.5 280)", "LINESTRING (59.5
280, 59.5 282.8)",

                    "LINESTRING (59.5 282.8, 59.5 293.6)", "LINESTRING (25.9
148.7, 35.1 148.7)",

                    "LINESTRING (35.1 148.7, 45.9 148.7)", "LINESTRING (45.9
148.7, 46 148.7)",

                    "LINESTRING (46 148.7, 46.8 148.7)", "LINESTRING (46.8
148.7, 54.3 148.7)",

                    "LINESTRING (54.3 148.7, 58.4 148.7)", "LINESTRING (58.4
148.7, 58.6 148.7)",

                    "LINESTRING (58.6 148.7, 59.1 148.7)", "LINESTRING (59.1
148.7, 59.5 148.7)",

                    "LINESTRING (59.5 148.7, 60.4 148.7)", "LINESTRING (60.4
148.7, 64.7 148.7)",

                    "LINESTRING (64.7 148.7, 69.9 148.7)", "LINESTRING (69.9
148.7, 75 148.7)",

                    "LINESTRING (75 148.7, 79 148.7)", "LINESTRING (79
148.7, 80.5 148.7)",

                    "LINESTRING (80.5 148.7, 81.8 148.7)", "LINESTRING (81.8
148.7, 83.2 148.7)",

                    "LINESTRING (83.2 148.7, 85.4 148.7)", "LINESTRING (85.4
148.7, 91.4 148.7)",

                    "LINESTRING (91.4 148.7, 92.1 148.7)", "LINESTRING (92.1
148.7, 98 148.7)",

                    "LINESTRING (98 148.7, 105.2 148.7)", "LINESTRING (105.2
148.7, 115.8 148.7)",

                    "LINESTRING (83.2 71.5, 83.2 85.9)", "LINESTRING (83.2
85.9, 83.2 115.2)",

                    "LINESTRING (83.2 115.2, 83.2 120.2)", "LINESTRING (83.2
120.2, 83.2 143.4)",

                    "LINESTRING (83.2 143.4, 83.2 147.1)", "LINESTRING (83.2
147.1, 83.2 148.7)",

                    "LINESTRING (83.2 148.7, 83.2 150.5)", "LINESTRING (83.2
150.5, 83.2 164.8)",

                    "LINESTRING (83.2 164.8, 83.2 170)", "LINESTRING (83.2
170, 83.2 173)",

                    "LINESTRING (83.2 173, 83.2 173.2)", "LINESTRING (83.2
173.2, 83.2 215.7)",

                    "LINESTRING (83.2 215.7, 83.2 220.2)", "LINESTRING (83.2
220.2, 83.2 223)",

                    "LINESTRING (83.2 223, 83.2 236)", "LINESTRING (83.2
236, 83.2 246.7)",

                    "LINESTRING (83.2 246.7, 83.2 252)", "LINESTRING (83.2
252, 83.2 276.6)",

                    "LINESTRING (83.2 276.6, 83.2 276.6)"

        };

      

      GeometryFactory fact = new GeometryFactory(new PrecisionModel (1E1),
0);

        

WKTReader wktRdr = new WKTReader(fact);

 

      ArrayList lines= new ArrayList();

        

      for(int rec= 0; rec < wktB.length; rec++)

      {

            Geometry a = wktRdr.read(wktB[rec]);

            lines.add(a);

      }

 

      Polygonizer polygonizer = new Polygonizer();

      polygonizer.add(lines);

   }

}

  

 

I cannot understand the exception and how can I solve it.

 

 

Thanks in advance,

Leticia

 

 

 

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20070407/e19ff3fe/attachment.html>


More information about the postgis-users mailing list