graticule 0.2.2 → 0.2.3
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/CHANGELOG.txt +4 -0
- data/Manifest.txt +9 -0
- data/Rakefile +69 -0
- data/lib/graticule.rb +2 -0
- data/lib/graticule/cli.rb +6 -4
- data/lib/graticule/geocoder/base.rb +112 -0
- data/lib/graticule/geocoder/geocoder_us.rb +1 -1
- data/lib/graticule/geocoder/google.rb +5 -5
- data/lib/graticule/geocoder/host_ip.rb +9 -18
- data/lib/graticule/geocoder/local_search_maps.rb +4 -4
- data/lib/graticule/geocoder/meta_carta.rb +1 -6
- data/lib/graticule/geocoder/rest.rb +6 -98
- data/lib/graticule/geocoder/yahoo.rb +1 -13
- data/lib/graticule/version.rb +1 -1
- data/site/index.html +114 -0
- data/site/plugin.html +82 -0
- data/site/stylesheets/style.css +73 -0
- data/test/config.yml.default +36 -0
- data/test/fixtures/responses/geocoder_us/success.xml +13 -5
- data/test/fixtures/responses/geocoder_us/unknown.xml +1 -1
- data/test/fixtures/responses/google/badkey.xml +1 -10
- data/test/fixtures/responses/google/missing_address.xml +1 -10
- data/test/fixtures/responses/google/partial.xml +1 -0
- data/test/fixtures/responses/google/success.xml +1 -37
- data/test/fixtures/responses/google/unavailable.xml +1 -10
- data/test/fixtures/responses/google/unknown_address.xml +1 -10
- data/test/fixtures/responses/host_ip/private.txt +1 -1
- data/test/fixtures/responses/host_ip/success.txt +1 -1
- data/test/fixtures/responses/host_ip/unknown.txt +1 -1
- data/test/fixtures/responses/local_search_maps/empty.txt +1 -0
- data/test/fixtures/responses/local_search_maps/not_found.txt +1 -0
- data/test/fixtures/responses/local_search_maps/success.txt +1 -1
- data/test/fixtures/responses/meta_carta/bad_address.xml +15 -7
- data/test/fixtures/responses/meta_carta/success.xml +29 -21
- data/test/fixtures/responses/yahoo/success.xml +2 -2
- data/test/fixtures/responses/yahoo/unknown_address.xml +6 -6
- data/test/mocks/uri.rb +3 -2
- data/test/unit/graticule/geocoder/google_test.rb +14 -0
- data/test/unit/graticule/geocoder/host_ip_test.rb +1 -0
- data/test/unit/graticule/geocoder/meta_carta_test.rb +1 -1
- data/test/unit/graticule/location_test.rb +1 -1
- metadata +10 -3
- data/test/unit/graticule/cli_test.rb +0 -26
@@ -1,10 +1 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"
|
2
|
-
<kml xmlns="http://earth.google.com/kml/2.0">
|
3
|
-
<Response>
|
4
|
-
<name>1600</name>
|
5
|
-
<Status>
|
6
|
-
<code>602</code>
|
7
|
-
<request>geocode</request>
|
8
|
-
</Status>
|
9
|
-
</Response>
|
10
|
-
</kml>
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?><kml xmlns="http://earth.google.com/kml/2.1"><Response><name>1600</name><Status><code>602</code><request>geocode</request></Status></Response></kml>
|
@@ -0,0 +1 @@
|
|
1
|
+
alert('Please provide a location');
|
@@ -0,0 +1 @@
|
|
1
|
+
alert('location not found');
|
@@ -1 +1 @@
|
|
1
|
-
map.centerAndZoom(new GPoint(-0.130427, 51.510036), 4);
|
1
|
+
map.centerAndZoom(new GPoint(-0.130427, 51.510036), 4);
|
@@ -1,9 +1,17 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
+
|
2
3
|
<!DOCTYPE Locations SYSTEM "Locations.dtd">
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
|
5
|
+
<Locations
|
6
|
+
xmlns:gml="http://www.opengis.net/gml"
|
7
|
+
CreatedBy="MetaCarta GeoParser v3.7.0-labs"
|
8
|
+
CreatedOn="Wed Apr 25 22:12:33 2007"
|
9
|
+
ConvertedFromBinaryFormat="0"
|
10
|
+
InputByteLength="0">
|
11
|
+
<ViewBox>
|
12
|
+
|
13
|
+
<gml:Box srsName="epsg:4326">
|
14
|
+
<gml:coordinates>-180.000000,-90.000000 180.000000,90.000000</gml:coordinates>
|
15
|
+
</gml:Box>
|
16
|
+
</ViewBox>
|
9
17
|
</Locations>
|
@@ -1,23 +1,31 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
2
|
+
|
2
3
|
<!DOCTYPE Locations SYSTEM "Locations.dtd">
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
4
|
+
|
5
|
+
<Locations
|
6
|
+
xmlns:gml="http://www.opengis.net/gml"
|
7
|
+
CreatedBy="MetaCarta GeoParser v3.7.0-labs"
|
8
|
+
CreatedOn="Wed Apr 25 22:12:33 2007"
|
9
|
+
ConvertedFromBinaryFormat="0"
|
10
|
+
InputByteLength="0">
|
11
|
+
<ViewBox>
|
12
|
+
|
13
|
+
<gml:Box srsName="epsg:4326">
|
14
|
+
<gml:coordinates>43.593900,32.538600 45.193900,34.138600</gml:coordinates>
|
15
|
+
</gml:Box>
|
16
|
+
</ViewBox>
|
17
|
+
<Location
|
18
|
+
|
19
|
+
Name="Baghdad"
|
20
|
+
Type=""
|
21
|
+
Population="-1"
|
22
|
+
Hierarchy="">
|
23
|
+
<ViewBox>
|
24
|
+
<gml:Box srsName="epsg:4326">
|
25
|
+
<gml:coordinates>43.593900,32.538600 45.193900,34.138600</gml:coordinates>
|
26
|
+
</gml:Box>
|
27
|
+
</ViewBox>
|
28
|
+
<RemainingQuery></RemainingQuery>
|
29
|
+
<Confidence>0.566875</Confidence> <Centroid><gml:Point><gml:coordinates>44.393900000000002,33.3386</gml:coordinates></gml:Point></Centroid>
|
30
|
+
</Location>
|
23
31
|
</Locations>
|
@@ -1,3 +1,3 @@
|
|
1
1
|
<?xml version="1.0"?>
|
2
|
-
<ResultSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:yahoo:maps" xsi:schemaLocation="urn:yahoo:maps http://api.local.yahoo.com/MapsService/V1/GeocodeResponse.xsd"><Result precision="address"><Latitude>37.416384</Latitude><Longitude>-122.024853</Longitude><Address>701 FIRST AVE</Address><City>SUNNYVALE</City><State>CA</State><Zip>94089-1019</Zip><Country>US</Country></Result></ResultSet>
|
3
|
-
<!--
|
2
|
+
<ResultSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:yahoo:maps" xsi:schemaLocation="urn:yahoo:maps http://api.local.yahoo.com/MapsService/V1/GeocodeResponse.xsd"><Result precision="address" warning="The exact location could not be found, here is the closest match: 701 First Ave, Sunnyvale, CA 94089"><Latitude>37.416384</Latitude><Longitude>-122.024853</Longitude><Address>701 FIRST AVE</Address><City>SUNNYVALE</City><State>CA</State><Zip>94089-1019</Zip><Country>US</Country></Result></ResultSet>
|
3
|
+
<!-- ws06.search.re2.yahoo.com uncompressed/chunked Wed Apr 25 15:13:01 PDT 2007 -->
|
@@ -1,6 +1,6 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<Error xmlns="urn:yahoo:api">
|
3
|
-
The following errors were detected:
|
4
|
-
<Message>unable to parse location</Message>
|
5
|
-
</Error>
|
6
|
-
<!--
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<Error xmlns="urn:yahoo:api">
|
3
|
+
The following errors were detected:
|
4
|
+
<Message>unable to parse location</Message>
|
5
|
+
</Error>
|
6
|
+
<!-- ws05.search.re2.yahoo.com uncompressed/chunked Wed Apr 25 15:13:01 PDT 2007 -->
|
data/test/mocks/uri.rb
CHANGED
@@ -40,11 +40,12 @@ class URI::HTTP # :nodoc:
|
|
40
40
|
|
41
41
|
alias original_open open
|
42
42
|
|
43
|
-
def open
|
43
|
+
def open(*args)
|
44
44
|
self.class.uris << self.to_s
|
45
45
|
io = StringIO.new(self.class.responses.shift)
|
46
46
|
OpenURI::Meta.init(io)
|
47
|
-
yield io
|
47
|
+
yield io if block_given?
|
48
|
+
io
|
48
49
|
end
|
49
50
|
|
50
51
|
end
|
@@ -24,6 +24,20 @@ module Graticule
|
|
24
24
|
)
|
25
25
|
assert_equal location, @geocoder.locate('1600 Amphitheatre Parkway, Mountain View, CA')
|
26
26
|
end
|
27
|
+
|
28
|
+
def test_partial
|
29
|
+
return unless prepare_response(:partial)
|
30
|
+
|
31
|
+
location = Location.new(
|
32
|
+
:locality => "San Francisco",
|
33
|
+
:region => "CA",
|
34
|
+
:country => "US",
|
35
|
+
:longitude => -122.418333,
|
36
|
+
:latitude => 37.775000
|
37
|
+
)
|
38
|
+
|
39
|
+
assert_equal location, @geocoder.locate('sf ca')
|
40
|
+
end
|
27
41
|
|
28
42
|
def test_bad_key
|
29
43
|
return unless prepare_response(:badkey)
|
@@ -14,7 +14,7 @@ module Graticule
|
|
14
14
|
def test_locate
|
15
15
|
prepare_response(:success)
|
16
16
|
|
17
|
-
expected = Location.new :latitude => 44.
|
17
|
+
expected = Location.new :latitude => 44.3939, :longitude => 33.3386
|
18
18
|
|
19
19
|
assert_equal expected, @geocoder.locate('baghdad')
|
20
20
|
assert_equal true, URI::HTTP.responses.empty?
|
@@ -29,7 +29,7 @@ module Graticule
|
|
29
29
|
assert_equal Location.new, Location.new
|
30
30
|
|
31
31
|
attrs = {:latitude => 100.5389, :longitude => -147.5893, :street => '123 A Street',
|
32
|
-
:locality => 'Somewhere', :region => 'NO', :postal_code => '12345', :country => 'USA'
|
32
|
+
:locality => 'Somewhere', :region => 'NO', :postal_code => '12345', :country => 'USA'}
|
33
33
|
|
34
34
|
assert_equal Location.new(attrs), Location.new(attrs)
|
35
35
|
attrs.each do |k,v|
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
|
|
3
3
|
specification_version: 1
|
4
4
|
name: graticule
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.
|
7
|
-
date: 2007-
|
6
|
+
version: 0.2.3
|
7
|
+
date: 2007-04-27 00:00:00 -04:00
|
8
8
|
summary: API for using all the popular geocoding services.
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -43,6 +43,7 @@ files:
|
|
43
43
|
- lib/graticule/distance/spherical.rb
|
44
44
|
- lib/graticule/distance/vincenty.rb
|
45
45
|
- lib/graticule/geocoder.rb
|
46
|
+
- lib/graticule/geocoder/base.rb
|
46
47
|
- lib/graticule/geocoder/bogus.rb
|
47
48
|
- lib/graticule/geocoder/geocoder_ca.rb
|
48
49
|
- lib/graticule/geocoder/geocoder_us.rb
|
@@ -55,11 +56,16 @@ files:
|
|
55
56
|
- lib/graticule/geocoder/yahoo.rb
|
56
57
|
- lib/graticule/location.rb
|
57
58
|
- lib/graticule/version.rb
|
59
|
+
- site/index.html
|
60
|
+
- site/plugin.html
|
61
|
+
- site/stylesheets/style.css
|
62
|
+
- test/config.yml.default
|
58
63
|
- test/fixtures/responses/geocoder_us/success.xml
|
59
64
|
- test/fixtures/responses/geocoder_us/unknown.xml
|
60
65
|
- test/fixtures/responses/google/badkey.xml
|
61
66
|
- test/fixtures/responses/google/limit.xml
|
62
67
|
- test/fixtures/responses/google/missing_address.xml
|
68
|
+
- test/fixtures/responses/google/partial.xml
|
63
69
|
- test/fixtures/responses/google/server_error.xml
|
64
70
|
- test/fixtures/responses/google/success.xml
|
65
71
|
- test/fixtures/responses/google/unavailable.xml
|
@@ -67,6 +73,8 @@ files:
|
|
67
73
|
- test/fixtures/responses/host_ip/private.txt
|
68
74
|
- test/fixtures/responses/host_ip/success.txt
|
69
75
|
- test/fixtures/responses/host_ip/unknown.txt
|
76
|
+
- test/fixtures/responses/local_search_maps/empty.txt
|
77
|
+
- test/fixtures/responses/local_search_maps/not_found.txt
|
70
78
|
- test/fixtures/responses/local_search_maps/success.txt
|
71
79
|
- test/fixtures/responses/meta_carta/bad_address.xml
|
72
80
|
- test/fixtures/responses/meta_carta/multiple.xml
|
@@ -91,7 +99,6 @@ files:
|
|
91
99
|
- test/unit/graticule/geocoder_test.rb
|
92
100
|
- test/unit/graticule/location_test.rb
|
93
101
|
test_files:
|
94
|
-
- test/unit/graticule/cli_test.rb
|
95
102
|
- test/unit/graticule/distance_test.rb
|
96
103
|
- test/unit/graticule/geocoder_test.rb
|
97
104
|
- test/unit/graticule/location_test.rb
|
@@ -1,26 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/../../test_helper'
|
2
|
-
require 'graticule/cli'
|
3
|
-
|
4
|
-
module Graticule
|
5
|
-
class CliTest < Test::Unit::TestCase
|
6
|
-
|
7
|
-
def setup
|
8
|
-
URI::HTTP.responses = []
|
9
|
-
URI::HTTP.uris = []
|
10
|
-
end
|
11
|
-
|
12
|
-
def test_start
|
13
|
-
prepare_response(:success)
|
14
|
-
Kernel.expects(:puts)
|
15
|
-
Kernel.stubs(:puts)
|
16
|
-
result = Graticule::Cli.start ['-s', 'yahoo', '-a', 'YahooDemo', 'Saugatuck,', 'MI']
|
17
|
-
end
|
18
|
-
|
19
|
-
protected
|
20
|
-
|
21
|
-
def prepare_response(id)
|
22
|
-
URI::HTTP.responses << response('yahoo', id)
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|