Coder Social home page Coder Social logo

Comments (5)

vfn avatar vfn commented on May 16, 2024

@biomiker have you had a chance to look at this issue? Do you think you could fix it and create a PR?

from geoswift.

johncrenshaw avatar johncrenshaw commented on May 16, 2024

I just ran into this and came here looking to see if it was a known issue. The problem is that LinearRing creates the underlying geometry using GEOSGeom_createLineString_r(), but GEOSGeom_createPolygon_r() requires that the shell and holes be created using GEOSGeom_createLinearRing_r().

I can confirm that adding a convenience initializer to LinearRing and and using GEOSGeom_createLinearRing_r() in that initializer resolves the problem.

This is what LinearRing looks like with the fix:

open class LinearRing : LineString {
    
    public convenience init?(points: [Coordinate]) {
        let seq = GEOSCoordSeq_create_r(GEOS_HANDLE, UInt32(points.count), 2)
        for (i,coord) in points.enumerated() {
            GEOSCoordSeq_setX_r(GEOS_HANDLE, seq, UInt32(i), coord.x)
            GEOSCoordSeq_setY_r(GEOS_HANDLE, seq, UInt32(i), coord.y)
        }
        guard let GEOSGeom = GEOSGeom_createLinearRing_r(GEOS_HANDLE, seq) else {
            return nil
        }
        self.init(GEOSGeom: GEOSGeom, destroyOnDeinit: true)
    }
    
}

from geoswift.

vfn avatar vfn commented on May 16, 2024

@johncrenshaw could you create a pull request with this change and tests? Thanks!

from geoswift.

vfn avatar vfn commented on May 16, 2024

@johncrenshaw Thank you for creating the pull request.

I have made a minor change and created a PR on your repo. Please have a look at it, and if you're happy with it, update your PR and we can merge it. Let me know your thoughts

johncrenshaw#1

from geoswift.

vfn avatar vfn commented on May 16, 2024

Fixed by #50

from geoswift.

Related Issues (20)

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.