geos-extensions 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MDdiYzQwZjU5MjYzNDMzNDI4ZGZjOTI5NmI0Yzc2NDJjOTYxNzE1Zg==
5
- data.tar.gz: !binary |-
6
- NDc0MWJiM2RmOTJiMzE5NTA2NGM3ZmZhMmQ3MDk1YWZjZTEwNmRkNw==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- MGM2NDQ3ODUzYTBkM2Y3OGViZGZkNWE3OTc2OTA4NWE1NTc3OTc5ZTM2MTZj
10
- MGMwNDA0OTY2Nzg4MTQ5OWRiMDlkODYwMjc4ZDhlZmJjMTQxMjFjMjVkZTAx
11
- MzRmYTFmNmY2ZTk2NTdjZTI3Zjc4NTFlNWI0Y2UzMWYyZjFkZDA=
12
- data.tar.gz: !binary |-
13
- YTkxYzA1NTMzYTdjNzU4NmFkZTY4YTEwNjM5MjhjYWE1MWMzNTJmOWM1MTNi
14
- ZTE5YjJhZDU3MDY2M2JjMzUyZGIyYWQxM2E5OGM2MGNkZTRhMDQ1ZTVjYTc1
15
- MDg4YjdhY2VjOWFkMzNjNzM4NWRjZjRiOTRlM2QxZTI5YmY2Yjc=
2
+ SHA1:
3
+ metadata.gz: 4c33ac11ab83bfa9dad9078c5fbf3dce2f37b651
4
+ data.tar.gz: 7f0abba994f7b1027d06b9e7f08ed0959488e863
5
+ SHA512:
6
+ metadata.gz: f2336461ca7276b8daa7ebe4c12093f8ef6998c2c9ac4df1120a69a0e05f2b7386586269a0c4f73f781731ed2871ace9d842d3cec7915063d354f16f7264ed4c
7
+ data.tar.gz: b4630e4ad25a59f061bc548f0d6097803ed42b7d4d703b4fe2607ca87c28b8bc74a7b2f73107a14edd03376e4b3dbd86086f483e24a08291591591c84a122b3a
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013 2167961 Ontario Inc., Zoocasa <code@zoocasa.com>
1
+ Copyright (c) 2014 2167961 Ontario Inc., Zoocasa <code@zoocasa.com>
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.description = "Extensions for the GEOS library."
12
12
  s.summary = s.description
13
13
  s.email = "code@zoocasa.com"
14
+ s.license = "MIT"
14
15
  s.extra_rdoc_files = [
15
16
  "README.rdoc"
16
17
  ]
@@ -1,7 +1,7 @@
1
1
 
2
2
  module Geos
3
3
  module Extensions
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
6
6
  end
7
7
 
@@ -26,6 +26,13 @@ module Geos
26
26
  c = self.centroid
27
27
  "#{Geos::Helper.number_with_precision(c.lat, precision)},#{Geos::Helper.number_with_precision(c.lng, precision)}"
28
28
  end
29
+ alias_method :to_g_url_value_point, :to_g_url_value
30
+
31
+ # Force to Google's toUrlValue as a set of bounds.
32
+ def to_g_url_value_bounds(precision = 6)
33
+ url_value = self.to_g_url_value(precision)
34
+ "#{url_value},#{url_value}"
35
+ end
29
36
  end
30
37
 
31
38
  module UrlValueBounds
@@ -34,6 +41,12 @@ module Geos
34
41
  e = self.envelope
35
42
  "#{e.southwest.to_g_url_value(precision)},#{e.northeast.to_g_url_value(precision)}"
36
43
  end
44
+ alias_method :to_g_url_value_bounds, :to_g_url_value
45
+
46
+ # Force to Google's toUrlValue as a point.
47
+ def to_g_url_value_point(precision = 6)
48
+ self.centroid.to_g_url_value(precision)
49
+ end
37
50
  end
38
51
  end
39
52
  end
@@ -42,36 +42,106 @@ class GoogleMapsApi2Tests < MiniTest::Unit::TestCase
42
42
  assert_equal('10.010,10.000', @point.to_g_url_value(3))
43
43
  end
44
44
 
45
+ def test_to_g_url_value_point_bounds
46
+ assert_equal('10.010000,10.000000,10.010000,10.000000', @point.to_g_url_value_bounds)
47
+ assert_equal('10.010,10.000,10.010,10.000', @point.to_g_url_value_bounds(3))
48
+ end
49
+
50
+ def test_to_g_url_value_point_point
51
+ assert_equal('10.010000,10.000000', @point.to_g_url_value_point)
52
+ assert_equal('10.010,10.000', @point.to_g_url_value_point(3))
53
+ end
54
+
45
55
  def test_to_g_url_value_polygon
46
56
  assert_equal('0.000000,0.000000,2.500000,5.000000', @polygon.to_g_url_value)
47
57
  assert_equal('0.000,0.000,2.500,5.000', @polygon.to_g_url_value(3))
48
58
  end
49
59
 
60
+ def test_to_g_url_value_polygon_bounds
61
+ assert_equal('0.000000,0.000000,2.500000,5.000000', @polygon.to_g_url_value_bounds)
62
+ assert_equal('0.000,0.000,2.500,5.000', @polygon.to_g_url_value_bounds(3))
63
+ end
64
+
65
+ def test_to_g_url_value_polygon_point
66
+ assert_equal('1.523810,2.023810', @polygon.to_g_url_value_point)
67
+ assert_equal('1.524,2.024', @polygon.to_g_url_value_point(3))
68
+ end
69
+
50
70
  def test_to_g_url_value_line_string
51
71
  assert_equal('0.000000,0.000000,10.000000,10.000000', @linestring.to_g_url_value)
52
72
  assert_equal('0.000,0.000,10.000,10.000', @linestring.to_g_url_value(3))
53
73
  end
54
74
 
75
+ def test_to_g_url_value_line_string_bounds
76
+ assert_equal('0.000000,0.000000,10.000000,10.000000', @linestring.to_g_url_value_bounds)
77
+ assert_equal('0.000,0.000,10.000,10.000', @linestring.to_g_url_value_bounds(3))
78
+ end
79
+
80
+ def test_to_g_url_value_line_string_point
81
+ assert_equal('0.000000,0.000000,10.000000,10.000000', @linestring.to_g_url_value_point)
82
+ assert_equal('0.000,0.000,10.000,10.000', @linestring.to_g_url_value_point(3))
83
+ end
84
+
55
85
  def test_to_g_url_value_multi_point
56
86
  assert_equal('0.000000,0.000000,10.000000,10.000000', @multipoint.to_g_url_value)
57
87
  assert_equal('0.000,0.000,10.000,10.000', @multipoint.to_g_url_value(3))
58
88
  end
59
89
 
90
+ def test_to_g_url_value_line_string_bounds
91
+ assert_equal('0.000000,0.000000,10.000000,10.000000', @multipoint.to_g_url_value_bounds)
92
+ assert_equal('0.000,0.000,10.000,10.000', @multipoint.to_g_url_value_bounds(3))
93
+ end
94
+
95
+ def test_to_g_url_value_line_string_point
96
+ assert_equal('5.000000,5.000000', @multipoint.to_g_url_value_point)
97
+ assert_equal('5.000,5.000', @multipoint.to_g_url_value_point(3))
98
+ end
99
+
60
100
  def test_to_g_url_value_multi_polygon
61
101
  assert_equal('0.000000,0.000000,15.000000,15.000000', @multipolygon.to_g_url_value)
62
102
  assert_equal('0.000,0.000,15.000,15.000', @multipolygon.to_g_url_value(3))
63
103
  end
64
104
 
105
+ def test_to_g_url_value_multi_polygon_bounds
106
+ assert_equal('0.000000,0.000000,15.000000,15.000000', @multipolygon.to_g_url_value_bounds)
107
+ assert_equal('0.000,0.000,15.000,15.000', @multipolygon.to_g_url_value_bounds(3))
108
+ end
109
+
110
+ def test_to_g_url_value_multi_polygon_point
111
+ assert_equal('7.500000,7.500000', @multipolygon.to_g_url_value_point)
112
+ assert_equal('7.500,7.500', @multipolygon.to_g_url_value_point(3))
113
+ end
114
+
65
115
  def test_to_g_url_value_multi_line_string
66
116
  assert_equal('-20.000000,-20.000000,30.000000,30.000000', @multilinestring.to_g_url_value)
67
117
  assert_equal('-20.000,-20.000,30.000,30.000', @multilinestring.to_g_url_value(3))
68
118
  end
69
119
 
120
+ def test_to_g_url_value_multi_line_string_bounds
121
+ assert_equal('-20.000000,-20.000000,30.000000,30.000000', @multilinestring.to_g_url_value_bounds)
122
+ assert_equal('-20.000,-20.000,30.000,30.000', @multilinestring.to_g_url_value_bounds(3))
123
+ end
124
+
125
+ def test_to_g_url_value_multi_line_string_point
126
+ assert_equal('5.000000,5.000000', @multilinestring.to_g_url_value_point)
127
+ assert_equal('5.000,5.000', @multilinestring.to_g_url_value_point(3))
128
+ end
129
+
70
130
  def test_to_g_url_value_geometry_collection
71
131
  assert_equal('0.000000,0.000000,14.000000,14.000000', @geometrycollection.to_g_url_value)
72
132
  assert_equal('0.000,0.000,14.000,14.000', @geometrycollection.to_g_url_value(3))
73
133
  end
74
134
 
135
+ def test_to_g_url_value_geometry_collection_bounds
136
+ assert_equal('0.000000,0.000000,14.000000,14.000000', @geometrycollection.to_g_url_value_bounds)
137
+ assert_equal('0.000,0.000,14.000,14.000', @geometrycollection.to_g_url_value_bounds(3))
138
+ end
139
+
140
+ def test_to_g_url_value_geometry_collection_point
141
+ assert_equal('6.712121,6.712121', @geometrycollection.to_g_url_value_point)
142
+ assert_equal('6.712,6.712', @geometrycollection.to_g_url_value_point(3))
143
+ end
144
+
75
145
  if defined?(JSON)
76
146
  def test_to_g_polygon
77
147
  assert_equal(
@@ -42,41 +42,6 @@ class GoogleMapsApi3Tests < MiniTest::Unit::TestCase
42
42
  assert_equal('0.000000,0.000000|2.500000,5.000000', @polygon.to_g_geocoder_bounds)
43
43
  end
44
44
 
45
- def test_to_g_url_value_point
46
- assert_equal('10.010000,10.000000', @point.to_g_url_value)
47
- assert_equal('10.010,10.000', @point.to_g_url_value(3))
48
- end
49
-
50
- def test_to_g_url_value_polygon
51
- assert_equal('0.000000,0.000000,2.500000,5.000000', @polygon.to_g_url_value)
52
- assert_equal('0.000,0.000,2.500,5.000', @polygon.to_g_url_value(3))
53
- end
54
-
55
- def test_to_g_url_value_line_string
56
- assert_equal('0.000000,0.000000,10.000000,10.000000', @linestring.to_g_url_value)
57
- assert_equal('0.000,0.000,10.000,10.000', @linestring.to_g_url_value(3))
58
- end
59
-
60
- def test_to_g_url_value_multi_point
61
- assert_equal('0.000000,0.000000,10.000000,10.000000', @multipoint.to_g_url_value)
62
- assert_equal('0.000,0.000,10.000,10.000', @multipoint.to_g_url_value(3))
63
- end
64
-
65
- def test_to_g_url_value_multi_polygon
66
- assert_equal('0.000000,0.000000,15.000000,15.000000', @multipolygon.to_g_url_value)
67
- assert_equal('0.000,0.000,15.000,15.000', @multipolygon.to_g_url_value(3))
68
- end
69
-
70
- def test_to_g_url_value_multi_line_string
71
- assert_equal('-20.000000,-20.000000,30.000000,30.000000', @multilinestring.to_g_url_value)
72
- assert_equal('-20.000,-20.000,30.000,30.000', @multilinestring.to_g_url_value(3))
73
- end
74
-
75
- def test_to_g_url_value_geometry_collection
76
- assert_equal('0.000000,0.000000,14.000000,14.000000', @geometrycollection.to_g_url_value)
77
- assert_equal('0.000,0.000,14.000,14.000', @geometrycollection.to_g_url_value(3))
78
- end
79
-
80
45
  if defined?(JSON)
81
46
  def poly_tester(type, expected, poly)
82
47
  json = poly.gsub(/new google.maps.LatLng\(([^)]+)\)/, '[ \1 ]').gsub(/"map":\s*map/, %{"map": "map"})
@@ -0,0 +1,148 @@
1
+
2
+ $: << File.dirname(__FILE__)
3
+ require 'test_helper'
4
+
5
+ begin
6
+ require 'json'
7
+ rescue LoadError
8
+ # do nothing
9
+ end
10
+
11
+ class GoogleMapsApiCommonTests
12
+ module Tests
13
+ include TestHelper
14
+
15
+ def initialize(*args)
16
+ @point = Geos.read(POINT_WKT)
17
+ @polygon = Geos.read(POLYGON_WKT)
18
+ @linestring = Geos.read(LINESTRING_WKT)
19
+ @multipoint = Geos.read(MULTIPOINT_WKT)
20
+ @multipolygon = Geos.read(MULTIPOLYGON_WKT)
21
+ @multilinestring = Geos.read(MULTILINESTRING_WKT)
22
+ @geometrycollection = Geos.read(GEOMETRYCOLLECTION_WKT)
23
+
24
+ super
25
+ end
26
+
27
+ def test_to_g_url_value_point
28
+ assert_equal('10.010000,10.000000', @point.to_g_url_value)
29
+ assert_equal('10.010,10.000', @point.to_g_url_value(3))
30
+ end
31
+
32
+ def test_to_g_url_value_point_bounds
33
+ assert_equal('10.010000,10.000000,10.010000,10.000000', @point.to_g_url_value_bounds)
34
+ assert_equal('10.010,10.000,10.010,10.000', @point.to_g_url_value_bounds(3))
35
+ end
36
+
37
+ def test_to_g_url_value_point_point
38
+ assert_equal('10.010000,10.000000', @point.to_g_url_value_point)
39
+ assert_equal('10.010,10.000', @point.to_g_url_value_point(3))
40
+ end
41
+
42
+ def test_to_g_url_value_polygon
43
+ assert_equal('0.000000,0.000000,2.500000,5.000000', @polygon.to_g_url_value)
44
+ assert_equal('0.000,0.000,2.500,5.000', @polygon.to_g_url_value(3))
45
+ end
46
+
47
+ def test_to_g_url_value_polygon_bounds
48
+ assert_equal('0.000000,0.000000,2.500000,5.000000', @polygon.to_g_url_value_bounds)
49
+ assert_equal('0.000,0.000,2.500,5.000', @polygon.to_g_url_value_bounds(3))
50
+ end
51
+
52
+ def test_to_g_url_value_polygon_point
53
+ assert_equal('1.523810,2.023810', @polygon.to_g_url_value_point)
54
+ assert_equal('1.524,2.024', @polygon.to_g_url_value_point(3))
55
+ end
56
+
57
+ def test_to_g_url_value_line_string
58
+ assert_equal('0.000000,0.000000,10.000000,10.000000', @linestring.to_g_url_value)
59
+ assert_equal('0.000,0.000,10.000,10.000', @linestring.to_g_url_value(3))
60
+ end
61
+
62
+ def test_to_g_url_value_line_string_bounds
63
+ assert_equal('0.000000,0.000000,10.000000,10.000000', @linestring.to_g_url_value_bounds)
64
+ assert_equal('0.000,0.000,10.000,10.000', @linestring.to_g_url_value_bounds(3))
65
+ end
66
+
67
+ def test_to_g_url_value_line_string_point
68
+ assert_equal('0.000000,0.000000,10.000000,10.000000', @linestring.to_g_url_value_point)
69
+ assert_equal('0.000,0.000,10.000,10.000', @linestring.to_g_url_value_point(3))
70
+ end
71
+
72
+ def test_to_g_url_value_multi_point
73
+ assert_equal('0.000000,0.000000,10.000000,10.000000', @multipoint.to_g_url_value)
74
+ assert_equal('0.000,0.000,10.000,10.000', @multipoint.to_g_url_value(3))
75
+ end
76
+
77
+ def test_to_g_url_value_line_string_bounds
78
+ assert_equal('0.000000,0.000000,10.000000,10.000000', @multipoint.to_g_url_value_bounds)
79
+ assert_equal('0.000,0.000,10.000,10.000', @multipoint.to_g_url_value_bounds(3))
80
+ end
81
+
82
+ def test_to_g_url_value_line_string_point
83
+ assert_equal('5.000000,5.000000', @multipoint.to_g_url_value_point)
84
+ assert_equal('5.000,5.000', @multipoint.to_g_url_value_point(3))
85
+ end
86
+
87
+ def test_to_g_url_value_multi_polygon
88
+ assert_equal('0.000000,0.000000,15.000000,15.000000', @multipolygon.to_g_url_value)
89
+ assert_equal('0.000,0.000,15.000,15.000', @multipolygon.to_g_url_value(3))
90
+ end
91
+
92
+ def test_to_g_url_value_multi_polygon_bounds
93
+ assert_equal('0.000000,0.000000,15.000000,15.000000', @multipolygon.to_g_url_value_bounds)
94
+ assert_equal('0.000,0.000,15.000,15.000', @multipolygon.to_g_url_value_bounds(3))
95
+ end
96
+
97
+ def test_to_g_url_value_multi_polygon_point
98
+ assert_equal('7.500000,7.500000', @multipolygon.to_g_url_value_point)
99
+ assert_equal('7.500,7.500', @multipolygon.to_g_url_value_point(3))
100
+ end
101
+
102
+ def test_to_g_url_value_multi_line_string
103
+ assert_equal('-20.000000,-20.000000,30.000000,30.000000', @multilinestring.to_g_url_value)
104
+ assert_equal('-20.000,-20.000,30.000,30.000', @multilinestring.to_g_url_value(3))
105
+ end
106
+
107
+ def test_to_g_url_value_multi_line_string_bounds
108
+ assert_equal('-20.000000,-20.000000,30.000000,30.000000', @multilinestring.to_g_url_value_bounds)
109
+ assert_equal('-20.000,-20.000,30.000,30.000', @multilinestring.to_g_url_value_bounds(3))
110
+ end
111
+
112
+ def test_to_g_url_value_multi_line_string_point
113
+ assert_equal('5.000000,5.000000', @multilinestring.to_g_url_value_point)
114
+ assert_equal('5.000,5.000', @multilinestring.to_g_url_value_point(3))
115
+ end
116
+
117
+ def test_to_g_url_value_geometry_collection
118
+ assert_equal('0.000000,0.000000,14.000000,14.000000', @geometrycollection.to_g_url_value)
119
+ assert_equal('0.000,0.000,14.000,14.000', @geometrycollection.to_g_url_value(3))
120
+ end
121
+
122
+ def test_to_g_url_value_geometry_collection_bounds
123
+ assert_equal('0.000000,0.000000,14.000000,14.000000', @geometrycollection.to_g_url_value_bounds)
124
+ assert_equal('0.000,0.000,14.000,14.000', @geometrycollection.to_g_url_value_bounds(3))
125
+ end
126
+
127
+ def test_to_g_url_value_geometry_collection_point
128
+ assert_equal('6.712121,6.712121', @geometrycollection.to_g_url_value_point)
129
+ assert_equal('6.712,6.712', @geometrycollection.to_g_url_value_point(3))
130
+ end
131
+ end
132
+
133
+ class Api2Tests < MiniTest::Unit::TestCase
134
+ include Tests
135
+
136
+ def setup
137
+ Geos::GoogleMaps.use_api(2)
138
+ end
139
+ end
140
+
141
+ class Api3Tests < MiniTest::Unit::TestCase
142
+ include Tests
143
+
144
+ def setup
145
+ Geos::GoogleMaps.use_api(3)
146
+ end
147
+ end
148
+ end
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geos-extensions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - J Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-21 00:00:00.000000000 Z
11
+ date: 2014-05-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
+ name: ffi-geos
14
15
  requirement: !ruby/object:Gem::Requirement
15
16
  requirements:
16
- - - ~>
17
+ - - "~>"
17
18
  - !ruby/object:Gem::Version
18
19
  version: '0.1'
20
+ type: :runtime
21
+ prerelease: false
19
22
  version_requirements: !ruby/object:Gem::Requirement
20
23
  requirements:
21
- - - ~>
24
+ - - "~>"
22
25
  - !ruby/object:Gem::Version
23
26
  version: '0.1'
24
- type: :runtime
25
- prerelease: false
26
- name: ffi-geos
27
27
  description: Extensions for the GEOS library.
28
28
  email: code@zoocasa.com
29
29
  executables: []
@@ -31,7 +31,7 @@ extensions: []
31
31
  extra_rdoc_files:
32
32
  - README.rdoc
33
33
  files:
34
- - .gitignore
34
+ - ".gitignore"
35
35
  - Gemfile
36
36
  - Guardfile
37
37
  - MIT-LICENSE
@@ -61,6 +61,7 @@ files:
61
61
  - lib/geos_extensions.rb
62
62
  - test/google_maps_api_2_tests.rb
63
63
  - test/google_maps_api_3_tests.rb
64
+ - test/google_maps_api_common_tests.rb
64
65
  - test/google_maps_polyline_encoder_tests.rb
65
66
  - test/helper_tests.rb
66
67
  - test/misc_tests.rb
@@ -69,7 +70,8 @@ files:
69
70
  - test/writer_tests.rb
70
71
  - test/yaml_tests.rb
71
72
  homepage: http://github.com/zoocasa/geos-extensions
72
- licenses: []
73
+ licenses:
74
+ - MIT
73
75
  metadata: {}
74
76
  post_install_message:
75
77
  rdoc_options: []
@@ -77,23 +79,24 @@ require_paths:
77
79
  - lib
78
80
  required_ruby_version: !ruby/object:Gem::Requirement
79
81
  requirements:
80
- - - ! '>='
82
+ - - ">="
81
83
  - !ruby/object:Gem::Version
82
84
  version: '0'
83
85
  required_rubygems_version: !ruby/object:Gem::Requirement
84
86
  requirements:
85
- - - ! '>='
87
+ - - ">="
86
88
  - !ruby/object:Gem::Version
87
89
  version: '0'
88
90
  requirements: []
89
91
  rubyforge_project:
90
- rubygems_version: 2.0.3
92
+ rubygems_version: 2.2.2
91
93
  signing_key:
92
94
  specification_version: 4
93
95
  summary: Extensions for the GEOS library.
94
96
  test_files:
95
97
  - test/google_maps_api_2_tests.rb
96
98
  - test/google_maps_api_3_tests.rb
99
+ - test/google_maps_api_common_tests.rb
97
100
  - test/google_maps_polyline_encoder_tests.rb
98
101
  - test/helper_tests.rb
99
102
  - test/misc_tests.rb