nofxx-georuby 1.9.0 → 1.9.1

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.
@@ -0,0 +1,21 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <feed xmlns="http://www.w3.org/2005/Atom"
3
+ xmlns:georss="http://www.georss.org/georss">
4
+ <title>Earthquakes</title>
5
+ <subtitle>International earthquake observation labs</subtitle>
6
+ <link href="http://example.org/"/>
7
+ <updated>2005-12-13T18:30:02Z</updated>
8
+ <author>
9
+ <name>Dr. Thaddeus Remor</name>
10
+ <email>tremor@quakelab.edu</email>
11
+ </author>
12
+ <id>urn:uuid:60a76c80-d399-11d9-b93C-0003939e0af6</id>
13
+ <entry>
14
+ <title>M 3.2, Mona Passage</title>
15
+ <link href="http://example.org/2005/09/09/atom01"/>
16
+ <id>urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a</id>
17
+ <updated>2005-08-17T07:02:32Z</updated>
18
+ <summary>We just had a big one.</summary>
19
+ <georss:point>45.256 -71.92</georss:point>
20
+ </entry>
21
+ </feed>
@@ -0,0 +1,40 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <rss version="2.0"
3
+ xmlns:georss="http://www.georss.org/georss"
4
+ xmlns:gml="http://www.opengis.net/gml">
5
+ <channel>
6
+ <link>http://maps.google.com</link>
7
+ <title>Cambridge Neighborhoods</title>
8
+ <description>One guy's view of Cambridge, MA</description>
9
+ <item>
10
+ <guid isPermaLink="false">00000111c36421c1321d3</guid>
11
+ <pubDate>Thu, 05 Apr 2007 20:16:31 +0000</pubDate>
12
+ <title>Central Square</title>
13
+ <description>The heart and soul of the "old" Cambridge. Depending on where you
14
+ stand, you can feel like you're in the 1970s or 2020.</description>
15
+ <author>rajrsingh</author>
16
+ <gml:Polygon>
17
+ <gml:exterior>
18
+ <gml:LinearRing>
19
+ <gml:posList>
20
+ -71.106216 42.366661
21
+ -71.105576 42.367104
22
+ -71.104378 42.367134
23
+ -71.103729 42.366249
24
+ -71.098793 42.363331
25
+ -71.101028 42.362541
26
+ -71.106865 42.366123
27
+ -71.106216 42.366661
28
+ </gml:posList>
29
+ </gml:LinearRing>
30
+ </gml:exterior>
31
+ </gml:Polygon>
32
+ </item>
33
+ <item>
34
+ <guid isPermaLink="false">00000111c365564928974</guid>
35
+ <pubDate>Thu, 05 Apr 2007 20:17:50 +0000</pubDate>
36
+ <title>MIT</title>
37
+ <description>Massachusetts Institute of Technology</description>
38
+ <author>rajrsingh</author>
39
+ <gml:Polygon>
40
+ <Snip and end fragment>
@@ -0,0 +1,22 @@
1
+ <?xml version="1.0"?>
2
+ <?xml-stylesheet href="/eqcenter/catalogs/rssxsl.php?feed=eqs7day-M5.xml" type="text/xsl"
3
+ media="screen"?>
4
+ <rss version="2.0"
5
+ xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
6
+ xmlns:dc="http://purl.org/dc/elements/1.1/">
7
+ <channel>
8
+ <title>USGS M5+ Earthquakes</title>
9
+ <description>Real-time, worldwide earthquake list for the past 7 days</description>
10
+ <link>http://earthquake.usgs.gov/eqcenter/</link>
11
+ <dc:publisher>U.S. Geological Survey</dc:publisher>
12
+ <pubDate>Thu, 27 Dec 2007 23:56:15 PST</pubDate>
13
+ <item>
14
+ <pubDate>Fri, 28 Dec 2007 05:24:17 GMT</pubDate>
15
+ <title>M 5.3, northern Sumatra, Indonesia</title>
16
+ <description>December 28, 2007 05:24:17 GMT</description>
17
+ <link>http://earthquake.usgs.gov/eqcenter/recenteqsww/Quakes/us2007llai.php</link>
18
+ <geo:lat>5.5319</geo:lat>
19
+ <geo:long>95.8972</geo:long>
20
+ </item>
21
+ </channel>
22
+ </rss>
@@ -1,6 +1,6 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
2
 
3
- DATA_DIR = File.dirname(__FILE__) + '/../../data/geojson/'
3
+ DATA_DIR = File.dirname(__FILE__) + '/../data/geojson/'
4
4
 
5
5
  # All geojson test examples are from the GeoJSON spec unless otherwise
6
6
  # specified
@@ -111,13 +111,13 @@ describe GeojsonParser do
111
111
  it "should create a specified Feature" do
112
112
  feature_json = <<-EOJ
113
113
  {
114
- "type":"Feature",
115
- "id":"OpenLayers.Feature.Vector_314",
116
- "properties":{"prop0": "value0"},
114
+ "type":"Feature",
115
+ "id":"OpenLayers.Feature.Vector_314",
116
+ "properties":{"prop0": "value0"},
117
117
  "geometry":{
118
- "type":"Point",
118
+ "type":"Point",
119
119
  "coordinates":[97.03125, 39.7265625]
120
- }
120
+ }
121
121
  }
122
122
  EOJ
123
123
  f = Geometry.from_geojson(feature_json)
@@ -0,0 +1,14 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ RSS_DATA_DIR = File.dirname(__FILE__) + '/../data/georss/'
4
+
5
+ describe GeorssParser do
6
+
7
+ it "should parse an rss file" do
8
+ geo = GeorssParser.new.parse(File.read(RSS_DATA_DIR + "/w3c.xml"))
9
+ geo.should be_a Point
10
+ end
11
+
12
+
13
+
14
+ end
@@ -9,13 +9,15 @@ require 'rubygems'
9
9
  # begin
10
10
  # require 'spec'
11
11
  # rescue LoadError
12
- require 'rspec'
12
+ require 'rspec'
13
13
  #end
14
14
 
15
15
  $:.unshift(File.dirname(__FILE__) + '/../lib')
16
16
  require 'geo_ruby'
17
17
  require 'geo_ruby/shp'
18
18
  require 'geo_ruby/gpx'
19
+ require 'geo_ruby/geojson'
20
+ require 'geo_ruby/georss'
19
21
 
20
22
  include GeoRuby
21
23
  include SimpleFeatures
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nofxx-georuby
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 1
7
- - 9
8
- - 0
9
- version: 1.9.0
4
+ prerelease:
5
+ version: 1.9.1
10
6
  platform: ruby
11
7
  authors:
12
8
  - Guilhem Vellut
@@ -17,54 +13,75 @@ autorequire:
17
13
  bindir: bin
18
14
  cert_chain: []
19
15
 
20
- date: 2011-01-14 00:00:00 -02:00
16
+ date: 2011-03-18 00:00:00 -03:00
21
17
  default_executable:
22
18
  dependencies:
23
19
  - !ruby/object:Gem::Dependency
24
- name: json_pure
25
- prerelease: false
20
+ name: dbf
26
21
  requirement: &id001 !ruby/object:Gem::Requirement
27
22
  none: false
28
23
  requirements:
29
24
  - - ">="
30
25
  - !ruby/object:Gem::Version
31
- segments:
32
- - 1
33
- - 4
34
- - 6
35
- version: 1.4.6
36
- type: :runtime
26
+ version: 1.5.0
27
+ type: :development
28
+ prerelease: false
37
29
  version_requirements: *id001
38
30
  - !ruby/object:Gem::Dependency
39
31
  name: rspec
40
- prerelease: false
41
32
  requirement: &id002 !ruby/object:Gem::Requirement
42
33
  none: false
43
34
  requirements:
44
35
  - - ">="
45
36
  - !ruby/object:Gem::Version
46
- segments:
47
- - 2
48
- - 0
49
- - 0
50
- version: 2.0.0
37
+ version: 2.3.0
51
38
  type: :development
39
+ prerelease: false
52
40
  version_requirements: *id002
53
41
  - !ruby/object:Gem::Dependency
54
- name: dbf
55
- prerelease: false
42
+ name: bundler
56
43
  requirement: &id003 !ruby/object:Gem::Requirement
57
44
  none: false
58
45
  requirements:
59
46
  - - ">="
60
47
  - !ruby/object:Gem::Version
61
- segments:
62
- - 1
63
- - 2
64
- - 9
65
- version: 1.2.9
48
+ version: 1.0.0
66
49
  type: :development
50
+ prerelease: false
67
51
  version_requirements: *id003
52
+ - !ruby/object:Gem::Dependency
53
+ name: rcov
54
+ requirement: &id004 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ type: :development
61
+ prerelease: false
62
+ version_requirements: *id004
63
+ - !ruby/object:Gem::Dependency
64
+ name: rspec
65
+ requirement: &id005 !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 2.0.0
71
+ type: :development
72
+ prerelease: false
73
+ version_requirements: *id005
74
+ - !ruby/object:Gem::Dependency
75
+ name: dbf
76
+ requirement: &id006 !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: 1.2.9
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: *id006
68
85
  description: GeoRuby provides geometric data types from the OGC 'Simple Features' specification.
69
86
  email: georuby@simplitex.com
70
87
  executables: []
@@ -75,12 +92,16 @@ extra_rdoc_files:
75
92
  - LICENSE
76
93
  - README.rdoc
77
94
  files:
95
+ - Gemfile
96
+ - Gemfile.lock
78
97
  - History.txt
79
98
  - LICENSE
80
99
  - README.rdoc
81
100
  - Rakefile
82
101
  - VERSION
83
102
  - lib/geo_ruby.rb
103
+ - lib/geo_ruby/geojson.rb
104
+ - lib/geo_ruby/georss.rb
84
105
  - lib/geo_ruby/gpx.rb
85
106
  - lib/geo_ruby/gpx4r/gpx.rb
86
107
  - lib/geo_ruby/shp.rb
@@ -89,11 +110,9 @@ files:
89
110
  - lib/geo_ruby/simple_features/envelope.rb
90
111
  - lib/geo_ruby/simple_features/ewkb_parser.rb
91
112
  - lib/geo_ruby/simple_features/ewkt_parser.rb
92
- - lib/geo_ruby/simple_features/geojson_parser.rb
93
113
  - lib/geo_ruby/simple_features/geometry.rb
94
114
  - lib/geo_ruby/simple_features/geometry_collection.rb
95
115
  - lib/geo_ruby/simple_features/geometry_factory.rb
96
- - lib/geo_ruby/simple_features/georss_parser.rb
97
116
  - lib/geo_ruby/simple_features/helper.rb
98
117
  - lib/geo_ruby/simple_features/line_string.rb
99
118
  - lib/geo_ruby/simple_features/linear_ring.rb
@@ -102,12 +121,10 @@ files:
102
121
  - lib/geo_ruby/simple_features/multi_polygon.rb
103
122
  - lib/geo_ruby/simple_features/point.rb
104
123
  - lib/geo_ruby/simple_features/polygon.rb
105
- - marcusmateus-georuby.gemspec
106
- - script/console
107
- - script/destroy
108
- - script/generate
109
- - script/txt2html
110
124
  - spec/data/geojson/feature_collection.json
125
+ - spec/data/georss/atom.xml
126
+ - spec/data/georss/gml.xml
127
+ - spec/data/georss/w3c.xml
111
128
  - spec/data/gpx/fells_loop.gpx
112
129
  - spec/data/gpx/long.gpx
113
130
  - spec/data/gpx/long.kml
@@ -127,16 +144,17 @@ files:
127
144
  - spec/data/polyline.dbf
128
145
  - spec/data/polyline.shp
129
146
  - spec/data/polyline.shx
147
+ - spec/geo_ruby/geojson_spec.rb
148
+ - spec/geo_ruby/georss.rb
149
+ - spec/geo_ruby/georss_spec.rb
130
150
  - spec/geo_ruby/gpx4r/gpx_spec.rb
131
151
  - spec/geo_ruby/shp4r/shp_spec.rb
132
152
  - spec/geo_ruby/simple_features/envelope_spec.rb
133
153
  - spec/geo_ruby/simple_features/ewkb_parser_spec.rb
134
154
  - spec/geo_ruby/simple_features/ewkt_parser_spec.rb
135
- - spec/geo_ruby/simple_features/geojson_parser_spec.rb
136
155
  - spec/geo_ruby/simple_features/geometry_collection_spec.rb
137
156
  - spec/geo_ruby/simple_features/geometry_factory_spec.rb
138
157
  - spec/geo_ruby/simple_features/geometry_spec.rb
139
- - spec/geo_ruby/simple_features/georss_parser_spec.rb
140
158
  - spec/geo_ruby/simple_features/line_string_spec.rb
141
159
  - spec/geo_ruby/simple_features/linear_ring_spec.rb
142
160
  - spec/geo_ruby/simple_features/multi_line_string_spec.rb
@@ -160,35 +178,32 @@ required_ruby_version: !ruby/object:Gem::Requirement
160
178
  requirements:
161
179
  - - ">="
162
180
  - !ruby/object:Gem::Version
163
- segments:
164
- - 0
165
181
  version: "0"
166
182
  required_rubygems_version: !ruby/object:Gem::Requirement
167
183
  none: false
168
184
  requirements:
169
185
  - - ">="
170
186
  - !ruby/object:Gem::Version
171
- segments:
172
- - 0
173
187
  version: "0"
174
188
  requirements: []
175
189
 
176
190
  rubyforge_project:
177
- rubygems_version: 1.3.7
191
+ rubygems_version: 1.5.2
178
192
  signing_key:
179
193
  specification_version: 3
180
194
  summary: Ruby data holder for OGC Simple Features
181
195
  test_files:
196
+ - spec/geo_ruby/geojson_spec.rb
197
+ - spec/geo_ruby/georss.rb
198
+ - spec/geo_ruby/georss_spec.rb
182
199
  - spec/geo_ruby/gpx4r/gpx_spec.rb
183
200
  - spec/geo_ruby/shp4r/shp_spec.rb
184
201
  - spec/geo_ruby/simple_features/envelope_spec.rb
185
202
  - spec/geo_ruby/simple_features/ewkb_parser_spec.rb
186
203
  - spec/geo_ruby/simple_features/ewkt_parser_spec.rb
187
- - spec/geo_ruby/simple_features/geojson_parser_spec.rb
188
204
  - spec/geo_ruby/simple_features/geometry_collection_spec.rb
189
205
  - spec/geo_ruby/simple_features/geometry_factory_spec.rb
190
206
  - spec/geo_ruby/simple_features/geometry_spec.rb
191
- - spec/geo_ruby/simple_features/georss_parser_spec.rb
192
207
  - spec/geo_ruby/simple_features/line_string_spec.rb
193
208
  - spec/geo_ruby/simple_features/linear_ring_spec.rb
194
209
  - spec/geo_ruby/simple_features/multi_line_string_spec.rb
@@ -1,132 +0,0 @@
1
- # GeoJSON parser based on the v1.0 spec at http://geojson.org/geojson-spec.html
2
- require 'json/pure'
3
-
4
- module GeoRuby
5
- module SimpleFeatures
6
- #Raised when an error in the GeoJSON string is detected
7
- class GeojsonFormatError < StandardError
8
- end
9
-
10
- # Class added to support geojson 'Feature' objects
11
- class GeojsonFeature
12
- attr_accessor :geometry, :properties, :id
13
-
14
- def initialize(geometry, properties = {}, id = nil)
15
- @geometry = geometry
16
- @properties = properties
17
- @id = id
18
- end
19
-
20
- def ==(other)
21
- if (self.class != other.class)
22
- false
23
- else
24
- (self.id == other.id) && (self.geometry == other.geometry) && (self.properties == other.properties)
25
- end
26
- end
27
-
28
- def to_json(options={})
29
- output = {}
30
- output[:type] = 'Feature'
31
- output[:geometry] = geometry
32
- output[:properties] = properties
33
- output[:id] = id unless id.nil?
34
- output.to_json(options)
35
- end
36
- alias :as_geojson :to_json
37
- end
38
-
39
- # Class added to support geojson 'Feature Collection' objects
40
- class GeojsonFeatureCollection
41
- attr_accessor :features
42
-
43
- def initialize(features)
44
- @features = features
45
- end
46
-
47
- def ==(other)
48
- if (self.class != other.class) || (features.size != other.features.size)
49
- return false
50
- else
51
- features.each_index do |index|
52
- return false if self.features[index] != other.features[index]
53
- end
54
- end
55
- true
56
- end
57
-
58
- def to_json(options = {})
59
- {:type => 'FeatureCollection',
60
- :features => features}.to_json(options)
61
- end
62
- alias :as_geojson :to_json
63
- end
64
-
65
-
66
- class GeojsonParser
67
- attr_reader :geometry
68
-
69
- def parse(geojson, srid=DEFAULT_SRID)
70
- @geometry = nil
71
- geohash = JSON.parse(geojson)
72
- parse_geohash(geohash, srid)
73
- end
74
-
75
- private
76
-
77
- def parse_geohash(geohash, srid)
78
- srid = srid_from_crs(geohash['crs']) || srid
79
- case geohash['type']
80
- when 'Point', 'MultiPoint', 'LineString', 'MultiLineString', 'Polygon', 'MultiPolygon', 'GeometryCollection'
81
- @geometry = parse_geometry(geohash, srid)
82
- when 'Feature'
83
- @geometry = parse_geojson_feature(geohash, srid)
84
- when 'FeatureCollection'
85
- @geometry = parse_geojson_feature_collection(geohash, srid)
86
- else
87
- GeojsonFormatError.new('Unknown GeoJSON type')
88
- end
89
- end
90
-
91
- def parse_geometry(geohash, srid)
92
- srid = srid_from_crs(geohash['crs']) || srid
93
- if geohash['type'] == 'GeometryCollection'
94
- parse_geometry_collection(geohash, srid)
95
- else
96
- klass = GeoRuby::SimpleFeatures.const_get(geohash['type'])
97
- klass.from_coordinates(geohash['coordinates'], srid, false, false)
98
- end
99
- end
100
-
101
- def parse_geometry_collection(geohash, srid)
102
- srid = srid_from_crs(geohash['crs']) || srid
103
- geometries = geohash['geometries'].map{|g| parse_geometry(g,srid)}
104
- GeometryCollection.from_geometries(geometries,srid)
105
- end
106
-
107
- def parse_geojson_feature(geohash, srid)
108
- srid = srid_from_crs(geohash['crs']) || srid
109
- geometry = parse_geometry(geohash['geometry'],srid)
110
- GeojsonFeature.new(geometry, geohash['properties'], geohash['id'])
111
- end
112
-
113
- def parse_geojson_feature_collection(geohash, srid)
114
- srid = srid_from_crs(geohash['crs']) || srid
115
- features = []
116
- geohash['features'].each do |feature|
117
- features << parse_geojson_feature(feature, srid)
118
- end
119
- GeojsonFeatureCollection.new(features)
120
- end
121
-
122
- def srid_from_crs(crs)
123
- # We somehow need to map crs to srid, currently only support for EPSG
124
- if crs && crs['type'] == 'OGC'
125
- urn = crs['properties']['urn'].split(':')
126
- return urn.last if urn[4] == 'EPSG'
127
- end
128
- return nil
129
- end
130
- end
131
- end
132
- end