Sander Vocke
Sander Vocke

Reputation: 135

Can a "points inside single geometry" query be sped up using a spatial index?

I am using SpatiaLite (or rather, its WebAssembly port SpatiaSQL.js) in a web application.

A use-case in this application is that the user wants to query point geometries (>500k of them, anywhere in the world) against a single (multi-)polygon geometry, filtering points which are not inside said geometry.

I don't know the (multi-)polygon in advance, because it is yielded by a dynamic mechanism. It could be e.g. a country, province, city, or a hand-drawn custom polygon.

Using a simple query with SpatiaLite's Within function works great. Performance is also great for small (multi-)polygons, such as a city. However, when querying against, say, Australia (a huge multi-polygon with many parts), performance suffers.

I am tied to SpatiaLite or a custom solution because most spatial database solutions cannot run in client-side JavaScript.

Sorry if this is an obvious question - I didn't find any similar questions so far.

Any thoughts on how to speed this up? Some loss of accuracy is acceptable.

Upvotes: 0

Views: 135

Answers (0)

Related Questions