rgeo 1.1.2 → 2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +144 -0
- data/ext/geos_c_impl/analysis.c +78 -0
- data/ext/geos_c_impl/analysis.h +42 -0
- data/ext/geos_c_impl/errors.c +35 -0
- data/ext/geos_c_impl/errors.h +22 -0
- data/ext/geos_c_impl/extconf.rb +6 -3
- data/ext/geos_c_impl/factory.c +14 -5
- data/ext/geos_c_impl/factory.h +5 -1
- data/ext/geos_c_impl/geometry.c +20 -2
- data/ext/geos_c_impl/geometry_collection.c +0 -17
- data/ext/geos_c_impl/main.c +5 -2
- data/ext/geos_c_impl/preface.h +3 -0
- data/lib/rgeo.rb +11 -13
- data/lib/rgeo/cartesian.rb +13 -23
- data/lib/rgeo/cartesian/analysis.rb +44 -20
- data/lib/rgeo/cartesian/bounding_box.rb +83 -79
- data/lib/rgeo/cartesian/calculations.rb +40 -38
- data/lib/rgeo/cartesian/factory.rb +134 -169
- data/lib/rgeo/cartesian/feature_classes.rb +2 -18
- data/lib/rgeo/cartesian/feature_methods.rb +37 -39
- data/lib/rgeo/cartesian/interface.rb +11 -9
- data/lib/rgeo/coord_sys.rb +9 -8
- data/lib/rgeo/coord_sys/cs/entities.rb +345 -303
- data/lib/rgeo/coord_sys/cs/factories.rb +30 -28
- data/lib/rgeo/coord_sys/cs/wkt_parser.rb +128 -126
- data/lib/rgeo/coord_sys/srs_database/{interface.rb → entry.rb} +26 -32
- data/lib/rgeo/coord_sys/srs_database/sr_org.rb +19 -17
- data/lib/rgeo/coord_sys/srs_database/url_reader.rb +21 -19
- data/lib/rgeo/error.rb +7 -1
- data/lib/rgeo/feature.rb +40 -51
- data/lib/rgeo/feature/curve.rb +2 -0
- data/lib/rgeo/feature/factory.rb +15 -13
- data/lib/rgeo/feature/factory_generator.rb +7 -5
- data/lib/rgeo/feature/geometry.rb +31 -29
- data/lib/rgeo/feature/geometry_collection.rb +6 -4
- data/lib/rgeo/feature/line.rb +2 -0
- data/lib/rgeo/feature/line_string.rb +3 -1
- data/lib/rgeo/feature/linear_ring.rb +12 -0
- data/lib/rgeo/feature/multi_curve.rb +2 -0
- data/lib/rgeo/feature/multi_line_string.rb +2 -0
- data/lib/rgeo/feature/multi_point.rb +2 -0
- data/lib/rgeo/feature/multi_polygon.rb +2 -0
- data/lib/rgeo/feature/multi_surface.rb +2 -0
- data/lib/rgeo/feature/point.rb +2 -0
- data/lib/rgeo/feature/polygon.rb +3 -1
- data/lib/rgeo/feature/surface.rb +2 -0
- data/lib/rgeo/feature/types.rb +107 -103
- data/lib/rgeo/geographic.rb +27 -37
- data/lib/rgeo/geographic/factory.rb +154 -199
- data/lib/rgeo/geographic/interface.rb +141 -137
- data/lib/rgeo/geographic/proj4_projector.rb +28 -23
- data/lib/rgeo/geographic/projected_feature_classes.rb +2 -18
- data/lib/rgeo/geographic/projected_feature_methods.rb +64 -54
- data/lib/rgeo/geographic/projected_window.rb +4 -2
- data/lib/rgeo/geographic/simple_mercator_projector.rb +41 -39
- data/lib/rgeo/geographic/spherical_feature_classes.rb +3 -18
- data/lib/rgeo/geographic/spherical_feature_methods.rb +90 -67
- data/lib/rgeo/geographic/spherical_math.rb +81 -87
- data/lib/rgeo/geos.rb +40 -53
- data/lib/rgeo/geos/capi_factory.rb +111 -136
- data/lib/rgeo/geos/capi_feature_classes.rb +22 -36
- data/lib/rgeo/geos/ffi_factory.rb +276 -297
- data/lib/rgeo/geos/ffi_feature_classes.rb +2 -20
- data/lib/rgeo/geos/ffi_feature_methods.rb +177 -169
- data/lib/rgeo/geos/interface.rb +25 -23
- data/lib/rgeo/geos/utils.rb +47 -39
- data/lib/rgeo/geos/zm_factory.rb +171 -185
- data/lib/rgeo/geos/zm_feature_classes.rb +2 -20
- data/lib/rgeo/geos/zm_feature_methods.rb +76 -72
- data/lib/rgeo/impl_helper.rb +8 -18
- data/lib/rgeo/impl_helper/basic_geometry_collection_methods.rb +84 -75
- data/lib/rgeo/impl_helper/basic_geometry_methods.rb +21 -23
- data/lib/rgeo/impl_helper/basic_line_string_methods.rb +95 -48
- data/lib/rgeo/impl_helper/basic_point_methods.rb +29 -25
- data/lib/rgeo/impl_helper/basic_polygon_methods.rb +68 -27
- data/lib/rgeo/impl_helper/math.rb +2 -0
- data/lib/rgeo/impl_helper/utils.rb +9 -15
- data/lib/rgeo/version.rb +3 -1
- data/lib/rgeo/wkrep.rb +24 -34
- data/lib/rgeo/wkrep/wkb_generator.rb +87 -84
- data/lib/rgeo/wkrep/wkb_parser.rb +93 -93
- data/lib/rgeo/wkrep/wkt_generator.rb +67 -63
- data/lib/rgeo/wkrep/wkt_parser.rb +172 -168
- metadata +30 -36
- data/lib/rgeo/feature/mixins.rb +0 -143
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f0ded4953c3ad02eb5512ae8a9e8dd204e2008360678807a4ecea567c39533c
|
4
|
+
data.tar.gz: 577998a9cc566eba2146fb5a5e02e26db330e38f2b8518551b50c86fa8a7a027
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01f855c7553814054b662dbc9e84629f878ee71f642901cfb32f09386737cba9e0a86a2e91cbbe660515095d24cb09fb45d4b0ed680eac2f8194e0399eafe7c7
|
7
|
+
data.tar.gz: 810f5ef0b1b0f7c20d1a2b8845cdd443b9646aa564965d98d2b0d9b4bb25211e810cc73b780ff14e405dd824f5d7305a8a473a952e89e0f397406672f8fceab1
|
data/README.md
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
## RGeo
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/rgeo.svg)](http://badge.fury.io/rb/rgeo)
|
4
|
+
[![Build Status](https://travis-ci.org/rgeo/rgeo.svg?branch=master)](https://travis-ci.org/rgeo/rgeo)
|
5
|
+
|
6
|
+
RGeo is a geospatial data library for Ruby.
|
7
|
+
|
8
|
+
:warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning:
|
9
|
+
|
10
|
+
This organization is looking for maintainers, see [this issue](https://github.com/rgeo/rgeo/issues/216) for more information.
|
11
|
+
|
12
|
+
:warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning::warning:
|
13
|
+
|
14
|
+
### Summary
|
15
|
+
|
16
|
+
RGeo is a key component for writing location-aware applications in the Ruby
|
17
|
+
programming language. At its core is an implementation of the industry
|
18
|
+
standard OGC Simple Features Specification, which provides data
|
19
|
+
representations of geometric objects such as points, lines, and polygons,
|
20
|
+
along with a set of geometric analysis operations. This makes it ideal for
|
21
|
+
modeling geolocation data. It also supports a suite of optional add-on modules
|
22
|
+
that provide various geolocation-related services.
|
23
|
+
|
24
|
+
Use the core **rgeo** gem to:
|
25
|
+
|
26
|
+
* Represent spatial and geolocation data objects such as points, lines, and
|
27
|
+
polygons in your Ruby application.
|
28
|
+
* Perform standard spatial analysis operations such as finding
|
29
|
+
intersections, creating buffers, and computing lengths and areas.
|
30
|
+
* Correctly handle spherical geometry, and compute geographic projections
|
31
|
+
for map display and data analysis.
|
32
|
+
* Read and write location data in the WKT and WKB representations used by
|
33
|
+
spatial databases.
|
34
|
+
|
35
|
+
|
36
|
+
### Dependencies
|
37
|
+
|
38
|
+
RGeo works with the following Ruby implementations:
|
39
|
+
|
40
|
+
* MRI Ruby 2.3.0 or later.
|
41
|
+
* Partial support for JRuby 9.0 or later. The FFI implementation of GEOS
|
42
|
+
is available (ffi-geos gem required) but CAPI is not.
|
43
|
+
* See earlier versions for support for older ruby versions.
|
44
|
+
|
45
|
+
Some features also require the following:
|
46
|
+
|
47
|
+
* GEOS 3.2 or later is highly recommended. (3.3.3 or later preferred.) Some
|
48
|
+
functions will not be available without it. This C/C++ library may be
|
49
|
+
available via your operating system's package manager (`sudo aptitude
|
50
|
+
install libgeos-dev` for debian based Linux distributions, `yum install geos geos-devel` for redhat based Linux distributions), or you can
|
51
|
+
download it from http://trac.osgeo.org/geos
|
52
|
+
* On some platforms, you should install the ffi-geos gem (version 1.2.0 or
|
53
|
+
later recommended.) JRuby requires this gem to link properly with Geos,
|
54
|
+
and Windows builds probably do as well.
|
55
|
+
|
56
|
+
### Installation
|
57
|
+
|
58
|
+
Install the RGeo gem:
|
59
|
+
|
60
|
+
```sh
|
61
|
+
gem install rgeo
|
62
|
+
```
|
63
|
+
|
64
|
+
or include it in your Gemfile:
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
gem "rgeo"
|
68
|
+
```
|
69
|
+
|
70
|
+
If you are using proj.4 extensions, include
|
71
|
+
[`rgeo-proj4`](https://github.com/rgeo/rgeo-proj4):
|
72
|
+
|
73
|
+
```ruby
|
74
|
+
gem "rgeo-proj4"
|
75
|
+
```
|
76
|
+
|
77
|
+
|
78
|
+
### Extensions
|
79
|
+
|
80
|
+
The [RGeo organization](https://github.com/rgeo) provides several gems that extend RGeo:
|
81
|
+
|
82
|
+
#### [`rgeo-proj4`](https://github.com/rgeo/rgeo-proj4)
|
83
|
+
|
84
|
+
Proj4 extensions
|
85
|
+
|
86
|
+
#### [`rgeo-geojson`](https://github.com/rgeo/rgeo-geojson)
|
87
|
+
|
88
|
+
Read and write GeoJSON
|
89
|
+
|
90
|
+
#### [`rgeo-shapefile`](https://github.com/rgeo/rgeo-shapefile)
|
91
|
+
|
92
|
+
Read ESRI shapefiles
|
93
|
+
|
94
|
+
#### [`activerecord-postgis-adapter`](https://github.com/rgeo/activerecord-postgis-adapter)
|
95
|
+
|
96
|
+
ActiveRecord connection adapter for PostGIS, based on postgresql (pg gem)
|
97
|
+
|
98
|
+
#### [`activerecord-mysql2spatial-adapter`](https://github.com/rgeo/activerecord-mysql2spatial-adapter)
|
99
|
+
|
100
|
+
ActiveRecord connection adapter for MySQL Spatial Extensions, based on mysql2
|
101
|
+
|
102
|
+
#### [`activerecord-spatialite-adapter`](https://github.com/rgeo/activerecord-spatialite-adapter)
|
103
|
+
|
104
|
+
ActiveRecord connection adapter for SpatiaLite, based on sqlite3 (*not maintained)
|
105
|
+
|
106
|
+
|
107
|
+
### Development and support
|
108
|
+
|
109
|
+
RDoc Documentation is available at https://www.rubydoc.info/gems/rgeo
|
110
|
+
|
111
|
+
Contributions are welcome. Please read the
|
112
|
+
[Contributing guidelines](https://github.com/rgeo/rgeo/blob/master/CONTRIBUTING.md).
|
113
|
+
|
114
|
+
Support may be available on the
|
115
|
+
[rgeo-users google group](https://groups.google.com/forum/#!forum/rgeo-users)
|
116
|
+
or on [Stack Overflow](https://stackoverflow.com/questions/tagged/rgeo).
|
117
|
+
|
118
|
+
|
119
|
+
### Acknowledgments
|
120
|
+
|
121
|
+
RGeo was created by [Daniel Azuma](http://www.daniel-azuma.com).
|
122
|
+
[Tee Parham](https://github.com/teeparham) is the current maintainer.
|
123
|
+
|
124
|
+
Thanks to [Pirq](http://www.pirq.com) and [Neighborland](https://neighborland.com)
|
125
|
+
for development support.
|
126
|
+
|
127
|
+
Thanks to [Travis-CI](https://travis-ci.org) for CI testing.
|
128
|
+
|
129
|
+
Thanks to [JetBrains](https://www.jetbrains.com/?from=rgeo) for RubyMine license.
|
130
|
+
|
131
|
+
RGeo calls the GEOS library to handle most Cartesian geometric calculations,
|
132
|
+
and the Proj4 library to handle projections and coordinate transformations.
|
133
|
+
These libraries are maintained by the Open Source Geospatial Foundation; more
|
134
|
+
information is available on [OSGeo's web site](http://www.osgeo.org).
|
135
|
+
|
136
|
+
JRuby support is made possible by the ffi-geos (and upcoming ffi-proj4) gems,
|
137
|
+
by [J Smith](https://github.com/dark-panda).
|
138
|
+
|
139
|
+
|
140
|
+
### License
|
141
|
+
|
142
|
+
Copyright (c) Daniel Azuma, Tee Parham
|
143
|
+
|
144
|
+
[License](https://github.com/rgeo/rgeo/blob/master/LICENSE.txt)
|
@@ -0,0 +1,78 @@
|
|
1
|
+
/*
|
2
|
+
Analysis methos for GEOS wrapper
|
3
|
+
*/
|
4
|
+
|
5
|
+
#include "preface.h"
|
6
|
+
|
7
|
+
#ifdef RGEO_GEOS_SUPPORTED
|
8
|
+
|
9
|
+
#include <ruby.h>
|
10
|
+
#include <geos_c.h>
|
11
|
+
|
12
|
+
#include "analysis.h"
|
13
|
+
#include "factory.h"
|
14
|
+
#include "errors.h"
|
15
|
+
|
16
|
+
RGEO_BEGIN_C
|
17
|
+
|
18
|
+
/*
|
19
|
+
* call-seq:
|
20
|
+
* RGeo::Geos::Analysis.ccw? -> true or false
|
21
|
+
*
|
22
|
+
* Checks direction for a ring, returns +true+ if counter-clockwise, +false+
|
23
|
+
* otherwise.
|
24
|
+
*/
|
25
|
+
#ifdef RGEO_GEOS_SUPPORTS_ISCCW
|
26
|
+
VALUE rgeo_geos_analysis_ccw_p(VALUE self, VALUE ring)
|
27
|
+
{
|
28
|
+
|
29
|
+
const RGeo_GeometryData* ring_data;
|
30
|
+
const GEOSCoordSequence* coord_seq;
|
31
|
+
char is_ccw;
|
32
|
+
|
33
|
+
rgeo_check_geos_object(ring);
|
34
|
+
|
35
|
+
ring_data = RGEO_GEOMETRY_DATA_PTR(ring);
|
36
|
+
|
37
|
+
coord_seq = GEOSGeom_getCoordSeq_r(ring_data->geos_context, ring_data->geom);
|
38
|
+
if (!coord_seq) { rb_raise(geos_error, "Could not retrieve CoordSeq from given ring."); }
|
39
|
+
if (!GEOSCoordSeq_isCCW_r(ring_data->geos_context, coord_seq, &is_ccw)) {
|
40
|
+
rb_raise(geos_error, "Could not determine if the CoordSeq is CCW.");
|
41
|
+
}
|
42
|
+
|
43
|
+
return is_ccw ? Qtrue : Qfalse;
|
44
|
+
};
|
45
|
+
#endif // RGEO_GEOS_SUPPORTS_ISCCW
|
46
|
+
|
47
|
+
|
48
|
+
/**
|
49
|
+
* call-seq:
|
50
|
+
* RGeo::Geos::Analysis.ccw_supported? -> true or false
|
51
|
+
*
|
52
|
+
* Checks if the RGEO_GEOS_SUPPORTS_ISCCW macro is defined, returns +true+
|
53
|
+
* if it is, +false+ otherwise
|
54
|
+
*/
|
55
|
+
VALUE rgeo_geos_analysis_supports_ccw(VALUE self)
|
56
|
+
{
|
57
|
+
#ifdef RGEO_GEOS_SUPPORTS_ISCCW
|
58
|
+
return Qtrue;
|
59
|
+
#else
|
60
|
+
return Qfalse;
|
61
|
+
#endif
|
62
|
+
}
|
63
|
+
|
64
|
+
|
65
|
+
void rgeo_init_geos_analysis(RGeo_Globals* globals)
|
66
|
+
{
|
67
|
+
VALUE geos_analysis_module;
|
68
|
+
|
69
|
+
geos_analysis_module = rb_define_module_under(globals->geos_module, "Analysis");
|
70
|
+
rb_define_singleton_method(geos_analysis_module, "ccw_supported?", rgeo_geos_analysis_supports_ccw, 0);
|
71
|
+
#ifdef RGEO_GEOS_SUPPORTS_ISCCW
|
72
|
+
rb_define_singleton_method(geos_analysis_module, "ccw?", rgeo_geos_analysis_ccw_p, 1);
|
73
|
+
#endif // RGEO_GEOS_SUPPORTS_ISCCW
|
74
|
+
}
|
75
|
+
|
76
|
+
RGEO_END_C
|
77
|
+
|
78
|
+
#endif
|
@@ -0,0 +1,42 @@
|
|
1
|
+
/*
|
2
|
+
Analysis methos for GEOS wrapper
|
3
|
+
*/
|
4
|
+
|
5
|
+
#ifndef RGEO_GEOS_ANALYSIS_INCLUDED
|
6
|
+
#define RGEO_GEOS_ANALYSIS_INCLUDED
|
7
|
+
|
8
|
+
#include <ruby.h>
|
9
|
+
|
10
|
+
#ifdef RGEO_GEOS_SUPPORTED
|
11
|
+
|
12
|
+
#include "factory.h"
|
13
|
+
|
14
|
+
RGEO_BEGIN_C
|
15
|
+
|
16
|
+
/*
|
17
|
+
* call-seq:
|
18
|
+
* RGeo::Geos::Analysis.ccw? -> true or false
|
19
|
+
*
|
20
|
+
* Checks direction for a ring, returns +true+ if counter-clockwise, +false+
|
21
|
+
* otherwise.
|
22
|
+
*/
|
23
|
+
#ifdef RGEO_GEOS_SUPPORTS_CCW
|
24
|
+
VALUE rgeo_geos_analysis_ccw_p(VALUE self, VALUE ring);
|
25
|
+
#endif // RGEO_GEOS_SUPPORTS_CCW
|
26
|
+
|
27
|
+
/**
|
28
|
+
* call-seq:
|
29
|
+
* RGeo::Geos::Analysis.ccw_supported? -> true or false
|
30
|
+
*
|
31
|
+
* Checks if the RGEO_GEOS_SUPPORTS_ISCCW macro is defined, returns +true+
|
32
|
+
* if it is, +false+ otherwise
|
33
|
+
*/
|
34
|
+
VALUE rgeo_geos_analysis_supports_ccw(VALUE self);
|
35
|
+
|
36
|
+
void rgeo_init_geos_analysis(RGeo_Globals* globals);
|
37
|
+
|
38
|
+
RGEO_END_C
|
39
|
+
|
40
|
+
#endif // RGEO_GEOS_SUPPORTED
|
41
|
+
|
42
|
+
#endif // RGEO_GEOS_ANALYSIS_INCLUDED
|
@@ -0,0 +1,35 @@
|
|
1
|
+
|
2
|
+
#ifndef RGEO_GEOS_ERROS_INCLUDED
|
3
|
+
#define RGEO_GEOS_ERROS_INCLUDED
|
4
|
+
|
5
|
+
#include <ruby.h>
|
6
|
+
|
7
|
+
#include "preface.h"
|
8
|
+
|
9
|
+
#ifdef RGEO_GEOS_SUPPORTED
|
10
|
+
|
11
|
+
#include "errors.h"
|
12
|
+
|
13
|
+
RGEO_BEGIN_C
|
14
|
+
|
15
|
+
// Any error relative to RGeo.
|
16
|
+
VALUE rgeo_error;
|
17
|
+
// RGeo error specific to the GEOS implementation.
|
18
|
+
VALUE geos_error;
|
19
|
+
|
20
|
+
|
21
|
+
void rgeo_init_geos_errors() {
|
22
|
+
VALUE rgeo_module;
|
23
|
+
VALUE error_module;
|
24
|
+
|
25
|
+
rgeo_module = rb_define_module("RGeo");
|
26
|
+
error_module = rb_define_module_under(rgeo_module, "Error");
|
27
|
+
rgeo_error = rb_define_class_under(error_module, "RGeoError", rb_eRuntimeError);
|
28
|
+
geos_error = rb_define_class_under(error_module, "GeosError", rgeo_error);
|
29
|
+
}
|
30
|
+
|
31
|
+
RGEO_END_C
|
32
|
+
|
33
|
+
#endif // RGEO_GEOS_SUPPORTED
|
34
|
+
|
35
|
+
#endif // RGEO_GEOS_ERROS_INCLUDED
|
@@ -0,0 +1,22 @@
|
|
1
|
+
|
2
|
+
#ifndef RGEO_GEOS_ERROS_INCLUDED
|
3
|
+
#define RGEO_GEOS_ERROS_INCLUDED
|
4
|
+
|
5
|
+
#include <ruby.h>
|
6
|
+
|
7
|
+
#ifdef RGEO_GEOS_SUPPORTED
|
8
|
+
|
9
|
+
RGEO_BEGIN_C
|
10
|
+
|
11
|
+
// Any error relative to RGeo.
|
12
|
+
extern VALUE rgeo_error;
|
13
|
+
// RGeo error specific to the GEOS implementation.
|
14
|
+
extern VALUE geos_error;
|
15
|
+
|
16
|
+
void rgeo_init_geos_errors();
|
17
|
+
|
18
|
+
RGEO_END_C
|
19
|
+
|
20
|
+
#endif // RGEO_GEOS_SUPPORTED
|
21
|
+
|
22
|
+
#endif // RGEO_GEOS_ERROS_INCLUDED
|
data/ext/geos_c_impl/extconf.rb
CHANGED
@@ -1,13 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
# -----------------------------------------------------------------------------
|
2
4
|
#
|
3
5
|
# Makefile builder for GEOS wrapper
|
4
6
|
#
|
5
7
|
# -----------------------------------------------------------------------------
|
6
8
|
def create_dummy_makefile
|
7
|
-
|
9
|
+
File.open("Makefile", "w") { |f_| f_.write(".PHONY: install\ninstall:\n") }
|
8
10
|
end
|
9
11
|
|
10
|
-
if
|
12
|
+
if RUBY_DESCRIPTION =~ /^jruby\s/
|
11
13
|
create_dummy_makefile
|
12
14
|
else
|
13
15
|
require "mkmf"
|
@@ -15,7 +17,7 @@ else
|
|
15
17
|
geosconfig = with_config("geos-config") || find_executable("geos-config")
|
16
18
|
|
17
19
|
if geosconfig
|
18
|
-
puts "Using GEOS compile configuration from
|
20
|
+
puts "Using GEOS compile configuration from #{geosconfig}"
|
19
21
|
$INCFLAGS << " " << `#{geosconfig} --cflags`.strip
|
20
22
|
geos_libs = `#{geosconfig} --clibs`.tr("\n", " ")
|
21
23
|
geos_libs.split(/\s+/).each do |flag|
|
@@ -29,6 +31,7 @@ else
|
|
29
31
|
have_func("GEOSPreparedContains_r", "geos_c.h")
|
30
32
|
have_func("GEOSPreparedDisjoint_r", "geos_c.h")
|
31
33
|
have_func("GEOSUnaryUnion_r", "geos_c.h")
|
34
|
+
have_func("GEOSCoordSeq_isCCW_r", "geos_c.h")
|
32
35
|
have_func("rb_memhash", "ruby.h")
|
33
36
|
end
|
34
37
|
|
data/ext/geos_c_impl/factory.c
CHANGED
@@ -16,6 +16,7 @@
|
|
16
16
|
#include "line_string.h"
|
17
17
|
#include "polygon.h"
|
18
18
|
#include "geometry_collection.h"
|
19
|
+
#include "errors.h"
|
19
20
|
|
20
21
|
RGEO_BEGIN_C
|
21
22
|
|
@@ -576,10 +577,11 @@ RGeo_Globals* rgeo_init_geos_factory()
|
|
576
577
|
VALUE wrapped_globals;
|
577
578
|
VALUE feature_module;
|
578
579
|
|
580
|
+
rgeo_module = rb_define_module("RGeo");
|
581
|
+
|
579
582
|
globals = ALLOC(RGeo_Globals);
|
580
583
|
|
581
584
|
// Cache some modules so we don't have to look them up by name every time
|
582
|
-
rgeo_module = rb_define_module("RGeo");
|
583
585
|
feature_module = rb_define_module_under(rgeo_module, "Feature");
|
584
586
|
globals->feature_module = feature_module;
|
585
587
|
globals->geos_module = rb_define_module_under(rgeo_module, "Geos");
|
@@ -623,10 +625,10 @@ RGeo_Globals* rgeo_init_geos_factory()
|
|
623
625
|
rb_define_method(geos_factory_class, "_wkb_generator", method_get_wkb_generator, 0);
|
624
626
|
rb_define_method(geos_factory_class, "_wkt_parser", method_get_wkt_parser, 0);
|
625
627
|
rb_define_method(geos_factory_class, "_wkb_parser", method_get_wkb_parser, 0);
|
626
|
-
rb_define_method(geos_factory_class, "
|
627
|
-
rb_define_method(geos_factory_class, "
|
628
|
-
rb_define_method(geos_factory_class, "
|
629
|
-
rb_define_method(geos_factory_class, "
|
628
|
+
rb_define_method(geos_factory_class, "read_for_marshal", method_factory_read_for_marshal, 1);
|
629
|
+
rb_define_method(geos_factory_class, "write_for_marshal", method_factory_write_for_marshal, 1);
|
630
|
+
rb_define_method(geos_factory_class, "read_for_psych", method_factory_read_for_psych, 1);
|
631
|
+
rb_define_method(geos_factory_class, "write_for_psych", method_factory_write_for_psych, 1);
|
630
632
|
rb_define_module_function(geos_factory_class, "_create", cmethod_factory_create, 7);
|
631
633
|
rb_define_module_function(geos_factory_class, "_geos_version", cmethod_factory_geos_version, 0);
|
632
634
|
rb_define_module_function(geos_factory_class, "_supports_unary_union?", cmethod_factory_supports_unary_union, 0);
|
@@ -831,6 +833,13 @@ char rgeo_is_geos_object(VALUE obj)
|
|
831
833
|
return (TYPE(obj) == T_DATA && RDATA(obj)->dfree == (RUBY_DATA_FUNC)destroy_geometry_func) ? 1 : 0;
|
832
834
|
}
|
833
835
|
|
836
|
+
void rgeo_check_geos_object(VALUE obj)
|
837
|
+
{
|
838
|
+
if (!rgeo_is_geos_object(obj)) {
|
839
|
+
rb_raise(rgeo_error, "Not a GEOS Geometry object.");
|
840
|
+
}
|
841
|
+
}
|
842
|
+
|
834
843
|
|
835
844
|
const GEOSGeometry* rgeo_get_geos_geometry_safe(VALUE obj)
|
836
845
|
{
|
data/ext/geos_c_impl/factory.h
CHANGED
@@ -10,7 +10,6 @@
|
|
10
10
|
|
11
11
|
RGEO_BEGIN_C
|
12
12
|
|
13
|
-
|
14
13
|
/*
|
15
14
|
Per-interpreter globals.
|
16
15
|
Most of these are cached references to commonly used classes, modules,
|
@@ -187,6 +186,11 @@ GEOSGeometry* rgeo_convert_to_detached_geos_geometry(VALUE obj, VALUE factory, V
|
|
187
186
|
*/
|
188
187
|
char rgeo_is_geos_object(VALUE obj);
|
189
188
|
|
189
|
+
/*
|
190
|
+
Raises a rgeo error if the object is not a GEOS Geometry implementation.
|
191
|
+
*/
|
192
|
+
void rgeo_check_geos_object(VALUE obj);
|
193
|
+
|
190
194
|
/*
|
191
195
|
Gets the underlying GEOS geometry for a given ruby object. Returns NULL
|
192
196
|
if the given ruby object is not a GEOS geometry wrapper.
|
data/ext/geos_c_impl/geometry.c
CHANGED
@@ -756,7 +756,9 @@ static VALUE method_geometry_buffer_with_style(VALUE self, VALUE distance, VALUE
|
|
756
756
|
GEOSBufferWithStyle_r(self_data->geos_context, self_geom,
|
757
757
|
rb_num2dbl(distance),
|
758
758
|
RGEO_FACTORY_DATA_PTR(factory)->buffer_resolution,
|
759
|
-
endCapStyle
|
759
|
+
rb_num2int(endCapStyle),
|
760
|
+
rb_num2int(joinStyle),
|
761
|
+
rb_num2dbl(mitreLimit)),
|
760
762
|
Qnil);
|
761
763
|
}
|
762
764
|
return result;
|
@@ -1053,6 +1055,21 @@ static VALUE method_geometry_invalid_reason(VALUE self)
|
|
1053
1055
|
return result;
|
1054
1056
|
}
|
1055
1057
|
|
1058
|
+
static VALUE method_geometry_point_on_surface(VALUE self)
|
1059
|
+
{
|
1060
|
+
VALUE result;
|
1061
|
+
RGeo_GeometryData* self_data;
|
1062
|
+
const GEOSGeometry* self_geom;
|
1063
|
+
|
1064
|
+
result = Qnil;
|
1065
|
+
self_data = RGEO_GEOMETRY_DATA_PTR(self);
|
1066
|
+
self_geom = self_data->geom;
|
1067
|
+
if (self_geom) {
|
1068
|
+
result = rgeo_wrap_geos_geometry(self_data->factory, GEOSPointOnSurface_r(self_data->geos_context, self_geom), Qnil);
|
1069
|
+
}
|
1070
|
+
return result;
|
1071
|
+
}
|
1072
|
+
|
1056
1073
|
|
1057
1074
|
/**** INITIALIZATION FUNCTION ****/
|
1058
1075
|
|
@@ -1063,7 +1080,7 @@ void rgeo_init_geos_geometry(RGeo_Globals* globals)
|
|
1063
1080
|
|
1064
1081
|
geos_geometry_methods = rb_define_module_under(globals->geos_module, "CAPIGeometryMethods");
|
1065
1082
|
|
1066
|
-
rb_define_method(geos_geometry_methods, "
|
1083
|
+
rb_define_method(geos_geometry_methods, "factory=", method_geometry_set_factory, 1);
|
1067
1084
|
rb_define_method(geos_geometry_methods, "initialize_copy", method_geometry_initialize_copy, 1);
|
1068
1085
|
rb_define_method(geos_geometry_methods, "_steal", method_geometry_steal, 1);
|
1069
1086
|
rb_define_method(geos_geometry_methods, "initialized?", method_geometry_initialized_p, 0);
|
@@ -1107,6 +1124,7 @@ void rgeo_init_geos_geometry(RGeo_Globals* globals)
|
|
1107
1124
|
rb_define_method(geos_geometry_methods, "sym_difference", method_geometry_sym_difference, 1);
|
1108
1125
|
rb_define_method(geos_geometry_methods, "valid?", method_geometry_is_valid, 0);
|
1109
1126
|
rb_define_method(geos_geometry_methods, "invalid_reason", method_geometry_invalid_reason, 0);
|
1127
|
+
rb_define_method(geos_geometry_methods, "point_on_surface", method_geometry_point_on_surface, 0);
|
1110
1128
|
}
|
1111
1129
|
|
1112
1130
|
|