griffordson-georuby-extras 0.6.0 → 0.7.0

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.
Files changed (5) hide show
  1. data/README +1 -0
  2. data/ext/pnpoly.c +12 -12
  3. data/ext/pnpoly.h +13 -1
  4. data/ext/vincenty.c +12 -12
  5. metadata +6 -8
data/README CHANGED
@@ -20,6 +20,7 @@ with GIS extensions for popular databases including Postgres and MySQL.
20
20
  * Adds the Vincenty 'direct' algorithm (point_at_bearing_and_distance).
21
21
  * Provides native C implementation of a ray casting algorithm to detect if a point is contained in a polygon.
22
22
  * No known problems; won't work with JRuby or non-MRI Ruby implementations.
23
+ * Compatible with Ruby 1.8.7 and 1.9.x
23
24
 
24
25
  == SYNOPSIS:
25
26
 
data/ext/pnpoly.c CHANGED
@@ -59,7 +59,7 @@
59
59
  #include "ruby.h"
60
60
  #include "pnpoly.h"
61
61
 
62
- static int pnpoly(int nvert, float *vertx, float *verty, float testx, float testy)
62
+ static int pnpoly(int nvert, double *vertx, double *verty, double testx, double testy)
63
63
  {
64
64
  int i, j, c = 0;
65
65
  for (i = 0, j = nvert-1; i < nvert; j = i++) {
@@ -74,17 +74,17 @@ VALUE point_in_poly(VALUE self, VALUE rb_x, VALUE rb_y, VALUE rb_points) {
74
74
  Check_Type(rb_x, T_FLOAT);
75
75
  Check_Type(rb_y, T_FLOAT);
76
76
  Check_Type(rb_points, T_ARRAY);
77
-
77
+
78
78
  int i = 0;
79
- int s = RARRAY(rb_points)->len;
80
- float *vertx;
81
- float *verty;
79
+ int s = (int)RARRAY_LEN(rb_points);
80
+ double *vertx;
81
+ double *verty;
82
82
 
83
- vertx = calloc(s, sizeof(float));
84
- verty = calloc(s, sizeof(float));
83
+ vertx = calloc(s, sizeof(double));
84
+ verty = calloc(s, sizeof(double));
85
85
 
86
- float test_x = RFLOAT(rb_x)->value;
87
- float test_y = RFLOAT(rb_y)->value;
86
+ double test_x = RFLOAT_VALUE(rb_x);
87
+ double test_y = RFLOAT_VALUE(rb_y);
88
88
 
89
89
  ID i_x = rb_intern("x");
90
90
  ID i_y = rb_intern("y");
@@ -95,11 +95,11 @@ VALUE point_in_poly(VALUE self, VALUE rb_x, VALUE rb_y, VALUE rb_points) {
95
95
  VALUE y = rb_funcall(point, i_y, 0);
96
96
  Check_Type(x, T_FLOAT);
97
97
  Check_Type(y, T_FLOAT);
98
- vertx[i] = RFLOAT(x)->value;
99
- verty[i] = RFLOAT(y)->value;
98
+ vertx[i] = RFLOAT_VALUE(x);
99
+ verty[i] = RFLOAT_VALUE(y);
100
100
  }
101
101
 
102
102
  return pnpoly(s, vertx, verty, test_x, test_y);
103
103
  }
104
104
 
105
- // end
105
+ // end
data/ext/pnpoly.h CHANGED
@@ -3,4 +3,16 @@
3
3
 
4
4
  VALUE point_in_poly(VALUE self, VALUE rb_lat, VALUE rb_lon, VALUE rb_points);
5
5
 
6
- #endif // _pnpoly_h_
6
+ #ifndef RUBY_19
7
+ #ifndef RARRAY_LEN
8
+ #define RARRAY_LEN(v) (RARRAY(v)-len)
9
+ #endif
10
+ #ifndef RARRAY_PTR
11
+ #define RARRAY_PTR(v) (RARRAY(v)-ptr)
12
+ #endif
13
+ #ifndef RFLOAT_VALUE
14
+ #define RFLOAT_VALUE(v) (RFLOAT(v)->value)
15
+ #endif
16
+ #endif
17
+
18
+ #endif // _pnpoly_h_
data/ext/vincenty.c CHANGED
@@ -51,12 +51,12 @@ static VALUE distance(VALUE self, VALUE rb_lon1, VALUE rb_lat1, VALUE rb_lon2, V
51
51
  Check_Type(rb_a, T_FLOAT);
52
52
  Check_Type(rb_b, T_FLOAT);
53
53
 
54
- double lon1 = RFLOAT(rb_lon1)->value;
55
- double lat1 = RFLOAT(rb_lat1)->value;
56
- double lon2 = RFLOAT(rb_lon2)->value;
57
- double lat2 = RFLOAT(rb_lat2)->value;
58
- double a = RFLOAT(rb_a)->value;
59
- double b = RFLOAT(rb_b)->value;
54
+ double lon1 = RFLOAT_VALUE(rb_lon1);
55
+ double lat1 = RFLOAT_VALUE(rb_lat1);
56
+ double lon2 = RFLOAT_VALUE(rb_lon2);
57
+ double lat2 = RFLOAT_VALUE(rb_lat2);
58
+ double a = RFLOAT_VALUE(rb_a);
59
+ double b = RFLOAT_VALUE(rb_b);
60
60
 
61
61
  double sinLambda, cosLambda, sinSigma, cosSigma, sigma, sinAlpha, cosSqAlpha, cos2SigmaM, C;
62
62
 
@@ -107,12 +107,12 @@ static VALUE point_from_lon_lat(VALUE self, VALUE rb_lon1, VALUE rb_lat1, VALUE
107
107
 
108
108
  VALUE ret;
109
109
 
110
- double lon1 = RFLOAT(rb_lon1)->value;
111
- double lat1 = RFLOAT(rb_lat1)->value;
112
- double brng = RFLOAT(rb_bearing)->value;
113
- double s = RFLOAT(rb_distance)->value;
114
- double a = RFLOAT(rb_a)->value;
115
- double b = RFLOAT(rb_b)->value;
110
+ double lon1 = RFLOAT_VALUE(rb_lon1);
111
+ double lat1 = RFLOAT_VALUE(rb_lat1);
112
+ double brng = RFLOAT_VALUE(rb_bearing);
113
+ double s = RFLOAT_VALUE(rb_distance);
114
+ double a = RFLOAT_VALUE(rb_a);
115
+ double b = RFLOAT_VALUE(rb_b);
116
116
 
117
117
  double f = (a-b) / a;
118
118
  double alpha1 = brng * DEG_TO_RAD;
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: griffordson-georuby-extras
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
5
- prerelease: false
4
+ hash: 3
5
+ prerelease:
6
6
  segments:
7
7
  - 0
8
- - 6
8
+ - 7
9
9
  - 0
10
- version: 0.6.0
10
+ version: 0.7.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Troy
@@ -16,8 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-06-30 00:00:00 -05:00
20
- default_executable:
19
+ date: 2012-07-24 00:00:00 Z
21
20
  dependencies:
22
21
  - !ruby/object:Gem::Dependency
23
22
  name: GeoRuby
@@ -56,7 +55,6 @@ files:
56
55
  - History.txt
57
56
  - test/test_vincenty.rb
58
57
  - test/test_pnpoly.rb
59
- has_rdoc: true
60
58
  homepage: http://github.com/griffordson/georuby-extras
61
59
  licenses: []
62
60
 
@@ -87,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
85
  requirements: []
88
86
 
89
87
  rubyforge_project:
90
- rubygems_version: 1.3.7
88
+ rubygems_version: 1.8.15
91
89
  signing_key:
92
90
  specification_version: 3
93
91
  summary: Native extensions and extra functions for the GeoRuby library.