Closed jamiecook closed 7 years ago
I went ahead and added these and cleaned up some examples where the code was assuming the type of the geometry. I think it's a bit clearer at application time, but it does add more exports to the main library
Hey Peter - at work we're running into problems with doing some simple spatial queries... basically a
foo :: Vector (Thing A that has a Geometry Polygon) -> Vector (Thing B that has Geometry Point) -> Map (Thing A) (Vector (Thing B))
foo as bs = Map.fromList $ fmap bar as
where bar a = (a, V.filter baz bs)
baz b = G.contains a b
That's rough psuedo code but the version i have compiles fine and runs... but will get a random way through the list and then fail with a seg fault - running multiple times it will get different lengths through the list before crashing. Chopping the list in half and doing it in two hits will work but it's obvious something is a bit wrong... I thought it might be the fact that so many geos contexts were being created and destroyed that something has overflown... but I can't be sure (polygons are here https://gist.github.com/jamiecook/68c723c56b6f0269b4bd57ac11834977 if you think this might be a good example to build into a test?).
Anyway, long story short, I thought I'd give the STR tree a go, as it's better suited to this workload when you have lots of data but realised that the implementation was incomplete. I've started giving it a crack and had some success (added a basic test and got it passing)... but i'm getting confused with all the branches floating around (mine is built on top of your PR branch)... so I just stuck my impl here... probably not the best place for it sorry.
Is there anything I can do to help get the various branches back into a merged state?
Glad the STR Tree helps out with that use case, but I definitely need to get the seg fault fixed when using normal geometries. I'll try to make a reproducible test case with your geometries.
I'll try to get the other PRs merged in. After I do, mind putting the STRTree stuff on its own branch? Thanks.
Ahh, I foolishly did a squash-merge when merging peter/pr-3 into master, yielding a bunch of conflicts when changing the base branch of this. Will try to resolve.
Replaced this dumpster fire with PRs #10 and #11
Would helpers like these be useful more generally than in the testing? It would allow us to add an actual error instead of just getting a non-exhaustive pattern match failure