geos-extensions 0.1.4 → 0.1.5
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.
- data/VERSION +1 -1
- data/geos-extensions.gemspec +2 -2
- data/lib/geos_extensions.rb +15 -14
- data/test/reader_tests.rb +14 -4
- data/test/test_helper.rb +2 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
data/geos-extensions.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "geos-extensions"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.5"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["J Smith"]
|
12
|
-
s.date = "2011-
|
12
|
+
s.date = "2011-12-02"
|
13
13
|
s.description = "Extensions for the GEOS library."
|
14
14
|
s.email = "code@zoocasa.com"
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/geos_extensions.rb
CHANGED
@@ -17,28 +17,29 @@ module Geos
|
|
17
17
|
autoload :ActiveRecord, File.join(GEOS_EXTENSIONS_BASE, *%w{ geos active_record_extensions })
|
18
18
|
autoload :GoogleMaps, File.join(GEOS_EXTENSIONS_BASE, *%w{ geos google_maps })
|
19
19
|
|
20
|
+
REGEXP_FLOAT = /(-?\d+(?:\.\d+)?)/
|
21
|
+
REGEXP_LAT_LNG = /#{REGEXP_FLOAT}\s*,\s*#{REGEXP_FLOAT}/
|
22
|
+
|
20
23
|
REGEXP_WKT = /^\s*(?:SRID=(-?[0-9]+);)?(\s*[PLMCG].+)/im
|
21
24
|
REGEXP_WKB_HEX = /^[A-Fa-f0-9\s]+$/
|
25
|
+
|
22
26
|
REGEXP_G_LAT_LNG_BOUNDS = /^
|
23
27
|
\(
|
24
|
-
\(
|
25
|
-
(-?\d+(?:\.\d+)?) # sw lat or x
|
26
|
-
\s*,\s*
|
27
|
-
(-?\d+(?:\.\d+)?) # sw lng or y
|
28
|
-
\)
|
28
|
+
\(#{REGEXP_LAT_LNG}\) # sw
|
29
29
|
\s*,\s*
|
30
|
-
\(
|
31
|
-
(-?\d+(?:\.\d+)?) # ne lat or x
|
32
|
-
\s*,\s*
|
33
|
-
(-?\d+(?:\.\d+)?) # ne lng or y
|
34
|
-
\)
|
30
|
+
\(#{REGEXP_LAT_LNG}\) # ne
|
35
31
|
\)
|
32
|
+
$
|
33
|
+
|
|
34
|
+
^
|
35
|
+
#{REGEXP_LAT_LNG} # sw
|
36
|
+
\s*,\s*
|
37
|
+
#{REGEXP_LAT_LNG} # ne
|
36
38
|
$/x
|
39
|
+
|
37
40
|
REGEXP_G_LAT_LNG = /^
|
38
41
|
\(?
|
39
|
-
|
40
|
-
\s*,\s*
|
41
|
-
(-?\d+(?:\.\d+)?) # lng or y
|
42
|
+
#{REGEXP_LAT_LNG}
|
42
43
|
\)?
|
43
44
|
$/x
|
44
45
|
|
@@ -108,7 +109,7 @@ module Geos
|
|
108
109
|
geom = case geometry
|
109
110
|
when REGEXP_G_LAT_LNG_BOUNDS
|
110
111
|
coords = Array.new
|
111
|
-
$~.captures.each_slice(2) { |f|
|
112
|
+
$~.captures.compact.each_slice(2) { |f|
|
112
113
|
coords << f.collect(&:to_f)
|
113
114
|
}
|
114
115
|
|
data/test/reader_tests.rb
CHANGED
@@ -76,10 +76,20 @@ class GeosReaderTests < Test::Unit::TestCase
|
|
76
76
|
bounds = Geos.from_g_lat_lng(BOUNDS_G_LAT_LNG)
|
77
77
|
|
78
78
|
assert_kind_of(Geos::Polygon, bounds)
|
79
|
-
assert_equal([ 0, 0 ], bounds.sw.to_a)
|
80
|
-
assert_equal([ 5, 5 ], bounds.ne.to_a)
|
81
|
-
assert_equal([ 0, 5 ], bounds.nw.to_a)
|
82
|
-
assert_equal([ 5, 0 ], bounds.se.to_a)
|
79
|
+
assert_equal([ 0.1, 0.1 ], bounds.sw.to_a)
|
80
|
+
assert_equal([ 5.2, 5.2 ], bounds.ne.to_a)
|
81
|
+
assert_equal([ 0.1, 5.2 ], bounds.nw.to_a)
|
82
|
+
assert_equal([ 5.2, 0.1 ], bounds.se.to_a)
|
83
|
+
end
|
84
|
+
|
85
|
+
def test_from_g_lat_lng_bounds_url_value
|
86
|
+
bounds = Geos.from_g_lat_lng(BOUNDS_G_LAT_LNG_URL_VALUE)
|
87
|
+
|
88
|
+
assert_kind_of(Geos::Polygon, bounds)
|
89
|
+
assert_equal([ 0.1, 0.1 ], bounds.sw.to_a)
|
90
|
+
assert_equal([ 5.2, 5.2 ], bounds.ne.to_a)
|
91
|
+
assert_equal([ 0.1, 5.2 ], bounds.nw.to_a)
|
92
|
+
assert_equal([ 5.2, 0.1 ], bounds.se.to_a)
|
83
93
|
end
|
84
94
|
|
85
95
|
def test_read
|
data/test/test_helper.rb
CHANGED
@@ -138,7 +138,8 @@ module TestHelper
|
|
138
138
|
|
139
139
|
POLYGON_WITH_INTERIOR_RING = "POLYGON((0 0, 5 0, 5 5, 0 5, 0 0),(4 4, 4 1, 1 1, 1 4, 4 4))"
|
140
140
|
|
141
|
-
BOUNDS_G_LAT_LNG = "((0, 0), (5, 5))"
|
141
|
+
BOUNDS_G_LAT_LNG = "((0.1, 0.1), (5.2, 5.2))"
|
142
|
+
BOUNDS_G_LAT_LNG_URL_VALUE = '0.1,0.1,5.2,5.2'
|
142
143
|
|
143
144
|
def assert_saneness_of_point(point)
|
144
145
|
assert_kind_of(Geos::Point, point)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geos-extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-
|
12
|
+
date: 2011-12-02 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Extensions for the GEOS library.
|
15
15
|
email: code@zoocasa.com
|