GeoRuby 0.2.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -25,6 +25,7 @@ To install the latest version, just type :
25
25
  - Correction of the output of the MultiPoint EWKT string to follow the specification, instead of what is shown in the examples (of the specification) and output by PostGIS. For example, the string previously output as MULTIPOINT(123.4 123.5,456.7 678.887) will now be output as MULTIPOINT((123.4 123.5),(456.7 678.887))
26
26
  - Modification of the EWKT input to support the correct MultiPoint EWKT format, on top of the previous one. So both MULTIPOINT(123.4 123.5,456.7 678.887) and MULTIPOINT((123.4 123.5),(456.7 678.887)) would be accepted as valid MultiPoint strings.
27
27
  - Addition of a +bounding_box+ method on geometries. Return an array of 2 points representing the 2 corners of the box.
28
+ - Geometries that are aggregation of other geometries (line strings, polygons, multi points, multi line strings, multi polygons and geometry collections) can now behave exactly like arrays.
28
29
 
29
30
  ===License
30
31
  GeoRuby is released under the MIT license.
@@ -26,6 +26,25 @@ module GeoRuby
26
26
  @y=y
27
27
  end
28
28
 
29
+ #Return the distance between the 2D points (ie taking care only of the x and y coordinates), assuming the points are in projected coordinates. Euclidian distance in whatever unit the x and y ordinates are.
30
+ def euclidian_distance(point)
31
+ Math.sqrt((point.x - x)**2 + (point.y - y)**2)
32
+ end
33
+
34
+ #Returns the sperical distance, with a radius of 6471000m, with the haversine law. Assumes x is the lon and y the lat, in radians. Returns the distance in meters by default, although by passing a value to the radius argument, this can be changed.
35
+ def spherical_distance(point,radius=6371000)
36
+ dlat = point.y - y
37
+ dlon = point.x - x
38
+ a = Math.sin(dlat/2)**2 + Math.cos(point.y) * Math.cos(y) * (Math.sin(dlon/2)**2)
39
+ c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a))
40
+ radius * c
41
+ end
42
+
43
+ #Ellipsoidal distance? Not implemented yet. Complicated and don't feel like it today. Check out http://www.movable-type.co.uk/scripts/LatLongVincenty.html for more info. I accept patches...
44
+ def ellipsoidal_distance(point)
45
+ end
46
+
47
+
29
48
  #Bounding box in 2D. Returns an array of 2 points
30
49
  def bounding_box
31
50
  [Point.from_x_y(@x,@y),Point.from_x_y(@x,@y)] #not too difficult...
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 = "0.2.1"
27
+ s.version = "1.0.0"
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)
@@ -137,6 +137,17 @@ class TestSimpleFeatures < Test::Unit::TestCase
137
137
  assert_equal("SRID=123;POINT(12.4 45.3)", point.as_ewkt(true,true,false))
138
138
  end
139
139
 
140
+ def test_point_distance
141
+ point1 = Point.from_x_y(0,0)
142
+ point2 = Point.from_x_y(3,4)
143
+ assert_equal(point1.euclidian_distance(point2),5)
144
+
145
+ point2 = Point.from_x_y(Math::PI,0)
146
+ assert_in_delta(point1.spherical_distance(point2),20015086,1)
147
+
148
+
149
+ end
150
+
140
151
  def test_line_string_creation
141
152
  line_string = LineString::new
142
153
  line_string.concat([Point.from_x_y(12.4,45.3),Point.from_x_y(45.4,41.6)])
metadata CHANGED
@@ -1,10 +1,10 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
2
+ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: GeoRuby
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.2.1
7
- date: 2006-06-02 00:00:00 +05:00
6
+ version: 1.0.0
7
+ date: 2006-08-23 00:00:00 +01:00
8
8
  summary: Ruby data holder for OGC Simple Features
9
9
  require_paths:
10
10
  - lib
@@ -25,6 +25,7 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
25
25
  platform: ruby
26
26
  signing_key:
27
27
  cert_chain:
28
+ post_install_message:
28
29
  authors:
29
30
  - Guilhem Vellut
30
31
  files: