rgeo 2.3.1 → 3.0.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.
- checksums.yaml +4 -4
 - data/.yardopts +6 -0
 - data/README.md +23 -14
 - data/ext/geos_c_impl/analysis.c +30 -25
 - data/ext/geos_c_impl/analysis.h +8 -7
 - data/ext/geos_c_impl/coordinates.c +27 -21
 - data/ext/geos_c_impl/coordinates.h +5 -2
 - data/ext/geos_c_impl/errors.c +19 -10
 - data/ext/geos_c_impl/errors.h +11 -4
 - data/ext/geos_c_impl/extconf.rb +42 -28
 - data/ext/geos_c_impl/factory.c +540 -451
 - data/ext/geos_c_impl/factory.h +105 -95
 - data/ext/geos_c_impl/geometry.c +593 -387
 - data/ext/geos_c_impl/geometry.h +10 -5
 - data/ext/geos_c_impl/geometry_collection.c +306 -339
 - data/ext/geos_c_impl/geometry_collection.h +6 -20
 - data/ext/geos_c_impl/globals.c +169 -0
 - data/ext/geos_c_impl/globals.h +46 -0
 - data/ext/geos_c_impl/line_string.c +271 -231
 - data/ext/geos_c_impl/line_string.h +5 -8
 - data/ext/geos_c_impl/main.c +16 -16
 - data/ext/geos_c_impl/point.c +65 -67
 - data/ext/geos_c_impl/point.h +4 -7
 - data/ext/geos_c_impl/polygon.c +137 -135
 - data/ext/geos_c_impl/polygon.h +11 -11
 - data/ext/geos_c_impl/preface.h +16 -10
 - data/ext/geos_c_impl/ruby_more.c +67 -0
 - data/ext/geos_c_impl/ruby_more.h +25 -0
 - data/lib/rgeo/cartesian/analysis.rb +5 -3
 - data/lib/rgeo/cartesian/bounding_box.rb +74 -79
 - data/lib/rgeo/cartesian/calculations.rb +64 -33
 - data/lib/rgeo/cartesian/factory.rb +57 -102
 - data/lib/rgeo/cartesian/feature_classes.rb +68 -46
 - data/lib/rgeo/cartesian/feature_methods.rb +67 -25
 - data/lib/rgeo/cartesian/interface.rb +6 -41
 - data/lib/rgeo/cartesian/planar_graph.rb +373 -0
 - data/lib/rgeo/cartesian/sweepline_intersector.rb +147 -0
 - data/lib/rgeo/cartesian/valid_op.rb +69 -0
 - data/lib/rgeo/cartesian.rb +3 -0
 - data/lib/rgeo/coord_sys/cs/entities.rb +303 -99
 - data/lib/rgeo/coord_sys/cs/factories.rb +0 -2
 - data/lib/rgeo/coord_sys/cs/wkt_parser.rb +90 -42
 - data/lib/rgeo/coord_sys.rb +1 -20
 - data/lib/rgeo/error.rb +15 -0
 - data/lib/rgeo/feature/curve.rb +0 -11
 - data/lib/rgeo/feature/factory.rb +26 -36
 - data/lib/rgeo/feature/factory_generator.rb +6 -14
 - data/lib/rgeo/feature/geometry.rb +146 -66
 - data/lib/rgeo/feature/geometry_collection.rb +16 -9
 - data/lib/rgeo/feature/line_string.rb +4 -5
 - data/lib/rgeo/feature/linear_ring.rb +0 -1
 - data/lib/rgeo/feature/multi_curve.rb +0 -6
 - data/lib/rgeo/feature/multi_surface.rb +3 -4
 - data/lib/rgeo/feature/point.rb +4 -5
 - data/lib/rgeo/feature/polygon.rb +1 -2
 - data/lib/rgeo/feature/surface.rb +3 -4
 - data/lib/rgeo/feature/types.rb +69 -85
 - data/lib/rgeo/geographic/factory.rb +98 -125
 - data/lib/rgeo/geographic/interface.rb +69 -166
 - data/lib/rgeo/geographic/projected_feature_classes.rb +21 -9
 - data/lib/rgeo/geographic/projected_feature_methods.rb +67 -42
 - data/lib/rgeo/geographic/projected_window.rb +36 -22
 - data/lib/rgeo/geographic/{proj4_projector.rb → projector.rb} +3 -5
 - data/lib/rgeo/geographic/simple_mercator_projector.rb +26 -25
 - data/lib/rgeo/geographic/spherical_feature_classes.rb +29 -9
 - data/lib/rgeo/geographic/spherical_feature_methods.rb +86 -9
 - data/lib/rgeo/geographic/spherical_math.rb +17 -20
 - data/lib/rgeo/geographic.rb +1 -1
 - data/lib/rgeo/geos/capi_factory.rb +87 -158
 - data/lib/rgeo/geos/capi_feature_classes.rb +50 -36
 - data/lib/rgeo/geos/ffi_factory.rb +105 -173
 - data/lib/rgeo/geos/ffi_feature_classes.rb +34 -10
 - data/lib/rgeo/geos/ffi_feature_methods.rb +105 -127
 - data/lib/rgeo/geos/interface.rb +20 -59
 - data/lib/rgeo/geos/utils.rb +5 -5
 - data/lib/rgeo/geos/zm_factory.rb +53 -95
 - data/lib/rgeo/geos/zm_feature_methods.rb +30 -33
 - data/lib/rgeo/geos.rb +8 -8
 - data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +9 -22
 - data/lib/rgeo/impl_helper/basic_geometry_methods.rb +1 -2
 - data/lib/rgeo/impl_helper/basic_line_string_methods.rb +28 -56
 - data/lib/rgeo/impl_helper/basic_point_methods.rb +2 -14
 - data/lib/rgeo/impl_helper/basic_polygon_methods.rb +17 -26
 - data/lib/rgeo/impl_helper/utils.rb +21 -0
 - data/lib/rgeo/impl_helper/valid_op.rb +350 -0
 - data/lib/rgeo/impl_helper/validity_check.rb +139 -0
 - data/lib/rgeo/impl_helper.rb +1 -0
 - data/lib/rgeo/version.rb +1 -1
 - data/lib/rgeo/wkrep/wkb_generator.rb +73 -63
 - data/lib/rgeo/wkrep/wkb_parser.rb +33 -31
 - data/lib/rgeo/wkrep/wkt_generator.rb +52 -45
 - data/lib/rgeo/wkrep/wkt_parser.rb +48 -35
 - data/lib/rgeo.rb +1 -3
 - metadata +50 -13
 - data/lib/rgeo/coord_sys/srs_database/entry.rb +0 -107
 - data/lib/rgeo/coord_sys/srs_database/sr_org.rb +0 -64
 - data/lib/rgeo/coord_sys/srs_database/url_reader.rb +0 -65
 
| 
         @@ -2,30 +2,27 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
              Line string methods for GEOS wrapper
         
     | 
| 
       3 
3 
     | 
    
         
             
            */
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
5 
     | 
    
         
             
            #ifndef RGEO_GEOS_LINE_STRING_INCLUDED
         
     | 
| 
       7 
6 
     | 
    
         
             
            #define RGEO_GEOS_LINE_STRING_INCLUDED
         
     | 
| 
       8 
7 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
            #include <ruby.h>
         
     | 
| 
       10 
8 
     | 
    
         
             
            #include <geos_c.h>
         
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
            #include "factory.h"
         
     | 
| 
      
 9 
     | 
    
         
            +
            #include <ruby.h>
         
     | 
| 
       13 
10 
     | 
    
         | 
| 
       14 
11 
     | 
    
         
             
            RGEO_BEGIN_C
         
     | 
| 
       15 
12 
     | 
    
         | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
13 
     | 
    
         
             
            /*
         
     | 
| 
       18 
14 
     | 
    
         
             
              Initializes the line string module. This should be called after
         
     | 
| 
       19 
15 
     | 
    
         
             
              the geometry module is initialized.
         
     | 
| 
       20 
16 
     | 
    
         
             
            */
         
     | 
| 
       21 
     | 
    
         
            -
            void 
     | 
| 
      
 17 
     | 
    
         
            +
            void
         
     | 
| 
      
 18 
     | 
    
         
            +
            rgeo_init_geos_line_string();
         
     | 
| 
       22 
19 
     | 
    
         | 
| 
       23 
20 
     | 
    
         
             
            /*
         
     | 
| 
       24 
21 
     | 
    
         
             
              Determines whether the given GEOS line string is closed.
         
     | 
| 
       25 
22 
     | 
    
         
             
              Returns Qtrue if true, Qfalse if false, or Qnil on an error.
         
     | 
| 
       26 
23 
     | 
    
         
             
            */
         
     | 
| 
       27 
     | 
    
         
            -
            VALUE 
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
      
 24 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 25 
     | 
    
         
            +
            rgeo_is_geos_line_string_closed(const GEOSGeometry* geom);
         
     | 
| 
       29 
26 
     | 
    
         | 
| 
       30 
27 
     | 
    
         
             
            RGEO_END_C
         
     | 
| 
       31 
28 
     | 
    
         | 
    
        data/ext/geos_c_impl/main.c
    CHANGED
    
    | 
         @@ -6,38 +6,38 @@ 
     | 
|
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            #ifdef RGEO_GEOS_SUPPORTED
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
            #include <ruby.h>
         
     | 
| 
       10 
9 
     | 
    
         
             
            #include <geos_c.h>
         
     | 
| 
      
 10 
     | 
    
         
            +
            #include <ruby.h>
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
      
 12 
     | 
    
         
            +
            #include "analysis.h"
         
     | 
| 
       12 
13 
     | 
    
         
             
            #include "errors.h"
         
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
14 
     | 
    
         
             
            #include "factory.h"
         
     | 
| 
       15 
15 
     | 
    
         
             
            #include "geometry.h"
         
     | 
| 
       16 
     | 
    
         
            -
            #include " 
     | 
| 
      
 16 
     | 
    
         
            +
            #include "geometry_collection.h"
         
     | 
| 
      
 17 
     | 
    
         
            +
            #include "globals.h"
         
     | 
| 
       17 
18 
     | 
    
         
             
            #include "line_string.h"
         
     | 
| 
      
 19 
     | 
    
         
            +
            #include "point.h"
         
     | 
| 
       18 
20 
     | 
    
         
             
            #include "polygon.h"
         
     | 
| 
       19 
     | 
    
         
            -
            #include " 
     | 
| 
       20 
     | 
    
         
            -
            #include "analysis.h"
         
     | 
| 
      
 21 
     | 
    
         
            +
            #include "ruby_more.h"
         
     | 
| 
       21 
22 
     | 
    
         | 
| 
       22 
23 
     | 
    
         
             
            #endif
         
     | 
| 
       23 
24 
     | 
    
         | 
| 
       24 
25 
     | 
    
         
             
            RGEO_BEGIN_C
         
     | 
| 
       25 
26 
     | 
    
         | 
| 
       26 
     | 
    
         
            -
            void 
     | 
| 
      
 27 
     | 
    
         
            +
            void
         
     | 
| 
      
 28 
     | 
    
         
            +
            Init_geos_c_impl()
         
     | 
| 
       27 
29 
     | 
    
         
             
            {
         
     | 
| 
       28 
30 
     | 
    
         
             
            #ifdef RGEO_GEOS_SUPPORTED
         
     | 
| 
       29 
     | 
    
         
            -
               
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
               
     | 
| 
       32 
     | 
    
         
            -
               
     | 
| 
       33 
     | 
    
         
            -
               
     | 
| 
       34 
     | 
    
         
            -
               
     | 
| 
       35 
     | 
    
         
            -
               
     | 
| 
       36 
     | 
    
         
            -
               
     | 
| 
       37 
     | 
    
         
            -
              rgeo_init_geos_analysis(globals);
         
     | 
| 
      
 31 
     | 
    
         
            +
              rgeo_init_geos_globals();
         
     | 
| 
      
 32 
     | 
    
         
            +
              rgeo_init_geos_factory();
         
     | 
| 
      
 33 
     | 
    
         
            +
              rgeo_init_geos_geometry();
         
     | 
| 
      
 34 
     | 
    
         
            +
              rgeo_init_geos_point();
         
     | 
| 
      
 35 
     | 
    
         
            +
              rgeo_init_geos_line_string();
         
     | 
| 
      
 36 
     | 
    
         
            +
              rgeo_init_geos_polygon();
         
     | 
| 
      
 37 
     | 
    
         
            +
              rgeo_init_geos_geometry_collection();
         
     | 
| 
      
 38 
     | 
    
         
            +
              rgeo_init_geos_analysis();
         
     | 
| 
       38 
39 
     | 
    
         
             
              rgeo_init_geos_errors();
         
     | 
| 
       39 
40 
     | 
    
         
             
            #endif
         
     | 
| 
       40 
41 
     | 
    
         
             
            }
         
     | 
| 
       41 
42 
     | 
    
         | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
43 
     | 
    
         
             
            RGEO_END_C
         
     | 
    
        data/ext/geos_c_impl/point.c
    CHANGED
    
    | 
         @@ -6,19 +6,19 @@ 
     | 
|
| 
       6 
6 
     | 
    
         | 
| 
       7 
7 
     | 
    
         
             
            #ifdef RGEO_GEOS_SUPPORTED
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
            #include <ruby.h>
         
     | 
| 
       10 
9 
     | 
    
         
             
            #include <geos_c.h>
         
     | 
| 
      
 10 
     | 
    
         
            +
            #include <ruby.h>
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
      
 12 
     | 
    
         
            +
            #include "coordinates.h"
         
     | 
| 
       12 
13 
     | 
    
         
             
            #include "factory.h"
         
     | 
| 
       13 
14 
     | 
    
         
             
            #include "geometry.h"
         
     | 
| 
      
 15 
     | 
    
         
            +
            #include "globals.h"
         
     | 
| 
       14 
16 
     | 
    
         
             
            #include "point.h"
         
     | 
| 
       15 
17 
     | 
    
         | 
| 
       16 
     | 
    
         
            -
            #include "coordinates.h"
         
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
18 
     | 
    
         
             
            RGEO_BEGIN_C
         
     | 
| 
       19 
19 
     | 
    
         | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 20 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 21 
     | 
    
         
            +
            method_point_geometry_type(VALUE self)
         
     | 
| 
       22 
22 
     | 
    
         
             
            {
         
     | 
| 
       23 
23 
     | 
    
         
             
              VALUE result;
         
     | 
| 
       24 
24 
     | 
    
         
             
              RGeo_GeometryData* self_data;
         
     | 
| 
         @@ -26,18 +26,17 @@ static VALUE method_point_geometry_type(VALUE self) 
     | 
|
| 
       26 
26 
     | 
    
         
             
              result = Qnil;
         
     | 
| 
       27 
27 
     | 
    
         
             
              self_data = RGEO_GEOMETRY_DATA_PTR(self);
         
     | 
| 
       28 
28 
     | 
    
         
             
              if (self_data->geom) {
         
     | 
| 
       29 
     | 
    
         
            -
                result =  
     | 
| 
      
 29 
     | 
    
         
            +
                result = rgeo_feature_point_module;
         
     | 
| 
       30 
30 
     | 
    
         
             
              }
         
     | 
| 
       31 
31 
     | 
    
         
             
              return result;
         
     | 
| 
       32 
32 
     | 
    
         
             
            }
         
     | 
| 
       33 
33 
     | 
    
         | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
      
 34 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 35 
     | 
    
         
            +
            method_point_coordinates(VALUE self)
         
     | 
| 
       36 
36 
     | 
    
         
             
            {
         
     | 
| 
       37 
37 
     | 
    
         
             
              VALUE result = Qnil;
         
     | 
| 
       38 
38 
     | 
    
         
             
              RGeo_GeometryData* self_data;
         
     | 
| 
       39 
39 
     | 
    
         
             
              const GEOSGeometry* self_geom;
         
     | 
| 
       40 
     | 
    
         
            -
              GEOSContextHandle_t context;
         
     | 
| 
       41 
40 
     | 
    
         
             
              const GEOSCoordSequence* coord_sequence;
         
     | 
| 
       42 
41 
     | 
    
         
             
              int zCoordinate;
         
     | 
| 
       43 
42 
     | 
    
         | 
| 
         @@ -45,23 +44,23 @@ static VALUE method_point_coordinates(VALUE self) 
     | 
|
| 
       45 
44 
     | 
    
         
             
              self_geom = self_data->geom;
         
     | 
| 
       46 
45 
     | 
    
         | 
| 
       47 
46 
     | 
    
         
             
              if (self_geom) {
         
     | 
| 
       48 
     | 
    
         
            -
                zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & 
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
                coord_sequence =  
     | 
| 
       51 
     | 
    
         
            -
                if(coord_sequence) {
         
     | 
| 
       52 
     | 
    
         
            -
                  result = rb_ary_pop( 
     | 
| 
      
 47 
     | 
    
         
            +
                zCoordinate = RGEO_FACTORY_DATA_PTR(self_data->factory)->flags &
         
     | 
| 
      
 48 
     | 
    
         
            +
                              RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M;
         
     | 
| 
      
 49 
     | 
    
         
            +
                coord_sequence = GEOSGeom_getCoordSeq(self_geom);
         
     | 
| 
      
 50 
     | 
    
         
            +
                if (coord_sequence) {
         
     | 
| 
      
 51 
     | 
    
         
            +
                  result = rb_ary_pop(
         
     | 
| 
      
 52 
     | 
    
         
            +
                    extract_points_from_coordinate_sequence(coord_sequence, zCoordinate));
         
     | 
| 
       53 
53 
     | 
    
         
             
                }
         
     | 
| 
       54 
54 
     | 
    
         
             
              }
         
     | 
| 
       55 
55 
     | 
    
         
             
              return result;
         
     | 
| 
       56 
56 
     | 
    
         
             
            }
         
     | 
| 
       57 
57 
     | 
    
         | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
      
 58 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 59 
     | 
    
         
            +
            method_point_x(VALUE self)
         
     | 
| 
       60 
60 
     | 
    
         
             
            {
         
     | 
| 
       61 
61 
     | 
    
         
             
              VALUE result;
         
     | 
| 
       62 
62 
     | 
    
         
             
              RGeo_GeometryData* self_data;
         
     | 
| 
       63 
63 
     | 
    
         
             
              const GEOSGeometry* self_geom;
         
     | 
| 
       64 
     | 
    
         
            -
              GEOSContextHandle_t self_context;
         
     | 
| 
       65 
64 
     | 
    
         
             
              const GEOSCoordSequence* coord_seq;
         
     | 
| 
       66 
65 
     | 
    
         
             
              double val;
         
     | 
| 
       67 
66 
     | 
    
         | 
| 
         @@ -69,10 +68,9 @@ static VALUE method_point_x(VALUE self) 
     | 
|
| 
       69 
68 
     | 
    
         
             
              self_data = RGEO_GEOMETRY_DATA_PTR(self);
         
     | 
| 
       70 
69 
     | 
    
         
             
              self_geom = self_data->geom;
         
     | 
| 
       71 
70 
     | 
    
         
             
              if (self_geom) {
         
     | 
| 
       72 
     | 
    
         
            -
                 
     | 
| 
       73 
     | 
    
         
            -
                coord_seq = GEOSGeom_getCoordSeq_r(self_context, self_geom);
         
     | 
| 
      
 71 
     | 
    
         
            +
                coord_seq = GEOSGeom_getCoordSeq(self_geom);
         
     | 
| 
       74 
72 
     | 
    
         
             
                if (coord_seq) {
         
     | 
| 
       75 
     | 
    
         
            -
                  if ( 
     | 
| 
      
 73 
     | 
    
         
            +
                  if (GEOSCoordSeq_getX(coord_seq, 0, &val)) {
         
     | 
| 
       76 
74 
     | 
    
         
             
                    result = rb_float_new(val);
         
     | 
| 
       77 
75 
     | 
    
         
             
                  }
         
     | 
| 
       78 
76 
     | 
    
         
             
                }
         
     | 
| 
         @@ -80,13 +78,12 @@ static VALUE method_point_x(VALUE self) 
     | 
|
| 
       80 
78 
     | 
    
         
             
              return result;
         
     | 
| 
       81 
79 
     | 
    
         
             
            }
         
     | 
| 
       82 
80 
     | 
    
         | 
| 
       83 
     | 
    
         
            -
             
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
      
 81 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 82 
     | 
    
         
            +
            method_point_y(VALUE self)
         
     | 
| 
       85 
83 
     | 
    
         
             
            {
         
     | 
| 
       86 
84 
     | 
    
         
             
              VALUE result;
         
     | 
| 
       87 
85 
     | 
    
         
             
              RGeo_GeometryData* self_data;
         
     | 
| 
       88 
86 
     | 
    
         
             
              const GEOSGeometry* self_geom;
         
     | 
| 
       89 
     | 
    
         
            -
              GEOSContextHandle_t self_context;
         
     | 
| 
       90 
87 
     | 
    
         
             
              const GEOSCoordSequence* coord_seq;
         
     | 
| 
       91 
88 
     | 
    
         
             
              double val;
         
     | 
| 
       92 
89 
     | 
    
         | 
| 
         @@ -94,10 +91,9 @@ static VALUE method_point_y(VALUE self) 
     | 
|
| 
       94 
91 
     | 
    
         
             
              self_data = RGEO_GEOMETRY_DATA_PTR(self);
         
     | 
| 
       95 
92 
     | 
    
         
             
              self_geom = self_data->geom;
         
     | 
| 
       96 
93 
     | 
    
         
             
              if (self_geom) {
         
     | 
| 
       97 
     | 
    
         
            -
                 
     | 
| 
       98 
     | 
    
         
            -
                coord_seq = GEOSGeom_getCoordSeq_r(self_context, self_geom);
         
     | 
| 
      
 94 
     | 
    
         
            +
                coord_seq = GEOSGeom_getCoordSeq(self_geom);
         
     | 
| 
       99 
95 
     | 
    
         
             
                if (coord_seq) {
         
     | 
| 
       100 
     | 
    
         
            -
                  if ( 
     | 
| 
      
 96 
     | 
    
         
            +
                  if (GEOSCoordSeq_getY(coord_seq, 0, &val)) {
         
     | 
| 
       101 
97 
     | 
    
         
             
                    result = rb_float_new(val);
         
     | 
| 
       102 
98 
     | 
    
         
             
                  }
         
     | 
| 
       103 
99 
     | 
    
         
             
                }
         
     | 
| 
         @@ -105,13 +101,12 @@ static VALUE method_point_y(VALUE self) 
     | 
|
| 
       105 
101 
     | 
    
         
             
              return result;
         
     | 
| 
       106 
102 
     | 
    
         
             
            }
         
     | 
| 
       107 
103 
     | 
    
         | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
      
 104 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 105 
     | 
    
         
            +
            get_3d_point(VALUE self, int flag)
         
     | 
| 
       110 
106 
     | 
    
         
             
            {
         
     | 
| 
       111 
107 
     | 
    
         
             
              VALUE result;
         
     | 
| 
       112 
108 
     | 
    
         
             
              RGeo_GeometryData* self_data;
         
     | 
| 
       113 
109 
     | 
    
         
             
              const GEOSGeometry* self_geom;
         
     | 
| 
       114 
     | 
    
         
            -
              GEOSContextHandle_t self_context;
         
     | 
| 
       115 
110 
     | 
    
         
             
              const GEOSCoordSequence* coord_seq;
         
     | 
| 
       116 
111 
     | 
    
         
             
              double val;
         
     | 
| 
       117 
112 
     | 
    
         | 
| 
         @@ -120,10 +115,9 @@ static VALUE get_3d_point(VALUE self, int flag) 
     | 
|
| 
       120 
115 
     | 
    
         
             
              self_geom = self_data->geom;
         
     | 
| 
       121 
116 
     | 
    
         
             
              if (self_geom) {
         
     | 
| 
       122 
117 
     | 
    
         
             
                if (RGEO_FACTORY_DATA_PTR(self_data->factory)->flags & flag) {
         
     | 
| 
       123 
     | 
    
         
            -
                   
     | 
| 
       124 
     | 
    
         
            -
                  coord_seq = GEOSGeom_getCoordSeq_r(self_context, self_geom);
         
     | 
| 
      
 118 
     | 
    
         
            +
                  coord_seq = GEOSGeom_getCoordSeq(self_geom);
         
     | 
| 
       125 
119 
     | 
    
         
             
                  if (coord_seq) {
         
     | 
| 
       126 
     | 
    
         
            -
                    if ( 
     | 
| 
      
 120 
     | 
    
         
            +
                    if (GEOSCoordSeq_getZ(coord_seq, 0, &val)) {
         
     | 
| 
       127 
121 
     | 
    
         
             
                      result = rb_float_new(val);
         
     | 
| 
       128 
122 
     | 
    
         
             
                    }
         
     | 
| 
       129 
123 
     | 
    
         
             
                  }
         
     | 
| 
         @@ -132,20 +126,20 @@ static VALUE get_3d_point(VALUE self, int flag) 
     | 
|
| 
       132 
126 
     | 
    
         
             
              return result;
         
     | 
| 
       133 
127 
     | 
    
         
             
            }
         
     | 
| 
       134 
128 
     | 
    
         | 
| 
       135 
     | 
    
         
            -
             
     | 
| 
       136 
     | 
    
         
            -
             
     | 
| 
      
 129 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 130 
     | 
    
         
            +
            method_point_z(VALUE self)
         
     | 
| 
       137 
131 
     | 
    
         
             
            {
         
     | 
| 
       138 
132 
     | 
    
         
             
              return get_3d_point(self, RGEO_FACTORYFLAGS_SUPPORTS_Z);
         
     | 
| 
       139 
133 
     | 
    
         
             
            }
         
     | 
| 
       140 
134 
     | 
    
         | 
| 
       141 
     | 
    
         
            -
             
     | 
| 
       142 
     | 
    
         
            -
             
     | 
| 
      
 135 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 136 
     | 
    
         
            +
            method_point_m(VALUE self)
         
     | 
| 
       143 
137 
     | 
    
         
             
            {
         
     | 
| 
       144 
138 
     | 
    
         
             
              return get_3d_point(self, RGEO_FACTORYFLAGS_SUPPORTS_M);
         
     | 
| 
       145 
139 
     | 
    
         
             
            }
         
     | 
| 
       146 
140 
     | 
    
         | 
| 
       147 
     | 
    
         
            -
             
     | 
| 
       148 
     | 
    
         
            -
             
     | 
| 
      
 141 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 142 
     | 
    
         
            +
            method_point_eql(VALUE self, VALUE rhs)
         
     | 
| 
       149 
143 
     | 
    
         
             
            {
         
     | 
| 
       150 
144 
     | 
    
         
             
              VALUE result;
         
     | 
| 
       151 
145 
     | 
    
         
             
              RGeo_GeometryData* self_data;
         
     | 
| 
         @@ -153,13 +147,14 @@ static VALUE method_point_eql(VALUE self, VALUE rhs) 
     | 
|
| 
       153 
147 
     | 
    
         
             
              result = rgeo_geos_klasses_and_factories_eql(self, rhs);
         
     | 
| 
       154 
148 
     | 
    
         
             
              if (RTEST(result)) {
         
     | 
| 
       155 
149 
     | 
    
         
             
                self_data = RGEO_GEOMETRY_DATA_PTR(self);
         
     | 
| 
       156 
     | 
    
         
            -
                result =  
     | 
| 
      
 150 
     | 
    
         
            +
                result = rgeo_geos_geometries_strict_eql(self_data->geom,
         
     | 
| 
      
 151 
     | 
    
         
            +
                                                         RGEO_GEOMETRY_DATA_PTR(rhs)->geom);
         
     | 
| 
       157 
152 
     | 
    
         
             
              }
         
     | 
| 
       158 
153 
     | 
    
         
             
              return result;
         
     | 
| 
       159 
154 
     | 
    
         
             
            }
         
     | 
| 
       160 
155 
     | 
    
         | 
| 
       161 
     | 
    
         
            -
             
     | 
| 
       162 
     | 
    
         
            -
             
     | 
| 
      
 156 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 157 
     | 
    
         
            +
            method_point_hash(VALUE self)
         
     | 
| 
       163 
158 
     | 
    
         
             
            {
         
     | 
| 
       164 
159 
     | 
    
         
             
              st_index_t hash;
         
     | 
| 
       165 
160 
     | 
    
         
             
              RGeo_GeometryData* self_data;
         
     | 
| 
         @@ -168,60 +163,64 @@ static VALUE method_point_hash(VALUE self) 
     | 
|
| 
       168 
163 
     | 
    
         
             
              self_data = RGEO_GEOMETRY_DATA_PTR(self);
         
     | 
| 
       169 
164 
     | 
    
         
             
              factory = self_data->factory;
         
     | 
| 
       170 
165 
     | 
    
         
             
              hash = rb_hash_start(0);
         
     | 
| 
       171 
     | 
    
         
            -
              hash = rgeo_geos_objbase_hash(factory,
         
     | 
| 
       172 
     | 
    
         
            -
             
     | 
| 
       173 
     | 
    
         
            -
              hash = rgeo_geos_coordseq_hash(self_data->geos_context, self_data->geom, hash);
         
     | 
| 
      
 166 
     | 
    
         
            +
              hash = rgeo_geos_objbase_hash(factory, rgeo_feature_point_module, hash);
         
     | 
| 
      
 167 
     | 
    
         
            +
              hash = rgeo_geos_coordseq_hash(self_data->geom, hash);
         
     | 
| 
       174 
168 
     | 
    
         
             
              return LONG2FIX(rb_hash_end(hash));
         
     | 
| 
       175 
169 
     | 
    
         
             
            }
         
     | 
| 
       176 
170 
     | 
    
         | 
| 
       177 
     | 
    
         
            -
             
     | 
| 
       178 
     | 
    
         
            -
             
     | 
| 
      
 171 
     | 
    
         
            +
            static VALUE
         
     | 
| 
      
 172 
     | 
    
         
            +
            cmethod_create(VALUE module, VALUE factory, VALUE x, VALUE y, VALUE z)
         
     | 
| 
       179 
173 
     | 
    
         
             
            {
         
     | 
| 
       180 
     | 
    
         
            -
              return rgeo_create_geos_point(factory, 
     | 
| 
       181 
     | 
    
         
            -
             
     | 
| 
      
 174 
     | 
    
         
            +
              return rgeo_create_geos_point(factory,
         
     | 
| 
      
 175 
     | 
    
         
            +
                                            rb_num2dbl(x),
         
     | 
| 
      
 176 
     | 
    
         
            +
                                            rb_num2dbl(y),
         
     | 
| 
      
 177 
     | 
    
         
            +
                                            RGEO_FACTORY_DATA_PTR(factory)->flags &
         
     | 
| 
      
 178 
     | 
    
         
            +
                                                RGEO_FACTORYFLAGS_SUPPORTS_Z_OR_M
         
     | 
| 
      
 179 
     | 
    
         
            +
                                              ? rb_num2dbl(z)
         
     | 
| 
      
 180 
     | 
    
         
            +
                                              : 0);
         
     | 
| 
       182 
181 
     | 
    
         
             
            }
         
     | 
| 
       183 
182 
     | 
    
         | 
| 
       184 
     | 
    
         
            -
             
     | 
| 
       185 
     | 
    
         
            -
             
     | 
| 
      
 183 
     | 
    
         
            +
            void
         
     | 
| 
      
 184 
     | 
    
         
            +
            rgeo_init_geos_point()
         
     | 
| 
       186 
185 
     | 
    
         
             
            {
         
     | 
| 
       187 
186 
     | 
    
         
             
              VALUE geos_point_methods;
         
     | 
| 
       188 
187 
     | 
    
         | 
| 
       189 
188 
     | 
    
         
             
              // Class methods for CAPIPointImpl
         
     | 
| 
       190 
     | 
    
         
            -
              rb_define_module_function( 
     | 
| 
      
 189 
     | 
    
         
            +
              rb_define_module_function(rgeo_geos_point_class, "create", cmethod_create, 4);
         
     | 
| 
       191 
190 
     | 
    
         | 
| 
       192 
191 
     | 
    
         
             
              // CAPIPointMethods module
         
     | 
| 
       193 
     | 
    
         
            -
              geos_point_methods = 
     | 
| 
      
 192 
     | 
    
         
            +
              geos_point_methods =
         
     | 
| 
      
 193 
     | 
    
         
            +
                rb_define_module_under(rgeo_geos_module, "CAPIPointMethods");
         
     | 
| 
       194 
194 
     | 
    
         
             
              rb_define_method(geos_point_methods, "rep_equals?", method_point_eql, 1);
         
     | 
| 
       195 
195 
     | 
    
         
             
              rb_define_method(geos_point_methods, "eql?", method_point_eql, 1);
         
     | 
| 
       196 
196 
     | 
    
         
             
              rb_define_method(geos_point_methods, "hash", method_point_hash, 0);
         
     | 
| 
       197 
     | 
    
         
            -
              rb_define_method( 
     | 
| 
      
 197 
     | 
    
         
            +
              rb_define_method(
         
     | 
| 
      
 198 
     | 
    
         
            +
                geos_point_methods, "geometry_type", method_point_geometry_type, 0);
         
     | 
| 
       198 
199 
     | 
    
         
             
              rb_define_method(geos_point_methods, "x", method_point_x, 0);
         
     | 
| 
       199 
200 
     | 
    
         
             
              rb_define_method(geos_point_methods, "y", method_point_y, 0);
         
     | 
| 
       200 
201 
     | 
    
         
             
              rb_define_method(geos_point_methods, "z", method_point_z, 0);
         
     | 
| 
       201 
202 
     | 
    
         
             
              rb_define_method(geos_point_methods, "m", method_point_m, 0);
         
     | 
| 
       202 
     | 
    
         
            -
              rb_define_method( 
     | 
| 
      
 203 
     | 
    
         
            +
              rb_define_method(
         
     | 
| 
      
 204 
     | 
    
         
            +
                geos_point_methods, "coordinates", method_point_coordinates, 0);
         
     | 
| 
       203 
205 
     | 
    
         
             
            }
         
     | 
| 
       204 
206 
     | 
    
         | 
| 
       205 
     | 
    
         
            -
             
     | 
| 
       206 
     | 
    
         
            -
             
     | 
| 
      
 207 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 208 
     | 
    
         
            +
            rgeo_create_geos_point(VALUE factory, double x, double y, double z)
         
     | 
| 
       207 
209 
     | 
    
         
             
            {
         
     | 
| 
       208 
210 
     | 
    
         
             
              VALUE result;
         
     | 
| 
       209 
     | 
    
         
            -
              RGeo_FactoryData* factory_data;
         
     | 
| 
       210 
     | 
    
         
            -
              GEOSContextHandle_t context;
         
     | 
| 
       211 
211 
     | 
    
         
             
              GEOSCoordSequence* coord_seq;
         
     | 
| 
       212 
212 
     | 
    
         
             
              GEOSGeometry* geom;
         
     | 
| 
       213 
213 
     | 
    
         | 
| 
       214 
214 
     | 
    
         
             
              result = Qnil;
         
     | 
| 
       215 
     | 
    
         
            -
               
     | 
| 
       216 
     | 
    
         
            -
              context = factory_data->geos_context;
         
     | 
| 
       217 
     | 
    
         
            -
              coord_seq = GEOSCoordSeq_create_r(context, 1, 3);
         
     | 
| 
      
 215 
     | 
    
         
            +
              coord_seq = GEOSCoordSeq_create(1, 3);
         
     | 
| 
       218 
216 
     | 
    
         
             
              if (coord_seq) {
         
     | 
| 
       219 
     | 
    
         
            -
                if ( 
     | 
| 
       220 
     | 
    
         
            -
                  if ( 
     | 
| 
       221 
     | 
    
         
            -
                    if ( 
     | 
| 
       222 
     | 
    
         
            -
                      geom =  
     | 
| 
      
 217 
     | 
    
         
            +
                if (GEOSCoordSeq_setX(coord_seq, 0, x)) {
         
     | 
| 
      
 218 
     | 
    
         
            +
                  if (GEOSCoordSeq_setY(coord_seq, 0, y)) {
         
     | 
| 
      
 219 
     | 
    
         
            +
                    if (GEOSCoordSeq_setZ(coord_seq, 0, z)) {
         
     | 
| 
      
 220 
     | 
    
         
            +
                      geom = GEOSGeom_createPoint(coord_seq);
         
     | 
| 
       223 
221 
     | 
    
         
             
                      if (geom) {
         
     | 
| 
       224 
     | 
    
         
            -
                        result = 
     | 
| 
      
 222 
     | 
    
         
            +
                        result =
         
     | 
| 
      
 223 
     | 
    
         
            +
                          rgeo_wrap_geos_geometry(factory, geom, rgeo_geos_point_class);
         
     | 
| 
       225 
224 
     | 
    
         
             
                      }
         
     | 
| 
       226 
225 
     | 
    
         
             
                    }
         
     | 
| 
       227 
226 
     | 
    
         
             
                  }
         
     | 
| 
         @@ -230,7 +229,6 @@ VALUE rgeo_create_geos_point(VALUE factory, double x, double y, double z) 
     | 
|
| 
       230 
229 
     | 
    
         
             
              return result;
         
     | 
| 
       231 
230 
     | 
    
         
             
            }
         
     | 
| 
       232 
231 
     | 
    
         | 
| 
       233 
     | 
    
         
            -
             
     | 
| 
       234 
232 
     | 
    
         
             
            RGEO_END_C
         
     | 
| 
       235 
233 
     | 
    
         | 
| 
       236 
234 
     | 
    
         
             
            #endif
         
     | 
    
        data/ext/geos_c_impl/point.h
    CHANGED
    
    | 
         @@ -2,28 +2,25 @@ 
     | 
|
| 
       2 
2 
     | 
    
         
             
              Point methods for GEOS wrapper
         
     | 
| 
       3 
3 
     | 
    
         
             
            */
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
5 
     | 
    
         
             
            #ifndef RGEO_GEOS_POINT_INCLUDED
         
     | 
| 
       7 
6 
     | 
    
         
             
            #define RGEO_GEOS_POINT_INCLUDED
         
     | 
| 
       8 
7 
     | 
    
         | 
| 
       9 
8 
     | 
    
         
             
            #include <ruby.h>
         
     | 
| 
       10 
9 
     | 
    
         | 
| 
       11 
     | 
    
         
            -
            #include "factory.h"
         
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
10 
     | 
    
         
             
            RGEO_BEGIN_C
         
     | 
| 
       14 
11 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
12 
     | 
    
         
             
            /*
         
     | 
| 
       17 
13 
     | 
    
         
             
              Initializes the point module. This should be called after
         
     | 
| 
       18 
14 
     | 
    
         
             
              the geometry module is initialized.
         
     | 
| 
       19 
15 
     | 
    
         
             
            */
         
     | 
| 
       20 
     | 
    
         
            -
            void 
     | 
| 
      
 16 
     | 
    
         
            +
            void
         
     | 
| 
      
 17 
     | 
    
         
            +
            rgeo_init_geos_point();
         
     | 
| 
       21 
18 
     | 
    
         | 
| 
       22 
19 
     | 
    
         
             
            /*
         
     | 
| 
       23 
20 
     | 
    
         
             
              Creates a 3d point and returns the ruby object.
         
     | 
| 
       24 
21 
     | 
    
         
             
            */
         
     | 
| 
       25 
     | 
    
         
            -
            VALUE 
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
      
 22 
     | 
    
         
            +
            VALUE
         
     | 
| 
      
 23 
     | 
    
         
            +
            rgeo_create_geos_point(VALUE factory, double x, double y, double z);
         
     | 
| 
       27 
24 
     | 
    
         | 
| 
       28 
25 
     | 
    
         
             
            RGEO_END_C
         
     | 
| 
       29 
26 
     | 
    
         |