And running the program in a third computer, I get a different exception:<br><br>Program received signal SIGSEGV, Segmentation fault.<br>[Switching to Thread 0xb7350a70 (LWP 1795)]<br>0xb758617b in geos::io::WKBWriter::write (this=0xbfc8605c, g=@0x805b4b8,<br>
os=@0xbfc85f90) at WKBWriter.cpp:77<br>77 WKBWriter.cpp: No such file or directory.<br> in WKBWriter.cpp<br>(gdb) backtrace<br>#0 0xb758617b in geos::io::WKBWriter::write (this=0xbfc8605c, g=@0x805b4b8,<br>
os=@0xbfc85f90) at WKBWriter.cpp:77<br>#1 0xb74a456b in GEOSGeomToWKB_buf (g=0x805b4b8, size=0xbfc860ac)<br> at geos_c.cpp:563<br>#2 0xb7aa63c7 in OGRGeometryFactory::<div id=":44" class="ii gt">createFromGEOS (geosGeom=0x805b4b8)<br>
at ogrgeometryfactory.cpp:1296<br>
#3 0xb7aac824 in OGRPolygon::Centroid (this=0x8050b30, poPoint=0xbfc861c0)<br> at ogrpolygon.cpp:740<br>#4 0xb7fa2d14 in CreateFeature (poPolygon=0x8050780, newPoLayer=0x8050570,<br> poFeature=0x80509a0) at testIndexes.cpp:57<br>
#5 0xb7fa3eae in CalculateShapeIndexes (baseName=0xbfc864e6 "abc",<br> outFile=0xbfc864b4 "out") at testIndexes.cpp:221<br><br>I start to wonder if my <a href="http://configure.in/" target="_blank">configure.in</a> is picking up the correct location for geos includes... I am gonna research a bit more about this and post results!<br>
Anyway, it would be great if anybody had some ideas why the program is
crashing with different errors in each pc... this is confusing me a bit!<br>Could it be because the geos version installed is different from the geos version that was used when compiling gdal?<br>
(In ubuntu I have some gdal binaries I have no idea-where-they-came-from and a svn version of geos...)<br> cheers,<br> Jo</div>
<br><br><div class="gmail_quote">2009/7/20 Jo <span dir="ltr"><<a href="mailto:doublebyte@gmail.com">doublebyte@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
And running the program in a third computer, I get a different exception:<br><br>Program received signal SIGSEGV, Segmentation fault.<br>[Switching to Thread 0xb7350a70 (LWP 1795)]<br>0xb758617b in geos::io::WKBWriter::write (this=0xbfc8605c, g=@0x805b4b8,<br>
os=@0xbfc85f90) at WKBWriter.cpp:77<br>77 WKBWriter.cpp: No such file or directory.<br> in WKBWriter.cpp<br>(gdb) backtrace<br>#0 0xb758617b in geos::io::WKBWriter::write (this=0xbfc8605c, g=@0x805b4b8,<br>
os=@0xbfc85f90) at WKBWriter.cpp:77<br>#1 0xb74a456b in GEOSGeomToWKB_buf (g=0x805b4b8, size=0xbfc860ac)<br> at geos_c.cpp:563<br>#2 0xb7aa63c7 in OGRGeometryFactory::createFromGEOS (geosGeom=0x805b4b8)<br> at ogrgeometryfactory.cpp:1296<br>
#3 0xb7aac824 in OGRPolygon::Centroid (this=0x8050b30, poPoint=0xbfc861c0)<br> at ogrpolygon.cpp:740<br>#4 0xb7fa2d14 in CreateFeature (poPolygon=0x8050780, newPoLayer=0x8050570,<br> poFeature=0x80509a0) at testIndexes.cpp:57<br>
#5 0xb7fa3eae in CalculateShapeIndexes (baseName=0xbfc864e6 "abc",<br> outFile=0xbfc864b4 "out") at testIndexes.cpp:221<br><br>I start to wonder if my <a href="http://configure.in" target="_blank">configure.in</a> is picking up the correct location for geos includes... I am gonna research a bit more about this and post results!<br>
Anyway, it would be great if anybody had some ideas why the program is crashing with different errors in each pc... this is confusing me a bit!<br>Could it be because the geos version installed is different from the geos version that was used when compiling gdal?<br>
(In ubuntu I have some gdal binaries I have no idea-where-they-came-from and a svn version of geos...)<br> cheers,<br> Jo<br>
<br><div class="gmail_quote">2009/7/20 <span dir="ltr"><<a href="mailto:geos-devel-request@lists.osgeo.org" target="_blank">geos-devel-request@lists.osgeo.org</a>></span><div><div></div><div class="h5"><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Send geos-devel mailing list submissions to<br>
<a href="mailto:geos-devel@lists.osgeo.org" target="_blank">geos-devel@lists.osgeo.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="http://lists.osgeo.org/mailman/listinfo/geos-devel" target="_blank">http://lists.osgeo.org/mailman/listinfo/geos-devel</a><br>
or, via email, send a message with subject or body 'help' to<br>
<a href="mailto:geos-devel-request@lists.osgeo.org" target="_blank">geos-devel-request@lists.osgeo.org</a><br>
<br>
You can reach the person managing the list at<br>
<a href="mailto:geos-devel-owner@lists.osgeo.org" target="_blank">geos-devel-owner@lists.osgeo.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of geos-devel digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
1. Computational Geometry Problem + Exception (Jo)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Mon, 20 Jul 2009 23:16:26 +0100<br>
From: Jo <<a href="mailto:doublebyte@gmail.com" target="_blank">doublebyte@gmail.com</a>><br>
Subject: [geos-devel] Computational Geometry Problem + Exception<br>
To: <a href="mailto:geos-devel@lists.osgeo.org" target="_blank">geos-devel@lists.osgeo.org</a><br>
Message-ID:<br>
<<a href="mailto:23ab5f0a0907201516g4af4646bm272acfeecc8a1fcb@mail.gmail.com" target="_blank">23ab5f0a0907201516g4af4646bm272acfeecc8a1fcb@mail.gmail.com</a>><br>
Content-Type: text/plain; charset="iso-8859-1"<br>
<br>
Hi,<br>
Sorry to bother you again, but I am getting sometimes this exception from<br>
GEOS and I don't have a clue what it is:<br>
<br>
test: CoordinateArraySequence.cpp:105: virtual const geos::geom::Coordinate&<br>
geos::geom::CoordinateArraySequence::getAt(size_t) const: Assertion<br>
`pos<vect->size()' failed.<br>
<br>
Backtracing it, I discovered that it comes from the ISCCW algorithm:<br>
<br>
#0 0xb7119c66 in raise () from /lib/libc.so.6<br>
#1 0xb711b571 in abort () from /lib/libc.so.6<br>
#2 0xb7112e60 in __assert_fail () from /lib/libc.so.6<br>
#3 0xb7884ee6 in geos::geom::CoordinateArraySequence::getAt (this=0x0,<br>
pos=7117)<br>
at<br>
/usr/local/lib/gcc/i686-pc-linux-gnu/3.4.6/../../../../include/c++/3.4.6/bits/stl_vector.h:375<br>
#4 0xb7876b79 in geos::algorithm::CGAlgorithms::isCCW (ring=0x804f2b8) at<br>
CGAlgorithms.cpp:175<br>
<br>
Does anybody has any ideas in what can be causing this?<br>
Strangely it breaks in different files in my two computers: both using GEOS,<br>
vs 3.2.0 from svn.<br>
Any help on this would be much appreciated!<br>
<br>
cheers,<br>
<br>
Jo<br>
<br>
2009/7/19 <<a href="mailto:geos-devel-request@lists.osgeo.org" target="_blank">geos-devel-request@lists.osgeo.org</a>><br>
<br>
> Send geos-devel mailing list submissions to<br>
> <a href="mailto:geos-devel@lists.osgeo.org" target="_blank">geos-devel@lists.osgeo.org</a><br>
><br>
> To subscribe or unsubscribe via the World Wide Web, visit<br>
> <a href="http://lists.osgeo.org/mailman/listinfo/geos-devel" target="_blank">http://lists.osgeo.org/mailman/listinfo/geos-devel</a><br>
> or, via email, send a message with subject or body 'help' to<br>
> <a href="mailto:geos-devel-request@lists.osgeo.org" target="_blank">geos-devel-request@lists.osgeo.org</a><br>
><br>
> You can reach the person managing the list at<br>
> <a href="mailto:geos-devel-owner@lists.osgeo.org" target="_blank">geos-devel-owner@lists.osgeo.org</a><br>
><br>
> When replying, please edit your Subject line so it is more specific<br>
> than "Re: Contents of geos-devel digest..."<br>
><br>
><br>
> Today's Topics:<br>
><br>
> 1. geos svn (Jo)<br>
><br>
><br>
> ----------------------------------------------------------------------<br>
><br>
> Message: 1<br>
> Date: Sun, 19 Jul 2009 23:10:01 +0100<br>
> From: Jo <<a href="mailto:doublebyte@gmail.com" target="_blank">doublebyte@gmail.com</a>><br>
> Subject: [geos-devel] geos svn<br>
> To: <a href="mailto:geos-devel@lists.osgeo.org" target="_blank">geos-devel@lists.osgeo.org</a><br>
> Message-ID:<br>
> <<a href="mailto:23ab5f0a0907191510s1d567375qdf13e491e1e06933@mail.gmail.com" target="_blank">23ab5f0a0907191510s1d567375qdf13e491e1e06933@mail.gmail.com</a>><br>
> Content-Type: text/plain; charset="iso-8859-1"<br>
><br>
> Latest SVN version of geos seems to be incomplete: no libtool and<br>
> lt-main.sh.<br>
> Also, the nightly release appears to be a broken tar file (at least I<br>
> cannot<br>
> open it in my pc)...<br>
> cheers,<br>
> Jo<br>
><br>
> 2009/7/19 <<a href="mailto:geos-devel-request@lists.osgeo.org" target="_blank">geos-devel-request@lists.osgeo.org</a>><br>
><br>
> > Send geos-devel mailing list submissions to<br>
> > <a href="mailto:geos-devel@lists.osgeo.org" target="_blank">geos-devel@lists.osgeo.org</a><br>
> ><br>
> > To subscribe or unsubscribe via the World Wide Web, visit<br>
> > <a href="http://lists.osgeo.org/mailman/listinfo/geos-devel" target="_blank">http://lists.osgeo.org/mailman/listinfo/geos-devel</a><br>
> > or, via email, send a message with subject or body 'help' to<br>
> > <a href="mailto:geos-devel-request@lists.osgeo.org" target="_blank">geos-devel-request@lists.osgeo.org</a><br>
> ><br>
> > You can reach the person managing the list at<br>
> > <a href="mailto:geos-devel-owner@lists.osgeo.org" target="_blank">geos-devel-owner@lists.osgeo.org</a><br>
> ><br>
> > When replying, please edit your Subject line so it is more specific<br>
> > than "Re: Contents of geos-devel digest..."<br>
> ><br>
> ><br>
> > Today's Topics:<br>
> ><br>
> > 1. Computational Geometry Problem (Jo)<br>
> ><br>
> ><br>
> > ----------------------------------------------------------------------<br>
> ><br>
> > Message: 1<br>
> > Date: Sun, 19 Jul 2009 22:56:53 +0100<br>
> > From: Jo <<a href="mailto:doublebyte@gmail.com" target="_blank">doublebyte@gmail.com</a>><br>
> > Subject: [geos-devel] Computational Geometry Problem<br>
> > To: <a href="mailto:geos-devel@lists.osgeo.org" target="_blank">geos-devel@lists.osgeo.org</a><br>
> > Message-ID:<br>
> > <<a href="mailto:23ab5f0a0907191456l5f8d648i4dce9666abf3dcf8@mail.gmail.com" target="_blank">23ab5f0a0907191456l5f8d648i4dce9666abf3dcf8@mail.gmail.com</a>><br>
> > Content-Type: text/plain; charset="iso-8859-1"<br>
> ><br>
> > Hi Sanak,<br>
> > Thanks a lot for the modified code: it worked on perfection!<br>
> > Here is a screenshot of a run with my shapefile:<br>
> ><br>
> > <a href="http://ladybug.no-ip.org/files/inCircleFinal.png" target="_blank">http://ladybug.no-ip.org/files/inCircleFinal.png</a><br>
> ><br>
> > Have a good rest of the weekend!<br>
> > Jo<br>
> ><br>
> > 2009/7/19 <<a href="mailto:geos-devel-request@lists.osgeo.org" target="_blank">geos-devel-request@lists.osgeo.org</a>><br>
> ><br>
> > > Send geos-devel mailing list submissions to<br>
> > > <a href="mailto:geos-devel@lists.osgeo.org" target="_blank">geos-devel@lists.osgeo.org</a><br>
> > ><br>
> > > To subscribe or unsubscribe via the World Wide Web, visit<br>
> > > <a href="http://lists.osgeo.org/mailman/listinfo/geos-devel" target="_blank">http://lists.osgeo.org/mailman/listinfo/geos-devel</a><br>
> > > or, via email, send a message with subject or body 'help' to<br>
> > > <a href="mailto:geos-devel-request@lists.osgeo.org" target="_blank">geos-devel-request@lists.osgeo.org</a><br>
> > ><br>
> > > You can reach the person managing the list at<br>
> > > <a href="mailto:geos-devel-owner@lists.osgeo.org" target="_blank">geos-devel-owner@lists.osgeo.org</a><br>
> > ><br>
> > > When replying, please edit your Subject line so it is more specific<br>
> > > than "Re: Contents of geos-devel digest..."<br>
> > ><br>
> > ><br>
> > > Today's Topics:<br>
> > ><br>
> > > 1. Re: Re: Computational Geometry Problem (Sanak Goe)<br>
> > ><br>
> > ><br>
> > > ----------------------------------------------------------------------<br>
> > ><br>
> > > Message: 1<br>
> > > Date: Sun, 19 Jul 2009 21:24:34 +0900<br>
> > > From: Sanak Goe <<a href="mailto:geosanak@gmail.com" target="_blank">geosanak@gmail.com</a>><br>
> > > Subject: Re: [geos-devel] Re: Computational Geometry Problem<br>
> > > To: GEOS Development List <<a href="mailto:geos-devel@lists.osgeo.org" target="_blank">geos-devel@lists.osgeo.org</a>><br>
> > > Message-ID:<br>
> > > <<a href="mailto:5f9be0a0907190524n5a8de434y38731cf04e7770d0@mail.gmail.com" target="_blank">5f9be0a0907190524n5a8de434y38731cf04e7770d0@mail.gmail.com</a>><br>
> > > Content-Type: text/plain; charset="iso-8859-1"<br>
> > ><br>
> > > Skipped content of type multipart/alternative-------------- next part<br>
> > > --------------<br>
> > > #include <locale.h><br>
> > > #include <iostream><br>
> > > #include <vector><br>
> > > #include <algorithm><br>
> > > #include <stdexcept><br>
> > > #include <map> // added by sanak 2009.07.19<br>
> > > #ifdef _MSC_VER<br>
> > > #include <io.h><br>
> > > #endif // _MSC_VER<br>
> > ><br>
> > > //Geos<br>
> > > #include <geos_c.h><br>
> > ><br>
> > > #include <geos/algorithm/CGAlgorithms.h><br>
> > > #include <geos/algorithm/HCoordinate.h><br>
> > > #include <geos/geom/Coordinate.h><br>
> > > #include <geos/geom/CoordinateArraySequence.h><br>
> > > #include <geos/geom/LineString.h><br>
> > > #include <geos/geom/MultiPoint.h><br>
> > > #include <geos/geom/Point.h><br>
> > > #include <geos/geom/Polygon.h><br>
> > > #include <geos/io/WKTReader.h><br>
> > > #include <geos/io/WKTWriter.h><br>
> > ><br>
> > > // <-- modified by sanak 2009.07.19<br>
> > > //const double epsilonArea = 100.0;<br>
> > > const double epsilonRadius = 0.1;<br>
> > > // --> modified by sanak 2009.07.19<br>
> > ><br>
> > > // <-- Boost code<br>
> > > template < class BidirectionalIterator ><br>
> > > bool next_combination ( BidirectionalIterator first1 ,<br>
> > > BidirectionalIterator last1 ,<br>
> > > BidirectionalIterator first2 ,<br>
> > > BidirectionalIterator last2 )<br>
> > > {<br>
> > > if (( first1 == last1 ) || ( first2 == last2 )) {<br>
> > > return false ;<br>
> > > }<br>
> > > BidirectionalIterator m1 = last1 ;<br>
> > > BidirectionalIterator m2 = last2 ; --m2;<br>
> > > while (--m1 != first1 && !(* m1 < *m2 )){<br>
> > > }<br>
> > > bool result = (m1 == first1 ) && !(* first1 < *m2 );<br>
> > > if (! result ) {<br>
> > > while ( first2 != m2 && !(* m1 < * first2 )) {<br>
> > > ++ first2 ;<br>
> > > }<br>
> > > first1 = m1;<br>
> > > std :: iter_swap (first1 , first2 );<br>
> > > ++ first1 ;<br>
> > > ++ first2 ;<br>
> > > }<br>
> > > if (( first1 != last1 ) && ( first2 != last2 )) {<br>
> > > m1 = last1 ; m2 = first2 ;<br>
> > > while (( m1 != first1 ) && (m2 != last2 )) {<br>
> > > std :: iter_swap (--m1 , m2 );<br>
> > > ++ m2;<br>
> > > }<br>
> > > std :: reverse (first1 , m1 );<br>
> > > std :: reverse (first1 , last1 );<br>
> > > std :: reverse (m2 , last2 );<br>
> > > std :: reverse (first2 , last2 );<br>
> > > }<br>
> > > return ! result ;<br>
> > > }<br>
> > ><br>
> > > template < class BidirectionalIterator ><br>
> > > bool next_combination ( BidirectionalIterator first ,<br>
> > > BidirectionalIterator middle ,<br>
> > > BidirectionalIterator last )<br>
> > > {<br>
> > > return next_combination (first , middle , middle , last );<br>
> > > }<br>
> > > // Boost Code --><br>
> > ><br>
> > > bool computeIncircle(<br>
> > > const geos::geom::Polygon*<br>
> poly,<br>
> > > const geos::geom::Polygon*<br>
> > negbuf,<br>
> > > geos::geom::Coordinate& center,<br>
> > > double& radius)<br>
> > > {<br>
> > > radius = 0.0;<br>
> > ><br>
> > > if (negbuf == NULL)<br>
> > > {<br>
> > > negbuf = poly;<br>
> > > }<br>
> > ><br>
> > > try<br>
> > > {<br>
> > ><br>
> > > if (!negbuf->isValid())<br>
> > > {<br>
> > > throw std::runtime_error("Invalid polygon.");<br>
> > > }<br>
> > ><br>
> > > if (negbuf->getNumInteriorRing() > 0)<br>
> > > {<br>
> > > throw std::runtime_error("This sample only<br>
> > supports<br>
> > > non-holes polygon.");<br>
> > > }<br>
> > ><br>
> > > const geos::geom::LineString* shell =<br>
> > > negbuf->getExteriorRing();<br>
> > > geos::geom::CoordinateArraySequence* coords =<br>
> > ><br>
> ><br>
> static_cast<geos::geom::CoordinateArraySequence*>(shell->getCoordinates());<br>
> > ><br>
> > > // compute orientation of ring<br>
> > > if (!geos::algorithm::CGAlgorithms::isCCW(coords))<br>
> > > {<br>
> > > coords->reverse(coords);<br>
> > > }<br>
> > ><br>
> > > // compute angle bisector of every continuous three<br>
> > points<br>
> > > in polygon<br>
> > > size_t cnt = coords->size() - 1;<br>
> > > // <-- modified by sanak 2009.07.19<br>
> > > //std::vector<geos::algorithm::HCoordinate*> bisects;<br>
> > > std::vector<size_t> bisectids;<br>
> > > std::map<size_t, geos::algorithm::HCoordinate*> bisects;<br>
> > > // --> modified by sanak 2009.07.19<br>
> > > for (size_t i = 0; i < cnt; i++)<br>
> > > {<br>
> > > size_t prev = (i == 0) ? cnt - 1 : i - 1;<br>
> > > size_t curr = i;<br>
> > > size_t next = (i == cnt - 1) ? 0 : i + 1;<br>
> > ><br>
> > > // <-- JTS 1.10 Code<br>
> > > geos::geom::Coordinate a = coords->getAt(prev);<br>
> > > geos::geom::Coordinate b = coords->getAt(curr);<br>
> > > geos::geom::Coordinate c = coords->getAt(next);<br>
> > ><br>
> > > double len0 = b.distance(a);<br>
> > > double len2 = b.distance(c);<br>
> > > double frac = len0 / (len0 + len2);<br>
> > > double dx = c.x - a.x;<br>
> > > double dy = c.y - a.y;<br>
> > ><br>
> > > geos::geom::Coordinate splitPt =<br>
> > > geos::geom::Coordinate(a.x + frac * dx, a.y + frac * dy);<br>
> > > // --> JTS 1.10 Code<br>
> > > // <-- modified by sanak 2009.07.19<br>
> > > //bisects.push_back(new<br>
> > > geos::algorithm::HCoordinate(b, splitPt));<br>
> > > bisectids.push_back(i);<br>
> > > bisects.insert(std::pair<size_t,<br>
> > > geos::algorithm::HCoordinate*>(i, new geos::algorithm::HCoordinate(b,<br>
> > > splitPt)));<br>
> > > // --> modified by sanak 2009.07.19<br>
> > > }<br>
> > ><br>
> > > // get intersection points of angle bisectors<br>
> > > geos::geom::CoordinateArraySequence intsects;<br>
> > > do<br>
> > > {<br>
> > > // <-- modified by sanak 2009.07.19<br>
> > > //geos::algorithm::HCoordinate* hc0 =<br>
> bisects[0];<br>
> > > //geos::algorithm::HCoordinate* hc1 =<br>
> bisects[1];<br>
> > > geos::algorithm::HCoordinate* hc0 =<br>
> > > bisects[bisectids[0]];<br>
> > > geos::algorithm::HCoordinate* hc1 =<br>
> > > bisects[bisectids[1]];<br>
> > > // --> modified by sanak 2009.07.19<br>
> > > geos::algorithm::HCoordinate* hcoord = new<br>
> > > geos::algorithm::HCoordinate(*hc0, *hc1);<br>
> > > try<br>
> > > {<br>
> > > // get intersection<br>
> > > geos::geom::Coordinate coord =<br>
> > > geos::geom::Coordinate(hcoord->getX(), hcoord->getY());<br>
> > ><br>
> > > // TODO:remove duplicate point<br>
> > > intsects.add(coord);<br>
> > > }<br>
> > > catch (std::exception& ex)<br>
> > > {<br>
> > > // no intersection<br>
> > > }<br>
> > > if (hcoord)<br>
> > > {<br>
> > > delete hcoord;<br>
> > > }<br>
> > > }<br>
> > > // <-- modified by sanak 2009.07.19<br>
> > > //while (next_combination(bisects.begin(),<br>
> bisects.begin()<br>
> > +<br>
> > > 2, bisects.end()));<br>
> > > while (next_combination(bisectids.begin(),<br>
> > bisectids.begin()<br>
> > > + 2, bisectids.end()));<br>
> > > // --> modified by sanak 2009.07.19<br>
> > ><br>
> > > // clean up<br>
> > > if (bisects.size() > 0)<br>
> > > {<br>
> > > std::cout << "bissects ok." << std::endl;<br>
> > > // <-- modified by sanak 2009.07.19<br>
> > ><br>
> > > //std::vector<geos::algorithm::HCoordinate*>::iterator it;<br>
> > > //for (it = bisects.begin(); it !=<br>
> bisects.end();<br>
> > > it++)<br>
> > > //{<br>
> > > // delete *it;<br>
> > > //}<br>
> > > std::map<size_t,<br>
> > > geos::algorithm::HCoordinate*>::iterator it;<br>
> > > for (it = bisects.begin(); it != bisects.end();<br>
> > > it++)<br>
> > > {<br>
> > > delete it->second;<br>
> > > }<br>
> > > // --> modified by sanak 2009.07.19<br>
> > > }<br>
> > > else<br>
> > > std::cout << "No bissects." << std::endl;<br>
> > ><br>
> > > std::cout << "intsects.size()" << intsects.size() <<<br>
> > > std::endl;<br>
> > > if (intsects.size() > 0)<br>
> > > {<br>
> > > std::cout << "intsects ok." << std::endl;<br>
> > ><br>
> > > geos::geom::Point* incenter = NULL;<br>
> > ><br>
> > > geos::geom::GeometryFactory factory;<br>
> > > const geos::geom::LineString* line =<br>
> > > poly->getExteriorRing();<br>
> > > //geos::geom::MultiPoint* rcpoints =<br>
> > > factory.createMultiPoint(intsects); // for debug<br>
> > ><br>
> > > std::vector<geos::geom::Coordinate*>::iterator<br>
> it;<br>
> > > for (size_t i = 0; i < intsects.size(); i++)<br>
> > > {<br>
> > > geos::geom::Coordinate coord =<br>
> > intsects[i];<br>
> > > // exclude points that are outer of<br>
> > polygon<br>
> > > if<br>
> > > (geos::algorithm::CGAlgorithms::isPointInRing(coord, coords))<br>
> > > {<br>
> > > geos::geom::Point* point =<br>
> > > factory.createPoint(coord);<br>
> > > // compute distance from every<br>
> > > candidates of centres to polygon, and choose largest one<br>
> > > double distance =<br>
> > > line->distance(point);<br>
> > > if (radius < distance)<br>
> > > {<br>
> > > radius = distance;<br>
> > > incenter = point;<br>
> > > }<br>
> > > }<br>
> > > //else std::cout << "Point not in Ring."<br>
> > <<<br>
> > > std::endl;<br>
> > > }<br>
> > ><br>
> > > if (incenter != NULL && radius != 0.0)<br>
> > > {<br>
> > > geos::io::WKTWriter writer;<br>
> > > std::cout << "wkt : " <<<br>
> > > writer.write(incenter) << std::endl;<br>
> > > std::cout << "radius : " <<<br>
> radius<br>
> > > << std::endl;<br>
> > ><br>
> > > center.x = incenter->getX();<br>
> > > center.y = incenter->getY();<br>
> > > //return true; // deleted by sanak<br>
> > > 2009.07.19<br>
> > > }<br>
> > > // <-- added by sanak 2009.07.19<br>
> > > else<br>
> > > {<br>
> > > geos::geom::Point* intPt =<br>
> > > negbuf->getInteriorPoint();<br>
> > > center.x = intPt->getX();<br>
> > > center.y = intPt->getY();<br>
> > > radius = line->distance(intPt);<br>
> > > }<br>
> > > return true;<br>
> > > // --> added by sanak 2009.07.19<br>
> > > }<br>
> > > else<br>
> > > {<br>
> > > std::cout << "No intsects." << std::endl;<br>
> > > throw std::runtime_error("Couldn't get<br>
> > incenter.");<br>
> > > }<br>
> > > }<br>
> > > catch (std::exception& ex)<br>
> > > {<br>
> > > std::cerr << "Exception : " << ex.what() << std::endl;<br>
> > > throw ex;<br>
> > > return false;<br>
> > > }<br>
> > > return false;<br>
> > > }<br>
> > ><br>
> > > int main(int argc, char* argv[])<br>
> > > {<br>
> > > // check stdin<br>
> > > #ifdef _MSC_VER<br>
> > > if (::_isatty(fileno(stdin)))<br>
> > > #else<br>
> > > if (::isatty(fileno(stdin)))<br>
> > > #endif // _MSC_VER<br>
> > > {<br>
> > > std::cerr << "Usage: %s < [wktfile(polygon)]" <<<br>
> > std::endl;<br>
> > > return -1;<br>
> > > }<br>
> > ><br>
> > > std::string line;<br>
> > > geos::io::WKTReader reader;<br>
> > > std::vector<geos::geom::Polygon*> g;<br>
> > > while (getline(std::cin, line, '\n'))<br>
> > > {<br>
> > > //std::cout << line << std::endl;<br>
> > > geos::geom::Polygon* geom =<br>
> > > static_cast<geos::geom::Polygon*>(reader.read(line));<br>
> > ><br>
> > > if (geom == NULL && geom->getGeometryType() !=<br>
> "Polygon")<br>
> > > {<br>
> > > throw std::runtime_error("This sample only<br>
> > supports<br>
> > > polygon geometry");<br>
> > > }<br>
> > ><br>
> > > geos::geom::Polygon* poly =<br>
> > > static_cast<geos::geom::Polygon*>(geom);<br>
> > > if (!poly->isValid())<br>
> > > {<br>
> > > throw std::runtime_error("Invalid polygon.");<br>
> > > }<br>
> > ><br>
> > > if (poly->getNumInteriorRing() > 0)<br>
> > > {<br>
> > > throw std::runtime_error("This sample only<br>
> > supports<br>
> > > non-holes polygon.");<br>
> > > }<br>
> > ><br>
> > > g.push_back(poly);<br>
> > > }<br>
> > ><br>
> > ><br>
> > > try<br>
> > > {<br>
> > ><br>
> > > for (int i=0 ; i < g.size(); ++i)<br>
> > > {<br>
> > > geos::geom::Polygon* negbuf = NULL;<br>
> > > double prevRadius = 0.0; // added by sanak<br>
> > > 2009.07.19<br>
> > > while (true)<br>
> > > {<br>
> > > geos::geom::Coordinate center;<br>
> > > double radius = 0.0;<br>
> > > if (computeIncircle(g[i], negbuf,<br>
> center,<br>
> > > radius))<br>
> > > {<br>
> > > // <-- modified by sanak<br>
> > 2009.07.19<br>
> > > //negbuf =<br>
> > > static_cast<geos::geom::Polygon*>(g[i]->buffer(-radius));<br>
> > > //if (negbuf == NULL &&<br>
> > > negbuf->getGeometryType() != "Polygon")<br>
> > > //{<br>
> > > // // TODO:<br>
> > > // throw<br>
> > > std::runtime_error("Intercepted!!!!!!!");<br>
> > > //}<br>
> > > //double area =<br>
> negbuf->getArea();<br>
> > ><br>
> > > //if (area < epsilonArea)<br>
> > > geos::geom::Geometry* buf =<br>
> > > g[i]->buffer(-(radius));<br>
> > > std::string buftype =<br>
> > > buf->getGeometryType();<br>
> > > if (buftype == "Polygon")<br>
> > > {<br>
> > > negbuf =<br>
> > > static_cast<geos::geom::Polygon*>(buf);<br>
> > > }<br>
> > > else if (buftype ==<br>
> > "MultiPolygon")<br>
> > > {<br>
> > > size_t cnt =<br>
> > > buf->getNumGeometries();<br>
> > > double maxradius = 0.0;<br>
> > > double tmpradius = 0.0;<br>
> > > geos::geom::Coordinate<br>
> > > tmpcenter;<br>
> > > for (size_t j = 0; j <<br>
> > cnt;<br>
> > > j++)<br>
> > > {<br>
> > > const<br>
> > > geos::geom::Polygon* item = static_cast<const<br>
> > > geos::geom::Polygon*>(buf->getGeometryN(j));<br>
> > > if<br>
> > > (computeIncircle(g[i], item, tmpcenter, tmpradius))<br>
> > > {<br>
> > > if<br>
> > > (tmpradius > maxradius)<br>
> > > {<br>
> > ><br>
> > > negbuf = static_cast<geos::geom::Polygon*>(item->clone());<br>
> > ><br>
> > > center = tmpcenter;<br>
> > ><br>
> > > radius = tmpradius;<br>
> > ><br>
> > > maxradius = tmpradius;<br>
> > > }<br>
> > > }<br>
> > > }<br>
> > > }<br>
> > ><br>
> > > if ((radius - prevRadius) <<br>
> > > epsilonRadius)<br>
> > > // --> modified by sanak<br>
> > 2009.07.19<br>
> > > {<br>
> > ><br>
> > > std::cout << "center : "<br>
> > <<<br>
> > > center.toString() << std::endl;<br>
> > > std::cout << "radius : "<br>
> > <<<br>
> > > radius << std::endl;<br>
> > ><br>
> > geos::geom::GeometryFactory<br>
> > > factory;<br>
> > > geos::geom::Point*<br>
> > centerPt<br>
> > > = factory.createPoint(center);<br>
> > > geos::geom::Geometry*<br>
> > > incircle = centerPt->buffer(radius);<br>
> > > geos::io::WKTWriter<br>
> > writer;<br>
> > > std::cout << "wkt : " <<<br>
> > > writer.write(incircle) << std::endl;<br>
> > > // <-- modified by sanak<br>
> > > 2009.07.19<br>
> > > //return 0;<br>
> > > break;<br>
> > > // --> modified by sanak<br>
> > > 2009.07.19<br>
> > > }<br>
> > > prevRadius = radius; // added by<br>
> > > sanak 2009.07.19<br>
> > > }<br>
> > > else<br>
> > > {<br>
> > > std::cout << "Could not<br>
> compute!"<br>
> > <<<br>
> > > std::endl;<br>
> > > return -2;<br>
> > > }<br>
> > > }<br>
> > > }<br>
> > > }<br>
> > > catch (std::exception& ex)<br>
> > > {<br>
> > > std::cerr << "Exception : " << ex.what() << std::endl;<br>
> > > return -3;<br>
> > > }<br>
> > ><br>
> > > return 0;<br>
> > > }<br>
> > ><br>
> > > ------------------------------<br>
> > ><br>
> > > _______________________________________________<br>
> > > geos-devel mailing list<br>
> > > <a href="mailto:geos-devel@lists.osgeo.org" target="_blank">geos-devel@lists.osgeo.org</a><br>
> > > <a href="http://lists.osgeo.org/mailman/listinfo/geos-devel" target="_blank">http://lists.osgeo.org/mailman/listinfo/geos-devel</a><br>
> > ><br>
> > > End of geos-devel Digest, Vol 81, Issue 13<br>
> > > ******************************************<br>
> > ><br>
> ><br>
> ><br>
> ><br>
> > --<br>
> > "#define QUESTION ((bb) || !(bb))" (Shakespeare)<br>
> > -------------- next part --------------<br>
> > An HTML attachment was scrubbed...<br>
> > URL:<br>
> ><br>
> <a href="http://lists.osgeo.org/pipermail/geos-devel/attachments/20090719/f83b16e1/attachment.html" target="_blank">http://lists.osgeo.org/pipermail/geos-devel/attachments/20090719/f83b16e1/attachment.html</a><br>
> ><br>
> > ------------------------------<br>
> ><br>
> > _______________________________________________<br>
> > geos-devel mailing list<br>
> > <a href="mailto:geos-devel@lists.osgeo.org" target="_blank">geos-devel@lists.osgeo.org</a><br>
> > <a href="http://lists.osgeo.org/mailman/listinfo/geos-devel" target="_blank">http://lists.osgeo.org/mailman/listinfo/geos-devel</a><br>
> ><br>
> > End of geos-devel Digest, Vol 81, Issue 14<br>
> > ******************************************<br>
> ><br>
><br>
><br>
><br>
> --<br>
> "#define QUESTION ((bb) || !(bb))" (Shakespeare)<br>
> -------------- next part --------------<br>
> An HTML attachment was scrubbed...<br>
> URL:<br>
> <a href="http://lists.osgeo.org/pipermail/geos-devel/attachments/20090719/d602a171/attachment.html" target="_blank">http://lists.osgeo.org/pipermail/geos-devel/attachments/20090719/d602a171/attachment.html</a><br>
><br>
> ------------------------------<br>
><br>
> _______________________________________________<br>
> geos-devel mailing list<br>
> <a href="mailto:geos-devel@lists.osgeo.org" target="_blank">geos-devel@lists.osgeo.org</a><br>
> <a href="http://lists.osgeo.org/mailman/listinfo/geos-devel" target="_blank">http://lists.osgeo.org/mailman/listinfo/geos-devel</a><br>
><br>
> End of geos-devel Digest, Vol 81, Issue 15<br>
> ******************************************<br>
><br>
<br>
<br>
<br>
--<br>
"#define QUESTION ((bb) || !(bb))" (Shakespeare)<br>
-------------- next part --------------<br>
An HTML attachment was scrubbed...<br>
URL: <a href="http://lists.osgeo.org/pipermail/geos-devel/attachments/20090720/40ba7c0d/attachment.html" target="_blank">http://lists.osgeo.org/pipermail/geos-devel/attachments/20090720/40ba7c0d/attachment.html</a><br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
geos-devel mailing list<br>
<a href="mailto:geos-devel@lists.osgeo.org" target="_blank">geos-devel@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/geos-devel" target="_blank">http://lists.osgeo.org/mailman/listinfo/geos-devel</a><br>
<br>
End of geos-devel Digest, Vol 81, Issue 17<br>
******************************************<br>
</blockquote></div></div></div><br><br clear="all"><br>-- <br><div><div></div><div class="h5">"#define QUESTION ((bb) || !(bb))" (Shakespeare)<br><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>"#define QUESTION ((bb) || !(bb))" (Shakespeare)<br><br>