GeoRuby 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -21,7 +21,7 @@ These geometries can be input and output in WKB/EWKB/WKT/EWKT format (as well as
21
21
 
22
22
  GeoRSS Simple, GeoRSS W3CGeo, GeoRSS GML can also be input and output. Note that they will not output valid RSS, but just the part strictly concerning the geometry as outlined in http://www.georss.org/1/ . Since the model does not allow multiple geometries, for geometry collections, only the first geometry will be output. Similarly, for polygons, the GeoRSS output will only contain the outer ring. As for W3CGeo output, only points can be output, so the first point of the geometry is chosen. By default the Simple format is output. Envelope can also be output in these formats: The box geometric type is chosen (except for W3CGeo, where the center of the envelope is chose).
23
23
 
24
- On top of that, there is now support for KML output. As for GeoRSS, a valid KML file will not be output, but only the geometric data. Options <tt>:id</tt>, <tt>:extrude</tt>, <tt>:tesselate</tt> and <tt>:altitude_mode</tt> can be given. Note that if the <tt>:altitude_mode</tt> option is not passed or set to <tt>clampedToGround</tt>, the altitude data will not be output even if present. Envelopes output a LatLonAltBox instead of a geometry.
24
+ On top of that, there is now support for KML output. As for GeoRSS, a valid KML file will not be output, but only the geometric data. Options <tt>:id</tt>, <tt>:extrude</tt>, <tt>:tesselate</tt> and <tt>:altitude_mode</tt> can be given. Note that if the <tt>:altitude_mode</tt> option is not passed or set to <tt>clampToGround</tt>, the altitude data will not be output even if present. Envelopes output a LatLonAltBox instead of a geometry.
25
25
 
26
26
  ===Installation
27
27
  To install the latest version, just type :
@@ -46,7 +46,7 @@ module GeoRuby
46
46
 
47
47
  #georss serialization: Dialect can be passed as option <tt>:dialect</tt> and set to <tt>:simple</tt> (default)
48
48
  #<tt>:w3cgeo</tt> or <tt>:gml</tt>. Options <tt>:featuretypetag
49
- def as_georss(options)
49
+ def as_georss(options = {})
50
50
  dialect= options[:dialect] || :simple
51
51
  case(dialect)
52
52
  when :simple
@@ -66,21 +66,21 @@ module GeoRuby
66
66
  end
67
67
 
68
68
  #georss simple representation
69
- def georss_simple_representation(options) #:nodoc:
69
+ def georss_simple_representation(options = {}) #:nodoc:
70
70
  georss_ns = options[:georss_ns] || "georss"
71
71
  geom_attr = options[:geom_attr]
72
72
  "<#{georss_ns}:box#{geom_attr}>#{lower_corner.y} #{lower_corner.x} #{upper_corner.y} #{upper_corner.x}</#{georss_ns}:box>\n"
73
73
  end
74
74
 
75
75
  #georss w3c representation : outputs the first point of the line
76
- def georss_w3cgeo_representation(options) #:nodoc:
76
+ def georss_w3cgeo_representation(options = {}) #:nodoc:
77
77
  w3cgeo_ns = options[:w3cgeo_ns] || "geo"
78
78
  point = self.center
79
79
  "<#{w3cgeo_ns}:lat>#{point.y}</#{w3cgeo_ns}:lat>\n<#{w3cgeo_ns}:long>#{point.x}</#{w3cgeo_ns}:long>\n"
80
80
  end
81
81
 
82
82
  #georss gml representation
83
- def georss_gml_representation(options) #:nodoc:
83
+ def georss_gml_representation(options = {}) #:nodoc:
84
84
  georss_ns = options[:georss_ns] || "georss"
85
85
  gml_ns = options[:gml_ns] || "gml"
86
86
  result = "<#{georss_ns}:where>\n<#{gml_ns}:Envelope>\n"
@@ -2,14 +2,7 @@ module GeoRuby#:nodoc:
2
2
  module SimpleFeatures
3
3
  #arbitrary default SRID
4
4
  DEFAULT_SRID=-1
5
- #indicates the presence of Z coordinates in EWKB strings
6
- Z_MASK=0x80000000
7
- #indicates the presence of M coordinates in EWKB strings.
8
- M_MASK=0x40000000
9
- #indicate the presence of a SRID in EWKB strings.
10
- SRID_MASK=0x20000000
11
-
12
-
5
+
13
6
  #Root of all geometric data classes.
14
7
  #Objects of class Geometry should not be instantiated.
15
8
  class Geometry
@@ -125,9 +118,10 @@ module GeoRuby#:nodoc:
125
118
  geom_data += "<tesselate>#{options[:tesselate]}</tesselate>\n" if options[:tesselate]
126
119
  geom_data += "<altitudeMode>#{options[:altitude_mode]}</altitudeMode>\n" if options[:altitude_mode]
127
120
 
128
- allow_z = with_z && (!options[:altitude_mode].nil?) && options[:atitude_mode] != "clampToGround"
121
+ allow_z = (with_z || !options[:altitude].nil? )&& (!options[:altitude_mode].nil?) && options[:atitude_mode] != "clampToGround"
122
+ fixed_z = options[:altitude]
129
123
 
130
- kml_representation(options.merge(:id_attr => id_attr, :geom_data => geom_data, :allow_z => allow_z))
124
+ kml_representation(options.merge(:id_attr => id_attr, :geom_data => geom_data, :allow_z => allow_z, :fixed_z => fixed_z))
131
125
  end
132
126
 
133
127
  #Creates a geometry based on a EWKB string. The actual class returned depends of the content of the string passed as argument. Since WKB strings are a subset of EWKB, they are also valid.
@@ -0,0 +1,18 @@
1
+ module GeoRuby
2
+ module SimpleFeatures
3
+ #indicates the presence of Z coordinates in EWKB strings
4
+ Z_MASK=0x80000000
5
+ #indicates the presence of M coordinates in EWKB strings.
6
+ M_MASK=0x40000000
7
+ #indicate the presence of a SRID in EWKB strings.
8
+ SRID_MASK=0x20000000
9
+ #GeoRSS namespace
10
+ GEORSS_NS = "http://www.georss.org/georss"
11
+ #GML Namespace
12
+ GML_NS = "http://www.opengis.net/gml"
13
+ #W3CGeo Namespace
14
+ W3CGEO_NS = "http://www.w3.org/2003/01/geo/wgs84_pos#"
15
+ #KML Namespace
16
+ KML_NS = "http://earth.google.com/kml/2.1"
17
+ end
18
+ end
@@ -116,14 +116,14 @@ module GeoRuby
116
116
  result = "<LineString#{options[:id_attr]}>\n"
117
117
  result += options[:geom_data]
118
118
  result += "<coordinates>"
119
- result += kml_poslist(options[:allow_z])
119
+ result += kml_poslist(options)
120
120
  result += "</coordinates>\n"
121
121
  result += "</LineString>\n"
122
122
  end
123
123
 
124
- def kml_poslist(allow_z) #:nodoc:
125
- if allow_z
126
- map {|point| "#{point.x},#{point.y},#{point.z || 0}" }.join(" ")
124
+ def kml_poslist(options) #:nodoc:
125
+ if options[:allow_z]
126
+ map {|point| "#{point.x},#{point.y},#{options[:fixed_z] || point.z || 0}" }.join(" ")
127
127
  else
128
128
  map {|point| "#{point.x},#{point.y}" }.join(" ")
129
129
  end
@@ -173,7 +173,7 @@ module GeoRuby
173
173
  result = "<Point#{options[:id_attr]}>\n"
174
174
  result += options[:geom_data]
175
175
  result += "<coordinates>#{x},#{y}"
176
- result += ",#{z || 0}" if options[:allow_z]
176
+ result += ",#{options[:fixed_z] || z ||0}" if options[:allow_z]
177
177
  result += "</coordinates>\n"
178
178
  result += "</Point>\n"
179
179
  end
@@ -103,7 +103,7 @@ module GeoRuby
103
103
  boundary = "innerBoundaryIs"
104
104
  end
105
105
  result += "<#{boundary}><LinearRing><coordinates>\n"
106
- result += ring.kml_poslist(options[:allow_z])
106
+ result += ring.kml_poslist(options)
107
107
  result += "\n</coordinates></LinearRing></#{boundary}>\n"
108
108
  end
109
109
  result += "</Polygon>\n"
data/lib/geo_ruby.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'geo_ruby/simple_features/helper'
1
2
  require 'geo_ruby/simple_features/geometry'
2
3
  require 'geo_ruby/simple_features/point'
3
4
  require 'geo_ruby/simple_features/line_string'
@@ -8,8 +9,8 @@ require 'geo_ruby/simple_features/multi_line_string'
8
9
  require 'geo_ruby/simple_features/multi_polygon'
9
10
  require 'geo_ruby/simple_features/geometry_collection'
10
11
  require 'geo_ruby/simple_features/envelope'
12
+ require 'geo_ruby/simple_features/geometry_factory'
11
13
  require 'geo_ruby/simple_features/ewkb_parser'
12
14
  require 'geo_ruby/simple_features/ewkt_parser'
13
- require 'geo_ruby/simple_features/geometry_factory'
14
15
  require 'geo_ruby/simple_features/georss_parser'
15
16
 
data/rakefile.rb CHANGED
@@ -24,7 +24,7 @@ spec = Gem::Specification::new do |s|
24
24
  s.platform = Gem::Platform::RUBY
25
25
 
26
26
  s.name = 'GeoRuby'
27
- s.version = "1.1.1"
27
+ s.version = "1.1.2"
28
28
  s.summary = "Ruby data holder for OGC Simple Features"
29
29
  s.description = <<EOF
30
30
  GeoRuby is intended as a holder for data returned from PostGIS and MySQL Spatial queries. The data model roughly follows the OGC "Simple Features for SQL" specification (see www.opengis.org/docs/99-049.pdf), although without any kind of advanced functionalities (such as geometric operators or reprojections)
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: GeoRuby
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.1.1
7
- date: 2007-01-02 00:00:00 +01:00
6
+ version: 1.1.2
7
+ date: 2007-01-05 00:00:00 +01:00
8
8
  summary: Ruby data holder for OGC Simple Features
9
9
  require_paths:
10
10
  - lib
@@ -37,6 +37,7 @@ files:
37
37
  - lib/geo_ruby/simple_features/geometry_collection.rb
38
38
  - lib/geo_ruby/simple_features/geometry_factory.rb
39
39
  - lib/geo_ruby/simple_features/georss_parser.rb
40
+ - lib/geo_ruby/simple_features/helper.rb
40
41
  - lib/geo_ruby/simple_features/linear_ring.rb
41
42
  - lib/geo_ruby/simple_features/line_string.rb
42
43
  - lib/geo_ruby/simple_features/multi_line_string.rb