Comments (9)
--alternative temp fix--
You can try reducing floating point precision to 6 decimal place (which is about 111mm), this will return a valid output and preserve the overall topology.
reference implementation:
func ReducePrecision(g geom.Geometry, decimalPlace int) geom.Geometry {
processPoint := func(xy geom.XY) geom.XY {
ratio := math.Pow(10, float64(decimalPlace))
x := math.Round(xy.X*ratio) / ratio
y := math.Round(xy.Y*ratio) / ratio
return geom.XY{X: x, Y: y}
}
return g.TransformXY(processPoint)
}
https://go.dev/play/p/nckAWTeE8gR
from simplefeatures.
Thank you for the detailed bug report, I should get some time to take a look at this soon.
from simplefeatures.
Having CGO is not too much of a problem, like on a CI it's okay, but the burden to maintain it for every developers environments, Mac windows ... is a bigger task, having the default build flag using the native not optimized Go would be the best option and a geos build tag for the CGO one.
But I remember you had a different API between geos and geom, which would make this difficult to implement it like that.
Thanks again for all the help, we are using your lib and it performs really well, most of the time using the native Go anyway.
from simplefeatures.
FYI the resulting polygon is probably invalid.
They visually look contiguous, but they are not, and they're actually only touching in 2 points.
from simplefeatures.
I've tested your fix branch on the same dataset, with success. Thank you.
from simplefeatures.
Thanks for testing! FYI I've created a new tag v0.42.0
that contains the panic fix.
I haven't worked out a fix for the root cause of the issue -- that's something I still intend to look into.
In the meantime, you may wish to look into using the Union wrapper from the GEOS C library. It handles those geometry without giving an error.
from simplefeatures.
A fix for the root cause has been added in v0.46.0.
from simplefeatures.
Thanks for the heads up, we switched to geos. Do you recommend moving back to the Go implementation?
from simplefeatures.
The main reasons you may wish to switch back to the Go implementation (and avoid the GEOS dependency) would be if you:
- You wish to avoid the dependency on the GEOS C++ library (and CGO in general). The GEOS dependency can potentially be annoying to manage (depending on your setup). E.g. getting all developers on your team to install the same version locally. It can be difficult to get a recent version of GEOS if you're stuck on an older base image (assuming you're using docker for deployments).
- CGO in general degrades much of the Go experience. Builds become slower and more complicated, cross-compilation becomes more difficult, some tools stop working (e.g. profiling).
The main reason to stay with the geos
package:
- It's faster than the Go implementation.
- In my experience, the latest version (v3.11 and onwards) is very stable with regard to the correctness of results (earlier versions have a lot of miscellaneous problems). It's used much more widely than the Go implementation in simplefeatures, so is better battle-hardened.
If the drawbacks of the geos
package and the CGO/GEOS dependency are not too bad for you, I'd recommend staying with geos
.
from simplefeatures.
Related Issues (20)
- Use multiple versions of GEOS in CI
- Add Envelope to rtree.Box helper
- Add a `String() string` method to envelope
- Update golangci-lint to use latest version
- Move benchmarks into a single package
- Unify GEOS wrappers
- Use generics internally
- Separate TWKB Unmarshallers
- Remove unneeded benchmarks
- Use alpine images for GEOS testing
- No rings error on intersection error HOT 4
- Rewrite GEOS reference implementation tests
- geom.Union failed at some cases HOT 3
- Use symmetric line/line intersection
- Coordinate type not retained for simplified empty geometries
- Function for NewCoordinates HOT 2
- Add GeoJSON Feature "foreign member" support
- Some versions of GEOS don't include a `geos.pc` file HOT 1
- Instruction to use GEOS HOT 5
- Building GEOS on Windows. HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from simplefeatures.