rgeo 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +29 -0
- data/ext/geos_c_impl/Makefile_2.2.3 +260 -0
- data/ext/geos_c_impl/coordinates.c +65 -0
- data/ext/geos_c_impl/coordinates.h +2 -0
- data/ext/geos_c_impl/extconf.rb +19 -43
- data/ext/geos_c_impl/geometry.c +24 -0
- data/ext/geos_c_impl/geometry_collection.c +99 -1
- data/ext/geos_c_impl/geos_c_impl_2.2.3.bundle +0 -0
- data/ext/geos_c_impl/line_string.c +38 -0
- data/ext/geos_c_impl/mkmf.log +123 -0
- data/ext/geos_c_impl/point.c +27 -0
- data/ext/geos_c_impl/polygon.c +26 -0
- data/ext/proj4_c_impl/Makefile_2.2.3 +260 -0
- data/ext/proj4_c_impl/extconf.rb +32 -32
- data/ext/proj4_c_impl/mkmf.log +47 -0
- data/ext/proj4_c_impl/proj4_c_impl_2.2.3.bundle +0 -0
- data/lib/rgeo.rb +10 -11
- data/lib/rgeo/cartesian.rb +7 -12
- data/lib/rgeo/cartesian/analysis.rb +13 -26
- data/lib/rgeo/cartesian/bounding_box.rb +45 -114
- data/lib/rgeo/cartesian/calculations.rb +3 -21
- data/lib/rgeo/cartesian/factory.rb +101 -122
- data/lib/rgeo/cartesian/feature_classes.rb +9 -59
- data/lib/rgeo/cartesian/feature_methods.rb +15 -45
- data/lib/rgeo/cartesian/interface.rb +6 -17
- data/lib/rgeo/coord_sys.rb +9 -15
- data/lib/rgeo/coord_sys/cs/entities.rb +84 -330
- data/lib/rgeo/coord_sys/cs/factories.rb +2 -32
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +52 -80
- data/lib/rgeo/coord_sys/proj4.rb +28 -67
- data/lib/rgeo/coord_sys/proj4_c_impl.bundle +0 -0
- data/lib/rgeo/coord_sys/srs_database/interface.rb +4 -24
- data/lib/rgeo/coord_sys/srs_database/proj4_data.rb +20 -38
- data/lib/rgeo/coord_sys/srs_database/sr_org.rb +6 -22
- data/lib/rgeo/coord_sys/srs_database/url_reader.rb +6 -21
- data/lib/rgeo/error.rb +0 -6
- data/lib/rgeo/feature.rb +18 -23
- data/lib/rgeo/feature/curve.rb +0 -14
- data/lib/rgeo/feature/factory.rb +13 -38
- data/lib/rgeo/feature/factory_generator.rb +4 -16
- data/lib/rgeo/feature/geometry.rb +18 -60
- data/lib/rgeo/feature/geometry_collection.rb +3 -17
- data/lib/rgeo/feature/line.rb +0 -10
- data/lib/rgeo/feature/line_string.rb +1 -13
- data/lib/rgeo/feature/linear_ring.rb +0 -9
- data/lib/rgeo/feature/mixins.rb +11 -36
- data/lib/rgeo/feature/multi_curve.rb +0 -11
- data/lib/rgeo/feature/multi_line_string.rb +0 -9
- data/lib/rgeo/feature/multi_point.rb +0 -9
- data/lib/rgeo/feature/multi_polygon.rb +0 -9
- data/lib/rgeo/feature/multi_surface.rb +0 -12
- data/lib/rgeo/feature/point.rb +0 -13
- data/lib/rgeo/feature/polygon.rb +1 -14
- data/lib/rgeo/feature/surface.rb +0 -12
- data/lib/rgeo/feature/types.rb +19 -61
- data/lib/rgeo/geographic.rb +10 -15
- data/lib/rgeo/geographic/factory.rb +126 -147
- data/lib/rgeo/geographic/interface.rb +67 -81
- data/lib/rgeo/geographic/proj4_projector.rb +13 -37
- data/lib/rgeo/geographic/projected_feature_classes.rb +7 -66
- data/lib/rgeo/geographic/projected_feature_methods.rb +15 -80
- data/lib/rgeo/geographic/projected_window.rb +15 -67
- data/lib/rgeo/geographic/simple_mercator_projector.rb +32 -56
- data/lib/rgeo/geographic/spherical_feature_classes.rb +9 -68
- data/lib/rgeo/geographic/spherical_feature_methods.rb +18 -51
- data/lib/rgeo/geographic/spherical_math.rb +26 -51
- data/lib/rgeo/geos.rb +23 -20
- data/lib/rgeo/geos/capi_factory.rb +125 -131
- data/lib/rgeo/geos/capi_feature_classes.rb +21 -88
- data/lib/rgeo/geos/ffi_factory.rb +90 -143
- data/lib/rgeo/geos/ffi_feature_classes.rb +8 -63
- data/lib/rgeo/geos/ffi_feature_methods.rb +46 -162
- data/lib/rgeo/geos/geos_c_impl.bundle +0 -0
- data/lib/rgeo/geos/interface.rb +4 -23
- data/lib/rgeo/geos/utils.rb +4 -19
- data/lib/rgeo/geos/zm_factory.rb +82 -131
- data/lib/rgeo/geos/zm_feature_classes.rb +8 -63
- data/lib/rgeo/geos/zm_feature_methods.rb +34 -107
- data/lib/rgeo/impl_helper.rb +8 -13
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +27 -71
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +10 -28
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +21 -57
- data/lib/rgeo/impl_helper/basic_point_methods.rb +12 -30
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +9 -28
- data/lib/rgeo/impl_helper/math.rb +4 -10
- data/lib/rgeo/impl_helper/utils.rb +2 -10
- data/lib/rgeo/version.rb +1 -1
- data/lib/rgeo/wkrep.rb +4 -9
- data/lib/rgeo/wkrep/wkb_generator.rb +22 -46
- data/lib/rgeo/wkrep/wkb_parser.rb +25 -52
- data/lib/rgeo/wkrep/wkt_generator.rb +39 -69
- data/lib/rgeo/wkrep/wkt_parser.rb +52 -89
- data/lib/rgeo/yaml.rb +1 -7
- data/test/common/factory_tests.rb +4 -19
- data/test/common/geometry_collection_tests.rb +6 -39
- data/test/common/line_string_tests.rb +10 -39
- data/test/common/multi_line_string_tests.rb +10 -30
- data/test/common/multi_point_tests.rb +15 -34
- data/test/common/multi_polygon_tests.rb +26 -28
- data/test/common/point_tests.rb +37 -59
- data/test/common/polygon_tests.rb +16 -25
- data/test/coord_sys/tc_ogc_cs.rb +151 -186
- data/test/coord_sys/tc_proj4.rb +35 -60
- data/test/coord_sys/tc_proj4_srs_data.rb +15 -24
- data/test/coord_sys/tc_sr_org.rb +11 -19
- data/test/coord_sys/tc_url_reader.rb +13 -23
- data/test/geos_capi/tc_factory.rb +7 -16
- data/test/geos_capi/tc_geometry_collection.rb +6 -14
- data/test/geos_capi/tc_line_string.rb +7 -15
- data/test/geos_capi/tc_misc.rb +26 -41
- data/test/geos_capi/tc_multi_line_string.rb +6 -14
- data/test/geos_capi/tc_multi_point.rb +7 -15
- data/test/geos_capi/tc_multi_polygon.rb +8 -18
- data/test/geos_capi/tc_parsing_unparsing.rb +11 -21
- data/test/geos_capi/tc_point.rb +12 -26
- data/test/geos_capi/tc_polygon.rb +52 -17
- data/test/geos_capi/tc_zmfactory.rb +7 -18
- data/test/geos_ffi/tc_factory.rb +7 -16
- data/test/geos_ffi/tc_geometry_collection.rb +7 -15
- data/test/geos_ffi/tc_line_string.rb +7 -15
- data/test/geos_ffi/tc_misc.rb +8 -18
- data/test/geos_ffi/tc_multi_line_string.rb +7 -15
- data/test/geos_ffi/tc_multi_point.rb +8 -16
- data/test/geos_ffi/tc_multi_polygon.rb +9 -18
- data/test/geos_ffi/tc_parsing_unparsing.rb +14 -24
- data/test/geos_ffi/tc_point.rb +13 -28
- data/test/geos_ffi/tc_polygon.rb +7 -17
- data/test/geos_ffi/tc_zmfactory.rb +8 -19
- data/test/projected_geographic/tc_factory.rb +7 -15
- data/test/projected_geographic/tc_geometry_collection.rb +7 -15
- data/test/projected_geographic/tc_line_string.rb +7 -15
- data/test/projected_geographic/tc_multi_line_string.rb +7 -16
- data/test/projected_geographic/tc_multi_point.rb +8 -17
- data/test/projected_geographic/tc_multi_polygon.rb +8 -16
- data/test/projected_geographic/tc_point.rb +11 -23
- data/test/projected_geographic/tc_polygon.rb +7 -15
- data/test/simple_cartesian/tc_calculations.rb +6 -22
- data/test/simple_cartesian/tc_factory.rb +7 -16
- data/test/simple_cartesian/tc_geometry_collection.rb +6 -15
- data/test/simple_cartesian/tc_line_string.rb +6 -15
- data/test/simple_cartesian/tc_multi_line_string.rb +6 -15
- data/test/simple_cartesian/tc_multi_point.rb +7 -16
- data/test/simple_cartesian/tc_multi_polygon.rb +7 -16
- data/test/simple_cartesian/tc_point.rb +10 -21
- data/test/simple_cartesian/tc_polygon.rb +6 -15
- data/test/simple_mercator/tc_factory.rb +6 -14
- data/test/simple_mercator/tc_geometry_collection.rb +6 -14
- data/test/simple_mercator/tc_line_string.rb +6 -14
- data/test/simple_mercator/tc_multi_line_string.rb +6 -15
- data/test/simple_mercator/tc_multi_point.rb +7 -16
- data/test/simple_mercator/tc_multi_polygon.rb +7 -15
- data/test/simple_mercator/tc_point.rb +11 -24
- data/test/simple_mercator/tc_polygon.rb +6 -14
- data/test/simple_mercator/tc_window.rb +10 -34
- data/test/spherical_geographic/tc_calculations.rb +5 -32
- data/test/spherical_geographic/tc_factory.rb +6 -15
- data/test/spherical_geographic/tc_geometry_collection.rb +6 -15
- data/test/spherical_geographic/tc_line_string.rb +6 -15
- data/test/spherical_geographic/tc_multi_line_string.rb +6 -15
- data/test/spherical_geographic/tc_multi_point.rb +7 -16
- data/test/spherical_geographic/tc_multi_polygon.rb +7 -16
- data/test/spherical_geographic/tc_point.rb +10 -22
- data/test/spherical_geographic/tc_polygon.rb +6 -15
- data/test/tc_cartesian_analysis.rb +4 -16
- data/test/tc_cartesian_bbox.rb +7 -21
- data/test/tc_mixins.rb +8 -25
- data/test/tc_oneoff.rb +5 -13
- data/test/tc_types.rb +7 -16
- data/test/wkrep/tc_wkb_generator.rb +63 -97
- data/test/wkrep/tc_wkb_parser.rb +63 -100
- data/test/wkrep/tc_wkt_generator.rb +54 -92
- data/test/wkrep/tc_wkt_parser.rb +84 -133
- metadata +39 -9
- data/lib/rgeo/coord_sys/srs_database/active_record_table.rb +0 -166
- data/test/coord_sys/tc_active_record_table.rb +0 -79
data/ext/geos_c_impl/geometry.c
CHANGED
@@ -741,6 +741,29 @@ static VALUE method_geometry_buffer(VALUE self, VALUE distance)
|
|
741
741
|
return result;
|
742
742
|
}
|
743
743
|
|
744
|
+
static VALUE method_geometry_buffer_with_style(VALUE self, VALUE distance, VALUE endCapStyle, VALUE joinStyle, VALUE mitreLimit)
|
745
|
+
{
|
746
|
+
VALUE result;
|
747
|
+
RGeo_GeometryData* self_data;
|
748
|
+
const GEOSGeometry* self_geom;
|
749
|
+
VALUE factory;
|
750
|
+
int resolution;
|
751
|
+
|
752
|
+
result = Qnil;
|
753
|
+
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
754
|
+
self_geom = self_data->geom;
|
755
|
+
if (self_geom) {
|
756
|
+
factory = self_data->factory;
|
757
|
+
result = rgeo_wrap_geos_geometry(factory,
|
758
|
+
GEOSBufferWithStyle_r(self_data->geos_context, self_geom,
|
759
|
+
rb_num2dbl(distance),
|
760
|
+
RGEO_FACTORY_DATA_PTR(factory)->buffer_resolution,
|
761
|
+
endCapStyle, joinStyle, mitreLimit),
|
762
|
+
Qnil);
|
763
|
+
}
|
764
|
+
return result;
|
765
|
+
}
|
766
|
+
|
744
767
|
static VALUE method_geometry_simplify(VALUE self, VALUE tolerance)
|
745
768
|
{
|
746
769
|
VALUE result;
|
@@ -987,6 +1010,7 @@ void rgeo_init_geos_geometry(RGeo_Globals* globals)
|
|
987
1010
|
rb_define_method(geos_geometry_methods, "relate?", method_geometry_relate, 2);
|
988
1011
|
rb_define_method(geos_geometry_methods, "distance", method_geometry_distance, 1);
|
989
1012
|
rb_define_method(geos_geometry_methods, "buffer", method_geometry_buffer, 1);
|
1013
|
+
rb_define_method(geos_geometry_methods, "buffer_with_style", method_geometry_buffer_with_style, 4);
|
990
1014
|
rb_define_method(geos_geometry_methods, "simplify", method_geometry_simplify, 1);
|
991
1015
|
rb_define_method(geos_geometry_methods, "convex_hull", method_geometry_convex_hull, 0);
|
992
1016
|
rb_define_method(geos_geometry_methods, "intersection", method_geometry_intersection, 1);
|
@@ -16,6 +16,8 @@
|
|
16
16
|
#include "polygon.h"
|
17
17
|
#include "geometry_collection.h"
|
18
18
|
|
19
|
+
#include "coordinates.h"
|
20
|
+
|
19
21
|
RGEO_BEGIN_C
|
20
22
|
|
21
23
|
|
@@ -270,7 +272,6 @@ static VALUE method_geometry_collection_each(VALUE self)
|
|
270
272
|
}
|
271
273
|
}
|
272
274
|
|
273
|
-
|
274
275
|
static VALUE method_multi_point_geometry_type(VALUE self)
|
275
276
|
{
|
276
277
|
VALUE result;
|
@@ -301,6 +302,38 @@ static VALUE method_multi_point_hash(VALUE self)
|
|
301
302
|
}
|
302
303
|
|
303
304
|
|
305
|
+
static VALUE method_multi_point_coordinates(VALUE self)
|
306
|
+
{
|
307
|
+
VALUE result = Qnil;
|
308
|
+
RGeo_GeometryData* self_data;
|
309
|
+
const GEOSGeometry* self_geom;
|
310
|
+
GEOSContextHandle_t context;
|
311
|
+
const GEOSCoordSequence* coord_sequence;
|
312
|
+
|
313
|
+
const GEOSGeometry* point;
|
314
|
+
unsigned int count;
|
315
|
+
unsigned int i;
|
316
|
+
int zCoordinate;
|
317
|
+
|
318
|
+
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
319
|
+
self_geom = self_data->geom;
|
320
|
+
|
321
|
+
if(self_geom) {
|
322
|
+
zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M;
|
323
|
+
context = self_data->geos_context;
|
324
|
+
count = GEOSGetNumGeometries_r(context, self_geom);
|
325
|
+
result = rb_ary_new2(count);
|
326
|
+
for(i = 0; i < count; ++i) {
|
327
|
+
point = GEOSGetGeometryN_r(context, self_geom, i);
|
328
|
+
coord_sequence = GEOSGeom_getCoordSeq_r(context, point);
|
329
|
+
rb_ary_push(result, rb_ary_pop(extract_points_from_coordinate_sequence(context, coord_sequence, zCoordinate)));
|
330
|
+
}
|
331
|
+
}
|
332
|
+
|
333
|
+
return result;
|
334
|
+
}
|
335
|
+
|
336
|
+
|
304
337
|
static VALUE method_multi_line_string_geometry_type(VALUE self)
|
305
338
|
{
|
306
339
|
VALUE result;
|
@@ -331,6 +364,37 @@ static VALUE method_multi_line_string_hash(VALUE self)
|
|
331
364
|
}
|
332
365
|
|
333
366
|
|
367
|
+
static VALUE method_multi_line_string_coordinates(VALUE self)
|
368
|
+
{
|
369
|
+
VALUE result = Qnil;
|
370
|
+
RGeo_GeometryData* self_data;
|
371
|
+
const GEOSGeometry* self_geom;
|
372
|
+
GEOSContextHandle_t context;
|
373
|
+
const GEOSCoordSequence* coord_sequence;
|
374
|
+
|
375
|
+
const GEOSGeometry* line_string;
|
376
|
+
unsigned int count;
|
377
|
+
unsigned int i;
|
378
|
+
int zCoordinate;
|
379
|
+
|
380
|
+
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
381
|
+
self_geom = self_data->geom;
|
382
|
+
|
383
|
+
if(self_geom) {
|
384
|
+
zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M;
|
385
|
+
context = self_data->geos_context;
|
386
|
+
count = GEOSGetNumGeometries_r(context, self_geom);
|
387
|
+
result = rb_ary_new2(count);
|
388
|
+
for(i = 0; i < count; ++i) {
|
389
|
+
line_string = GEOSGetGeometryN_r(context, self_geom, i);
|
390
|
+
coord_sequence = GEOSGeom_getCoordSeq_r(context, line_string);
|
391
|
+
rb_ary_push(result, extract_points_from_coordinate_sequence(context, coord_sequence, zCoordinate));
|
392
|
+
}
|
393
|
+
}
|
394
|
+
|
395
|
+
return result;
|
396
|
+
}
|
397
|
+
|
334
398
|
static VALUE method_multi_line_string_length(VALUE self)
|
335
399
|
{
|
336
400
|
VALUE result;
|
@@ -413,6 +477,36 @@ static VALUE method_multi_polygon_hash(VALUE self)
|
|
413
477
|
}
|
414
478
|
|
415
479
|
|
480
|
+
static VALUE method_multi_polygon_coordinates(VALUE self)
|
481
|
+
{
|
482
|
+
VALUE result = Qnil;
|
483
|
+
RGeo_GeometryData* self_data;
|
484
|
+
const GEOSGeometry* self_geom;
|
485
|
+
GEOSContextHandle_t context;
|
486
|
+
|
487
|
+
const GEOSGeometry* poly;
|
488
|
+
unsigned int count;
|
489
|
+
unsigned int i;
|
490
|
+
int zCoordinate;
|
491
|
+
|
492
|
+
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
493
|
+
self_geom = self_data->geom;
|
494
|
+
|
495
|
+
if(self_geom) {
|
496
|
+
zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M;
|
497
|
+
context = self_data->geos_context;
|
498
|
+
count = GEOSGetNumGeometries_r(context, self_geom);
|
499
|
+
result = rb_ary_new2(count);
|
500
|
+
for(i = 0; i < count; ++i) {
|
501
|
+
poly = GEOSGetGeometryN_r(context, self_geom, i);
|
502
|
+
rb_ary_push(result, extract_points_from_polygon(context, poly, zCoordinate));
|
503
|
+
}
|
504
|
+
}
|
505
|
+
|
506
|
+
return result;
|
507
|
+
}
|
508
|
+
|
509
|
+
|
416
510
|
static VALUE method_multi_polygon_area(VALUE self)
|
417
511
|
{
|
418
512
|
VALUE result;
|
@@ -516,10 +610,12 @@ void rgeo_init_geos_geometry_collection(RGeo_Globals* globals)
|
|
516
610
|
rb_define_method(geos_geometry_collection_methods, "[]", method_geometry_collection_brackets, 1);
|
517
611
|
rb_define_method(geos_geometry_collection_methods, "each", method_geometry_collection_each, 0);
|
518
612
|
|
613
|
+
|
519
614
|
// Methods for MultiPointImpl
|
520
615
|
geos_multi_point_methods = rb_define_module_under(globals->geos_module, "CAPIMultiPointMethods");
|
521
616
|
rb_define_method(geos_multi_point_methods, "geometry_type", method_multi_point_geometry_type, 0);
|
522
617
|
rb_define_method(geos_multi_point_methods, "hash", method_multi_point_hash, 0);
|
618
|
+
rb_define_method(geos_multi_point_methods, "coordinates", method_multi_point_coordinates, 0);
|
523
619
|
|
524
620
|
// Methods for MultiLineStringImpl
|
525
621
|
geos_multi_line_string_methods = rb_define_module_under(globals->geos_module, "CAPIMultiLineStringMethods");
|
@@ -527,6 +623,7 @@ void rgeo_init_geos_geometry_collection(RGeo_Globals* globals)
|
|
527
623
|
rb_define_method(geos_multi_line_string_methods, "length", method_multi_line_string_length, 0);
|
528
624
|
rb_define_method(geos_multi_line_string_methods, "is_closed?", method_multi_line_string_is_closed, 0);
|
529
625
|
rb_define_method(geos_multi_line_string_methods, "hash", method_multi_line_string_hash, 0);
|
626
|
+
rb_define_method(geos_multi_line_string_methods, "coordinates", method_multi_line_string_coordinates, 0);
|
530
627
|
|
531
628
|
// Methods for MultiPolygonImpl
|
532
629
|
geos_multi_polygon_methods = rb_define_module_under(globals->geos_module, "CAPIMultiPolygonMethods");
|
@@ -535,6 +632,7 @@ void rgeo_init_geos_geometry_collection(RGeo_Globals* globals)
|
|
535
632
|
rb_define_method(geos_multi_polygon_methods, "centroid", method_multi_polygon_centroid, 0);
|
536
633
|
rb_define_method(geos_multi_polygon_methods, "point_on_surface", method_multi_polygon_point_on_surface, 0);
|
537
634
|
rb_define_method(geos_multi_polygon_methods, "hash", method_multi_polygon_hash, 0);
|
635
|
+
rb_define_method(geos_multi_polygon_methods, "coordinates", method_multi_polygon_coordinates, 0);
|
538
636
|
}
|
539
637
|
|
540
638
|
|
Binary file
|
@@ -16,6 +16,8 @@
|
|
16
16
|
#include "point.h"
|
17
17
|
#include "line_string.h"
|
18
18
|
|
19
|
+
#include "coordinates.h"
|
20
|
+
|
19
21
|
RGEO_BEGIN_C
|
20
22
|
|
21
23
|
|
@@ -96,6 +98,41 @@ static VALUE method_line_string_num_points(VALUE self)
|
|
96
98
|
}
|
97
99
|
|
98
100
|
|
101
|
+
static void d(VALUE v) {
|
102
|
+
ID sym_puts = rb_intern("puts");
|
103
|
+
ID sym_inspect = rb_intern("inspect");
|
104
|
+
rb_funcall(rb_mKernel, sym_puts, 1,
|
105
|
+
rb_funcall(v, sym_inspect, 0));
|
106
|
+
}
|
107
|
+
|
108
|
+
static VALUE method_line_string_coordinates(VALUE self)
|
109
|
+
{
|
110
|
+
VALUE result;
|
111
|
+
VALUE point_tuple;
|
112
|
+
RGeo_GeometryData* self_data;
|
113
|
+
const GEOSGeometry* self_geom;
|
114
|
+
const GEOSCoordSequence* coord_sequence;
|
115
|
+
int zCoordinate;
|
116
|
+
|
117
|
+
GEOSContextHandle_t context;
|
118
|
+
|
119
|
+
result = Qnil;
|
120
|
+
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
121
|
+
self_geom = self_data->geom;
|
122
|
+
|
123
|
+
if (self_geom) {
|
124
|
+
zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M;
|
125
|
+
context = self_data->geos_context;
|
126
|
+
coord_sequence = GEOSGeom_getCoordSeq_r(context, self_geom);
|
127
|
+
if(coord_sequence) {
|
128
|
+
result = extract_points_from_coordinate_sequence(context, coord_sequence, zCoordinate);
|
129
|
+
}
|
130
|
+
}
|
131
|
+
return result;
|
132
|
+
}
|
133
|
+
|
134
|
+
|
135
|
+
|
99
136
|
static VALUE get_point_from_coordseq(VALUE self, const GEOSCoordSequence* coord_seq, unsigned int i, char has_z)
|
100
137
|
{
|
101
138
|
VALUE result;
|
@@ -589,6 +626,7 @@ void rgeo_init_geos_line_string(RGeo_Globals* globals)
|
|
589
626
|
rb_define_method(geos_line_string_methods, "end_point", method_line_string_end_point, 0);
|
590
627
|
rb_define_method(geos_line_string_methods, "is_closed?", method_line_string_is_closed, 0);
|
591
628
|
rb_define_method(geos_line_string_methods, "is_ring?", method_line_string_is_ring, 0);
|
629
|
+
rb_define_method(geos_line_string_methods, "coordinates", method_line_string_coordinates, 0);
|
592
630
|
|
593
631
|
// CAPILinearRingMethods module
|
594
632
|
geos_linear_ring_methods = rb_define_module_under(globals->geos_module, "CAPILinearRingMethods");
|
@@ -0,0 +1,123 @@
|
|
1
|
+
find_executable: checking for geos-config... -------------------- yes
|
2
|
+
|
3
|
+
--------------------
|
4
|
+
|
5
|
+
have_header: checking for geos_c.h... -------------------- yes
|
6
|
+
|
7
|
+
"clang -o conftest -I/Users/tee/.rubies/ruby-2.2.3/include/ruby-2.2.0/x86_64-darwin14 -I/Users/tee/.rubies/ruby-2.2.3/include/ruby-2.2.0/ruby/backward -I/Users/tee/.rubies/ruby-2.2.3/include/ruby-2.2.0 -I. -I/usr/local/Cellar/geos/3.5.0/include -I/Users/tee/.rubies/ruby-2.2.3/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -pipe conftest.c -L. -L/Users/tee/.rubies/ruby-2.2.3/lib -L. -L/Users/tee/.rubies/ruby-2.2.3/lib -fstack-protector -L/usr/local/lib -L/usr/local/Cellar/geos/3.5.0/lib -lgeos_c -lruby-static -framework CoreFoundation -lpthread -lgmp -ldl -lobjc "
|
8
|
+
checked program was:
|
9
|
+
/* begin */
|
10
|
+
1: #include "ruby.h"
|
11
|
+
2:
|
12
|
+
3: int main(int argc, char **argv)
|
13
|
+
4: {
|
14
|
+
5: return 0;
|
15
|
+
6: }
|
16
|
+
/* end */
|
17
|
+
|
18
|
+
"clang -E -I/Users/tee/.rubies/ruby-2.2.3/include/ruby-2.2.0/x86_64-darwin14 -I/Users/tee/.rubies/ruby-2.2.3/include/ruby-2.2.0/ruby/backward -I/Users/tee/.rubies/ruby-2.2.3/include/ruby-2.2.0 -I. -I/usr/local/Cellar/geos/3.5.0/include -I/Users/tee/.rubies/ruby-2.2.3/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -pipe conftest.c -o conftest.i"
|
19
|
+
checked program was:
|
20
|
+
/* begin */
|
21
|
+
1: #include "ruby.h"
|
22
|
+
2:
|
23
|
+
3: #include <geos_c.h>
|
24
|
+
/* end */
|
25
|
+
|
26
|
+
--------------------
|
27
|
+
|
28
|
+
have_func: checking for GEOSSetSRID_r() in geos_c.h... -------------------- yes
|
29
|
+
|
30
|
+
"clang -o conftest -I/Users/tee/.rubies/ruby-2.2.3/include/ruby-2.2.0/x86_64-darwin14 -I/Users/tee/.rubies/ruby-2.2.3/include/ruby-2.2.0/ruby/backward -I/Users/tee/.rubies/ruby-2.2.3/include/ruby-2.2.0 -I. -I/usr/local/Cellar/geos/3.5.0/include -I/Users/tee/.rubies/ruby-2.2.3/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -pipe conftest.c -L. -L/Users/tee/.rubies/ruby-2.2.3/lib -L. -L/Users/tee/.rubies/ruby-2.2.3/lib -fstack-protector -L/usr/local/lib -L/usr/local/Cellar/geos/3.5.0/lib -lgeos_c -lruby-static -framework CoreFoundation -L/usr/local/Cellar/geos/3.5.0/lib -lgeos_c -lpthread -lgmp -ldl -lobjc "
|
31
|
+
checked program was:
|
32
|
+
/* begin */
|
33
|
+
1: #include "ruby.h"
|
34
|
+
2:
|
35
|
+
3: #include <geos_c.h>
|
36
|
+
4:
|
37
|
+
5: /*top*/
|
38
|
+
6: extern int t(void);
|
39
|
+
7: int main(int argc, char **argv)
|
40
|
+
8: {
|
41
|
+
9: if (argc > 1000000) {
|
42
|
+
10: printf("%p", &t);
|
43
|
+
11: }
|
44
|
+
12:
|
45
|
+
13: return 0;
|
46
|
+
14: }
|
47
|
+
15: int t(void) { void ((*volatile p)()); p = (void ((*)()))GEOSSetSRID_r; return 0; }
|
48
|
+
/* end */
|
49
|
+
|
50
|
+
--------------------
|
51
|
+
|
52
|
+
have_func: checking for GEOSPreparedContains_r() in geos_c.h... -------------------- yes
|
53
|
+
|
54
|
+
"clang -o conftest -I/Users/tee/.rubies/ruby-2.2.3/include/ruby-2.2.0/x86_64-darwin14 -I/Users/tee/.rubies/ruby-2.2.3/include/ruby-2.2.0/ruby/backward -I/Users/tee/.rubies/ruby-2.2.3/include/ruby-2.2.0 -I. -I/usr/local/Cellar/geos/3.5.0/include -I/Users/tee/.rubies/ruby-2.2.3/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -pipe conftest.c -L. -L/Users/tee/.rubies/ruby-2.2.3/lib -L. -L/Users/tee/.rubies/ruby-2.2.3/lib -fstack-protector -L/usr/local/lib -L/usr/local/Cellar/geos/3.5.0/lib -lgeos_c -lruby-static -framework CoreFoundation -L/usr/local/Cellar/geos/3.5.0/lib -lgeos_c -lpthread -lgmp -ldl -lobjc "
|
55
|
+
checked program was:
|
56
|
+
/* begin */
|
57
|
+
1: #include "ruby.h"
|
58
|
+
2:
|
59
|
+
3: #include <geos_c.h>
|
60
|
+
4:
|
61
|
+
5: /*top*/
|
62
|
+
6: extern int t(void);
|
63
|
+
7: int main(int argc, char **argv)
|
64
|
+
8: {
|
65
|
+
9: if (argc > 1000000) {
|
66
|
+
10: printf("%p", &t);
|
67
|
+
11: }
|
68
|
+
12:
|
69
|
+
13: return 0;
|
70
|
+
14: }
|
71
|
+
15: int t(void) { void ((*volatile p)()); p = (void ((*)()))GEOSPreparedContains_r; return 0; }
|
72
|
+
/* end */
|
73
|
+
|
74
|
+
--------------------
|
75
|
+
|
76
|
+
have_func: checking for GEOSPreparedDisjoint_r() in geos_c.h... -------------------- yes
|
77
|
+
|
78
|
+
"clang -o conftest -I/Users/tee/.rubies/ruby-2.2.3/include/ruby-2.2.0/x86_64-darwin14 -I/Users/tee/.rubies/ruby-2.2.3/include/ruby-2.2.0/ruby/backward -I/Users/tee/.rubies/ruby-2.2.3/include/ruby-2.2.0 -I. -I/usr/local/Cellar/geos/3.5.0/include -I/Users/tee/.rubies/ruby-2.2.3/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -pipe conftest.c -L. -L/Users/tee/.rubies/ruby-2.2.3/lib -L. -L/Users/tee/.rubies/ruby-2.2.3/lib -fstack-protector -L/usr/local/lib -L/usr/local/Cellar/geos/3.5.0/lib -lgeos_c -lruby-static -framework CoreFoundation -L/usr/local/Cellar/geos/3.5.0/lib -lgeos_c -lpthread -lgmp -ldl -lobjc "
|
79
|
+
checked program was:
|
80
|
+
/* begin */
|
81
|
+
1: #include "ruby.h"
|
82
|
+
2:
|
83
|
+
3: #include <geos_c.h>
|
84
|
+
4:
|
85
|
+
5: /*top*/
|
86
|
+
6: extern int t(void);
|
87
|
+
7: int main(int argc, char **argv)
|
88
|
+
8: {
|
89
|
+
9: if (argc > 1000000) {
|
90
|
+
10: printf("%p", &t);
|
91
|
+
11: }
|
92
|
+
12:
|
93
|
+
13: return 0;
|
94
|
+
14: }
|
95
|
+
15: int t(void) { void ((*volatile p)()); p = (void ((*)()))GEOSPreparedDisjoint_r; return 0; }
|
96
|
+
/* end */
|
97
|
+
|
98
|
+
--------------------
|
99
|
+
|
100
|
+
have_func: checking for rb_memhash() in ruby.h... -------------------- yes
|
101
|
+
|
102
|
+
"clang -o conftest -I/Users/tee/.rubies/ruby-2.2.3/include/ruby-2.2.0/x86_64-darwin14 -I/Users/tee/.rubies/ruby-2.2.3/include/ruby-2.2.0/ruby/backward -I/Users/tee/.rubies/ruby-2.2.3/include/ruby-2.2.0 -I. -I/usr/local/Cellar/geos/3.5.0/include -I/Users/tee/.rubies/ruby-2.2.3/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -pipe conftest.c -L. -L/Users/tee/.rubies/ruby-2.2.3/lib -L. -L/Users/tee/.rubies/ruby-2.2.3/lib -fstack-protector -L/usr/local/lib -L/usr/local/Cellar/geos/3.5.0/lib -lgeos_c -lruby-static -framework CoreFoundation -L/usr/local/Cellar/geos/3.5.0/lib -lgeos_c -lpthread -lgmp -ldl -lobjc "
|
103
|
+
checked program was:
|
104
|
+
/* begin */
|
105
|
+
1: #include "ruby.h"
|
106
|
+
2:
|
107
|
+
3: #include <ruby.h>
|
108
|
+
4:
|
109
|
+
5: /*top*/
|
110
|
+
6: extern int t(void);
|
111
|
+
7: int main(int argc, char **argv)
|
112
|
+
8: {
|
113
|
+
9: if (argc > 1000000) {
|
114
|
+
10: printf("%p", &t);
|
115
|
+
11: }
|
116
|
+
12:
|
117
|
+
13: return 0;
|
118
|
+
14: }
|
119
|
+
15: int t(void) { void ((*volatile p)()); p = (void ((*)()))rb_memhash; return 0; }
|
120
|
+
/* end */
|
121
|
+
|
122
|
+
--------------------
|
123
|
+
|
data/ext/geos_c_impl/point.c
CHANGED
@@ -13,6 +13,8 @@
|
|
13
13
|
#include "geometry.h"
|
14
14
|
#include "point.h"
|
15
15
|
|
16
|
+
#include "coordinates.h"
|
17
|
+
|
16
18
|
RGEO_BEGIN_C
|
17
19
|
|
18
20
|
|
@@ -30,6 +32,30 @@ static VALUE method_point_geometry_type(VALUE self)
|
|
30
32
|
}
|
31
33
|
|
32
34
|
|
35
|
+
static VALUE method_point_coordinates(VALUE self)
|
36
|
+
{
|
37
|
+
VALUE result = Qnil;
|
38
|
+
RGeo_GeometryData* self_data;
|
39
|
+
const GEOSGeometry* self_geom;
|
40
|
+
GEOSContextHandle_t context;
|
41
|
+
const GEOSCoordSequence* coord_sequence;
|
42
|
+
int zCoordinate;
|
43
|
+
|
44
|
+
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
45
|
+
self_geom = self_data->geom;
|
46
|
+
|
47
|
+
if (self_geom) {
|
48
|
+
zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M;
|
49
|
+
context = self_data->geos_context;
|
50
|
+
coord_sequence = GEOSGeom_getCoordSeq_r(context, self_geom);
|
51
|
+
if(coord_sequence) {
|
52
|
+
result = rb_ary_pop(extract_points_from_coordinate_sequence(context, coord_sequence, zCoordinate));
|
53
|
+
}
|
54
|
+
}
|
55
|
+
return result;
|
56
|
+
}
|
57
|
+
|
58
|
+
|
33
59
|
static VALUE method_point_x(VALUE self)
|
34
60
|
{
|
35
61
|
VALUE result;
|
@@ -173,6 +199,7 @@ void rgeo_init_geos_point(RGeo_Globals* globals)
|
|
173
199
|
rb_define_method(geos_point_methods, "y", method_point_y, 0);
|
174
200
|
rb_define_method(geos_point_methods, "z", method_point_z, 0);
|
175
201
|
rb_define_method(geos_point_methods, "m", method_point_m, 0);
|
202
|
+
rb_define_method(geos_point_methods, "coordinates", method_point_coordinates, 0);
|
176
203
|
}
|
177
204
|
|
178
205
|
|
data/ext/geos_c_impl/polygon.c
CHANGED
@@ -15,6 +15,8 @@
|
|
15
15
|
#include "line_string.h"
|
16
16
|
#include "polygon.h"
|
17
17
|
|
18
|
+
#include "coordinates.h"
|
19
|
+
|
18
20
|
RGEO_BEGIN_C
|
19
21
|
|
20
22
|
|
@@ -113,6 +115,29 @@ static VALUE method_polygon_point_on_surface(VALUE self)
|
|
113
115
|
}
|
114
116
|
|
115
117
|
|
118
|
+
static VALUE method_polygon_coordinates(VALUE self)
|
119
|
+
{
|
120
|
+
VALUE result = Qnil;
|
121
|
+
RGeo_GeometryData* self_data;
|
122
|
+
const GEOSGeometry* self_geom;
|
123
|
+
GEOSContextHandle_t self_context;
|
124
|
+
|
125
|
+
GEOSGeometry* ring;
|
126
|
+
GEOSCoordSequence* coord_sequence;
|
127
|
+
unsigned int interior_ring_count;
|
128
|
+
int zCoordinate;
|
129
|
+
|
130
|
+
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
131
|
+
self_geom = self_data->geom;
|
132
|
+
|
133
|
+
if (self_geom) {
|
134
|
+
zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M;
|
135
|
+
self_context = self_data->geos_context;
|
136
|
+
result = extract_points_from_polygon(self_context, self_geom, zCoordinate);
|
137
|
+
}
|
138
|
+
return result;
|
139
|
+
}
|
140
|
+
|
116
141
|
static VALUE method_polygon_exterior_ring(VALUE self)
|
117
142
|
{
|
118
143
|
VALUE result;
|
@@ -274,6 +299,7 @@ void rgeo_init_geos_polygon(RGeo_Globals* globals)
|
|
274
299
|
rb_define_method(geos_polygon_methods, "num_interior_rings", method_polygon_num_interior_rings, 0);
|
275
300
|
rb_define_method(geos_polygon_methods, "interior_ring_n", method_polygon_interior_ring_n, 1);
|
276
301
|
rb_define_method(geos_polygon_methods, "interior_rings", method_polygon_interior_rings, 0);
|
302
|
+
rb_define_method(geos_polygon_methods, "coordinates", method_polygon_coordinates, 0);
|
277
303
|
}
|
278
304
|
|
279
305
|
|