rgeo 0.2.0 → 0.2.1

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 (37) hide show
  1. data/History.rdoc +6 -0
  2. data/README.rdoc +10 -7
  3. data/Version +1 -1
  4. data/ext/geos_c_impl/extconf.rb +42 -34
  5. data/ext/geos_c_impl/factory.c +56 -39
  6. data/ext/geos_c_impl/factory.h +55 -45
  7. data/ext/geos_c_impl/geometry.c +137 -93
  8. data/ext/geos_c_impl/geometry_collection.c +67 -46
  9. data/ext/geos_c_impl/line_string.c +79 -54
  10. data/ext/geos_c_impl/point.c +37 -24
  11. data/ext/geos_c_impl/polygon.c +40 -25
  12. data/ext/proj4_c_impl/extconf.rb +44 -36
  13. data/lib/rgeo/coord_sys.rb +3 -1
  14. data/lib/rgeo/geos.rb +3 -1
  15. data/lib/rgeo/geos/impl_additions.rb +12 -10
  16. data/test/coord_sys/tc_proj4.rb +1 -1
  17. data/test/geos/tc_factory.rb +1 -1
  18. data/test/geos/tc_geometry_collection.rb +1 -1
  19. data/test/geos/tc_line_string.rb +1 -1
  20. data/test/geos/tc_misc.rb +1 -1
  21. data/test/geos/tc_multi_line_string.rb +1 -1
  22. data/test/geos/tc_multi_point.rb +1 -1
  23. data/test/geos/tc_multi_polygon.rb +1 -1
  24. data/test/geos/tc_point.rb +1 -1
  25. data/test/geos/tc_polygon.rb +1 -1
  26. data/test/geos/tc_zmfactory.rb +1 -1
  27. data/test/projected_geographic/tc_geometry_collection.rb +1 -1
  28. data/test/projected_geographic/tc_line_string.rb +1 -1
  29. data/test/projected_geographic/tc_multi_line_string.rb +1 -1
  30. data/test/projected_geographic/tc_multi_point.rb +1 -1
  31. data/test/projected_geographic/tc_multi_polygon.rb +1 -1
  32. data/test/projected_geographic/tc_point.rb +1 -1
  33. data/test/projected_geographic/tc_polygon.rb +1 -1
  34. data/test/simple_cartesian/tc_calculations.rb +1 -1
  35. data/test/tc_oneoff.rb +5 -5
  36. data/test/wkrep/tc_wkt_parser.rb +4 -4
  37. metadata +3 -3
@@ -52,9 +52,9 @@ RGEO_BEGIN_C
52
52
  static VALUE method_point_geometry_type(VALUE self)
53
53
  {
54
54
  VALUE result = Qnil;
55
- const GEOSGeometry* self_geom = RGEO_GET_GEOS_GEOMETRY(self);
56
- if (self_geom) {
57
- result = rb_const_get_at(RGEO_GLOBALS_FROM_GEOMETRY(self)->features_module, rb_intern("Point"));
55
+ RGeo_GeometryData* self_data = RGEO_GEOMETRY_DATA_PTR(self);
56
+ if (self_data->geom) {
57
+ result = RGEO_FACTORY_DATA_PTR(self_data->factory)->globals->feature_point;
58
58
  }
59
59
  return result;
60
60
  }
@@ -63,12 +63,14 @@ static VALUE method_point_geometry_type(VALUE self)
63
63
  static VALUE method_point_x(VALUE self)
64
64
  {
65
65
  VALUE result = Qnil;
66
- const GEOSGeometry* self_geom = RGEO_GET_GEOS_GEOMETRY(self);
66
+ RGeo_GeometryData* self_data = RGEO_GEOMETRY_DATA_PTR(self);
67
+ const GEOSGeometry* self_geom = self_data->geom;
67
68
  if (self_geom) {
68
- const GEOSCoordSequence* coord_seq = GEOSGeom_getCoordSeq_r(RGEO_CONTEXT_FROM_GEOMETRY(self), self_geom);
69
+ GEOSContextHandle_t self_context = self_data->geos_context;
70
+ const GEOSCoordSequence* coord_seq = GEOSGeom_getCoordSeq_r(self_context, self_geom);
69
71
  if (coord_seq) {
70
72
  double val;
71
- if (GEOSCoordSeq_getX_r(RGEO_CONTEXT_FROM_GEOMETRY(self), coord_seq, 0, &val)) {
73
+ if (GEOSCoordSeq_getX_r(self_context, coord_seq, 0, &val)) {
72
74
  result = rb_float_new(val);
73
75
  }
74
76
  }
@@ -80,12 +82,14 @@ static VALUE method_point_x(VALUE self)
80
82
  static VALUE method_point_y(VALUE self)
81
83
  {
82
84
  VALUE result = Qnil;
83
- const GEOSGeometry* self_geom = RGEO_GET_GEOS_GEOMETRY(self);
85
+ RGeo_GeometryData* self_data = RGEO_GEOMETRY_DATA_PTR(self);
86
+ const GEOSGeometry* self_geom = self_data->geom;
84
87
  if (self_geom) {
85
- const GEOSCoordSequence* coord_seq = GEOSGeom_getCoordSeq_r(RGEO_CONTEXT_FROM_GEOMETRY(self), self_geom);
88
+ GEOSContextHandle_t self_context = self_data->geos_context;
89
+ const GEOSCoordSequence* coord_seq = GEOSGeom_getCoordSeq_r(self_context, self_geom);
86
90
  if (coord_seq) {
87
91
  double val;
88
- if (GEOSCoordSeq_getY_r(RGEO_CONTEXT_FROM_GEOMETRY(self), coord_seq, 0, &val)) {
92
+ if (GEOSCoordSeq_getY_r(self_context, coord_seq, 0, &val)) {
89
93
  result = rb_float_new(val);
90
94
  }
91
95
  }
@@ -97,13 +101,17 @@ static VALUE method_point_y(VALUE self)
97
101
  static VALUE get_3d_point(VALUE self, int flag)
98
102
  {
99
103
  VALUE result = Qnil;
100
- const GEOSGeometry* self_geom = RGEO_GET_GEOS_GEOMETRY(self);
101
- if (self_geom && RGEO_FACTORY_DATA_FROM_GEOMETRY(self)->flags & flag) {
102
- const GEOSCoordSequence* coord_seq = GEOSGeom_getCoordSeq_r(RGEO_CONTEXT_FROM_GEOMETRY(self), self_geom);
103
- if (coord_seq) {
104
- double val;
105
- if (GEOSCoordSeq_getZ_r(RGEO_CONTEXT_FROM_GEOMETRY(self), coord_seq, 0, &val)) {
106
- result = rb_float_new(val);
104
+ RGeo_GeometryData* self_data = RGEO_GEOMETRY_DATA_PTR(self);
105
+ const GEOSGeometry* self_geom = self_data->geom;
106
+ if (self_geom) {
107
+ if (RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & flag) {
108
+ GEOSContextHandle_t self_context = self_data->geos_context;
109
+ const GEOSCoordSequence* coord_seq = GEOSGeom_getCoordSeq_r(self_context, self_geom);
110
+ if (coord_seq) {
111
+ double val;
112
+ if (GEOSCoordSeq_getZ_r(self_context, coord_seq, 0, &val)) {
113
+ result = rb_float_new(val);
114
+ }
107
115
  }
108
116
  }
109
117
  }
@@ -127,7 +135,8 @@ static VALUE method_point_eql(VALUE self, VALUE rhs)
127
135
  {
128
136
  VALUE result = rgeo_geos_klasses_and_factories_eql(self, rhs);
129
137
  if (RTEST(result)) {
130
- result = rgeo_geos_coordseqs_eql(RGEO_CONTEXT_FROM_GEOMETRY(self), RGEO_GET_GEOS_GEOMETRY(self), RGEO_GET_GEOS_GEOMETRY(rhs), RGEO_FACTORY_DATA_FROM_GEOMETRY(self)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M);
138
+ RGeo_GeometryData* self_data = RGEO_GEOMETRY_DATA_PTR(self);
139
+ result = rgeo_geos_coordseqs_eql(self_data->geos_context, self_data->geom, RGEO_GEOMETRY_DATA_PTR(rhs)->geom, RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M);
131
140
  }
132
141
  return result;
133
142
  }
@@ -142,7 +151,9 @@ static VALUE cmethod_create(VALUE module, VALUE factory, VALUE x, VALUE y, VALUE
142
151
 
143
152
  void rgeo_init_geos_point(RGeo_Globals* globals)
144
153
  {
145
- VALUE geos_point_class = rb_define_class_under(globals->geos_module, "PointImpl", rb_const_get_at(globals->geos_module, rb_intern("GeometryImpl")));
154
+ VALUE geos_point_class = rb_define_class_under(globals->geos_module, "PointImpl", globals->geos_geometry);
155
+ globals->geos_point = geos_point_class;
156
+ globals->feature_point = rb_const_get_at(globals->feature_module, rb_intern("Point"));
146
157
 
147
158
  rb_define_module_function(geos_point_class, "create", cmethod_create, 4);
148
159
 
@@ -158,14 +169,16 @@ void rgeo_init_geos_point(RGeo_Globals* globals)
158
169
  VALUE rgeo_create_geos_point(VALUE factory, double x, double y, double z)
159
170
  {
160
171
  VALUE result = Qnil;
161
- GEOSCoordSequence* coord_seq = GEOSCoordSeq_create_r(RGEO_CONTEXT_FROM_FACTORY(factory), 1, 3);
172
+ RGeo_FactoryData* factory_data = RGEO_FACTORY_DATA_PTR(factory);
173
+ GEOSContextHandle_t context = factory_data->geos_context;
174
+ GEOSCoordSequence* coord_seq = GEOSCoordSeq_create_r(context, 1, 3);
162
175
  if (coord_seq) {
163
- if (GEOSCoordSeq_setX_r(RGEO_CONTEXT_FROM_FACTORY(factory), coord_seq, 0, x)) {
164
- if (GEOSCoordSeq_setY_r(RGEO_CONTEXT_FROM_FACTORY(factory), coord_seq, 0, y)) {
165
- if (GEOSCoordSeq_setZ_r(RGEO_CONTEXT_FROM_FACTORY(factory), coord_seq, 0, z)) {
166
- GEOSGeometry* geom = GEOSGeom_createPoint_r(RGEO_CONTEXT_FROM_FACTORY(factory), coord_seq);
176
+ if (GEOSCoordSeq_setX_r(context, coord_seq, 0, x)) {
177
+ if (GEOSCoordSeq_setY_r(context, coord_seq, 0, y)) {
178
+ if (GEOSCoordSeq_setZ_r(context, coord_seq, 0, z)) {
179
+ GEOSGeometry* geom = GEOSGeom_createPoint_r(context, coord_seq);
167
180
  if (geom) {
168
- result = rgeo_wrap_geos_geometry(factory, geom, rb_const_get_at(RGEO_GLOBALS_FROM_FACTORY(factory)->geos_module, rb_intern("PointImpl")));
181
+ result = rgeo_wrap_geos_geometry(factory, geom, factory_data->globals->geos_point);
169
182
  }
170
183
  }
171
184
  }
@@ -54,7 +54,8 @@ static VALUE method_polygon_eql(VALUE self, VALUE rhs)
54
54
  {
55
55
  VALUE result = rgeo_geos_klasses_and_factories_eql(self, rhs);
56
56
  if (RTEST(result)) {
57
- result = rgeo_geos_polygons_eql(RGEO_CONTEXT_FROM_GEOMETRY(self), RGEO_GET_GEOS_GEOMETRY(self), RGEO_GET_GEOS_GEOMETRY(rhs), RGEO_FACTORY_DATA_FROM_GEOMETRY(self)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M);
57
+ RGeo_GeometryData* self_data = RGEO_GEOMETRY_DATA_PTR(self);
58
+ result = rgeo_geos_polygons_eql(self_data->geos_context, self_data->geom, RGEO_GEOMETRY_DATA_PTR(rhs)->geom, RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M);
58
59
  }
59
60
  return result;
60
61
  }
@@ -63,9 +64,9 @@ static VALUE method_polygon_eql(VALUE self, VALUE rhs)
63
64
  static VALUE method_polygon_geometry_type(VALUE self)
64
65
  {
65
66
  VALUE result = Qnil;
66
- const GEOSGeometry* self_geom = RGEO_GET_GEOS_GEOMETRY(self);
67
- if (self_geom) {
68
- result = rb_const_get_at(RGEO_GLOBALS_FROM_GEOMETRY(self)->features_module, rb_intern("Polygon"));
67
+ RGeo_GeometryData* self_data = RGEO_GEOMETRY_DATA_PTR(self);
68
+ if (self_data->geom) {
69
+ result = RGEO_FACTORY_DATA_PTR(self_data->factory)->globals->feature_polygon;
69
70
  }
70
71
  return result;
71
72
  }
@@ -74,10 +75,11 @@ static VALUE method_polygon_geometry_type(VALUE self)
74
75
  static VALUE method_polygon_area(VALUE self)
75
76
  {
76
77
  VALUE result = Qnil;
77
- const GEOSGeometry* self_geom = RGEO_GET_GEOS_GEOMETRY(self);
78
+ RGeo_GeometryData* self_data = RGEO_GEOMETRY_DATA_PTR(self);
79
+ const GEOSGeometry* self_geom = self_data->geom;
78
80
  if (self_geom) {
79
81
  double area;
80
- if (GEOSArea_r(RGEO_CONTEXT_FROM_GEOMETRY(self), self_geom, &area)) {
82
+ if (GEOSArea_r(self_data->geos_context, self_geom, &area)) {
81
83
  result = rb_float_new(area);
82
84
  }
83
85
  }
@@ -88,9 +90,10 @@ static VALUE method_polygon_area(VALUE self)
88
90
  static VALUE method_polygon_centroid(VALUE self)
89
91
  {
90
92
  VALUE result = Qnil;
91
- const GEOSGeometry* self_geom = RGEO_GET_GEOS_GEOMETRY(self);
93
+ RGeo_GeometryData* self_data = RGEO_GEOMETRY_DATA_PTR(self);
94
+ const GEOSGeometry* self_geom = self_data->geom;
92
95
  if (self_geom) {
93
- result = rgeo_wrap_geos_geometry(RGEO_FACTORY_FROM_GEOMETRY(self), GEOSGetCentroid_r(RGEO_CONTEXT_FROM_GEOMETRY(self), self_geom), rb_const_get_at(RGEO_GLOBALS_FROM_GEOMETRY(self)->geos_module, rb_intern("PointImpl")));
96
+ result = rgeo_wrap_geos_geometry(self_data->factory, GEOSGetCentroid_r(self_data->geos_context, self_geom), RGEO_FACTORY_DATA_PTR(self_data->factory)->globals->geos_point);
94
97
  }
95
98
  return result;
96
99
  }
@@ -99,9 +102,10 @@ static VALUE method_polygon_centroid(VALUE self)
99
102
  static VALUE method_polygon_point_on_surface(VALUE self)
100
103
  {
101
104
  VALUE result = Qnil;
102
- const GEOSGeometry* self_geom = RGEO_GET_GEOS_GEOMETRY(self);
105
+ RGeo_GeometryData* self_data = RGEO_GEOMETRY_DATA_PTR(self);
106
+ const GEOSGeometry* self_geom = self_data->geom;
103
107
  if (self_geom) {
104
- result = rgeo_wrap_geos_geometry(RGEO_FACTORY_FROM_GEOMETRY(self), GEOSPointOnSurface_r(RGEO_CONTEXT_FROM_GEOMETRY(self), self_geom), rb_const_get_at(RGEO_GLOBALS_FROM_GEOMETRY(self)->geos_module, rb_intern("PointImpl")));
108
+ result = rgeo_wrap_geos_geometry(self_data->factory, GEOSPointOnSurface_r(self_data->geos_context, self_geom), RGEO_FACTORY_DATA_PTR(self_data->factory)->globals->geos_point);
105
109
  }
106
110
  return result;
107
111
  }
@@ -110,9 +114,10 @@ static VALUE method_polygon_point_on_surface(VALUE self)
110
114
  static VALUE method_polygon_exterior_ring(VALUE self)
111
115
  {
112
116
  VALUE result = Qnil;
113
- const GEOSGeometry* self_geom = RGEO_GET_GEOS_GEOMETRY(self);
117
+ RGeo_GeometryData* self_data = RGEO_GEOMETRY_DATA_PTR(self);
118
+ const GEOSGeometry* self_geom = self_data->geom;
114
119
  if (self_geom) {
115
- result = rgeo_wrap_geos_geometry_clone(RGEO_FACTORY_FROM_GEOMETRY(self), GEOSGetExteriorRing_r(RGEO_CONTEXT_FROM_GEOMETRY(self), self_geom), rb_const_get_at(RGEO_GLOBALS_FROM_GEOMETRY(self)->geos_module, rb_intern("LinearRingImpl")));
120
+ result = rgeo_wrap_geos_geometry_clone(self_data->factory, GEOSGetExteriorRing_r(self_data->geos_context, self_geom), RGEO_FACTORY_DATA_PTR(self_data->factory)->globals->geos_linear_ring);
116
121
  }
117
122
  return result;
118
123
  }
@@ -121,9 +126,10 @@ static VALUE method_polygon_exterior_ring(VALUE self)
121
126
  static VALUE method_polygon_num_interior_rings(VALUE self)
122
127
  {
123
128
  VALUE result = Qnil;
124
- const GEOSGeometry* self_geom = RGEO_GET_GEOS_GEOMETRY(self);
129
+ RGeo_GeometryData* self_data = RGEO_GEOMETRY_DATA_PTR(self);
130
+ const GEOSGeometry* self_geom = self_data->geom;
125
131
  if (self_geom) {
126
- int num = GEOSGetNumInteriorRings_r(RGEO_CONTEXT_FROM_GEOMETRY(self), self_geom);
132
+ int num = GEOSGetNumInteriorRings_r(self_data->geos_context, self_geom);
127
133
  if (num >= 0) {
128
134
  result = INT2NUM(num);
129
135
  }
@@ -135,9 +141,10 @@ static VALUE method_polygon_num_interior_rings(VALUE self)
135
141
  static VALUE method_polygon_interior_ring_n(VALUE self, VALUE n)
136
142
  {
137
143
  VALUE result = Qnil;
138
- const GEOSGeometry* self_geom = RGEO_GET_GEOS_GEOMETRY(self);
144
+ RGeo_GeometryData* self_data = RGEO_GEOMETRY_DATA_PTR(self);
145
+ const GEOSGeometry* self_geom = self_data->geom;
139
146
  if (self_geom) {
140
- result = rgeo_wrap_geos_geometry_clone(RGEO_FACTORY_FROM_GEOMETRY(self), GEOSGetInteriorRingN_r(RGEO_CONTEXT_FROM_GEOMETRY(self), self_geom, NUM2INT(n)), rb_const_get_at(RGEO_GLOBALS_FROM_GEOMETRY(self)->geos_module, rb_intern("LinearRingImpl")));
147
+ result = rgeo_wrap_geos_geometry_clone(self_data->factory, GEOSGetInteriorRingN_r(self_data->geos_context, self_geom, NUM2INT(n)), RGEO_FACTORY_DATA_PTR(self_data->factory)->globals->geos_linear_ring);
141
148
  }
142
149
  return result;
143
150
  }
@@ -146,14 +153,18 @@ static VALUE method_polygon_interior_ring_n(VALUE self, VALUE n)
146
153
  static VALUE method_polygon_interior_rings(VALUE self)
147
154
  {
148
155
  VALUE result = Qnil;
149
- const GEOSGeometry* self_geom = RGEO_GET_GEOS_GEOMETRY(self);
156
+ RGeo_GeometryData* self_data = RGEO_GEOMETRY_DATA_PTR(self);
157
+ const GEOSGeometry* self_geom = self_data->geom;
150
158
  if (self_geom) {
151
- int count = GEOSGetNumInteriorRings_r(RGEO_CONTEXT_FROM_GEOMETRY(self), self_geom);
159
+ GEOSContextHandle_t self_context = self_data->geos_context;
160
+ int count = GEOSGetNumInteriorRings_r(self_context, self_geom);
152
161
  if (count >= 0) {
153
162
  result = rb_ary_new2(count);
163
+ VALUE factory = self_data->factory;
164
+ VALUE linear_ring_class = RGEO_FACTORY_DATA_PTR(self_data->factory)->globals->geos_linear_ring;
154
165
  int i;
155
166
  for (i=0; i<count; ++i) {
156
- rb_ary_store(result, i, rgeo_wrap_geos_geometry_clone(RGEO_FACTORY_FROM_GEOMETRY(self), GEOSGetInteriorRingN_r(RGEO_CONTEXT_FROM_GEOMETRY(self), self_geom, i), rb_const_get_at(RGEO_GLOBALS_FROM_GEOMETRY(self)->geos_module, rb_intern("LinearRingImpl"))));
167
+ rb_ary_store(result, i, rgeo_wrap_geos_geometry_clone(factory, GEOSGetInteriorRingN_r(self_context, self_geom, i), linear_ring_class));
157
168
  }
158
169
  }
159
170
  }
@@ -164,9 +175,11 @@ static VALUE method_polygon_interior_rings(VALUE self)
164
175
  static VALUE cmethod_create(VALUE module, VALUE factory, VALUE exterior, VALUE interior_array)
165
176
  {
166
177
  Check_Type(interior_array, T_ARRAY);
167
- VALUE linear_ring_type = rb_const_get_at(RGEO_GLOBALS_FROM_FACTORY(factory)->features_module, rb_intern("LinearRing"));
178
+ RGeo_FactoryData* factory_data = RGEO_FACTORY_DATA_PTR(factory);
179
+ VALUE linear_ring_type = factory_data->globals->feature_linear_ring;
168
180
  GEOSGeometry* exterior_geom = rgeo_convert_to_detached_geos_geometry(exterior, factory, linear_ring_type, NULL);
169
181
  if (exterior_geom) {
182
+ GEOSContextHandle_t context = factory_data->geos_context;
170
183
  unsigned int len = (unsigned int)RARRAY_LEN(interior_array);
171
184
  GEOSGeometry** interior_geoms = ALLOC_N(GEOSGeometry*, len == 0 ? 1 : len);
172
185
  if (interior_geoms) {
@@ -179,18 +192,18 @@ static VALUE cmethod_create(VALUE module, VALUE factory, VALUE exterior, VALUE i
179
192
  }
180
193
  }
181
194
  if (len == actual_len) {
182
- GEOSGeometry* polygon = GEOSGeom_createPolygon_r(RGEO_CONTEXT_FROM_FACTORY(factory), exterior_geom, interior_geoms, actual_len);
195
+ GEOSGeometry* polygon = GEOSGeom_createPolygon_r(context, exterior_geom, interior_geoms, actual_len);
183
196
  if (polygon) {
184
197
  free(interior_geoms);
185
- return rgeo_wrap_geos_geometry(factory, polygon, rb_const_get_at(RGEO_GLOBALS_FROM_FACTORY(factory)->geos_module, rb_intern("PolygonImpl")));
198
+ return rgeo_wrap_geos_geometry(factory, polygon, factory_data->globals->geos_polygon);
186
199
  }
187
200
  }
188
201
  for (i=0; i<actual_len; ++i) {
189
- GEOSGeom_destroy_r(RGEO_CONTEXT_FROM_FACTORY(factory), interior_geoms[i]);
202
+ GEOSGeom_destroy_r(context, interior_geoms[i]);
190
203
  }
191
204
  free(interior_geoms);
192
205
  }
193
- GEOSGeom_destroy_r(RGEO_CONTEXT_FROM_FACTORY(factory), exterior_geom);
206
+ GEOSGeom_destroy_r(context, exterior_geom);
194
207
  }
195
208
  return Qnil;
196
209
  }
@@ -198,7 +211,9 @@ static VALUE cmethod_create(VALUE module, VALUE factory, VALUE exterior, VALUE i
198
211
 
199
212
  void rgeo_init_geos_polygon(RGeo_Globals* globals)
200
213
  {
201
- VALUE geos_polygon_class = rb_define_class_under(globals->geos_module, "PolygonImpl", rb_const_get_at(globals->geos_module, rb_intern("GeometryImpl")));
214
+ VALUE geos_polygon_class = rb_define_class_under(globals->geos_module, "PolygonImpl", globals->geos_geometry);
215
+ globals->geos_polygon = geos_polygon_class;
216
+ globals->feature_polygon = rb_const_get_at(globals->feature_module, rb_intern("Polygon"));
202
217
 
203
218
  rb_define_module_function(geos_polygon_class, "create", cmethod_create, 3);
204
219
 
@@ -34,41 +34,49 @@
34
34
  ;
35
35
 
36
36
 
37
- require 'mkmf'
38
-
39
- header_dirs_ =
40
- [
41
- '/usr/local/include',
42
- '/usr/local/proj/include',
43
- '/usr/local/proj4/include',
44
- '/opt/local/include',
45
- ::Config::CONFIG['includedir'],
46
- '/usr/include',
47
- ]
48
- lib_dirs_ =
49
- [
50
- '/usr/local/lib',
51
- '/usr/local/proj/lib',
52
- '/usr/local/proj4/lib',
53
- '/opt/local/lib',
54
- ::Config::CONFIG['libdir'],
55
- '/usr/lib',
56
- ]
57
- header_dirs_.delete_if{ |path_| !::File.directory?(path_) }
58
- lib_dirs_.delete_if{ |path_| !::File.directory?(path_) }
59
-
60
- found_proj_ = false
61
- header_dirs_, lib_dirs_ = dir_config('proj', header_dirs_, lib_dirs_)
62
- if have_header('proj_api.h')
63
- $libs << ' -lproj'
64
- if have_func('pj_init_plus', 'proj_api.h')
65
- found_proj_ = true
66
- else
67
- $libs.gsub!(' -lproj', '')
37
+ if ::RUBY_DESCRIPTION =~ /^jruby\s/
38
+
39
+ ::File.open('Makefile', 'w'){ |f_| f_.write(".PHONY: install\ninstall:\n") }
40
+
41
+ else
42
+
43
+ require 'mkmf'
44
+
45
+ header_dirs_ =
46
+ [
47
+ '/usr/local/include',
48
+ '/usr/local/proj/include',
49
+ '/usr/local/proj4/include',
50
+ '/opt/local/include',
51
+ ::Config::CONFIG['includedir'],
52
+ '/usr/include',
53
+ ]
54
+ lib_dirs_ =
55
+ [
56
+ '/usr/local/lib',
57
+ '/usr/local/proj/lib',
58
+ '/usr/local/proj4/lib',
59
+ '/opt/local/lib',
60
+ ::Config::CONFIG['libdir'],
61
+ '/usr/lib',
62
+ ]
63
+ header_dirs_.delete_if{ |path_| !::File.directory?(path_) }
64
+ lib_dirs_.delete_if{ |path_| !::File.directory?(path_) }
65
+
66
+ found_proj_ = false
67
+ header_dirs_, lib_dirs_ = dir_config('proj', header_dirs_, lib_dirs_)
68
+ if have_header('proj_api.h')
69
+ $libs << ' -lproj'
70
+ if have_func('pj_init_plus', 'proj_api.h')
71
+ found_proj_ = true
72
+ else
73
+ $libs.gsub!(' -lproj', '')
74
+ end
68
75
  end
76
+ unless found_proj_
77
+ puts "**** WARNING: Unable to find Proj headers or Proj version is too old."
78
+ puts "**** Compiling without Proj support."
79
+ end
80
+ create_makefile('rgeo/coord_sys/proj4_c_impl')
81
+
69
82
  end
70
- unless found_proj_
71
- puts "**** WARNING: Unable to find Proj headers or Proj version is too old."
72
- puts "**** Compiling without Proj support."
73
- end
74
- create_makefile('rgeo/coord_sys/proj4_c_impl')
@@ -54,5 +54,7 @@ end
54
54
 
55
55
 
56
56
  # Implementation files
57
- require 'rgeo/coord_sys/proj4_c_impl'
57
+ begin
58
+ require 'rgeo/coord_sys/proj4_c_impl'
59
+ rescue ::LoadError; end
58
60
  require 'rgeo/coord_sys/proj4'
data/lib/rgeo/geos.rb CHANGED
@@ -64,7 +64,9 @@ end
64
64
  # Implementation files
65
65
  require 'rgeo/geos/factory'
66
66
  require 'rgeo/geos/interface'
67
- require 'rgeo/geos/geos_c_impl'
67
+ begin
68
+ require 'rgeo/geos/geos_c_impl'
69
+ rescue ::LoadError; end
68
70
  require 'rgeo/geos/impl_additions'
69
71
  require 'rgeo/geos/zm_factory'
70
72
  require 'rgeo/geos/zm_impl'
@@ -53,16 +53,18 @@ module RGeo
53
53
 
54
54
 
55
55
  # :stopdoc:
56
- IMPL_CLASSES = {
57
- Feature::Point => PointImpl,
58
- Feature::LineString => LineStringImpl,
59
- Feature::LinearRing => LinearRingImpl,
60
- Feature::Line => LineImpl,
61
- Feature::GeometryCollection => GeometryCollectionImpl,
62
- Feature::MultiPoint => MultiPointImpl,
63
- Feature::MultiLineString => MultiLineStringImpl,
64
- Feature::MultiPolygon => MultiPolygonImpl,
65
- }
56
+ if ::RGeo::Geos.supported?
57
+ IMPL_CLASSES = {
58
+ Feature::Point => PointImpl,
59
+ Feature::LineString => LineStringImpl,
60
+ Feature::LinearRing => LinearRingImpl,
61
+ Feature::Line => LineImpl,
62
+ Feature::GeometryCollection => GeometryCollectionImpl,
63
+ Feature::MultiPoint => MultiPointImpl,
64
+ Feature::MultiLineString => MultiLineStringImpl,
65
+ Feature::MultiPolygon => MultiPolygonImpl,
66
+ }
67
+ end
66
68
  # :startdoc:
67
69
 
68
70
 
@@ -115,4 +115,4 @@ module RGeo
115
115
 
116
116
  end
117
117
  end
118
- end
118
+ end if ::RGeo::CoordSys::Proj4.supported?
@@ -88,4 +88,4 @@ module RGeo
88
88
 
89
89
  end
90
90
  end
91
- end
91
+ end if ::RGeo::Geos.supported?
@@ -59,4 +59,4 @@ module RGeo
59
59
 
60
60
  end
61
61
  end
62
- end
62
+ end if ::RGeo::Geos.supported?
@@ -59,4 +59,4 @@ module RGeo
59
59
 
60
60
  end
61
61
  end
62
- end
62
+ end if ::RGeo::Geos.supported?