spatial-index

Benefits of nearest neighbor search with Morton-order?

孤人 提交于 2019-12-04 05:26:59
While working on the simulation of particle interactions, I stumbled across grid indexing in Morton-order (Z-order)( Wikipedia link ) which is regarded to provide an efficient nearest neighbor cell search. The main reason that I've read is the almost sequential ordering of spatially close cells in memory. Being in the middle of a first implementation, I can not wrap my head around how to efficiently implement the algorithm for the nearest neighbors, especially in comparison to a basic uniform grid. Given a cell (x,y) it is trivial to obtain the 8 neighbor cell indices and compute the

Spatial Index in MySQL - ERROR - Cannot get geometry object from data you send to the GEOMETRY field

Deadly 提交于 2019-12-03 12:17:44
I am new to the whole 'spatial index' thing, but it seems to be the best solution for filtering based on latitude/longitude. So I added a column to my table: So I created a geometry field: ALTER TABLE `addresses` ADD `point` POINT NOT NULL And then I tried to add an index: ALTER TABLE `addresses` ADD SPATIAL INDEX ( `point` ) But I get an error: #1416 - Cannot get geometry object from data you send to the GEOMETRY field What am I doing wrong here? jisaacstone OK I found the solution: Can't create a spatial index if some of the column fields contain no data. After running UPDATE `addresses` SET

Spatial index/query (finding k nearest points)

孤人 提交于 2019-12-03 09:02:58
I have +10k points (latitude, longitude) and I'm building an app that shows you the k nearest points to a user's location. I think this is a very common problem and I don't want to reinvent the wheel. I'm learning about Quadtrees. It seems to be a good approach to solve this spatial problem. I'm using these tools: Python 2.5 MySQL MongoDb Building the Quadtree is not that hard: http://donar.umiacs.umd.edu/quadtree/points/pointquad.html But once I've created the tree and saved it to a db (MySQL or MongoDb), how I run the query? I need to run queries like these: Find all points within 10 km of

Approximate, incremental nearest-neighbour algorithm for moving bodies

橙三吉。 提交于 2019-12-03 02:04:16
问题 Bounty This question raises several issues. The bounty will go to an answer which addresses them holistically. Here's a problem I've been playing with. NOTE I'm especially interested in solutions that are not based in Euclidian space. There is a set of Actors which form a crowd of size K. The distance d(ActorA,ActorB) is easily computable for any two actors (solutions should work for various definitions of 'distance') and we can find the set of N nearest neighbours for any given Actor using

Optimising the drawing of overlapping rectangles

a 夏天 提交于 2019-12-03 01:29:00
问题 I have a large number of rectangles, and some overlap others; each rectangle has an absolute z-order and a colour . (Each 'rectangle' is actually the axis-aligned bounding box of a particle effect, mesh or texture and may be semi-transparent. But its easier to think abstractly about coloured rectangles as long as you don't try to cull rectangles behind others, so I will use that in the problem description:) The cost of changing the 'colour' is quite high; its much faster to draw two blue

What is a SPATIAL INDEX and when should I use it?

家住魔仙堡 提交于 2019-12-02 20:01:56
Like most of the average PHP web developers I use MySql as a RDBMS. MySql (as other RDBMS also) offers SPATIAL INDEX features, but I'm don't get it very well. I have googled for it but didn't find clear real world examples to clarify my bad knowledge about it. Could someone explain me a little bit what is a SPATIAL INDEX and when should I use it? You can use a spatial index for indexing geo-objects - shapes. The spatial index makes it possible to efficiently search for objects that overlap in space Spatial Index is like an ordinary index with this difference that Spatial objects are not 1D

MySQL: Invalid GIS data provided to function st_geometryfromtext

余生颓废 提交于 2019-12-01 09:41:43
Here's my code: SET @poly = 'Polygon((-98.07697478272888 30.123832577126326, -98.07697478272888 30.535734310413392, -97.48302581787107 30.535734310413392, -97.48302581787107 30.123832577126326))'; SELECT name FROM county_shapes WHERE MBRContains(ST_GeomFromText(@poly), SHAPE); Whenever I run that I get a "MySQL: Invalid GIS data provided to function st_geometryfromtext" error. This returns the same error: SELECT name FROM county_shapes WHERE MBRContains(ST_GeomFromText('Polygon((-98.07697478272888 30.123832577126326, -98.07697478272888 30.535734310413392, -97.48302581787107 30.535734310413392,

How to create spatial index using EF 6.1 fluent API

一曲冷凌霜 提交于 2019-11-30 19:55:58
Well, the question is clear enough. Is it possible to create spatial indexes using Entity Framework 6.1 fluent API? Short answer- No, it is not. I have seen this tangentially referenced throughout blogs and have found no concrete examples of implementation. It seems to be related to the fact that spatial indexes are filtered indexes, which are not supported in Entity Framework. As support for my answer I constructed a POC console app with the most recent version of Entity Framework (6.1). I took the following steps Created a model that had a property of the type DbGeography Enabled automatic

Best Performance-Critical Algorithm for Solving Nearest Neighbor

烂漫一生 提交于 2019-11-30 12:21:18
问题 We have a list of x,y pairs. Every pair represents a point on a 2D space. I want to find the closest point from this list, to a specific point xq,yq. What is the best performance-critical algorithm for this problem? Lisp of points is not going to change; which means I do not need to perform insertion and deletion. I want just to find the nearest neighbor of a target xq,yq point in this set. Edit 1: Thanks to all! As Stephan202 has guessed correctly, I want to do this repeatedly; like a

Is there any documented free R-Tree implementation for .NET?

拟墨画扇 提交于 2019-11-30 11:07:18
I found some open source R-Tree implementations in C#, but none with documentation nor signs of being used by someone else than the developer. Jader Dias The NetTopologySuite is a JTS port to C# and it contains a STRtree class which is a read-only R-Tree I know of none, but I would point out that libraries like this tend to: Get written (normally with some bugs). Bugs get ironed out though use. All active bugs are fixed Optional 'Latent' bugs which could never happen due to previous semantics of the platform on which the library operates crop up if the platform changes in some way. Thus lack