geospatial 1.11.1 → 1.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/geospatial/location.rb +22 -22
- data/lib/geospatial/polygon.rb +20 -2
- data/lib/geospatial/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46655140f5da1a76565f09afb88784d5b7649b1603e21f1c03bbd6f106949a44
|
4
|
+
data.tar.gz: eacbf6a8aabb6b2cacdbdc243a1879c1a58d31e9f9964c46635f54880d18b542
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77dc08c1bc0441bbb1df97395454892f4bcd610dd7706eca9b884bd228594b60335763e45d222bef819e58d22a579b154e88e2ee0fa6a90603e44990480c0bd4
|
7
|
+
data.tar.gz: 236392df8641f5c37a3022249e4253587352fcd5024180fc36b5f4171525a66218433b114805b7762836c134da7d1fd40ab8c52b2b560e86786eb84d2f10d365
|
data/lib/geospatial/location.rb
CHANGED
@@ -21,31 +21,31 @@
|
|
21
21
|
require_relative 'distance'
|
22
22
|
|
23
23
|
module Geospatial
|
24
|
-
#
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
# WGS 84 eccentricity
|
35
|
-
WGS84_E = 8.1819190842622e-2
|
24
|
+
# WGS 84 semi-major axis constant in meters
|
25
|
+
WGS84_A = 6378137.0
|
26
|
+
# WGS 84 semi-minor axis constant in meters
|
27
|
+
WGS84_B = 6356752.3
|
28
|
+
|
29
|
+
# Earth Radius
|
30
|
+
R = (WGS84_A + WGS84_B) / 2.0
|
31
|
+
|
32
|
+
# WGS 84 eccentricity
|
33
|
+
WGS84_E = 8.1819190842622e-2
|
36
34
|
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
# Radians to degrees multiplier
|
36
|
+
R2D = (180.0 / Math::PI)
|
37
|
+
D2R = (Math::PI / 180.0)
|
40
38
|
|
41
|
-
|
42
|
-
|
43
|
-
|
39
|
+
MIN_LONGITUDE = -180.0 * D2R
|
40
|
+
MAX_LONGITUDE = 180.0 * D2R
|
41
|
+
VALID_LONGITUDE = -180.0...180.0
|
44
42
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
43
|
+
MIN_LATITUDE = -90.0 * D2R
|
44
|
+
MAX_LATITUDE = 90.0 * D2R
|
45
|
+
VALID_LATITUDE = -90.0...90.0
|
46
|
+
|
47
|
+
# This location is specifically relating to a WGS84 coordinate on Earth.
|
48
|
+
class Location
|
49
49
|
class << self
|
50
50
|
def from_ecef(x, y, z)
|
51
51
|
# Constants (WGS ellipsoid)
|
data/lib/geospatial/polygon.rb
CHANGED
@@ -77,6 +77,24 @@ module Geospatial
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
+
# @param [Float] radius The radius of the sphere on which to compute the area.
|
81
|
+
def area(radius = 1.0)
|
82
|
+
if @points.size > 2
|
83
|
+
area = 0.0
|
84
|
+
|
85
|
+
self.edges.each do |p1, p2|
|
86
|
+
r1 = (p2[0] - p1[0]) * D2R
|
87
|
+
r2 = 2 + Math::sin(p1[1] * D2R) + Math::sin(p2[1] * D2R)
|
88
|
+
|
89
|
+
area += r1 * r2
|
90
|
+
end
|
91
|
+
|
92
|
+
return (area * radius * radius / 2.0).abs
|
93
|
+
else
|
94
|
+
return 0.0
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
80
98
|
def simplify(minimum_distance = 1)
|
81
99
|
simplified_points = @points.first(1)
|
82
100
|
|
@@ -103,7 +121,7 @@ module Geospatial
|
|
103
121
|
count = 0
|
104
122
|
|
105
123
|
edges.each do |pa, pb|
|
106
|
-
if pa[1] <= p[1]
|
124
|
+
if pa[1] <= p[1]
|
107
125
|
if pb[1] >= p[1] and Polygon.is_left(pa, pb, p) > 0
|
108
126
|
count += 1
|
109
127
|
end
|
@@ -121,7 +139,7 @@ module Geospatial
|
|
121
139
|
def include_point?(point)
|
122
140
|
return false unless bounding_box.include_point?(point)
|
123
141
|
|
124
|
-
self.winding_number(point)
|
142
|
+
self.winding_number(point).odd?
|
125
143
|
end
|
126
144
|
|
127
145
|
def intersect_with_box?(other)
|
data/lib/geospatial/version.rb
CHANGED
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.
|
4
|
+
version: 1.12.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: 2018-
|
11
|
+
date: 2018-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.7.
|
128
|
+
rubygems_version: 2.7.8
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: Provides abstractions for dealing with geographical locations efficiently
|