Comments (14)
A geos prepared geometry is an rtree behind the scenes, yes. So things like point in multipolygon query the tree transparently.
from geo.
FWIW I believe a GEOS prepared geometry indexes every coordinate pair (Line
in geo terminology). This is vastly different than indexing each polygon, especially for large polygons like country/land boundaries. I think what you want is #803.
I think that geo will automatically build in-effect a prepared geometry before doing the intersection, but there's currently no API to allow the user to persist this. So if you're doing repeated intersections I'd expect bad performance compared to GEOS
from geo.
Any way to do a quick test if that makes any difference?
As discussed in #803, https://github.com/georust/geo/compare/mkirk/prepared-geom?expand=1 could be a good starting point.
from geo.
No, but you can decompose the multipolygon into polygons and add them to an rstar spatial index: https://docs.rs/rstar/latest/rstar/struct.RTree.html. The rtree is serializable, re-exported by geo (so it should "just work" for bulk loading the multipolygon Vec), and you can associate extra data with each polygon by using https://docs.rs/rstar/latest/rstar/primitives/struct.GeomWithData.html
from geo.
Thanks, for the tip. Do you know if that is how geos is doing it?
from geo.
I'm trying to add all my Polygons to an RTree, and then check if a point is contained by any of the polygons. But I'm getting this error:
Compiling roaring-landmask v0.7.3 (/home/gauteh/met/roaring-landmask)
error[E0599]: the method `nearest_neighbor` exists for struct `RTree<Polygon>`, but its trait bounds were not satisfied
--> src/shapes.rs:74:28
|
74 | let po = self.geom.nearest_neighbor(&p);
| ^^^^^^^^^^^^^^^^ method cannot be called on `RTree<Polygon>` due to unsatisfied trait bounds
|
::: /home/gauteh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/geo-types-0.7.13/src/geometry/polygon.rs:71:1
|
71 | pub struct Polygon<T: CoordNum = f64> {
| ------------------------------------- doesn't satisfy `geo::Polygon: PointDistance`
|
= note: the following trait bounds were not satisfied:
`geo::Polygon: PointDistance`
gauteh/roaring-landmask@b8e3a21
How can I search through the Polygons and check if the point is contained?
from geo.
I think Polygons
should implement contains_point
, but not PointDistance
. Only contains_point
and envelope-stuff is necessary for this check? Maybe PointDistance
needs to be split.
from geo.
I wrapped the polygons and implemented contains (gauteh/roaring-landmask@60bc592)
The performance is better, but still roughly 1000x worse than geos :/
test shapes::tests::benches::test_contains_in_ocean ... bench: 1,403,390 ns/iter (+/- 175,985)
test shapes::tests::benches::test_contains_on_land ... bench: 1,395,731 ns/iter (+/- 111,216)
from geo.
Can you post a link to your benchmark? I just want to make sure I'm understanding everything here.
from geo.
Hi, the benchmark is here: https://github.com/gauteh/roaring-landmask/blob/685ed6f43e944a604545c452273ded4ab901ce42/src/shapes.rs#L201
You run it with: cargo bench shapes --features nightly, requires python at least 3.10. main branch is with geos, the linked PR is with geo.
Thanks
from geo.
Thanks, that seems like something that needs to be done on geo level. It appears to have got some work, but still require some effort?
from geo.
Would it be enough to persist/cache this intermediate step? Any way to do a quick test if that makes any difference?
from geo.
You can enable serialise / deserialise support for trees by enabling the serde feature on the rstar dependency. I haven't done it myself, but it should be pretty straightforward using something like https://docs.rs/bincode/latest/bincode/
from geo.
It's not the rstar, but what is mentioned here: #1184 (comment) . Rstar didn't help enough.
from geo.
Related Issues (20)
- st_makeline function HOT 2
- Helper for converting between Mercator and Euclidean coordinates HOT 1
- getting one of the closest point for `Closest::Indeterminate` HOT 2
- Consider applying for support from OSGEO or OGC?
- Algorithm to partition a polygon (convex decomposition) using the Hertel-Mehlhorn algorithm HOT 1
- Documentation for monotone-decomposition
- Panic on clip operation HOT 2
- Iām confused about the clip API. Could the operations be more clearly documented? HOT 6
- Add a buffer feature like turfjs HOT 1
- panic on polygon union HOT 1
- Replace HaversineIntermediate with HaversineLineInterpolatePoint and HaversineDensify HOT 2
- Segementize LineString into arbitrary lengths. HOT 4
- Note availability of rstar spatial index early in docs HOT 1
- Merge geo-types and geo crate HOT 5
- BooleanOps panic in `Snake::into_ring`
- Boolean difference causes panic: `segment not found` HOT 6
- Enhance SpadeTriangulation API
- Semantics for AffineTransform composition is reversed HOT 5
- `bounding_rect` comsume a lot of cpu?? HOT 23
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 geo.