GithubHelp home page GithubHelp logo

juliageo / libgeos.jl Goto Github PK

View Code? Open in Web Editor NEW
69.0 69.0 24.0 829 KB

Julia package for manipulation and analysis of planar geometric objects

License: MIT License

Julia 100.00%
computational-geometry geo geometry geos geospatial gis julia vector

libgeos.jl's People

Contributors

alex-s-gardner avatar dependabot[bot] avatar evetion avatar felixcremer avatar garborg avatar github-actions[bot] avatar jaakkor2 avatar juliatagbot avatar jw3126 avatar mathieu17g avatar maxfreu avatar meggart avatar melonedo avatar nraynaud avatar omritreidel avatar rafaqz avatar simondanisch avatar skygering avatar staticfloat avatar tkelman avatar visr avatar yeesian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libgeos.jl's Issues

writegeom precision vs significant digits on geometries with setPrecision applied

LibGEOS.jl v0.6.6 exposed the WKTWriter options #82, and set the default roundingprecision::Int=-1, i.e., disabled as per https://geos.osgeo.org/doxygen/classgeos_1_1io_1_1WKTWriter.html#a55b7fd9ffcec35f7a4f823a0c9464dce.

Now with LibGEOS.jl v.0.6.6 and GEOS_jll v3.9.0+0

using LibGEOS
p = readgeom("POINT (654321.12345 0.12345)")
p0 = setPrecision(p, 0); # floating precision
writegeom(p0)

gives

"POINT (654321.12345 0.12345)"

but setting the grid size to 0.02

p2 = setPrecision(p, 0.02);
writegeom(p2)

gives

"POINT (6.5e+05 0.12)"

and

p4 = setPrecision(p, 0.0001);
writegeom(p4)
"POINT (6.543e+05 0.1235)"

I.e., huge loss of precision, looks like number of significant digits is coming from the grid size.

However,

writer = LibGEOS.WKTWriter(LibGEOS._context, trim=false, roundingprecision=-1);
writegeom(p2, writer)
"POINT (654321.12 0.12)"

seems to work as expected. But this not

writer = LibGEOS.WKTWriter(LibGEOS._context, trim=true, roundingprecision=-1);
writegeom(p2, writer)
"POINT (6.5e+05 0.12)"

So, somehow it is related to trimming.

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

bug in MultiPoint/MultiLineString

The constructor of MultiPoint and MultiLineString using a Vector of points is broken.
LibGEOS.MultiPoint(Vector{Float64}[[0,0],[10,0],[10,10],[11,10]])
results in the following error

RROR: MethodError: GEOSGeom_createCollection has no method matching GEOSGeom_createCollection(::Int32, ::Ptr{Ptr{Ptr{Void}}}, ::Int64)
Closest candidates are:
GEOSGeom_createCollection(::Int32, ::Ptr{Ptr{Ptr{Void}}}, ::UInt32)

It seems that the problem is that the function createCollection(geomtype::Int, geoms::Vector{GEOSGeom}) uses length(geoms) which returm an Int64 rather than UInt32

create multi geometries from vector of single geometries

using LibGEOS, GeoInterface

# 3 overlapping circles in a triangle
circles = [
    buffer(Point(0.0, 0.0), 1.0),
    buffer(Point(1.0, 0.0), 1.0),
    buffer(Point(0.5, 1.0), 1.0),
]

# now if from these 3 polygons we want to create a single MultiPolygon
# you might expect this to work:
MultiPolygon(circles)
# but you get -> ERROR: LoadError: MethodError: no method matching MultiPolygon(::Vector{Polygon})
# going through the GeoInterface constructor works, but will be less efficient
MultiPolygon(GeoInterface.coordinates(circles))

mutable struct MultiPolygon <: GeoInterface.AbstractMultiPolygon
ptr::GEOSGeom
function MultiPolygon(ptr::GEOSGeom)
multipolygon = new(ptr)
finalizer(destroyGeom, multipolygon)
multipolygon
end
MultiPolygon(multipolygon::Vector{Vector{Vector{Vector{Float64}}}}) =
MultiPolygon(createCollection(GEOS_MULTIPOLYGON,
GEOSGeom[createPolygon(createLinearRing(coords[1]),
GEOSGeom[createLinearRing(c) for c in coords[2:end]])
for coords in multipolygon]))
MultiPolygon(obj::T) where {T<:GeoInterface.AbstractMultiPolygon} = MultiPolygon(GeoInterface.coordinates(obj))
end

This probably goes for all multi geometries, not just multipolygon.

Remaining steps to v0.1.0

  • [README] Installation instructions, after v0.0.3 is tagged in METADATA
  • [README] Travis/Coveralls/PkgEval badges
  • [documentation] provide more examples, perhaps in a separate website
  • [documentation] list exported/public functions and their signatures
  • [ ] change name from LibGEOS.jl to GEOS.jl (see #10)

fix tests on julia 1.5

Julia 1.5 exports a new function, contains: https://github.com/JuliaLang/julia/blob/release-1.5/NEWS.md#new-library-functions

Unfortunately that is one of the functions this package exports. We should check if we define it only for our own types, and if so, extend the base function on Julia 1.5 and higher.

WARNING: both LibGEOS and Base export "contains"; uses of it in module Main must be qualified
GEOS operations: Error During Test at /home/pkgeval/.julia/packages/LibGEOS/ujyzF/test/test_geos_operations.jl:25
  Got exception outside of a @test
  UndefVarError: contains not defined
  Stacktrace:
   [1] top-level scope at /home/pkgeval/.julia/packages/LibGEOS/ujyzF/test/test_geos_operations.jl:225
   [2] top-level scope at /workspace/srcdir/usr/share/julia/stdlib/v1.5/Test/src/Test.jl:1114
   [3] top-level scope at /home/pkgeval/.julia/packages/LibGEOS/ujyzF/test/test_geos_operations.jl:26
   [4] include(::String) at ./client.jl:457
   [5] top-level scope at /home/pkgeval/.julia/packages/LibGEOS/ujyzF/test/runtests.jl:6
   [6] top-level scope at /workspace/srcdir/usr/share/julia/stdlib/v1.5/Test/src/Test.jl:1114
   [7] top-level scope at /home/pkgeval/.julia/packages/LibGEOS/ujyzF/test/runtests.jl:5
   [8] include(::String) at ./client.jl:457
   [9] top-level scope at none:6
   [10] eval(::Module, ::Any) at ./boot.jl:331
   [11] exec_options(::Base.JLOptions) at ./client.jl:272
   [12] _start() at ./client.jl:506
  
Test Summary:              | Pass  Error  Total
LibGEOS                    |  284      1    285
  GEOS functions           |  163           163
  GEOS operations          |   80      1     81
  Geo interface            |   33            33
  LibGEOS regressions      |    6             6
  LibGEOS invalid geometry |    2             2
ERROR: LoadError: Some tests did not pass: 284 passed, 0 failed, 1 errored, 0 broken.
in expression starting at /home/pkgeval/.julia/packages/LibGEOS/ujyzF/test/runtests.jl:4

0.3.0 compilation failure on deps.jl

Pkg.add("LibGEOS") on a 2017-12-13 (d386e40) install of Julia 0.6.2 on Linux Mint 17.3 yields the compilation error

LoadError: BinaryProvider.LibraryProduct("/home/x/.julia/v0.6/LibGEOS/deps/usr/lib", String["libgeos_c"], :libgeos, "Prefix(/home/x/.julia/v0.6/LibGEOS/deps/usr)") is not satisfied, cannot generate deps.jl!
while loading /home/x/.julia/v0.6/LibGEOS/deps/build.jl, in expression starting on line 38

The temporary solution seems to be
Pkg.pin("LibGEOS", v"0.2.1")
Pkg.build("LibGEOS")

but no error occurs on Mint 18.2, which points to libgeos-3.6.1.so and libgeos_c.so.1.10.1 (whereas Mint 17.3 points to libgeos-3.6.2.so and libgeos_c.so.1.10.2)

Polygon() crashed

pts = [[0.,0.],[10.,0.], [10.,10.],[0.,10.] ]
Polygon([pts]) # crashed here

pts = [[0.,0.],[10.,0.], [10.,10.],[0.,10.] ]
Polygon([pts]) # correct

suggestion:
(1) Polygon() should check the input and add the end point if last input point is not same as the first point.
(2) throw an error rather than crash.

running on Win7, Julia 5.0, LibGEOS v0.1.0

Crashes when using @threads with intersection functions

Currently, I have two arrays of type Array{Polygon,1}, called grid_1 and grid_2. I would like to find the intersecting area of every point of grid_1 with every point of grid_2 (i.e., yield a matrix with dimensions length(grid_1) by length(grid_2). I am wondering if there is anyway that may be faster that running a two for loops as follows?

polygon_intersection = Matrix{Float64}(undef,length(grid_1),length(grid_2));
for i = 1:length(grid_1)
    for j = 1:length(grid_2)
        polygon_intersection[i,j] = area(intersection(grid_1[i],grid_2[j]))
    end
end

I was thinking of using something of the form area.(intersection.(grid_1[i],grid_2)) and then only have to loop over one dimension, but that does not appear to be implemented (and I am not sure these array calculations would even be faster than a for loop). Any suggestions are appreciated!

GEOSCoordSeq_isCCW_r() seems to have wrong parameter type

Hi, I'm a beginner at julia, so apologies if I'm wrong.

The last parameter to GEOSCoordSeq_isCCW_r() in the C API is an output boolean parameter called is_ccw and declared char* .
It got translated to Cstring in julia, but by my understanding this is an error because Cstring can't have a null byte in their buffer, and GEOSCoordSeq_isCCW_r() will want to write 0 if the path is not CCW.

I think a Ptr{UInt8} was warranted in this case.

thank you for your good work.

julia API:

is_ccw::Cstring,

C API:
https://libgeos.org/doxygen/geos__c_8h.html#a8f4d265d599fbd41f4149fcf81095b1a

How to write to WKB?

p1 = readgeom("POLYGON((0 0,1 0,1 1,0 0))")
writegeom(p1)

got a WKT string: "POLYGON((0 0,1 0,1 1,0 0))"
but how can i write to WKB, whatever bits string or hex string.

Support for construing object using arrays

It would be great to have support for constructing Polygon, MultiPoints, etc from a simple Julia array.

ext_coords = [0 1 1 0 0; 0 0 1 1 0]
polygon = Polygon(ext_coords)

points = rand(2,5)
mp = MultiPolygon(points)

parseWKT Segmentation fault

parseWKT is segfauling when it is given a polygon that does not close.

p2 = parseWKT("POLYGON((0.0 0.0,1.0 0.0,1.0 1.0,0.0 1.0))")

STRtree Initialization?

Hey, I've been toying around with getting an STRTree initialized, and am running into issues. Any guidance would be appreciated.

I've been looking at using the constructors directly with the tools currently in the library:

using LibGEOS

# Examples from the readme
p1 = readgeom("POLYGON((0 0,1 0,1 1,0 0))")
p2 = readgeom("POLYGON((0 0,1 0,1 1,0 1,0 0))")
p3 = readgeom("POLYGON((2 0,3 0,3 1,2 1,2 0))")

tree = LibGEOS.GEOSSTRtree_create_r(LibGEOS._context.ptr, 3)
LibGEOS.GEOSSTRtree_insert_r(LibGEOS._context.ptr, tree, p1, 1)

But this gives an unsafe_convert(::Type{Ptr{Nothing}}, ::Polygon error at l.1318..

I'm not sure if I fully understand, but

  1. I'd expect typeof(tree) to be LibGEOS.GEOSSTRTree, or Ptr{LibGEOS.GEOSSTRTree}, not Ptr{Nothing}?
  2. Using LibGEOS.GEOSSTRtree_create(3), you always get a null, but with the _r versions, you get a new address every time (which is what I'd expect)

Thanks, & I hope that's clear.

Expose makeValid

I see that there is a function LibGEOS.GEOSMakeValid in the generated code.

Unfortunately, when I call it like LibGEOS.GEOSMakeValid(Ref(p)) where p is a self-intersecting polygon, I get back a null pointer.

This would be a very nice function to have working, but I don't understand how call it (else I would have brought a pull request).

Is there any way to get this to work?

Point(2,3) crashed

p1 = Point( 2, 3 )

the Julia command console crashed.

This may be caused by no existing matching function of Point( x::Int, y::Int ) in geos_types.jl.

running on Win7, Julia 5.0, LibGEOS v0.1.0

prepintersects gives segmentation fault

I see stochastically segmentation faults using Julia v1.1.0 and LibGEOS v0.4.1.

Example below (could be cleaned up, but this is a version that I was able to crash). Weird thing is that if I sleep half a second after the unaryUnion, I cannot crash. Also, instead of sleep, some println statements here and there can help.

using LibGEOS # v0.4.1
function debug_prepintersect()
	p = [LibGEOS.Polygon([100*[[rand(),rand()]] .+ [[0.0,0.0],[2.0,0.0],[2.0,2.0],[0.0,2.0],[0.0,0.0]]]) for t=1:10]
	geoc = readgeom("GEOMETRYCOLLECTION( " * join(writegeom.(p), ',') * " )")
	uu = unaryUnion(geoc)
	# sleep(0.5) # sleeping prevents segmentation fault ?!
	prepgeom = prepareGeom(uu.ptr)
	for i = 1:10000
		a = prepintersects(prepgeom, LibGEOS.Point(100*[rand()-0.5,rand()-0.5]).ptr)
	 	if a 
	 		println(i, " ", a)
	 	end
	end
	nothing
end

after a few calls to debug_prepintersect() I get

julia> debug_prepintersect()
2215 true
4909 true
4961 true

Please submit a bug report with steps to reproduce this fault, and any error messages that follow (in their entirety). Thanks.
Exception: EXCEPTION_ACCESS_VIOLATION at 0x174bb8ef -- envelopesIntersect at /workspace/srcdir/geos-3.6.2/src/geom/prep\BasicPreparedG
in expression starting at no file:0
envelopesIntersect at /workspace/srcdir/geos-3.6.2/src/geom/prep\BasicPreparedGeometry.cpp:43
intersects at /workspace/srcdir/geos-3.6.2/src/geom/prep\PreparedPolygon.cpp:132
GEOSPreparedIntersects_r at /workspace/srcdir/geos-3.6.2/capi\geos_ts_c.cpp:5813
prepintersects at C:\Users\jruohio\.julia\packages\LibGEOS\PHdfr\src\geos_c.jl:794 [inlined]
prepintersects at C:\Users\jruohio\.julia\packages\LibGEOS\PHdfr\src\geos_functions.jl:759
debug_prepintersect at .\REPL[2]:8
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2219
do_call at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:323
eval_value at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:411
eval_stmt_value at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:362 [inlined]
eval_body at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:755
jl_interpret_toplevel_thunk_callback at /home/Administrator/buildbot/worker/package_win64/build/src\interpreter.c:885
unknown function (ip: FFFFFFFFFFFFFFFE)
unknown function (ip: 0000000006468E6F)
unknown function (ip: FFFFFFFFFFFFFFFF)
jl_toplevel_eval_flex at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:764
jl_toplevel_eval at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:773 [inlined]
jl_toplevel_eval_in at /home/Administrator/buildbot/worker/package_win64/build/src\toplevel.c:793
eval at .\boot.jl:328
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2219
eval_user_input at C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.1\REPL\src\REPL.jl:85
run_backend at C:\Users\jruohio\.julia\packages\Revise\yp5KG\src\Revise.jl:769
#58 at .\task.jl:259
jl_fptr_trampoline at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:1864
jl_apply_generic at /home/Administrator/buildbot/worker/package_win64/build/src\gf.c:2219
jl_apply at /home/Administrator/buildbot/worker/package_win64/build/src\julia.h:1571 [inlined]
start_task at /home/Administrator/buildbot/worker/package_win64/build/src\task.c:572
Allocations: 7823481 (Pool: 7822096; Big: 1385); GC: 17

Should this package be renamed to GEOS.jl?

Following the manual in

Guidelines for naming a Package:
[...]
6. Packages that wrap external libraries or programs should be named after those libraries or programs.

  • CPLEX.jl wraps the CPLEX library, which can be identified easily in a web search.
  • MATLAB.jl provides an interface to call the MATLAB engine from within Julia.

@garborg @c42f

segmentation fault when `deepcopy` on LibGEOS.Polygon

I think doing deepcopy on a LibGEOS.Polygon causes (not reliably) a segfault. I will try to produce an example later.

My guess is that a C++ destructor is getting called, but julia still holds a pointer, but I have not looked into it.

Access to `GEOSGeom_getXMin`, `GEOSGeom_getXMax`, `GEOSGeom_getYMin` and `GEOSGeom_getYMax`

@visr I have not found functions giving access to GEOSGeom_getXMin, GEOSGeom_getXMax, GEOSGeom_getYMin and GEOSGeom_getYMax, shall I make a PR with functions wrapping libgoes_api.jl functions like something as below:

function getXMin(ptr::GEOSGeom, context::GEOSContext = _context)
    result = GEOSGeom_getXMin_r(context.ptr, ptr)
    if result == C_NULL
        error("LibGEOS: Error in GEOSGeom_getXMin_r")
    end
    result
end

for geom in (:Point, :MultiPoint, :LineString, :MultiLineString, :LinearRing, :Polygon, :MultiPolygon, :GeometryCollection)
    @eval getXMin(obj::$geom) = getXMin(obj.ptr)
end

Ambiguity in createCoordSeq

There are currently two methods createCoordSeq that accepts 2 integers (since Integer <: Real). This causes

LibGEOS.getCoordinates(LibGEOS.createCoordSeq(1,2))

to return
1-element Array{Array{Float64,1},1}:
[0.0,0.0]

and

LibGEOS.getCoordinates(LibGEOS.createCoordSeq(1.0,2.0))

to return
1-element Array{Array{Float64,1},1}:
[1.0,2.0]

Which is very counter intuitive and also cases a segmentation fault when creating a Point with integers (see #24 )

There are a few ways to fix this. The one I think is most suitable is:
make createCoordSeq(size::Integer, ndim::Integer) privet i.e. _createCoordSeq(size::Integer, ndim::Integer)

Any thought @yeesian ?

Permission to relicense to MIT

LibGEOS.jl is currently licensed under the LGPL v3. All other packages that fall under JuliaGeo have an MIT license, just like the majority of registered Julia package.

With this issue I would like to ask all contributors if they would agree to relicense their contributions to LibGEOS.jl under the MIT license.

The GEOS library that is wrapped has a LGPL v2.1 license, but since that project itself is not modified here, we are not bound to it. In a similar fashion the main Python wrapper of GEOS, Shapely, has a 3-Clause BSD license.

Tagging all contributors so far for a reply:
@yeesian @evetion @OmriRoames @garborg @meggart @staticfloat @SimonDanisch @tkelman

bug in createCoordSeq

createCoordSeq method doesn't work with am input vector

LibGEOS.createCoordSeq([0.0, 2.0])

results in

ERROR: UndefVarError: coord not defined
in createCoordSeq(::Array{Float64,1}) at /home/omri/.julia/v0.5/LibGEOS/src/geos_functions.jl:161

Decide on scope of prepared geometry

Do all normal methods also work on them, i.e. by operating on the .ownedby property? Currently, things like isEmpty are not defined in preparedgeometries.

`parseWKT` gives Segmentation fault

I'm trying to create a polygon from a WKT string which has additional content which makes julia crash.

wkt = "SRID=32756; POLYGON ((481676.5592297933180816 7207446.6192339314147830, 481670.9812610360677354 7207436.6032548164948821, 481656.8734335989574902 7207443.3182328715920448, 481661.5463352609076537 7207453.9481827337294817, 481676.5592297933180816 7207446.6192339314147830))"

p=parseWKT(s)

gives:

signal (11): Segmentation fault
unknown function (ip: (nil))
Segmentation fault

Does parseWKT only support Integer arguments?

This works:

parseWKT("POLYGON((-1. 1., 1. 3., 0. 2., -1. 1.))")

but this fails:

parseWKT("POLYGON((-1. 1., 1. 3., 0. 2., -1. 1.5))")

with

LibGEOS: Error in GEOSGeomFromWKT
geomFromWKT(::String) at geos_functions.jl:21
parseWKT(::String) at geos_operations.jl:25
include_string(::String, ::String) at loading.jl:515
eval(::Module, ::Any) at boot.jl:235
(::Atom.##63#66)() at eval.jl:103
withpath(::Atom.##63#66, ::Void) at utils.jl:30
withpath(::Function, ::Void) at eval.jl:38
macro expansion at eval.jl:102 [inlined]
(::Atom.##62#65{Dict{String,Any}})() at task.jl:80

If this is intentional, what is the suggested use case for polygons that represents spatial objects (e.g. Shapefiles)? These are usually on Float64.

Base.normalize! on v0.4

This function is new on v0.5, and not yet in Compat.jl.

We get this warning on julia v0.4

julia> using LibGEOS
WARNING: could not import Base.normalize! into LibGEOS

After JuliaLang/Compat.jl#253 is merged and tagged, we can take care of this, and bump our required Compat.jl version.

[PkgEval] LibGEOS may have a testing issue on Julia 0.4 (2015-06-24)

PackageEvaluator.jl is a script that runs nightly. It attempts to load all Julia packages and run their tests (if available) on both the stable version of Julia (0.3) and the nightly build of the unstable version (0.4). The results of this script are used to generate a package listing enhanced with testing results.

On Julia 0.4

  • On 2015-06-24 the testing status was N/A - new package.
  • On 2015-06-24 the testing status changed to Tests fail.

This issue was filed because your testing status became worse. No additional issues will be filed if your package remains in this state, and no issue will be filed if it improves. If you'd like to opt-out of these status-change messages, reply to this message saying you'd like to and @IainNZ will add an exception. If you'd like to discuss PackageEvaluator.jl please file an issue at the repository. For example, your package may be untestable on the test machine due to a dependency - an exception can be added.

Test log:

>>> 'Pkg.add("LibGEOS")' log
INFO: Cloning cache of LibGEOS from git://github.com/JuliaGeo/LibGEOS.jl.git
INFO: Installing LibGEOS v0.0.1
INFO: Package database updated

>>> 'Pkg.test("LibGEOS")' log
INFO: Testing LibGEOS
ERROR: LoadError: LoadError: LoadError: ArgumentError: GeoInterface not found in path
 in require at ./loading.jl:48
 in include at ./boot.jl:254
 in include_from_node1 at ./loading.jl:133
 in reload_path at ./loading.jl:157
 in _require at ./loading.jl:69
 in require at ./loading.jl:52
 in include at ./boot.jl:254
 in include_from_node1 at ./loading.jl:133
 in include at ./boot.jl:254
 in include_from_node1 at loading.jl:133
 in process_options at ./client.jl:304
 in _start at ./client.jl:404
while loading /home/vagrant/.julia/v0.4/LibGEOS/src/LibGEOS.jl, in expression starting on line 5
while loading /home/vagrant/.julia/v0.4/LibGEOS/test/test_geos_functions.jl, in expression starting on line 1
while loading /home/vagrant/.julia/v0.4/LibGEOS/test/runtests.jl, in expression starting on line 1

===============================[ ERROR: LibGEOS ]===============================

failed process: Process(`/home/vagrant/julia/bin/julia --check-bounds=yes --code-coverage=none --color=no /home/vagrant/.julia/v0.4/LibGEOS/test/runtests.jl`, ProcessExited(1)) [1]

================================================================================
INFO: No packages to install, update or remove
ERROR: LibGEOS had test errors
 in error at ./error.jl:21
 in test at pkg/entry.jl:746
 in anonymous at pkg/dir.jl:31
 in cd at file.jl:22
 in cd at pkg/dir.jl:31
 in test at pkg.jl:71
 in process_options at ./client.jl:280
 in _start at ./client.jl:404


>>> End of log

GEOS version mismatch

Minor thing now, compat of GEOS_jll
https://github.com/JuliaGeo/LibGEOS.jl/blob/v0.6.6/Project.toml#L13

GEOS_jll = "3.8"

allows GEOS_jll update to 3.9. Then

julia> LibGEOS.GEOSversion()
"3.9.0-CAPI-1.16.2"

julia> LibGEOS.GEOS_CAPI_VERSION
"3.8.0-CAPI-1.13.1"

Compat could be a bit more strict defining the jll version to match the library version when https://github.com/JuliaGeo/LibGEOS.jl/blob/master/gen/wrap_geos.jl was last run. In this case

GEOS_jll = "~3.8"

That said, I am happy about the speed improvements in GEOS_jll v3.9.0+0 vs v3.8.1+0 that the present compat allows.

Add `LineString` constructors based on `Point`s and `LineString`s

@visr what about adding LineString constructors based on Points and LineStrings?

It could look like:

LineString(ls::LineString, pt::Point) = LineString([coordinates(ls); [coordinates(pt)]])
LineString(ls::LineString, pt1::Point, pt2::Point, pts::Vararg{Point}) = LineString(LineString(ls, pt1), pt2, pts...)
LineString(pt1::Point, pt2::Point) = LineString([coordinates(pt1), coordinates(pt2)])
LineString(pt1::Point, pt2::Point, pt3::Point, pts::Vararg{Point}) = LineString(LineString(pt1, pt2), pt3, pts...)

This may be extended to other geometry types

GEOSConstrainedDelaunayTriangulation_r loops forever on a valid polygon

Hi, I reported this issue on GEOS (libgeos/geos#653 ), but it actually seems to be linked to julia.
I have a polygon that sends GEOSConstrainedDelaunayTriangulation_r into a tailspin when called from julia (infinite loop that globles more and more memory over time).

I packaged my test here: https://gist.github.com/nraynaud/6dfbb78d94e1598d0f29d54f70722288

my computer is an Intel macbook pro

$ uname -a
Darwin macreuse.local 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64 x86_64

here is my test program:

import LibGEOS

wkt = open("weird_polygon.wkt") do file
    read(file, String)
end
poly = LibGEOS.readgeom(wkt)
@show "before tri"
@show LibGEOS.isValid(poly)
LibGEOS.GEOSConstrainedDelaunayTriangulation_r(LibGEOS._context.ptr, poly.ptr)
@show "after tri"

here is the devilish polygon:
tri

POLYGON ((1.7862685046962532 0.2923021911868067, 1.7728389809573666 0.2627438719792648, 1.746100000000001 0.2334000000000009, 1.7150804631420686 0.2161586105737922, 1.6759 0.209, 0.3241 0.209, 0.2840389403162291 0.2165244534091589, 0.26281199593527 0.2271117271007482, 0.2451970039279606 0.2409124780256404, 0.220203873371505 0.2753019366857534, 0.2119959512407714 0.2984989878101932, 0.209 0.3233, 0.209 1.6759, 0.2114712418577923 1.6990146526776198, 0.2178177033571282 1.7193153375833403, 0.2407676132817306 1.7547086448098228, 0.2571000000000007 1.7690000000000003, 0.2775992176450858 1.7808316429453195, 0.3030606643061082 1.7889360141633408, 0.324 1.791, 1.676 1.791, 1.715794594594594 1.7835675675675677, 1.7371880040647283 1.7728882728992528, 1.755414722418766 1.7584861946606423, 1.7697324306821693 1.7419033500911634, 1.7821822966428729 1.7193153375833379, 1.7885287581422071 1.699014652677622, 1.7908999998269444 1.6775046880767683, 1.7909999998269444 0.3230046880767684, 1.7862685046962532 0.2923021911868067), (0.691 0.9229754642711925, 0.691 0.7011541640387603, 0.6936627376889104 0.6937321576162595, 0.7020245357288075 0.691, 0.9238458359612397 0.691, 0.9312678423837405 0.6936627376889104, 0.934 0.7020245357288075, 0.934 0.9238458359612397, 0.9313372623110896 0.9312678423837405, 0.9229893209534975 0.9339991155309167, 0.6990442469761068 0.9339012801993407, 0.693329984148253 0.9309041524224672, 0.691 0.9229754642711925), (0.6953392867391299 1.067444033745615, 0.9259557530238928 1.0660987198006593, 0.9315698728030161 1.0689552959301913, 0.9339991155309167 1.0770106790465024, 0.9339012801993407 1.3009557530238929, 0.9315721240202081 1.3060497565109876, 0.9229893209534982 1.3089991155309166, 0.6990442469761072 1.3089012801993407, 0.6934301271969839 1.3060447040698087, 0.691 1.2983866353711833, 0.691 1.0758139687976573, 0.6953392867391299 1.067444033745615), (1.3031380819680736 0.6915341696737235, 1.3089993838262433 0.7013965510439816, 1.3089012068069301 0.9261237482521002, 1.30633726231109 0.93126784238374, 1.2986034489560137 0.9339993838262434, 1.0738762517478988 0.9339012068069299, 1.0687321576162598 0.9313372623110899, 1.0659999999999998 0.923589585046487, 1.0659999999999998 0.7011541640387645, 1.0689552959301913 0.6934301271969839, 1.0770245357288075 0.691, 1.3031380819680736 0.6915341696737235), (1.0690958475775336 1.068329984148252, 1.076410414953513 1.0659999999999998, 1.2991860312023409 1.0659999999999998, 1.3065698728030166 1.0689552959301918, 1.3090000000000002 1.0770245357288104, 1.3090000000000002 1.2988458359612356, 1.3063372623110892 1.306267842383741, 1.2986034489560183 1.3089993838262433, 1.0738762517478997 1.3089012068069301, 1.068732157616259 1.3063372623110892, 1.0660006161737567 1.2986034489560183, 1.0660987931930699 1.0738762517478997, 1.0690958475775336 1.068329984148252))

here is the console result on the Apple computer:

$ julia --project=. -L test.jl 
"before tri" = "before tri"
LibGEOS.isValid(poly) = true
^C
signal (15): Terminated: 15
in expression starting at /Users/nraynaud/dev/test_delaunay/test.jl:9
_ZN4geos11triangulate7polygon17PolygonHoleJoiner18getLeftShellVertexERKNS_4geom10CoordinateE at /Users/nraynaud/.julia/artifacts/a0d7cbd6dcc9500ac170de3fc30cb2373349205e/lib/libgeos.3.10.2.dylib (unknown line)
_ZN4geos11triangulate7polygon17PolygonHoleJoiner8joinHoleEPKNS_4geom10LinearRingE at /Users/nraynaud/.julia/artifacts/a0d7cbd6dcc9500ac170de3fc30cb2373349205e/lib/libgeos.3.10.2.dylib (unknown line)
_ZN4geos11triangulate7polygon17PolygonHoleJoiner9joinHolesEv at /Users/nraynaud/.julia/artifacts/a0d7cbd6dcc9500ac170de3fc30cb2373349205e/lib/libgeos.3.10.2.dylib (unknown line)
_ZN4geos11triangulate7polygon17PolygonHoleJoiner7computeEv at /Users/nraynaud/.julia/artifacts/a0d7cbd6dcc9500ac170de3fc30cb2373349205e/lib/libgeos.3.10.2.dylib (unknown line)
_ZN4geos11triangulate7polygon17PolygonHoleJoiner4joinEPKNS_4geom7PolygonE at /Users/nraynaud/.julia/artifacts/a0d7cbd6dcc9500ac170de3fc30cb2373349205e/lib/libgeos.3.10.2.dylib (unknown line)
_ZN4geos11triangulate7polygon31ConstrainedDelaunayTriangulator18triangulatePolygonEPKNS_4geom7PolygonERNS0_3tri7TriListE at /Users/nraynaud/.julia/artifacts/a0d7cbd6dcc9500ac170de3fc30cb2373349205e/lib/libgeos.3.10.2.dylib (unknown line)
_ZN4geos11triangulate7polygon31ConstrainedDelaunayTriangulator7computeEv at /Users/nraynaud/.julia/artifacts/a0d7cbd6dcc9500ac170de3fc30cb2373349205e/lib/libgeos.3.10.2.dylib (unknown line)
_ZN4geos11triangulate7polygon31ConstrainedDelaunayTriangulator11triangulateEPKNS_4geom8GeometryE at /Users/nraynaud/.julia/artifacts/a0d7cbd6dcc9500ac170de3fc30cb2373349205e/lib/libgeos.3.10.2.dylib (unknown line)
GEOSConstrainedDelaunayTriangulation_r at /Users/nraynaud/.julia/artifacts/a0d7cbd6dcc9500ac170de3fc30cb2373349205e/lib/libgeos_c.1.16.0.dylib (unknown line)
GEOSConstrainedDelaunayTriangulation_r at /Users/nraynaud/.julia/packages/LibGEOS/VT0Ub/src/libgeos_api.jl:866
unknown function (ip: 0x10a7bd6a6)
jl_apply_generic at /usr/local/Cellar/julia/1.7.3/lib/julia/libjulia-internal.1.7.dylib (unknown line)
do_call at /usr/local/Cellar/julia/1.7.3/lib/julia/libjulia-internal.1.7.dylib (unknown line)
eval_body at /usr/local/Cellar/julia/1.7.3/lib/julia/libjulia-internal.1.7.dylib (unknown line)
jl_interpret_toplevel_thunk at /usr/local/Cellar/julia/1.7.3/lib/julia/libjulia-internal.1.7.dylib (unknown line)
jl_toplevel_eval_flex at /usr/local/Cellar/julia/1.7.3/lib/julia/libjulia-internal.1.7.dylib (unknown line)
jl_toplevel_eval_flex at /usr/local/Cellar/julia/1.7.3/lib/julia/libjulia-internal.1.7.dylib (unknown line)
jl_toplevel_eval_in at /usr/local/Cellar/julia/1.7.3/lib/julia/libjulia-internal.1.7.dylib (unknown line)
eval at ./boot.jl:373 [inlined]
include_string at ./loading.jl:1196
jl_apply_generic at /usr/local/Cellar/julia/1.7.3/lib/julia/libjulia-internal.1.7.dylib (unknown line)
_include at ./loading.jl:1253
include at ./Base.jl:418 [inlined]
exec_options at ./client.jl:275
_start at ./client.jl:495
jfptr__start_38713.clone_1 at /usr/local/Cellar/julia/1.7.3/lib/julia/sys.dylib (unknown line)
jl_apply_generic at /usr/local/Cellar/julia/1.7.3/lib/julia/libjulia-internal.1.7.dylib (unknown line)
true_main at /usr/local/Cellar/julia/1.7.3/lib/julia/libjulia-internal.1.7.dylib (unknown line)
jl_repl_entrypoint at /usr/local/Cellar/julia/1.7.3/lib/julia/libjulia-internal.1.7.dylib (unknown line)
unknown function (ip: 0x0)
Allocations: 1424748 (Pool: 1424062; Big: 686); GC: 2
fatal: error thrown and no exception handler available.
InterruptException()
jl_get_binding_ at /usr/local/Cellar/julia/1.7.3/lib/julia/libjulia-internal.1.7.dylib (unknown line)
jl_get_global at /usr/local/Cellar/julia/1.7.3/lib/julia/libjulia-internal.1.7.dylib (unknown line)
jl_atexit_hook at /usr/local/Cellar/julia/1.7.3/lib/julia/libjulia-internal.1.7.dylib (unknown line)
jl_exit at /usr/local/Cellar/julia/1.7.3/lib/julia/libjulia-internal.1.7.dylib (unknown line)
jl_exit_thread0_cb at /usr/local/Cellar/julia/1.7.3/lib/julia/libjulia-internal.1.7.dylib (unknown line)

here is me running the same operation in geos (Apple):

$ geosop 
geosop - GEOS 3.11.0
Executes GEOS geometry operations
Usage:
[...]
$ time geosop -a weird_polygon.wkt constrainedDelaunay -f wkt >/dev/null

real	0m0.005s
user	0m0.003s
sys	0m0.001s

here is the result in a Linux VM (same underlying computer):

$ ~/julia-1.7.3/bin/julia --project=.  -L test.jl 
"before tri" = "before tri"
LibGEOS.isValid(poly) = true
ERROR: LoadError: GEOSError
	std::bad_alloc
Stacktrace:
 [1] geosjl_errorhandler(message::Ptr{UInt8}, userdata::Ptr{Nothing})
   @ LibGEOS ~/.julia/packages/LibGEOS/VT0Ub/src/LibGEOS.jl:106
 [2] GEOSConstrainedDelaunayTriangulation_r(handle::Ptr{Nothing}, g::Ptr{Nothing})
   @ LibGEOS ~/.julia/packages/LibGEOS/VT0Ub/src/libgeos_api.jl:866
 [3] top-level scope
   @ /vagrant/test.jl:9
in expression starting at /vagrant/test.jl:9
vagrant@vagrant:/vagrant$ uname -a
Linux vagrant 4.15.0-58-generic #64-Ubuntu SMP Tue Aug 6 11:12:41 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

an extract of Manifest.toml:

julia_version = "1.7.3"
manifest_format = "2.0"


[[deps.GEOS_jll]]
deps = ["Artifacts", "JLLWrappers", "Libdl", "Pkg"]
git-tree-sha1 = "4ceb4cdae127931b852ced4d3782bb51ab5e2632"
uuid = "d604d12d-fa86-5845-992e-78dc15976526"
version = "3.10.2+0"


[[deps.LibGEOS]]
deps = ["CEnum", "GEOS_jll", "GeoInterface"]
git-tree-sha1 = "b1506853804fb55b998eb61b66d3afb089dbfa28"
uuid = "a90b1aa1-3769-5649-ba7e-abc5a9d163eb"
version = "0.6.12"

Thank you for your nice library.

lineMerge ?

it seems that lineMerge is not exposed in the operations file, is there a reason?
do you have a workaround?

thank you for your work.

precision model or setPrecision

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 ?

`createCollection` in geos operations

I would like to add createCollection to geos operations with a signature like:

MULTIPART_GEOMETRY_TYPES = Union{LG.MultiPoint, LG.MultiLineString, LG.MultiPolygon, LG.GeometryCollection}
function createCollection(T<:MULTIPART_GEOMETRY_TYPES, geomvec::Vector{GI.AbstractGeometry}, context::GEOSContext = _context)
    ...
end

segmentation fault in Point constructor

I'm getting a seg fault when I'm creating a point with integers

Point(2, 3)

results in

signal (11): Segmentation fault
while loading no file, in expression starting on line 0
unknown function (ip: 0xffffffffffffffff)
Type at /home/omri/.julia/v0.5/LibGEOS/src/geos_types.jl:10
unknown function (ip: 0x7fd1367347cc)
jl_call_method_internal at /build/julia-c0WfgE/julia-0.5.0/src/julia_internal.h:189 [inlined]
jl_apply_generic at /build/julia-c0WfgE/julia-0.5.0/src/gf.c:1942
do_call at /build/julia-c0WfgE/julia-0.5.0/src/interpreter.c:66
eval at /build/julia-c0WfgE/julia-0.5.0/src/interpreter.c:190
jl_toplevel_eval_flex at /build/julia-c0WfgE/julia-0.5.0/src/toplevel.c:558 [inlined]
jl_toplevel_eval at /build/julia-c0WfgE/julia-0.5.0/src/toplevel.c:580
jl_toplevel_eval_in_warn at /build/julia-c0WfgE/julia-0.5.0/src/builtins.c:590
eval at ./boot.jl:234
unknown function (ip: 0x7fd34530f67f)
jl_call_method_internal at /build/julia-c0WfgE/julia-0.5.0/src/julia_internal.h:189 [inlined]
jl_apply_generic at /build/julia-c0WfgE/julia-0.5.0/src/gf.c:1942
eval_user_input at ./REPL.jl:64
unknown function (ip: 0x7fd13672cdb6)
jl_call_method_internal at /build/julia-c0WfgE/julia-0.5.0/src/julia_internal.h:189 [inlined]
jl_apply_generic at /build/julia-c0WfgE/julia-0.5.0/src/gf.c:1942
macro expansion at ./REPL.jl:95 [inlined]
#3 at ./event.jl:68
unknown function (ip: 0x7fd136729f2f)
jl_call_method_internal at /build/julia-c0WfgE/julia-0.5.0/src/julia_internal.h:189 [inlined]
jl_apply_generic at /build/julia-c0WfgE/julia-0.5.0/src/gf.c:1942
jl_apply at /build/julia-c0WfgE/julia-0.5.0/src/julia.h:1392 [inlined]
start_task at /build/julia-c0WfgE/julia-0.5.0/src/task.c:253
unknown function (ip: 0xffffffffffffffff)
Allocations: 2023301 (Pool: 2022391; Big: 910); GC: 1
Segmentation fault

[PkgEval] LibGEOS may have a testing issue on Julia 0.3 (2015-06-24)

PackageEvaluator.jl is a script that runs nightly. It attempts to load all Julia packages and run their tests (if available) on both the stable version of Julia (0.3) and the nightly build of the unstable version (0.4). The results of this script are used to generate a package listing enhanced with testing results.

On Julia 0.3

  • On 2015-06-24 the testing status was N/A - new package.
  • On 2015-06-24 the testing status changed to Tests fail.

This issue was filed because your testing status became worse. No additional issues will be filed if your package remains in this state, and no issue will be filed if it improves. If you'd like to opt-out of these status-change messages, reply to this message saying you'd like to and @IainNZ will add an exception. If you'd like to discuss PackageEvaluator.jl please file an issue at the repository. For example, your package may be untestable on the test machine due to a dependency - an exception can be added.

Test log:

>>> 'Pkg.add("LibGEOS")' log
INFO: Cloning cache of LibGEOS from git://github.com/JuliaGeo/LibGEOS.jl.git
INFO: Installing LibGEOS v0.0.1
INFO: Package database updated

>>> 'Pkg.test("LibGEOS")' log
INFO: Testing LibGEOS
ERROR: GeoInterface not found
 in require at loading.jl:47
 in include at ./boot.jl:245
 in include_from_node1 at ./loading.jl:128
 in reload_path at loading.jl:152
 in _require at loading.jl:67
 in require at loading.jl:51
 in include at ./boot.jl:245
 in include_from_node1 at ./loading.jl:128
 in include at ./boot.jl:245
 in include_from_node1 at loading.jl:128
 in process_options at ./client.jl:285
 in _start at ./client.jl:354
while loading /home/vagrant/.julia/v0.3/LibGEOS/src/LibGEOS.jl, in expression starting on line 5
while loading /home/vagrant/.julia/v0.3/LibGEOS/test/test_geos_functions.jl, in expression starting on line 1
while loading /home/vagrant/.julia/v0.3/LibGEOS/test/runtests.jl, in expression starting on line 1

===============================[ ERROR: LibGEOS ]===============================

failed process: Process(`/home/vagrant/julia/bin/julia /home/vagrant/.julia/v0.3/LibGEOS/test/runtests.jl`, ProcessExited(1)) [1]

================================================================================
INFO: No packages to install, update or remove
ERROR: LibGEOS had test errors
 in error at error.jl:21
 in test at pkg/entry.jl:718
 in anonymous at pkg/dir.jl:28
 in cd at ./file.jl:20
 in cd at pkg/dir.jl:28
 in test at pkg.jl:67
 in process_options at ./client.jl:213
 in _start at ./client.jl:354


>>> End of log

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.