metacarta-geoparser 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,12 @@
1
+ = 1.0.2
2
+
3
+ * Upgraded to rc-rest 2.0.0
4
+
5
+ = 1.0.1
6
+
7
+ * Fixed bugs due to changes in output format.
8
+
9
+ = 1.0.0
10
+
11
+ * Birthay!
12
+
File without changes
@@ -1,6 +1,7 @@
1
- LICENSE
1
+ History.txt
2
+ LICENSE.txt
2
3
  Manifest.txt
3
- README
4
+ README.txt
4
5
  Rakefile
5
6
  lib/metacarta_geoparser.rb
6
7
  test/test_metacarta_geoparser.rb
File without changes
data/Rakefile CHANGED
@@ -1,69 +1,27 @@
1
- require 'rubygems'
2
- require 'rake'
3
- require 'rake/testtask'
4
- require 'rake/rdoctask'
5
- require 'rake/gempackagetask'
1
+ require 'hoe'
6
2
 
7
- $VERBOSE = nil
3
+ require './lib/metacarta_geoparser'
8
4
 
9
- spec = Gem::Specification.new do |s|
10
- s.name = 'metacarta-geoparser'
11
- s.version = '1.0.0'
12
- s.summary = 'MetaCarta GeoParser API Library'
13
- s.description = 'Map addresses to latitude and longitude with MetaCarta\'s
14
- GeoParser API.'
15
- s.author = 'Eric Hodel'
16
- s.email = 'eric@robotcoop.com'
5
+ DEV_DOC_PATH = "Libraries/metacarta-geoparser"
17
6
 
18
- s.has_rdoc = true
19
- s.files = File.read('Manifest.txt').split($/)
20
- s.require_path = 'lib'
21
-
22
- s.add_dependency 'rc-rest', '>= 1.0.0'
23
- end
24
-
25
- desc 'Run tests'
26
- task :default => [ :test ]
7
+ hoe = Hoe.new 'metacarta-geoparser', MetaCartaGeoParser::VERSION do |p|
8
+ p.summary = 'MetaCarta GeoParser API Library'
9
+ p.description = 'Map addresses to latitude and longitude with MetaCarta\'s GeoParser API.'
10
+ p.author = 'Eric Hodel'
11
+ p.email = 'drbrain@segment7.net'
12
+ p.url = "http://dev.robotcoop.com/#{DEV_DOC_PATH}"
13
+ p.changes = File.read('History.txt').scan(/\A(=.*?)^=/m).first.first
14
+ p.rubyforge_name = 'rctools'
27
15
 
28
- Rake::TestTask.new('test') do |t|
29
- t.libs << '../rc-rest/lib'
30
- t.pattern = 'test/test_*.rb'
31
- t.verbose = true
16
+ p.extra_deps << ['rc-rest', '>= 2.0.0']
32
17
  end
33
18
 
34
- desc 'Update Manifest.txt'
35
- task :update_manifest do
36
- sh "find . -type f | sed -e 's%./%%' | egrep -v 'svn|swp|~' | egrep -v '^(doc|pkg)/' | sort > Manifest.txt"
37
- end
38
-
39
- desc 'Generate RDoc'
40
- Rake::RDocTask.new :rdoc do |rd|
41
- rd.rdoc_dir = 'doc'
42
- rd.rdoc_files.add 'lib', 'README', 'LICENSE'
43
- rd.main = 'README'
44
- rd.options << '-d' if `which dot` =~ /\/dot/
45
- rd.options << '-t MetaCarta GeoParser'
46
- end
19
+ SPEC = hoe.spec
47
20
 
48
- desc 'Generate RDoc for dev.robotcoop.com'
49
- Rake::RDocTask.new :dev_rdoc do |rd|
50
- rd.rdoc_dir = '../../../www/trunk/dev/html/Libraries/google-geocode'
51
- rd.rdoc_files.add 'lib', 'README', 'LICENSE'
52
- rd.main = 'README'
53
- rd.options << '-d' if `which dot` =~ /\/dot/
54
- rd.options << '-t MetaCarta GeoParser'
21
+ begin
22
+ require '../tasks'
23
+ rescue LoadError
55
24
  end
56
25
 
57
- desc 'Build Gem'
58
- Rake::GemPackageTask.new spec do |pkg|
59
- pkg.need_tar = true
60
- end
61
-
62
- desc 'Clean up'
63
- task :clean => [ :clobber_rdoc, :clobber_package ]
64
-
65
- desc 'Clean up'
66
- task :clobber => [ :clean ]
67
-
68
26
  # vim: syntax=Ruby
69
27
 
@@ -7,6 +7,8 @@ require 'rc_rest'
7
7
 
8
8
  class MetaCartaGeoParser < RCRest
9
9
 
10
+ VERSION = '1.0.2'
11
+
10
12
  class Error < RCRest::Error; end
11
13
 
12
14
  ##
@@ -25,7 +27,7 @@ class MetaCartaGeoParser < RCRest
25
27
  # Locates +place+ and returns a Location object.
26
28
 
27
29
  def locate(place)
28
- locations, = get :q => place
30
+ locations, = get nil, :q => place
29
31
  return locations.first
30
32
  end
31
33
 
@@ -36,17 +38,17 @@ class MetaCartaGeoParser < RCRest
36
38
  # surround them.
37
39
 
38
40
  def locations(place)
39
- get :loc => place
41
+ get nil, :loc => place
40
42
  end
41
43
 
42
44
  def check_error(xml) # :nodoc:
43
45
  raise AddressError, 'bad location' unless xml.elements['Locations/Location']
44
46
  end
45
47
 
46
- def make_url(params) # :nodoc:
48
+ def make_url(method, params) # :nodoc:
47
49
  params[:output] = 'locations'
48
50
 
49
- super params
51
+ super method, params
50
52
  end
51
53
 
52
54
  def parse_response(xml) # :nodoc:
@@ -65,8 +67,8 @@ class MetaCartaGeoParser < RCRest
65
67
  location.hierarchy = l.attributes['Hierarchy']
66
68
 
67
69
  coords = l.elements['Centroid/gml:Point/gml:coordinates'].text.split ','
68
- location.latitude = coords.first.to_f
69
- location.longitude = coords.last.to_f
70
+ location.latitude = coords.last.to_f
71
+ location.longitude = coords.first.to_f
70
72
 
71
73
  confidence = l.elements['Confidence']
72
74
  location.confidence = confidence.text.to_f if confidence
@@ -87,7 +89,6 @@ class MetaCartaGeoParser < RCRest
87
89
  return viewbox.text.split(' ').map do |coords|
88
90
  coords.split(',').map { |c| c.to_f }
89
91
  end
90
-
91
92
  end
92
93
 
93
94
  end
@@ -1,4 +1,5 @@
1
1
  require 'test/unit'
2
+ require 'rubygems'
2
3
  require 'rc_rest/uri_stub'
3
4
  require 'metacarta_geoparser'
4
5
 
@@ -20,13 +21,13 @@ class TestMetaCartaGeoParser < Test::Unit::TestCase
20
21
  <Locations
21
22
  xmlns:gml="http://www.opengis.net/gml"
22
23
  CreatedBy="MetaCarta GeoParser v3.5.0-labs-alpha"
23
- CreatedOn="Thu Jun 15 23:56:50 2006"
24
- ConvertedFromBinaryFormat="False"
25
- InputByteLength="0">
24
+ CreatedOn="Wed Oct 18 18:01:33 2006"
25
+ ConvertedFromBinaryFormat="0"
26
+ InputByteLength="1">
26
27
  <ViewBox>
27
28
 
28
29
  <gml:Box srsName="epsg:4326">
29
- <gml:coordinates>26.238611,37.293889 40.438611,51.493889</gml:coordinates>
30
+ <gml:coordinates>29.298889,29.966667 72.766667,37.166667</gml:coordinates>
30
31
  </gml:Box>
31
32
  </ViewBox>
32
33
  <Location
@@ -37,24 +38,130 @@ class TestMetaCartaGeoParser < Test::Unit::TestCase
37
38
  Hierarchy="Iraq/Baghdad/Baghdad">
38
39
  <ViewBox>
39
40
  <gml:Box srsName="epsg:4326">
40
- <gml:coordinates>26.238611,37.293889 40.438611,51.493889</gml:coordinates>
41
+ <gml:coordinates>43.593889,32.538611 45.193889,34.138611</gml:coordinates>
41
42
  </gml:Box>
42
- </ViewBox>
43
- <RemainingQuery></RemainingQuery>
44
- <Confidence>0.195185</Confidence> <Centroid><gml:Point><gml:coordinates>44.393889,33.338611</gml:coordinates></gml:Point></Centroid>
43
+ </ViewBox> <Centroid><gml:Point><gml:coordinates>44.393889,33.338611</gml:coordinates></gml:Point></Centroid>
44
+ </Location>
45
+ <Location
46
+
47
+ Name="Bagdade"
48
+ Type="PPL"
49
+ Population="-1"
50
+ Hierarchy="Iran/Khorasan/Bagdade">
51
+ <ViewBox>
52
+ <gml:Box srsName="epsg:4326">
53
+ <gml:coordinates>57.715833,33.168056 58.915833,34.368056</gml:coordinates>
54
+ </gml:Box>
55
+ </ViewBox> <Centroid><gml:Point><gml:coordinates>58.315832999999998,33.768056</gml:coordinates></gml:Point></Centroid>
56
+ </Location>
57
+ <Location
58
+
59
+ Name="Baghdad"
60
+ Type="ADM2"
61
+ Population="3841268"
62
+ Hierarchy="Iraq/Baghdad/Baghdad">
63
+ <ViewBox>
64
+ <gml:Box srsName="epsg:4326">
65
+ <gml:coordinates>43.567775,32.553325 45.267339,34.084988</gml:coordinates>
66
+ </gml:Box>
67
+ </ViewBox> <Centroid><gml:Point><gml:coordinates>44.417557000000002,33.319156999999997</gml:coordinates></gml:Point></Centroid>
68
+ </Location>
69
+ <Location
70
+
71
+ Name="Baghdad"
72
+ Type=""
73
+ Population="3841268"
74
+ Hierarchy="Iraq/Baghdad">
75
+ <ViewBox>
76
+ <gml:Box srsName="epsg:4326">
77
+ <gml:coordinates>43.897263,32.751564 44.926292,33.900391</gml:coordinates>
78
+ </gml:Box>
79
+ </ViewBox> <Centroid><gml:Point><gml:coordinates>44.411777999999998,33.325977000000002</gml:coordinates></gml:Point></Centroid>
80
+ </Location>
81
+ <Location
82
+
83
+ Name="Baghdad"
84
+ Type="AREA"
85
+ Population="-1"
86
+ Hierarchy="Syria/Idlib/Baghdad">
87
+ <ViewBox>
88
+ <gml:Box srsName="epsg:4326">
89
+ <gml:coordinates>35.600000,34.766667 38.000000,37.166667</gml:coordinates>
90
+ </gml:Box>
91
+ </ViewBox> <Centroid><gml:Point><gml:coordinates>36.799999999999997,35.966667</gml:coordinates></gml:Point></Centroid>
92
+ </Location>
93
+ <Location
94
+
95
+ Name="Baghdad"
96
+ Type="PPL"
97
+ Population="-1"
98
+ Hierarchy="Egypt/Al Iskandar�yah/Baghdad">
99
+ <ViewBox>
100
+ <gml:Box srsName="epsg:4326">
101
+ <gml:coordinates>29.298889,30.378611 30.298889,31.378611</gml:coordinates>
102
+ </gml:Box>
103
+ </ViewBox> <Centroid><gml:Point><gml:coordinates>29.798888999999999,30.878610999999999</gml:coordinates></gml:Point></Centroid>
104
+ </Location>
105
+ <Location
106
+
107
+ Name="Baghdad"
108
+ Type="STM"
109
+ Population="-1"
110
+ Hierarchy="Pakistan/Balochistan/Baghdad">
111
+ <ViewBox>
112
+ <gml:Box srsName="epsg:4326">
113
+ <gml:coordinates>66.394444,30.426389 67.394444,31.426389</gml:coordinates>
114
+ </gml:Box>
115
+ </ViewBox> <Centroid><gml:Point><gml:coordinates>66.894443999999993,30.926389</gml:coordinates></gml:Point></Centroid>
116
+ </Location>
117
+ <Location
118
+
119
+ Name="Baghdad"
120
+ Type="SPNG"
121
+ Population="-1"
122
+ Hierarchy="Pakistan/Balochistan/Baghdad">
123
+ <ViewBox>
124
+ <gml:Box srsName="epsg:4326">
125
+ <gml:coordinates>66.845833,30.208333 67.845833,31.208333</gml:coordinates>
126
+ </gml:Box>
127
+ </ViewBox> <Centroid><gml:Point><gml:coordinates>67.345832999999999,30.708333</gml:coordinates></gml:Point></Centroid>
128
+ </Location>
129
+ <Location
130
+
131
+ Name="Baghdad"
132
+ Type="PPL"
133
+ Population="-1"
134
+ Hierarchy="Pakistan/Punjab/Baghdad">
135
+ <ViewBox>
136
+ <gml:Box srsName="epsg:4326">
137
+ <gml:coordinates>71.566667,29.966667 72.766667,31.166667</gml:coordinates>
138
+ </gml:Box>
139
+ </ViewBox> <Centroid><gml:Point><gml:coordinates>72.166667000000004,30.566666999999999</gml:coordinates></gml:Point></Centroid>
140
+ </Location>
141
+ <Location
142
+
143
+ Name="Baghdad"
144
+ Type="PPL"
145
+ Population="-1"
146
+ Hierarchy="Afghanistan/Vardak/Baghdad">
147
+ <ViewBox>
148
+ <gml:Box srsName="epsg:4326">
149
+ <gml:coordinates>67.383333,33.716667 68.383333,34.716667</gml:coordinates>
150
+ </gml:Box>
151
+ </ViewBox> <Centroid><gml:Point><gml:coordinates>67.883332999999993,34.216667</gml:coordinates></gml:Point></Centroid>
45
152
  </Location>
46
153
  </Locations>
47
154
  EOF
48
155
 
49
156
  expected = MetaCartaGeoParser::Location.new 'Baghdad', 'PPLC', 5672516,
50
157
  'Iraq/Baghdad/Baghdad',
51
- 44.393889, 33.338611, 0.195185,
52
- [[26.238611, 37.293889],
53
- [40.438611, 51.493889]]
158
+ 33.338611, 44.393889, nil,
159
+ [[43.593889, 32.538611],
160
+ [45.193889, 34.138611]]
54
161
 
55
162
  location = @mg.locate('baghdad')
56
163
  assert_equal expected, location
57
- assert_equal [44.393889, 33.338611], location.coordinates
164
+ assert_equal [33.338611, 44.393889], location.coordinates
58
165
 
59
166
  assert_equal true, URI::HTTP.responses.empty?
60
167
  assert_equal 1, URI::HTTP.uris.length
@@ -143,12 +250,12 @@ class TestMetaCartaGeoParser < Test::Unit::TestCase
143
250
  expected = [
144
251
  MetaCartaGeoParser::Location.new('Seattle', 'PPL', 563374,
145
252
  'United States/Washington/King/Seattle',
146
- -122.33083, 47.60639, nil,
253
+ 47.60639, -122.33083, nil,
147
254
  [[43.806390, -126.130830],
148
255
  [51.406390, -118.530830]]),
149
256
  MetaCartaGeoParser::Location.new('Seattle', 'PRT', nil,
150
257
  'United States/Seattle',
151
- -122.333333, 47.6, nil,
258
+ 47.6, -122.333333, nil,
152
259
  [[43.8, -126.133333],
153
260
  [51.4, -118.533333]]),
154
261
  ]
metadata CHANGED
@@ -1,16 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.99
2
+ rubygems_version: 0.9.0.6
3
3
  specification_version: 1
4
4
  name: metacarta-geoparser
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.0
7
- date: 2006-06-16 00:00:00 -07:00
6
+ version: 1.0.2
7
+ date: 2006-11-27 00:00:00 -08:00
8
8
  summary: MetaCarta GeoParser API Library
9
9
  require_paths:
10
10
  - lib
11
- email: eric@robotcoop.com
12
- homepage:
13
- rubyforge_project:
11
+ email: drbrain@segment7.net
12
+ homepage: http://dev.robotcoop.com/Libraries/metacarta-geoparser
13
+ rubyforge_project: rctools
14
14
  description: Map addresses to latitude and longitude with MetaCarta's GeoParser API.
15
15
  autorequire:
16
16
  default_executable:
@@ -29,14 +29,15 @@ post_install_message:
29
29
  authors:
30
30
  - Eric Hodel
31
31
  files:
32
- - LICENSE
32
+ - History.txt
33
+ - LICENSE.txt
33
34
  - Manifest.txt
34
- - README
35
+ - README.txt
35
36
  - Rakefile
36
37
  - lib/metacarta_geoparser.rb
37
38
  - test/test_metacarta_geoparser.rb
38
- test_files: []
39
-
39
+ test_files:
40
+ - test/test_metacarta_geoparser.rb
40
41
  rdoc_options: []
41
42
 
42
43
  extra_rdoc_files: []
@@ -48,6 +49,15 @@ extensions: []
48
49
  requirements: []
49
50
 
50
51
  dependencies:
52
+ - !ruby/object:Gem::Dependency
53
+ name: hoe
54
+ version_requirement:
55
+ version_requirements: !ruby/object:Gem::Version::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: 1.1.4
60
+ version:
51
61
  - !ruby/object:Gem::Dependency
52
62
  name: rc-rest
53
63
  version_requirement:
@@ -55,5 +65,5 @@ dependencies:
55
65
  requirements:
56
66
  - - ">="
57
67
  - !ruby/object:Gem::Version
58
- version: 1.0.0
68
+ version: 2.0.0
59
69
  version: