[geos-devel] How to create a noded set of linestrings?

Brent Fraser bfraser at geoanalytic.com
Wed Apr 2 18:12:57 EDT 2008


Hello all,

  I'm really new to using GEOS so please bear with me.

My basic problem is to create polygons from lines (single
segment linestrings).  Using the GEOS example.cpp (and ogr)
I've been able to scavange code to read my shapefile of
lines, apply the polygonizer to create polygons, then create
a shapefile of polygons.  Works great.

But the lines have a few cases of crossing intersections
which I'd like to intersect before polygonization.  How can
I get a "noded" set of geometry?  Is it one method in GEOS
or something like (btw the code below is NOT logically
correct!):

 for (unsigned int i=0; i<input_geoms->size(); i++) {
  Geometry *g1 = (*input_geoms)[i];
  for (unsigned int j=i; j<input_geoms->size(); j++) {
   Geometry *g2 = (*input_geoms)[j];
   try {
    if ( g1->crosses(g2) )
    {
     Geometry *g3 = g1->Union(g2);
     geoms->push_back(g3);
    }else
    {
     geoms->push_back(g1);
    }
   }
  }
 }

Thanks!

Brent Fraser
GeoAnalytic Inc.
Calgary, Alberta



More information about the geos-devel mailing list