GeoRuby 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1,5 +1,5 @@
1
1
  =GeoRuby
2
- This is GeoRuby 1.2.1. It is intended as a holder for data returned from PostGIS and the Spatial Extensions of MySql. The data model roughly follows the OGC "Simple Features for SQL" specification (see http://www.opengis.org/docs/99-049.pdf), although without any kind of advanced functionalities (such as geometric operators or reprojections).
2
+ This is GeoRuby 1.2.3 It is intended as a holder for data returned from PostGIS and the Spatial Extensions of MySql. The data model roughly follows the OGC "Simple Features for SQL" specification (see http://www.opengis.org/docs/99-049.pdf), although without any kind of advanced functionalities (such as geometric operators or reprojections).
3
3
 
4
4
  ===Available data types
5
5
  The following geometric data types are provided :
@@ -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). These formats can also be input and a GeoRuby geometry will be created. Note that it will not read a valid RSS file, only a geometry string.
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>clampToGround</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 and input. 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. For the output, the following geometric types are supported : Point, LineString, Polygon.
25
25
 
26
26
  ===SHP Reading
27
27
  Support for reading ESRI shapefiles (http://www.esri.com/library/whitepapers/pdfs/shapefile.pdf) has been added. A tool called <tt>shp2sql.rb</tt> is also provided : it shows how to use the SHP reading functionality together with the spatial adapter plugin for Rails to import spatial features into MySQL and PostGIS.
@@ -177,12 +177,12 @@ module GeoRuby
177
177
  @shp.seek(16,IO::SEEK_CUR)
178
178
  ms = Array.new(num_points) {@shp.read(8).unpack("E")[0]}
179
179
  points = Array.new(num_points) do |i|
180
- Point.from_x_y_z_m(xys[i][0],xys[i][1],zs[i],ms[i])
180
+ GeoRuby::SimpleFeatures::Point.from_x_y_z_m(xys[i][0],xys[i][1],zs[i],ms[i])
181
181
  end
182
182
  line_strings = Array.new(num_parts) do |i|
183
- GeoRuby::SimpleFeatures::LineString.from_points(points[(parts[i])...(parts[i+1])],DEFAULT_SRID,true,true)
183
+ GeoRuby::SimpleFeatures::LineString.from_points(points[(parts[i])...(parts[i+1])],GeoRuby::SimpleFeatures::DEFAULT_SRID,true,true)
184
184
  end
185
- geometry = GeoRuby::SimpleFeatures::MultiLineString.from_line_strings(line_strings,DEFAULT_SRID,true,true)
185
+ geometry = GeoRuby::SimpleFeatures::MultiLineString.from_line_strings(line_strings,GeoRuby::SimpleFeatures::DEFAULT_SRID,true,true)
186
186
 
187
187
 
188
188
  when ShpType::POLYGONZ
@@ -201,9 +201,9 @@ module GeoRuby
201
201
  Point.from_x_y_z_m(xys[i][0],xys[i][1],zs[i],ms[i])
202
202
  end
203
203
  linear_rings = Array.new(num_parts) do |i|
204
- GeoRuby::SimpleFeatures::LinearRing.from_points(points[(parts[i])...(parts[i+1])],DEFAULT_SRID,true,true)
204
+ GeoRuby::SimpleFeatures::LinearRing.from_points(points[(parts[i])...(parts[i+1])],GeoRuby::SimpleFeatures::DEFAULT_SRID,true,true)
205
205
  end
206
- geometry = GeoRuby::SimpleFeatures::MultiPolygon.from_polygons([GeoRuby::SimpleFeatures::Polygon.from_linear_rings(linear_rings)],DEFAULT_SRID,true,true)
206
+ geometry = GeoRuby::SimpleFeatures::MultiPolygon.from_polygons([GeoRuby::SimpleFeatures::Polygon.from_linear_rings(linear_rings)],GeoRuby::SimpleFeatures::DEFAULT_SRID,true,true)
207
207
 
208
208
 
209
209
  when ShpType::MULTIPOINTZ
@@ -219,7 +219,7 @@ module GeoRuby
219
219
  Point.from_x_y_z_m(xys[i][0],xys[i][1],zs[i],ms[i])
220
220
  end
221
221
 
222
- geometry = GeoRuby::SimpleFeatures::MultiPoint.from_points(points,DEFAULT_SRID,true,true)
222
+ geometry = GeoRuby::SimpleFeatures::MultiPoint.from_points(points,GeoRuby::SimpleFeatures::DEFAULT_SRID,true,true)
223
223
 
224
224
  when ShpType::POINTM
225
225
  x, y, m = @shp.read(24).unpack("E3")
@@ -237,9 +237,9 @@ module GeoRuby
237
237
  Point.from_x_y_m(xys[i][0],xys[i][1],ms[i])
238
238
  end
239
239
  line_strings = Array.new(num_parts) do |i|
240
- GeoRuby::SimpleFeatures::LineString.from_points(points[(parts[i])...(parts[i+1])],DEFAULT_SRID,false,true)
240
+ GeoRuby::SimpleFeatures::LineString.from_points(points[(parts[i])...(parts[i+1])],GeoRuby::SimpleFeatures::DEFAULT_SRID,false,true)
241
241
  end
242
- geometry = GeoRuby::SimpleFeatures::MultiLineString.from_line_strings(line_strings,DEFAULT_SRID,false,true)
242
+ geometry = GeoRuby::SimpleFeatures::MultiLineString.from_line_strings(line_strings,GeoRuby::SimpleFeatures::DEFAULT_SRID,false,true)
243
243
 
244
244
 
245
245
  when ShpType::POLYGONM
@@ -256,9 +256,9 @@ module GeoRuby
256
256
  Point.from_x_y_m(xys[i][0],xys[i][1],ms[i])
257
257
  end
258
258
  linear_rings = Array.new(num_parts) do |i|
259
- GeoRuby::SimpleFeatures::LinearRing.from_points(points[(parts[i])...(parts[i+1])],DEFAULT_SRID,false,true)
259
+ GeoRuby::SimpleFeatures::LinearRing.from_points(points[(parts[i])...(parts[i+1])],GeoRuby::SimpleFeatures::DEFAULT_SRID,false,true)
260
260
  end
261
- geometry = GeoRuby::SimpleFeatures::MultiPolygon.from_polygons([GeoRuby::SimpleFeatures::Polygon.from_linear_rings(linear_rings)],DEFAULT_SRID,false,true)
261
+ geometry = GeoRuby::SimpleFeatures::MultiPolygon.from_polygons([GeoRuby::SimpleFeatures::Polygon.from_linear_rings(linear_rings)],GeoRuby::SimpleFeatures::DEFAULT_SRID,false,true)
262
262
 
263
263
 
264
264
  when ShpType::MULTIPOINTM
@@ -272,7 +272,7 @@ module GeoRuby
272
272
  Point.from_x_y_m(xys[i][0],xys[i][1],ms[i])
273
273
  end
274
274
 
275
- geometry = GeoRuby::SimpleFeatures::MultiPoint.from_points(points,DEFAULT_SRID,false,true)
275
+ geometry = GeoRuby::SimpleFeatures::MultiPoint.from_points(points,GeoRuby::SimpleFeatures::DEFAULT_SRID,false,true)
276
276
  else
277
277
  geometry = nil
278
278
  end
@@ -122,7 +122,7 @@ module GeoRuby
122
122
  e
123
123
  end
124
124
 
125
- #Creates a new envelope. Accept a sequence of points as argument : ((x,y),(x,y))
125
+ #Creates a new envelope. Accept a sequence of point coordinates as argument : ((x,y),(x,y))
126
126
  def self.from_coordinates(points,srid=DEFAULT_SRID,with_z=false)
127
127
  e = Envelope.new(srid,with_z)
128
128
  e.lower_corner, e.upper_corner = points.collect{|point_coords| Point.from_coordinates(point_coords,srid,with_z)}
@@ -77,9 +77,9 @@ module GeoRuby
77
77
  raise GeorssFormatError.new("Bad GML GeoRSS format: Malformed Polygon")
78
78
  end
79
79
  elsif gml =~ /^<\s*[^:>]*:Envelope\s*>/
80
- if gml =~ /<[^:>]*:LowerCorner\s*>([^<]*)</
80
+ if gml =~ /<\s*[^:>]*:lowerCorner\s*>([^<]*)</
81
81
  lc = $1.split(" ").collect { |x| x.to_f}.reverse
82
- if gml =~ /<[^:>]*:UpperCorner\s*>([^<]*)</
82
+ if gml =~ /<\s*[^:>]*:upperCorner\s*>([^<]*)</
83
83
  uc = $1.split(" ").collect { |x| x.to_f}.reverse
84
84
  @geometry = Envelope.from_coordinates([lc,uc])
85
85
  else
@@ -95,24 +95,24 @@ module GeoRuby
95
95
  #must be simple format
96
96
  if georss =~ /^<\s*[^>:]*:point([^>]*)>(.*)</m
97
97
  tags = $1
98
- point = $2.split(" ")
98
+ point = $2.gsub(","," ").split(" ")
99
99
  @geometry = Point.from_x_y(point[1].to_f,point[0].to_f)
100
100
  elsif georss =~ /^<\s*[^>:]*:line([^>]*)>(.*)</m
101
101
  tags = $1
102
102
  @geometry = LineString.new
103
- xy = $2.split(" ")
103
+ xy = $2.gsub(","," ").split(" ")
104
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
105
  elsif georss =~ /^<\s*[^>:]*:polygon([^>]*)>(.*)</m
106
106
  tags = $1
107
107
  @geometry = Polygon.new
108
108
  linear_ring = LinearRing.new
109
109
  @geometry << linear_ring
110
- xy = $2.split(" ")
110
+ xy = $2.gsub(","," ").split(" ")
111
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
112
  elsif georss =~ /^<\s*[^>:]*:box([^>]*)>(.*)</m
113
113
  tags = $1
114
114
  corners = []
115
- xy = $2.split(" ")
115
+ xy = $2.gsub(","," ").split(" ")
116
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
117
  @geometry = Envelope.from_points(corners)
118
118
  else
@@ -122,11 +122,11 @@ module GeoRuby
122
122
  #geometry found: parse tags
123
123
  return unless with_tags
124
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="([^"]*)"/
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
130
 
131
131
  end
132
132
  end
@@ -4,11 +4,11 @@ module GeoRuby
4
4
  module SimpleFeatures
5
5
  #Represents a point. It is in 3D if the Z coordinate is not +nil+.
6
6
  class Point < Geometry
7
-
8
-
7
+
9
8
  attr_accessor :x,:y,:z,:m
10
- #if you prefer calling the coordinates lat and lon
9
+ #if you prefer calling the coordinates lat and lon (or lng, for GeoKit compatibility)
11
10
  alias :lon :x
11
+ alias :lng :x
12
12
  alias :lat :y
13
13
 
14
14
  def initialize(srid=DEFAULT_SRID,with_z=false,with_m=false)
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.2.2"
27
+ s.version = "1.2.3"
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)
@@ -146,7 +146,7 @@ class TestGeorssKml < Test::Unit::TestCase
146
146
  assert_equal(geom.class, Envelope)
147
147
  assert_equal(e, geom)
148
148
 
149
- str = "<georss:where><gml:Envelope><gml:LowerCorner>-45.3 \n 4.456</gml:LowerCorner><gml:UpperCorner>41.6 \t\n 45.4</gml:UpperCorner></gml:Envelope></georss:where>"
149
+ str = "<georss:where><gml:Envelope><gml:lowerCorner>-45.3 \n 4.456</gml:lowerCorner><gml:upperCorner>41.6 \t\n 45.4</gml:upperCorner></gml:Envelope></georss:where>"
150
150
  geom = Geometry.from_georss(str)
151
151
  assert_equal(geom.class, Envelope)
152
152
  assert_equal(e, geom)
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.2.2
7
- date: 2007-03-24 00:00:00 +01:00
6
+ version: 1.2.3
7
+ date: 2007-04-01 00:00:00 +02:00
8
8
  summary: Ruby data holder for OGC Simple Features
9
9
  require_paths:
10
10
  - lib