[geos-devel] GeometryFactory - call for explanation

strk at refractions.net strk at refractions.net
Fri Mar 31 03:06:04 EST 2006


I'm in favour of this, but it would be an immutable
instance, using a FLOATING PrecisionModel.
There is already one in Geometry::INTERNAL_FACTORY, I
would change it's access method to GeometryFactory::defaultInstance()
and ensure constness.

--strk;

On Thu, Mar 30, 2006 at 06:20:58PM -0700, Charlie Savage wrote:
> While on the subject of geometry factories....
> 
> Would it be possible to add a global, default factory?  This would be 
> very helpful when accessing GEOS from scripting languages like ruby and 
> python.
> 
> The first issue it would solve is worrying about keeping geometry 
> factories alive for longer than the geometries themselves.  This is 
> tricker than it sounds because at least in Ruby you're dealing with a 
> mark and sweep garbage collector.  So what I do in Ruby is create a 
> global factory and always use that.
> 
> However, that solution breaks down when dealing with marshaling 
> objects.  Ruby has the concept of marshal/unmarshal like a lot of other 
> languages.  Since GEOS is in C, these methods need to be implemented in 
> C++ (as part of the SWIG bindings).  Thus, since I'm in C++ I don't have 
> easy access to the geometry factory I created on the Ruby side.  Thus in 
> C++ I can create a GeometryFactory as a global of some sort fully 
> realizing it will never be freed and thus leak memory.  The alternative 
> is worse, create the factory, create the geometry, free the factory, get 
> a segmentation fault.  For the moment, I go with a static variable in 
> the SWIG bindings...would be nice to get something like this officially 
> supported.
> 
> Of course, removing the dependency between geometries and factories 
> would be even better.  I have no idea if its possible since I haven't 
> looked at that part of the code - but it is a bit annoying having the 
> back reference from geometries to factories to have to worry about.
> 
> Charlie
> 
> 
> Mateusz Łoskot wrote:
> >Hi,
> >
> >Could anyone explain/confirm me assumptions behind
> >the GeometryFactory class?
> >Depending on its semantic I'd have some proposal to refactor it.
> >Here are my qusetions:
> >
> >Are following assumptions correct?
> >
> >1. Ever instance of Geometry type (or its subtype) can have assigned its
> >own instance of GeometryFactory
> >
> >2. One instance of GeometryFactory class can be shared (assigned to)
> >between more than one objects of Geometry class
> >
> >3. It is not assumed that all geometries share the same
> >common instance of GeometryFactory
> >
> >Thanks in advance for comments
> >Cheers
> >  



> _______________________________________________
> geos-devel mailing list
> geos-devel at geos.refractions.net
> http://geos.refractions.net/mailman/listinfo/geos-devel


-- 

 /"\    ASCII Ribbon Campaign
 \ /    Respect for low technology.
  X     Keep e-mail messages readable by any computer system.
 / \    Keep it ASCII. 




More information about the geos-devel mailing list