[geos-devel] about buffer of self-intersect polygon

2010-12-09 Thread xie_jiong
Hi All,

   Dose GEOS supports buffer of self-intersected polygon, just like 'POLYGON 
((2 2,-2 -2,2 -2,-2 2,2 2))'. I get the wrong polygon result with 
GEOSBuffer('POLYGON ((2 2,-2 -2,2 -2,-2 2,2 2))',0.5,8). I use newest verion.
   Thanks.

Jiong___
geos-devel mailing list
geos-devel@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/geos-devel

Re: [geos-devel] about buffer of self-intersect polygon

2010-12-09 Thread strk
On Thu, Dec 09, 2010 at 04:59:24PM +0800, xie_jiong wrote:
 Hi All,
 
Dose GEOS supports buffer of self-intersected polygon, just like 'POLYGON 
 ((2 2,-2 -2,2 -2,-2 2,2 2))'. I get the wrong polygon result with 
 GEOSBuffer('POLYGON ((2 2,-2 -2,2 -2,-2 2,2 2))',0.5,8). I use newest verion.

Self-intersecting polygon is invalid.
Any invalid input is not supposed to yeld meaningful output.
You need to clean the invalidity up.

FYI: PostGIS has a geos-based routing doing a cleanup like this:

# select st_asewkt(st_makevalid('POLYGON ((2 2,-2 -2,2 -2,-2 2,2 2))'));
MULTIPOLYGON(((2 2,0 0,-2 2,2 2)),((0 0,2 -2,-2 -2,0 0)))

You can then successfully buffer the result (getting back to a POLYGON).

--strk;

  ()   Free GIS  Flash consultant/developer
  /\   http://strk.keybit.net/services.html
___
geos-devel mailing list
geos-devel@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/geos-devel


[geos-devel] Help - Want to merge / join two polygons

2010-12-09 Thread Namrata

Hi,

I am exploring GEOS features. I want to know if it is possible to merge or
join 2 polygons?

And if I have MultiplePolygons and want to merge /join them all, is there
any such method in GEOS?

Your kind help is appreciated.

Thanks,
Namrata
-- 
View this message in context: 
http://osgeo-org.1803224.n2.nabble.com/Help-Want-to-merge-join-two-polygons-tp5818592p5818592.html
Sent from the GEOS Developers mailing list archive at Nabble.com.
___
geos-devel mailing list
geos-devel@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/geos-devel


Re: [geos-devel] Help - Want to merge / join two polygons

2010-12-09 Thread strk
On Thu, Dec 09, 2010 at 03:10:00AM -0800, Namrata wrote:
 
 Hi,
 
 I am exploring GEOS features. I want to know if it is possible to merge or
 join 2 polygons?
 
 And if I have MultiplePolygons and want to merge /join them all, is there
 any such method in GEOS?

Sure. See the Union operation.
For a collection, see the Cascaded flavor.

--strk; 

  ()   Free GIS  Flash consultant/developer
  /\   http://strk.keybit.net/services.html
___
geos-devel mailing list
geos-devel@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/geos-devel


Re: [geos-devel] Ruby, FFI and ERROR_/NOTICE_MESSAGE

2010-12-09 Thread Sean Gillies
On Wed, Dec 8, 2010 at 10:34 PM, J Smith dark.panda+li...@gmail.com wrote:
 On Thu, Dec 9, 2010 at 12:09 AM, Charlie Savage c...@savagexi.com wrote:
 I believe that the crux of the problem may be due to GEOS's error
 handlers using varargs, which libffi cannot handle in callbacks
 according to its documentation.

 Just did a quick read of https://github.com/ffi/ffi/wiki/examples and the
 google group. Seems like in general FFI does support varargs.  Are callbacks
 a special case that isn't handled?  How hard do you suppose to get them to
 work?


 I think callbacks are a special case, although the documentation is
 somewhat vague. In the Missing Features section of the info
 documentation, it says:

 There is no support for calling varargs functions.  This may work on
 some platforms, depending on how the ABI is defined, but it is not
 reliable.

 I believe this is referring to callbacks. When setting up a callback
 along these lines...

 attach_function(:initGEOS_r, callback([ :string, :varargs ], :void), :void)
 ...
 FFIGeos.initGEOS_r(
  self.method(:error_handler),
  self.method(:error_handler)
 )
 ...
 def error_handler(*args)
  p(args)
 end

 All you get for the varargs argument is nil and the segfaults and
 weirdness occurs as before. It appears that this is a special case, I
 guess.

 Another option beyond modifying GEOS directly might be to write a
 small native C shim between the CAPI and Ruby and access the error
 messages through that. It might not be ideal, as I think it would be
 preferable to keep the library purely Ruby, but it would be an option
 that wouldn't affect the CAPI or cause any binary compatibility breaks
 should the context handler need to be changed.

 I'll ask around the FFI groups and see what turns up.

 Cheers!

FWIW, here's the GeoDjango approach:

  
http://code.djangoproject.com/browser/django/trunk/django/contrib/gis/geos/libgeos.py#L53

and the Shapely approach:

  https://github.com/sgillies/shapely/blob/master/shapely/geos.py#L148

Shapely by default takes the error messages and sends them to
/dev/null because I didn't find them super useful. Each of the above
use a callback factory from ctypes

  http://docs.python.org/library/ctypes.html#callback-functions
___
geos-devel mailing list
geos-devel@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/geos-devel


Re: [geos-devel] Ruby, FFI and ERROR_/NOTICE_MESSAGE

2010-12-09 Thread J Smith
On Thu, Dec 9, 2010 at 12:32 PM, Sean Gillies sean.gill...@gmail.com wrote:
 FWIW, here's the GeoDjango approach:

  http://code.djangoproject.com/browser/django/trunk/django/contrib/gis/geos/libgeos.py#L53

 and the Shapely approach:

  https://github.com/sgillies/shapely/blob/master/shapely/geos.py#L148

 Shapely by default takes the error messages and sends them to
 /dev/null because I didn't find them super useful. Each of the above
 use a callback factory from ctypes

  http://docs.python.org/library/ctypes.html#callback-functions

I was poking around those projects last night and gave a similar
approach a try by tossing the errors out and relying on return values
from GEOS functions instead, but the problem remains.

I pared everything down to a minimal script to reproduce the problem.
Here's where it gets weird... this is the definition of the
initialization with the notice and error handlers:

def error_handler(*args)
  #print anything
  raise args[0] % args[1]
end

This will cause the segfault/weirdness to occur. However, when you
uncomment the print line, you get no segfault or weirdness. The print
line can even output an empty string so long as you NULL terminate it,
so outputting with 'print \0' will still eliminate the segfaults.

I'll drop a line to the FFI groups when I get a chance and we'll see
how that goes.

Cheers
___
geos-devel mailing list
geos-devel@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/geos-devel


Re: [geos-devel] Ruby, FFI and ERROR_/NOTICE_MESSAGE

2010-12-09 Thread Charlie Savage

Alright, I think it's all good. I posted to the ruby-ffi list and got
back a response already and the prognosis is good! See
http://groups.google.com/group/ruby-ffi/browse_thread/thread/836d6c772d8088dc
, wherein I picked up the science that Mr. Wayne Meissner laid down.


Ah, reading his response, your callbacks were eaten by the garbage 
collector.  That would explain the strange behavior and why commenting 
in and out lines of codes would sometimes change the results.  Sorry, I 
should have put 2 and 2 together based on your earlier description (been 
there done that with those sort of symptoms wrapping other C extensions).




Apparently the garbage collector was collecting some objects that
shouldn't have been collected, so the solution is to store them
somewhere until they can more safely be discarded with. I've patched
things up and stored the error and notice handler return values in
Thread.current and voilà, things started working -- no segfaults, no
weird memory errors. The full test suite is now running crash-free on
both Ruby 1.8.7 and 1.9.2, including a new multithreading test using
multiple WkbWriters, byte orders and dimensions and the whole shebang.


Excellent.


Anyways, things are looking quite good now and we're getting closer to
a usable state! Rad!


Nice work!

Charlie
___
geos-devel mailing list
geos-devel@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/geos-devel