If there is no search for one coordinate, you can offer hashing x, y coordinate pairs. Post will offer some hash with a small combination, like hash = ( y << 16 ) ^ x; .
But you want to access your data for a value for x or y. The structure for storing points and effectively performing operations on it is a QTree or Quad Tree point. See here .
Point quad is an adaptation of a binary tree used to represent two-dimensional point data. It shares the characteristics of all quadrants but is a true tree, since the center of the unit is always at a point.
A node of a point quadrant is similar to a node of a binary tree, with the main difference being that it has four pointers (one for each quadrant) instead of two ("left" and "right"), as in a regular binary tree. Also, the key is usually decomposed into two parts, referring to x and y. Therefore, a node contains the following information: 4 Pointers: quad ['NW], quad [' NE], quad ['SW] and quad [' SE]; which, in turn, contains: a key; usually expressed in x, y coordinates; e.g. name
Then you can get a recursive function to query all points in the AABB range. You can adapt this implementation of QueryRange()
class QuadTree { function queryRange(AABB range) { Array of XY pointsInRange;
octoback
source share