thomersch / grandine

Processing geo data is no fun. Grandine changes this.
Apache License 2.0
53 stars 3 forks source link

Remove GEOS Dependency by implementing own clipping algorithm #2

Open thomersch opened 7 years ago

thomersch commented 7 years ago

Unfortunately my attempt of implementing polygon clipping (intersecting bbox and polygon) failed miserably, because I kept having issues with real world examples. To be able to process polygons I started using GEOS, the geospatial library. The big downside of this approach is that GEOS is not very fast as it needs cgo to call its C-interface which has a high overhead for this kind of usage. Using C libraries also makes cross-compilation more cumbersome.

I would like to have a pure Go polygon intersection implementation. An implementation of a third-party package could be viable, if the process of converting the data structure doesn't have a too big overhead.

thomersch commented 7 years ago

Just added a benchmark in b07134aa530512c744c1d08d2230e0689b9687df, which shows how horrible it is:

 BenchmarkClipToBBox-8 1000 1675839 ns/op 56635 B/op 735 allocs/op
thomersch commented 6 years ago

I implemented polyclip-go, which is a Golang implementation of the Martinez clipping algorithm, in a branch, but this turned out to be broken and produce invalid geometries.

Still looking for a suitable replacement library.