geospatial 1.3.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 11b074e2d3cdfac7ba59e1a7a2577c02824130aa
4
- data.tar.gz: e72051ddbdfdac6aff2e38da188662ccf975118b
3
+ metadata.gz: af57f14cdc085ce808e8462af23af0e269797b86
4
+ data.tar.gz: f7bc6d182e0b5366a6ada00112c555a35576977b
5
5
  SHA512:
6
- metadata.gz: 80d7551c77bd067e796b44cce6cfb6e3fc7ae56eee263aff1f11ea09ff76d6e60763181bd9796032154be6e863d3c90d5d474902f2b9b532b5b4acd726723852
7
- data.tar.gz: 2a3b2f858503eb5697e6f3d4576ed273a3d1f493205be97446c20fca8770fe1bb26a0229ff9e118a5b00dc00fd3d511ff171428130d3addf6e1bf66cea0ccb3b
6
+ metadata.gz: 20a32b175c72f9989a8ffe6f29fa06637af22fda65d8d61c240d25c701268468248e4e52bc719b33e9f1c3396702fac0c49924e4878fae2d8ff07af8a4564251
7
+ data.tar.gz: 471174aee8a1270436599bdfed01d623ff9a3d34dbce7b7221d63b9e266fbfdc5e4da8bd0ca990342a010b68281b7a3fddbd6f5fbfad33757de2ed05fa155c87
data/README.md CHANGED
@@ -34,26 +34,42 @@ Or install it yourself as:
34
34
 
35
35
  The simplest way to use this library is to use the built in `Map`:
36
36
 
37
- map = Geospatial::Map.new
38
- map << Geospatial::Location.new(170.53, -43.89) # Lake Tekapo, New Zealand.
39
- map << Geospatial::Location.new(170.45, -43.94) # Lake Alex, New Zealand.
40
- map << Geospatial::Location.new(151.21, -33.85) # Sydney, Australia.
37
+ ```ruby
38
+ map = Geospatial::Map.new
39
+ map << Geospatial::Location.new(170.53, -43.89) # Lake Tekapo, New Zealand.
40
+ map << Geospatial::Location.new(170.45, -43.94) # Lake Alex, New Zealand.
41
+ map << Geospatial::Location.new(151.21, -33.85) # Sydney, Australia.
41
42
 
42
- map.sort! # or assume an ordered database index.
43
+ map.sort! # or assume an ordered database index.
43
44
 
44
- new_zealand = Geospatial::Box.from_bounds(Vector[166.0, -48.0], Vector[180.0, -34.0])
45
+ new_zealand = Geospatial::Box.from_bounds(Vector[166.0, -48.0], Vector[180.0, -34.0])
45
46
 
46
- points = subject.query(new_zealand)
47
- expect(points).to include(lake_tekapo, lake_alex)
48
- expect(points).to_not include(sydney)
47
+ points = subject.query(new_zealand)
48
+ expect(points).to include(lake_tekapo, lake_alex)
49
+ expect(points).to_not include(sydney)
50
+ ```
49
51
 
50
52
  At a lower level you can use the method in the `Geospatial::Hilbert` module to `map`, `unmap` and `traverse` the Hilbert mapping.
51
53
 
54
+ ### Computing a Hilbert Index
55
+
56
+ ```ruby
57
+ #!/usr/bin/env ruby
58
+ require 'geospatial/map'
59
+ require 'geospatial/dimensions'
60
+ require 'geospatial/hilbert/curve'
61
+
62
+ map = Geospatial::Map.for_earth(30)
63
+ coordinate = ARGV.collect(&:to_f)
64
+ index = map.hash_for_coordinates(coordinate)
65
+ puts index
66
+ ```
67
+
52
68
  ### Geotemporal Indexes
53
69
 
54
70
  The Hilbert curve is multi-dimensional and therefore can represent multi-dimensional data, e.g. latitude, longitude and time, in a single index. The curve expands uniformly in all dimensions, so you can't control the precision of the dimensions independently.
55
71
 
56
- Mathematically speaking, it's possible to compose curves together to form curves of different precision/properties. However, how these fit together generally is a bit more complex, especially in terms of exploring the curve via traversal.
72
+ Mathematically speaking, it's possible to [compose curves together](https://github.com/cne1x/sfseize) to form curves of different precision/properties. However, how these fit together generally is a bit more complex, especially in terms of exploring the curve via traversal.
57
73
 
58
74
  ## Contributing
59
75
 
@@ -46,6 +46,10 @@ module Geospatial
46
46
  VALID_LATITUDE = MIN_LATITUDE...MAX_LATITUDE
47
47
 
48
48
  class << self
49
+ def [] (longitude:, latitude:)
50
+ self.new(longitude, latitude)
51
+ end
52
+
49
53
  def from_ecef(x, y, z)
50
54
  # Constants (WGS ellipsoid)
51
55
  a = WGS84_A
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Geospatial
22
- VERSION = "1.3.1"
22
+ VERSION = "1.4.0"
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geospatial
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-09 00:00:00.000000000 Z
11
+ date: 2017-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec