geotree 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d76fc2dc033f2ce8bcbfd647c63d571f24727a0c
4
- data.tar.gz: c08e6cfb67594b35a46bcdab10fac8bf3b10a41a
3
+ metadata.gz: e27ac7237a87748973d68e8e8ab42fa3fd3de713
4
+ data.tar.gz: 2d3c2f8fe96472d903d0779b2f998af147c92b3e
5
5
  SHA512:
6
- metadata.gz: 7fe31727a3a6d8188f467e08c63fda63fe15ec6d5bb5678051ee2364276f3a9dfd54a941be42df578c6defca1ff390eaf08d9cf48d47e7970f4d921581378ce6
7
- data.tar.gz: 90b7fd6dbea9a82724ea3307b6361723829e05274356d7eeefe247f22e9e9b5e3b41943818c8b2ae85c3f00d1625e9a545b06bb3448f283729ea73ef8e64a7ae
6
+ metadata.gz: bd5d7194460709171d65219dbdf19686d24d2b8cf768c3aa5ac5fc4a010157654b4ad3cc44dea7c250ff578cab3b6484a40da57d9f7784740ef998599453ec1a
7
+ data.tar.gz: 26cc87072057131efa87568e1990a8fd8aa8f2fed43b4f3424bfed117a81eb69d3b0958c7894d03b7a9bee130a0e2d826b35d4d2aeaba8e9466f6f2d8b5556ae
@@ -10,4 +10,8 @@
10
10
 
11
11
  * Version 1.1.3
12
12
  * Fixed problem with link URL's
13
-
13
+
14
+ * Version 1.1.4
15
+ * Placed on github
16
+ * Moved some documentation out of class headers and into README file
17
+
@@ -0,0 +1,140 @@
1
+
2
+ geotree
3
+ =======
4
+ GeoTree is a ruby gem that maintains a set of geographical points, reports points lying within a query rectangle,
5
+ and supports multiple levels of detail.
6
+
7
+ Written by Jeff Sember, April 2013.
8
+
9
+ [Source code documentation can be found here.](http://rubydoc.info/gems/geotree/frames)
10
+
11
+
12
+
13
+ GeoTree
14
+ -------
15
+
16
+ A GeoTree is a variant of a k-d tree (with d = 2), and stores data points that have a latitude
17
+ and longitude, a unique integer identifier, and an optional 'weight' (e.g., the
18
+ size of a city). A GeoTree is capable of efficiently
19
+ reporting all points lying within (axis-aligned) query rectangles.
20
+ GeoTrees are disk-based data structures and can store a very large
21
+ number of points efficiently.
22
+
23
+ [Here's an animation of a GeoTree in action.](http://www.cs.ubc.ca/~jpsember/geo_tree.ps)
24
+
25
+
26
+ Like a B+ tree, a GeoTree has a large branching factor
27
+ and the nodes are large to improve performance when the tree is stored
28
+ on disk.
29
+
30
+ A GeoTree is usually stored within a disk file, though it is also possible to
31
+ construct a tree that exists only in memory; see the initialize(...) method.
32
+
33
+
34
+ Usage:
35
+
36
+ * Open a tree. If no tree exists, a new, empty one is created:
37
+
38
+ t = GeoTree.open("treepath.bin")
39
+
40
+ * Add datapoints:
41
+
42
+ dp = DataPoint.new(42, 3, Loc.new(120,300))
43
+ t.add(dp)
44
+
45
+ * Remove datapoints:
46
+
47
+ t.remove(dp)
48
+
49
+ * Find all points within a particular rectangle:
50
+
51
+ b = Bounds.new(x,y,width,height)
52
+ pts = t.find(b)
53
+
54
+ * Close a tree; flush any changes:
55
+
56
+ t.close()
57
+
58
+
59
+ One of the problems with k-d trees (including this one) is that they can become
60
+ unbalanced after a number of insertions and deletions. To deal with this,
61
+ consider these two suggestions:
62
+
63
+ 1. When constructing the initial tree, if the datapoints are given in a random
64
+ order, the tree will (with high probability) be constructed in a balanced form.
65
+ By contrast, consider what happens if the points (1,1), (2,2), (3,3), ... are
66
+ added in sequence to an initially empty tree. The tree will be very unbalanced,
67
+ with poor performance.
68
+ To address this problem, if you are not confident that the points you initially
69
+ provide are in a sufficiently random sequence, you can enable 'point buffering':
70
+
71
+
72
+ t = GeoTree.open("treepath.bin")
73
+
74
+ t.buffering = true buffering is now active
75
+
76
+ t.add(dp1)
77
+ t.add(dp2) these points are stored in a temporary disk file
78
+ t.add(dp3)
79
+ :
80
+
81
+ t.buffering = false the points will be shuffled into a random sequence and
82
+ added to the tree
83
+
84
+
85
+ 1. Periodically, you can start with a new tree, and add all of the datapoints using the
86
+ above buffering technique. This is easy to do if the datapoints are also stored
87
+ externally to the GeoTree (for instance, as parts of larger records in some database).
88
+ Otherwise, (i) the datapoints can be retrieved from the tree to an array
89
+ (by using a sufficiently large query rectangle), (ii) a new tree can be constructed,
90
+ and (iii) each of the points in the array can be added to the new tree.
91
+
92
+
93
+
94
+ MultiTree
95
+ -------
96
+
97
+
98
+ The gem includes MultiTree, a GeoTree variant that supports queries at multiple
99
+ levels of detail. For example, when focusing on a small region it can return points
100
+ that would be omitted when querying a much larger region.
101
+
102
+ [Here's an animation of a MultiTree in action.](http://www.cs.ubc.ca/~jpsember/multi_tree.ps)
103
+
104
+
105
+ As one use case, consider a map application. Ideally, it should display approximately
106
+ the same number of datapoints when the screen displays the entire state of California, as well as
107
+ when it is 'zoomed in' on a particular section of the Los Angeles area.
108
+
109
+
110
+ To accomplish this, a MultiTree maintains several GeoTrees, each for a different
111
+ level of detail. The highest detail tree contains every datapoint that has been
112
+ added to the tree, and lower detail trees will have progressively fewer points.
113
+
114
+ When querying a MultiTree, the user must specify which level of detail (i.e.,
115
+ which of the contained trees) is to be examined.
116
+
117
+
118
+ Usage:
119
+
120
+ * Open a tree. If no tree exists, a new, empty one is created:
121
+
122
+ detail_levels = 5
123
+ t = MultiTree.new("treepath.bin", detail_levels)
124
+
125
+ * Adding and removing datapoints are the same as with GeoTrees:
126
+
127
+ dp = DataPoint.new(42, 3, Loc.new(120,300))
128
+ t.add(dp)
129
+ t.remove(dp)
130
+
131
+ * Find all points within a particular rectangle (specifying the level of detail):
132
+
133
+ b = Bounds.new(x,y,width,height)
134
+ pts = t.find(b, 3)
135
+
136
+ * Close a tree; flush any changes:
137
+
138
+ t.close()
139
+
140
+
@@ -3,76 +3,8 @@ require_relative 'node'
3
3
  req 'diskblockfile ptbuffer'
4
4
 
5
5
  module GeoTreeModule
6
- #
7
- # A variant of a kd-tree, it is capable of maintaining sets of 2D points and efficiently
8
- # reporting all points lying within (axis-aligned) query rectangles.
9
- #
10
- # Like a B+ tree, it has a large branching factor
11
- # and the nodes are large to improve performance when the tree is stored
12
- # on disk.
13
- #
14
- # A GeoTree is usually stored within a disk file, though it is also possible to
15
- # construct a tree that exists only in memory; see the initialize(...) method.
16
- #
17
- # {An animation of a GeoTree in action.}[link:http://www.cs.ubc.ca/~jpsember/geo_tree.ps]
18
- #
19
- # Usage:
20
- #
21
- # [] Open a tree. If no tree exists, a new, empty one is created.
22
- #
23
- # t = GeoTree.open("treepath.bin")
24
- #
25
- # [] Add datapoints.
26
- #
27
- # dp = DataPoint.new(...)
28
- # t.add(dp)
29
- #
30
- # [] Remove datapoints.
31
- #
32
- # t.remove(dp)
33
- #
34
- # [] Find all points within a particular rectangle.
35
- #
36
- # b = Bounds.new(x,y,width,height)
37
- #
38
- # pts = t.find(b)
39
- #
40
- # [] Close tree; flush any changes.
41
- #
42
- # t.close()
43
- #
44
- #
45
- # One of the problems with kd-trees (including this one) is that they can become
46
- # unbalanced after a number of insertions and deletions. To deal with this,
47
- # consider these two suggestions:
48
- #
49
- # 1) When constructing the initial tree, if the datapoints are given in a random
50
- # order, the tree will (with high probability) be constructed in a balanced form.
51
- # By contrast, consider what happens if the points (1,1), (2,2), (3,3), ... are
52
- # added in sequence to an initially empty tree. The tree will be very unbalanced,
53
- # with poor performance.
54
- # To address this problem, if you are not confident that the points you initially
55
- # provide are in a sufficiently random sequence, you can enable 'point buffering':
56
- #
57
- # t = GeoTree.open("treepath.bin")
58
- #
59
- # t.buffering = true # buffering is now active
60
- #
61
- # t.add(dp1)
62
- # t.add(dp2) # these points are stored in a temporary disk file
63
- # t.add(dp3)
64
- # :
65
- #
66
- # t.buffering = false # the points will be shuffled into a random sequence and
67
- # # added to the tree
68
- #
69
- #
70
- # 2) Periodically, you can start with a new tree, and add all of the datapoints using the
71
- # above buffering technique. This is easy to do if the datapoints are also stored
72
- # externally to the GeoTree (for instance, as parts of larger records in some database).
73
- # Otherwise, (i) the datapoints can be retrieved from the tree to an array
74
- # (by using a sufficiently large query rectangle), (ii) a new tree can be constructed,
75
- # and (iii) each of the points in the array can be added to the new tree.
6
+ #
7
+ # See the README file for a discussion of this class.
76
8
  #
77
9
  class GeoTree
78
10
 
@@ -2,21 +2,8 @@ require_relative 'tools'
2
2
  req 'geotree'
3
3
 
4
4
  module GeoTreeModule
5
-
6
- # A variant of GeoTree that supports queries at multiple resolutions.
7
5
  #
8
- # For example, a map application should return approximately the same number of
9
- # datapoints when the screen displays the entire state of California, as well as
10
- # when it is 'zoomed in' on a particular section of the Los Angeles area.
11
- #
12
- # To accomplish this, a MultiTree maintains several GeoTrees, each for a different
13
- # level of detail. The highest detail tree contains every datapoint that has been
14
- # added to the tree, and lower detail trees will have progressively fewer points.
15
- #
16
- # When querying a MultiTree, the user must specify which level of detail (i.e.,
17
- # which of the contained trees) is to be examined.
18
- #
19
- # {An animation of a MultiTree in action.}[link:http://www.cs.ubc.ca/~jpsember/multi_tree.ps]
6
+ # See the README file for a description of this class.
20
7
  #
21
8
  class MultiTree
22
9
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geotree
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Sember
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-01 00:00:00.000000000 Z
11
+ date: 2013-04-09 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: " \nA GeoTree is a variant of a k-d tree, and stores data points that
14
14
  have a latitude and longitude, \na unique integer identifier, and an optional 'weight'
@@ -37,7 +37,7 @@ files:
37
37
  - lib/geotree/ptbuffer.rb
38
38
  - lib/geotree/tools.rb
39
39
  - CHANGELOG.txt
40
- - README.txt
40
+ - README.md
41
41
  - test/test_blockfile.rb
42
42
  - test/test_externalsort.rb
43
43
  - test/test_geotree.rb
data/README.txt DELETED
@@ -1,29 +0,0 @@
1
- # @markup markdown
2
-
3
- geotree
4
- =======
5
- A ruby gem that maintains a set of geographical points, reports points lying within a query rectangle,
6
- and supports multiple levels of detail.
7
-
8
- Written and (c) by Jeff Sember, April 2013.
9
-
10
-
11
- GeoTree
12
- -------
13
-
14
- A GeoTree is a variant of a k-d tree, and stores data points that have a latitude
15
- and longitude, a unique integer identifier, and an optional 'weight' (e.g., the
16
- size of a city). GeoTrees are disk-based data structures and can store a very large
17
- number of points efficiently. If desired, for smaller data sets, memory-only trees
18
- can be constructed instead.
19
-
20
- Here's an animation of a GeoTree in action: <http://www.cs.ubc.ca/~jpsember/geo_tree.ps>
21
-
22
- MultiTree
23
- -------
24
-
25
- The gem includes MultiTree, a GeoTree variant that supports queries at multiple
26
- levels of detail. For example, when focusing on a small region it can return points
27
- that would be omitted when querying a much larger region.
28
-
29
- Here's an animation of a MultiTree in action: <http://www.cs.ubc.ca/~jpsember/multi_tree.ps>