Giter VIP home page Giter VIP logo

Comments (7)

ewestern avatar ewestern commented on August 24, 2024

Thanks for making the test!
I think I know the issue. Will try to push something later today.

from geos.

jamiecook avatar jamiecook commented on August 24, 2024

Ack! don't leave me hangin'!!!!

I've been doing some debugging of my own but don't have a solid idea yet - can you give a newbie a 2min version of your idea?

from geos.

ewestern avatar ewestern commented on August 24, 2024

Sure.
The issue (I think!) has to do with the transfer of ownership of individual Geometry objects that belong to a MultiGeometry object.
If you look in Raw.CoordSeq, you'll notice a CoordinateSequence class, that has instances for both CoordSeq and CoordSeqConst.
The idea is that: sometimes you might want a coordinate sequence that lives completely separate from whatever geometry once owned it -- and sometimes you might want to just peek at the value, but let the parent geometry continue to own it.

The same thing needs to be done for Geometry.

What's happening in some cases is that the functions that convert between Haskell types and C types are unclear about whether the sub-geometries they want are ones that maintain parent ownership and ones that do not maintain parent ownership. So in a couple places we're adding a finalizer to an object whose parent (which retains ownership) already has a finalizer attached. The first one deallocates the child object through the parent, and the one attached to the child results in a "pointer being freed was not allocated" error.

The solution that I've started on is creating a Geometry class, which has instances for Geom (a type with a finalizer) and GeomConst (a type without a finalizer). Most functions will use the instance method for accessing these, but certain functions that expect the object to maintain parent ownership can specify that in their type.

Does that make sense?

from geos.

jamiecook avatar jamiecook commented on August 24, 2024

Ah yes it does! And it's not something I would have been able to get to the bottom of easily.

Just to be clear, in general I should be able to (for Polygons say) use the returned objects without being in the Geos monad right? For example:
image

I also emailed you separately to this - do you happen to have any good examples of using the library (esp to talk to PostGIS). I'm thinking that I might be able to help out with drafting some examples into the README, but I'm still a bit unsure whether I'm using the library right.

from geos.

jamiecook avatar jamiecook commented on August 24, 2024

The reason I ask is that even when I use PostGIS to break the multipolygon up into simple polygons

SELECT encode((ST_DUMP(ST_Simplify(wkb_geometry::geometry, 0.01))).geom::geometry(Polygon,4326), 'hex') 
FROM my_table

I get a core dump on that show line ?

image

from geos.

ewestern avatar ewestern commented on August 24, 2024

Have you seen this issue after recent fixes?

from geos.

jamiecook avatar jamiecook commented on August 24, 2024

No i'm pretty sure this was closed off in an earlier PR.

from geos.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.