nofxx-georuby 1.9.0 → 1.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,135 +0,0 @@
1
- require 'geo_ruby/simple_features/point'
2
- require 'geo_ruby/simple_features/line_string'
3
- require 'geo_ruby/simple_features/linear_ring'
4
- require 'geo_ruby/simple_features/polygon'
5
- require 'geo_ruby/simple_features/multi_point'
6
- require 'geo_ruby/simple_features/multi_line_string'
7
- require 'geo_ruby/simple_features/multi_polygon'
8
- require 'geo_ruby/simple_features/geometry_collection'
9
- require 'geo_ruby/simple_features/envelope'
10
-
11
- module GeoRuby
12
- module SimpleFeatures
13
-
14
- #Raised when an error in the GeoRSS string is detected
15
- class GeorssFormatError < StandardError
16
- end
17
-
18
- #Contains tags possibly found on GeoRss Simple geometries
19
- class GeorssTags < Struct.new(:featuretypetag,:relationshiptag,:elev,:floor,:radius)
20
- end
21
-
22
- #Parses GeoRSS strings
23
- #You can also use directly the static method Geometry.from_georss
24
- class GeorssParser
25
- attr_reader :georss_tags, :geometry
26
-
27
- #Parses the georss geometry passed as argument and notifies the factory of events
28
- #The parser assumes
29
- def parse(georss,with_tags = false)
30
- @geometry = nil
31
- @georss_tags = GeorssTags.new
32
- parse_geometry(georss,with_tags)
33
- end
34
-
35
- private
36
- def parse_geometry(georss,with_tags)
37
- georss.strip!
38
- #check for W3CGeo first
39
- if georss =~ /<[^:>]*:lat\s*>([^<]*)</
40
- #if valid, it is W3CGeo
41
- lat = $1.to_f
42
- if georss =~ /<[^:>]*:long\s*>([^<]*)</
43
- lon = $1.to_f
44
- @geometry = Point.from_x_y(lon,lat)
45
- else
46
- raise GeorssFormatError.new("Bad W3CGeo GeoRSS format")
47
- end
48
- elsif georss =~ /^<\s*[^:>]*:where\s*>/
49
- #GML format found
50
- gml = $'.strip
51
- if gml =~ /^<\s*[^:>]*:Point\s*>/
52
- #gml point
53
- if gml =~ /<\s*[^:>]*:pos\s*>([^<]*)/
54
- point = $1.split(" ")
55
- #lat comes first
56
- @geometry = Point.from_x_y(point[1].to_f,point[0].to_f)
57
- else
58
- raise GeorssFormatError.new("Bad GML GeoRSS format: Malformed Point")
59
- end
60
- elsif gml =~ /^<\s*[^:>]*:LineString\s*>/
61
- if gml =~ /<\s*[^:>]*:posList\s*>([^<]*)/
62
- xy = $1.split(" ")
63
- @geometry = LineString.new
64
- 0.upto(xy.size/2 - 1) { |index| @geometry << Point.from_x_y(xy[index*2 + 1].to_f,xy[index*2].to_f)}
65
- else
66
- raise GeorssFormatError.new("Bad GML GeoRSS format: Malformed LineString")
67
- end
68
- elsif gml =~ /^<\s*[^:>]*:Polygon\s*>/
69
- if gml =~ /<\s*[^:>]*:posList\s*>([^<]*)/
70
- xy = $1.split(" ")
71
- @geometry = Polygon.new
72
- linear_ring = LinearRing.new
73
- @geometry << linear_ring
74
- xy = $1.split(" ")
75
- 0.upto(xy.size/2 - 1) { |index| linear_ring << Point.from_x_y(xy[index*2 + 1].to_f,xy[index*2].to_f)}
76
- else
77
- raise GeorssFormatError.new("Bad GML GeoRSS format: Malformed Polygon")
78
- end
79
- elsif gml =~ /^<\s*[^:>]*:Envelope\s*>/
80
- if gml =~ /<\s*[^:>]*:lowerCorner\s*>([^<]*)</
81
- lc = $1.split(" ").collect { |x| x.to_f}.reverse
82
- if gml =~ /<\s*[^:>]*:upperCorner\s*>([^<]*)</
83
- uc = $1.split(" ").collect { |x| x.to_f}.reverse
84
- @geometry = Envelope.from_coordinates([lc,uc])
85
- else
86
- raise GeorssFormatError.new("Bad GML GeoRSS format: Malformed Envelope")
87
- end
88
- else
89
- raise GeorssFormatError.new("Bad GML GeoRSS format: Malformed Envelope")
90
- end
91
- else
92
- raise GeorssFormatError.new("Bad GML GeoRSS format: Unknown geometry type")
93
- end
94
- else
95
- #must be simple format
96
- if georss =~ /^<\s*[^>:]*:point([^>]*)>(.*)</m
97
- tags = $1
98
- point = $2.gsub(","," ").split(" ")
99
- @geometry = Point.from_x_y(point[1].to_f,point[0].to_f)
100
- elsif georss =~ /^<\s*[^>:]*:line([^>]*)>(.*)</m
101
- tags = $1
102
- @geometry = LineString.new
103
- xy = $2.gsub(","," ").split(" ")
104
- 0.upto(xy.size/2 - 1) { |index| @geometry << Point.from_x_y(xy[index*2 + 1].to_f,xy[index*2].to_f)}
105
- elsif georss =~ /^<\s*[^>:]*:polygon([^>]*)>(.*)</m
106
- tags = $1
107
- @geometry = Polygon.new
108
- linear_ring = LinearRing.new
109
- @geometry << linear_ring
110
- xy = $2.gsub(","," ").split(" ")
111
- 0.upto(xy.size/2 - 1) { |index| linear_ring << Point.from_x_y(xy[index*2 + 1].to_f,xy[index*2].to_f)}
112
- elsif georss =~ /^<\s*[^>:]*:box([^>]*)>(.*)</m
113
- tags = $1
114
- corners = []
115
- xy = $2.gsub(","," ").split(" ")
116
- 0.upto(xy.size/2 - 1) {|index| corners << Point.from_x_y(xy[index*2 + 1].to_f,xy[index*2].to_f)}
117
- @geometry = Envelope.from_points(corners)
118
- else
119
- raise GeorssFormatError.new("Bad Simple GeoRSS format: Unknown geometry type")
120
- end
121
-
122
- #geometry found: parse tags
123
- return unless with_tags
124
-
125
- @georss_tags.featuretypetag = $1 if tags =~ /featuretypetag=['"]([^"']*)['"]/
126
- @georss_tags.relationshiptag = $1 if tags =~ /relationshiptag=['"]([^'"]*)['"]/
127
- @georss_tags.elev = $1.to_f if tags =~ /elev=['"]([^'"]*)['"]/
128
- @georss_tags.floor = $1.to_i if tags =~ /floor=['"]([^'"]*)['"]/
129
- @georss_tags.radius = $1.to_f if tags =~ /radius=['"]([^'"]*)['"]/
130
-
131
- end
132
- end
133
- end
134
- end
135
- end
@@ -1,136 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{marcusmateus-georuby}
8
- s.version = "1.8.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Guilhem Vellut", "Marcos Piccinini", "Marcus Mateus"]
12
- s.date = %q{2010-12-19}
13
- s.description = %q{GeoRuby provides geometric data types from the OGC 'Simple Features' specification.}
14
- s.email = %q{georuby@simplitex.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE",
17
- "README.rdoc"
18
- ]
19
- s.files = [
20
- "History.txt",
21
- "LICENSE",
22
- "README.rdoc",
23
- "Rakefile",
24
- "VERSION",
25
- "lib/geo_ruby.rb",
26
- "lib/geo_ruby/gpx.rb",
27
- "lib/geo_ruby/gpx4r/gpx.rb",
28
- "lib/geo_ruby/shp.rb",
29
- "lib/geo_ruby/shp4r/dbf.rb",
30
- "lib/geo_ruby/shp4r/shp.rb",
31
- "lib/geo_ruby/simple_features/envelope.rb",
32
- "lib/geo_ruby/simple_features/ewkb_parser.rb",
33
- "lib/geo_ruby/simple_features/ewkt_parser.rb",
34
- "lib/geo_ruby/simple_features/geojson_parser.rb",
35
- "lib/geo_ruby/simple_features/geometry.rb",
36
- "lib/geo_ruby/simple_features/geometry_collection.rb",
37
- "lib/geo_ruby/simple_features/geometry_factory.rb",
38
- "lib/geo_ruby/simple_features/georss_parser.rb",
39
- "lib/geo_ruby/simple_features/helper.rb",
40
- "lib/geo_ruby/simple_features/line_string.rb",
41
- "lib/geo_ruby/simple_features/linear_ring.rb",
42
- "lib/geo_ruby/simple_features/multi_line_string.rb",
43
- "lib/geo_ruby/simple_features/multi_point.rb",
44
- "lib/geo_ruby/simple_features/multi_polygon.rb",
45
- "lib/geo_ruby/simple_features/point.rb",
46
- "lib/geo_ruby/simple_features/polygon.rb",
47
- "script/console",
48
- "script/destroy",
49
- "script/generate",
50
- "script/txt2html",
51
- "spec/data/geojson/feature_collection.json",
52
- "spec/data/gpx/fells_loop.gpx",
53
- "spec/data/gpx/long.gpx",
54
- "spec/data/gpx/long.kml",
55
- "spec/data/gpx/long.nmea",
56
- "spec/data/gpx/short.gpx",
57
- "spec/data/gpx/short.kml",
58
- "spec/data/gpx/tracktreks.gpx",
59
- "spec/data/multipoint.dbf",
60
- "spec/data/multipoint.shp",
61
- "spec/data/multipoint.shx",
62
- "spec/data/point.dbf",
63
- "spec/data/point.shp",
64
- "spec/data/point.shx",
65
- "spec/data/polygon.dbf",
66
- "spec/data/polygon.shp",
67
- "spec/data/polygon.shx",
68
- "spec/data/polyline.dbf",
69
- "spec/data/polyline.shp",
70
- "spec/data/polyline.shx",
71
- "spec/geo_ruby/gpx4r/gpx_spec.rb",
72
- "spec/geo_ruby/shp4r/shp_spec.rb",
73
- "spec/geo_ruby/simple_features/envelope_spec.rb",
74
- "spec/geo_ruby/simple_features/ewkb_parser_spec.rb",
75
- "spec/geo_ruby/simple_features/ewkt_parser_spec.rb",
76
- "spec/geo_ruby/simple_features/geojson_parser_spec.rb",
77
- "spec/geo_ruby/simple_features/geometry_collection_spec.rb",
78
- "spec/geo_ruby/simple_features/geometry_factory_spec.rb",
79
- "spec/geo_ruby/simple_features/geometry_spec.rb",
80
- "spec/geo_ruby/simple_features/georss_parser_spec.rb",
81
- "spec/geo_ruby/simple_features/line_string_spec.rb",
82
- "spec/geo_ruby/simple_features/linear_ring_spec.rb",
83
- "spec/geo_ruby/simple_features/multi_line_string_spec.rb",
84
- "spec/geo_ruby/simple_features/multi_point_spec.rb",
85
- "spec/geo_ruby/simple_features/multi_polygon_spec.rb",
86
- "spec/geo_ruby/simple_features/point_spec.rb",
87
- "spec/geo_ruby/simple_features/polygon_spec.rb",
88
- "spec/geo_ruby_spec.rb",
89
- "spec/spec_helper.rb"
90
- ]
91
- s.homepage = %q{http://github.com/marcusmateus/georuby}
92
- s.require_paths = ["lib"]
93
- s.rubygems_version = %q{1.3.7}
94
- s.summary = %q{Ruby data holder for OGC Simple Features}
95
- s.test_files = [
96
- "spec/geo_ruby/gpx4r/gpx_spec.rb",
97
- "spec/geo_ruby/shp4r/shp_spec.rb",
98
- "spec/geo_ruby/simple_features/envelope_spec.rb",
99
- "spec/geo_ruby/simple_features/ewkb_parser_spec.rb",
100
- "spec/geo_ruby/simple_features/ewkt_parser_spec.rb",
101
- "spec/geo_ruby/simple_features/geojson_parser_spec.rb",
102
- "spec/geo_ruby/simple_features/geometry_collection_spec.rb",
103
- "spec/geo_ruby/simple_features/geometry_factory_spec.rb",
104
- "spec/geo_ruby/simple_features/geometry_spec.rb",
105
- "spec/geo_ruby/simple_features/georss_parser_spec.rb",
106
- "spec/geo_ruby/simple_features/line_string_spec.rb",
107
- "spec/geo_ruby/simple_features/linear_ring_spec.rb",
108
- "spec/geo_ruby/simple_features/multi_line_string_spec.rb",
109
- "spec/geo_ruby/simple_features/multi_point_spec.rb",
110
- "spec/geo_ruby/simple_features/multi_polygon_spec.rb",
111
- "spec/geo_ruby/simple_features/point_spec.rb",
112
- "spec/geo_ruby/simple_features/polygon_spec.rb",
113
- "spec/geo_ruby_spec.rb",
114
- "spec/spec_helper.rb"
115
- ]
116
-
117
- if s.respond_to? :specification_version then
118
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
119
- s.specification_version = 3
120
-
121
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
122
- s.add_runtime_dependency(%q<json_pure>, [">= 1.4.6"])
123
- s.add_development_dependency(%q<rspec>, [">= 2.0.0"])
124
- s.add_development_dependency(%q<dbf>, [">= 1.2.9"])
125
- else
126
- s.add_dependency(%q<json_pure>, [">= 1.4.6"])
127
- s.add_dependency(%q<rspec>, [">= 2.0.0"])
128
- s.add_dependency(%q<dbf>, [">= 1.2.9"])
129
- end
130
- else
131
- s.add_dependency(%q<json_pure>, [">= 1.4.6"])
132
- s.add_dependency(%q<rspec>, [">= 2.0.0"])
133
- s.add_dependency(%q<dbf>, [">= 1.2.9"])
134
- end
135
- end
136
-
@@ -1,10 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # File: script/console
3
- irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
-
5
- libs = " -r irb/completion"
6
- # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
- # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
- libs << " -r #{File.dirname(__FILE__) + '/../lib/geo_ruby.rb'}"
9
- puts "Loading geo_ruby gem"
10
- exec "#{irb} #{libs} --simple-prompt"
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/destroy'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::SimpleFeatures.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
-
4
- begin
5
- require 'rubigen'
6
- rescue LoadError
7
- require 'rubygems'
8
- require 'rubigen'
9
- end
10
- require 'rubigen/scripts/generate'
11
-
12
- ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
- RubiGen::SimpleFeatures.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
- RubiGen::Scripts::Generate.new.run(ARGV)
@@ -1,82 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- GEM_NAME = 'geo_ruby' # what ppl will type to install your gem
4
- RUBYFORGE_PROJECT = 'geo_ruby'
5
-
6
- require 'rubygems'
7
- begin
8
- require 'newgem'
9
- require 'rubyforge'
10
- rescue LoadError
11
- puts "\n\nGenerating the website requires the newgem RubyGem"
12
- puts "Install: gem install newgem\n\n"
13
- exit(1)
14
- end
15
- require 'redcloth'
16
- require 'syntax/convertors/html'
17
- require 'erb'
18
- require File.dirname(__FILE__) + "/../lib/#{GEM_NAME}/version.rb"
19
-
20
- version = GeoRuby::VERSION::STRING
21
- download = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
22
-
23
- def rubyforge_project_id
24
- RubyForge.new.autoconfig["group_ids"][RUBYFORGE_PROJECT]
25
- end
26
-
27
- class Fixnum
28
- def ordinal
29
- # teens
30
- return 'th' if (10..19).include?(self % 100)
31
- # others
32
- case self % 10
33
- when 1: return 'st'
34
- when 2: return 'nd'
35
- when 3: return 'rd'
36
- else return 'th'
37
- end
38
- end
39
- end
40
-
41
- class Time
42
- def pretty
43
- return "#{mday}#{mday.ordinal} #{strftime('%B')} #{year}"
44
- end
45
- end
46
-
47
- def convert_syntax(syntax, source)
48
- return Syntax::Convertors::HTML.for_syntax(syntax).convert(source).gsub(%r!^<pre>|</pre>$!,'')
49
- end
50
-
51
- if ARGV.length >= 1
52
- src, template = ARGV
53
- template ||= File.join(File.dirname(__FILE__), '/../website/template.html.erb')
54
- else
55
- puts("Usage: #{File.split($0).last} source.txt [template.html.erb] > output.html")
56
- exit!
57
- end
58
-
59
- template = ERB.new(File.open(template).read)
60
-
61
- title = nil
62
- body = nil
63
- File.open(src) do |fsrc|
64
- title_text = fsrc.readline
65
- body_text_template = fsrc.read
66
- body_text = ERB.new(body_text_template).result(binding)
67
- syntax_items = []
68
- body_text.gsub!(%r!<(pre|code)[^>]*?syntax=['"]([^'"]+)[^>]*>(.*?)</\1>!m){
69
- ident = syntax_items.length
70
- element, syntax, source = $1, $2, $3
71
- syntax_items << "<#{element} class='syntax'>#{convert_syntax(syntax, source)}</#{element}>"
72
- "syntax-temp-#{ident}"
73
- }
74
- title = RedCloth.new(title_text).to_html.gsub(%r!<.*?>!,'').strip
75
- body = RedCloth.new(body_text).to_html
76
- body.gsub!(%r!(?:<pre><code>)?syntax-temp-(\d+)(?:</code></pre>)?!){ syntax_items[$1.to_i] }
77
- end
78
- stat = File.stat(src)
79
- created = stat.ctime
80
- modified = stat.mtime
81
-
82
- $stdout << template.result(binding)