Skip to content

precision model or setPrecision #64

@jaakkor2

Description

@jaakkor2

This example is problematic with float precision

using LibGEOS
p1 = LibGEOS.Polygon([[[75.9, 30.7], [79.9, 30.7], [77.9, 28.7], [75.9, 30.7]]]);
p2 = LibGEOS.Polygon([[[81.0, 26.8], [76.0, 26.8], [81.0, 31.8], [81.0, 26.8]]]);
julia> intersects(p1,p2) # should be true
true
julia> touches(p1,p2) # should be true
false
julia> is12 = intersection(p1,p2);
julia> area(is12)
3.552713678800501e-15
julia> writegeom(is12)
"POLYGON ((79.9000000000000057 30.6999999999999993, 77.9000000000000057 28.6999999999999993, 77.9000000000000057 28.7000000000000028, 79.9000000000000057 30.6999999999999993))"
julia> LibGEOS.GEOSGeom_getPrecision(p1.ptr)
-1.0
julia> LibGEOS.GEOSGeom_getPrecision(p2.ptr)
-1.0
using Plots
plot([p1,p2])

libgeos

I cannot figure out usage of setPrecision that does not seem to do anything, this is what I tried

LibGEOS.GEOSGeom_setPrecision(p2.ptr,0.1,0);

There seems to be a precision model in GEOS
https://github.com/libgeos/geos/blob/master/src/geom/PrecisionModel.cpp
but is this exposed in LibGEOS.jl ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions