rgeo 0.1.18 → 0.1.19
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.
- data/History.rdoc +11 -0
- data/README.rdoc +17 -30
- data/Version +1 -1
- data/ext/geos_c_impl/factory.c +4 -9
- data/ext/geos_c_impl/factory.h +8 -8
- data/ext/geos_c_impl/geometry.c +19 -2
- data/ext/geos_c_impl/geometry_collection.c +1 -1
- data/ext/geos_c_impl/polygon.c +2 -2
- data/lib/active_record/connection_adapters/mysql2spatial_adapter.rb +8 -6
- data/lib/active_record/connection_adapters/mysqlspatial_adapter.rb +8 -6
- data/lib/rgeo/active_record/arel_modifications.rb +4 -0
- data/lib/rgeo/active_record/base_modifications.rb +37 -2
- data/lib/rgeo/active_record/mysql_common.rb +2 -2
- data/lib/rgeo/cartesian.rb +6 -22
- data/lib/rgeo/cartesian/analysis.rb +3 -0
- data/lib/rgeo/cartesian/bounding_box.rb +337 -0
- data/lib/rgeo/cartesian/feature_classes.rb +11 -11
- data/lib/rgeo/cartesian/feature_methods.rb +5 -0
- data/lib/rgeo/cartesian/interface.rb +21 -4
- data/lib/rgeo/features/geometry.rb +0 -15
- data/lib/rgeo/geography/interface.rb +33 -6
- data/lib/rgeo/geography/simple_mercator/feature_classes.rb +30 -17
- data/lib/rgeo/geography/simple_mercator/feature_methods.rb +1 -1
- data/lib/rgeo/geography/simple_spherical/feature_classes.rb +38 -11
- data/lib/rgeo/geos.rb +2 -0
- data/lib/rgeo/geos/factory.rb +37 -21
- data/lib/rgeo/geos/impl_additions.rb +20 -0
- data/lib/rgeo/geos/interface.rb +17 -8
- data/lib/rgeo/geos/zm_factory.rb +241 -0
- data/lib/rgeo/geos/zm_impl.rb +432 -0
- data/lib/rgeo/impl_helpers/basic_geometry_collection_methods.rb +39 -0
- data/lib/rgeo/impl_helpers/basic_geometry_methods.rb +0 -5
- data/lib/rgeo/impl_helpers/basic_line_string_methods.rb +10 -1
- data/lib/rgeo/impl_helpers/basic_point_methods.rb +1 -13
- data/lib/rgeo/impl_helpers/basic_polygon_methods.rb +10 -0
- data/tests/common/geometry_collection_tests.rb +16 -0
- data/tests/common/point_tests.rb +27 -1
- data/tests/geos/tc_point.rb +2 -0
- data/tests/geos/tc_zmfactory.rb +85 -0
- data/tests/simple_cartesian/tc_geometry_collection.rb +1 -0
- data/tests/simple_cartesian/tc_point.rb +2 -1
- data/tests/simple_mercator/tc_point.rb +2 -0
- data/tests/simple_spherical/tc_geometry_collection.rb +2 -0
- data/tests/simple_spherical/tc_point.rb +2 -1
- data/tests/tc_oneoff.rb +0 -1
- data/tests/wkrep/tc_wkb_generator.rb +4 -4
- data/tests/wkrep/tc_wkb_parser.rb +2 -2
- data/tests/wkrep/tc_wkt_generator.rb +4 -4
- data/tests/wkrep/tc_wkt_parser.rb +5 -5
- metadata +23 -3
data/History.rdoc
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
=== 0.1.19 / 2010-11-23
|
2
|
+
|
3
|
+
* The GEOS implementation now supports ZM (4-dimensional data), via a wrapper since the underlying GEOS library doesn't support 4d data natively.
|
4
|
+
* Added a BoundingBox tool to the Cartesian module.
|
5
|
+
* Fleshed out a few more methods of SimpleCartesian and SimpleSpherical.
|
6
|
+
* The simple Cartesian point implementation included a bit more leakage from the Geography implementations (pole equivalence, lat/lon methods). Fixed.
|
7
|
+
* Under certain circumstances, collections and polygons using GEOS could lose their Z or M coordinates. Fixed.
|
8
|
+
* There were some cases when implementations based on ImplHelpers were pulling in the wrong methods. Fixed.
|
9
|
+
* Taking the envelope of an empty GEOS collection yielded an illegal object that could cause a crash. Fixed. It now yields an empty collection.
|
10
|
+
* Taking the boundary of an empty GEOS collection yielded nil. Fixed. It now yields an empty collection.
|
11
|
+
|
1
12
|
=== 0.1.18 / 2010-11-22
|
2
13
|
|
3
14
|
* API CHANGE: GeoJSON defaults to no JSON parser rather than to the JSON library. GeoJSON also fails better when attempting to use a JSON parser that isn't installed.
|
data/README.rdoc
CHANGED
@@ -5,7 +5,7 @@ RGeo is a spatial data library for Ruby.
|
|
5
5
|
It provides an implementation of the Open Geospatial Consortium's Simple
|
6
6
|
Features Specification, used by most standard spatial/geographic data
|
7
7
|
storage systems such as PostGIS. It also provides a suite of useful tools
|
8
|
-
for writing location-
|
8
|
+
for writing location-aware applications using Ruby-based frameworks such
|
9
9
|
as Ruby On Rails.
|
10
10
|
|
11
11
|
IMPORTANT: RGeo is currently under development, and we consider it to be
|
@@ -16,10 +16,10 @@ use of RGeo in production.
|
|
16
16
|
|
17
17
|
=== Summary
|
18
18
|
|
19
|
-
RGeo is a core component for writing location-
|
19
|
+
RGeo is a core component for writing location-aware applications in the
|
20
20
|
Ruby programming language. It provides the basic tools for modeling
|
21
|
-
location data and communicating with
|
22
|
-
and
|
21
|
+
location data and communicating with location-aware storage systems
|
22
|
+
and services.
|
23
23
|
|
24
24
|
Use RGeo to:
|
25
25
|
|
@@ -35,8 +35,7 @@ Use RGeo to:
|
|
35
35
|
location-based web services such as SimpleGeo.
|
36
36
|
* Read legacy GIS data from ESRI shapefiles.
|
37
37
|
* Extend Ruby On Rails to handle location data in a web application.
|
38
|
-
*
|
39
|
-
the Open Geospatial Consortium.
|
38
|
+
* Follow the latest standards from the Open Geospatial Consortium.
|
40
39
|
|
41
40
|
=== Requirements
|
42
41
|
|
@@ -44,7 +43,7 @@ RGeo has the following prerequisites:
|
|
44
43
|
|
45
44
|
* Ruby 1.8.7 or later. Ruby 1.9.2 or later preferred.
|
46
45
|
Rubinius and JRuby are not yet supported.
|
47
|
-
* GEOS 3.2 or later highly recommended. Some functions will not be
|
46
|
+
* GEOS 3.2 or later is highly recommended. Some functions will not be
|
48
47
|
available without it. This C/C++ library may be available via your
|
49
48
|
operating system's package manager, or you can download it from
|
50
49
|
http://geos.osgeo.org/
|
@@ -52,7 +51,7 @@ RGeo has the following prerequisites:
|
|
52
51
|
install the "json" gem. Ruby 1.9 has JSON support in its standard
|
53
52
|
library and does not require the gem.
|
54
53
|
* If you are using the shapefile reader, you should install the "dbf"
|
55
|
-
gem
|
54
|
+
gem version 1.5.2 or later, which is required to read the attributes.
|
56
55
|
* The ActiveRecord adapters for MySQL Spatial, PostGIS, and SpatiaLite
|
57
56
|
require ActiveRecord 3.0.3 or later, Arel 2.0 or later, and the
|
58
57
|
corresponding database driver gems (e.g. "mysql" or "mysql2").
|
@@ -78,33 +77,21 @@ the switches interpreted by the gem command. For example:
|
|
78
77
|
|
79
78
|
gem install rgeo -- --with-geos-dir=/path/to/my/geos/installation
|
80
79
|
|
81
|
-
=== Known issues
|
82
|
-
|
83
|
-
* Some planned and documented functionality on the SimpleCartesian and
|
84
|
-
SimpleSpherical data implementations is not yet implemented.
|
85
|
-
* Reading of shapefile attributes is dependent on the "dbf" gem.
|
86
|
-
Unfortunately, the current version of dbf, 1.5.0, has a hard dependency
|
87
|
-
on ActiveSupport 3.0.1, which renders it incompatible with the
|
88
|
-
ActiveRecord adapters, which require at least ActiveRecord 3.0.3
|
89
|
-
(not to mention also rendering it incompatible with Rails 3.0.3...)
|
90
|
-
I have filed a bug report with dbf to try to get this resolved.
|
91
|
-
|
92
80
|
=== To-do items
|
93
81
|
|
94
|
-
This is our
|
82
|
+
This is our planned feature roadmap, in rough priority order.
|
95
83
|
|
84
|
+
* Projection subsystem, and support for arbitrary projections in the
|
85
|
+
geography module, utilizing proj4.
|
96
86
|
* SpatiaLite and PostGIS adapters for ActiveRecord. (We already have an
|
97
87
|
adapter for MySQL Spatial.)
|
88
|
+
* Integration with certain third-party services such as SimpleGeo.
|
98
89
|
* Support for bbox and crs elements of GeoJSON.
|
99
|
-
*
|
100
|
-
* Projection subsystem, and support for arbitrary projections in the
|
101
|
-
geography module, utilizing proj4.
|
102
|
-
* Geography implementation utilizing ellipsoidal geometry, probably
|
103
|
-
utilizing geographiclib.
|
104
|
-
* Integration with other third-party formats and services, potentially
|
105
|
-
including SimpleGeo, GeoRSS, KML.
|
106
|
-
* JRuby support via JTS integration.
|
90
|
+
* Ellipsoidal geography implementation, probably utilizing geographiclib.
|
107
91
|
* Rubinius support for GEOS integration.
|
92
|
+
* JRuby support via JTS integration.
|
93
|
+
* Support for writing shapefiles. (Reading is already implemented.)
|
94
|
+
* Read and write other formats such as GeoRSS and KML.
|
108
95
|
|
109
96
|
=== Development and support
|
110
97
|
|
@@ -128,8 +115,8 @@ projects can be found on OSGeo's web site (http://www.osgeo.org/).
|
|
128
115
|
|
129
116
|
The ActiveRecord adapters owe some debt to the spatial_adapter plugin
|
130
117
|
(http://github.com/fragility/spatial_adapter). We made a few different
|
131
|
-
design decisions for RGeo, but studying the spatial_adapter source gave
|
132
|
-
a head start on our implementation.
|
118
|
+
design decisions for RGeo, but studying the spatial_adapter source gave
|
119
|
+
us a head start on our implementation.
|
133
120
|
|
134
121
|
Although we don't use shapelib (http://shapelib.maptools.org/) to read
|
135
122
|
ESRI shapefiles, we did borrow a bunch of their test cases.
|
data/Version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.19
|
data/ext/geos_c_impl/factory.c
CHANGED
@@ -121,12 +121,11 @@ static void destroy_globals_func(RGeo_Globals* data)
|
|
121
121
|
}
|
122
122
|
|
123
123
|
|
124
|
-
// Mark function for globals data. This
|
125
|
-
//
|
124
|
+
// Mark function for globals data. This should mark any globals that
|
125
|
+
// need to be held through garbage collection (none at the moment.)
|
126
126
|
|
127
127
|
static void mark_globals_func(RGeo_Globals* data)
|
128
128
|
{
|
129
|
-
rb_gc_mark(data->default_factory);
|
130
129
|
}
|
131
130
|
|
132
131
|
|
@@ -225,7 +224,6 @@ RGeo_Globals* rgeo_init_geos_factory()
|
|
225
224
|
VALUE rgeo_module = rb_define_module("RGeo");
|
226
225
|
globals->geos_module = rb_define_module_under(rgeo_module, "Geos");
|
227
226
|
globals->features_module = rb_define_module_under(rgeo_module, "Features");
|
228
|
-
globals->default_factory = Qnil;
|
229
227
|
|
230
228
|
// Add C methods to the factory.
|
231
229
|
VALUE geos_factory_class = rb_const_get_at(globals->geos_module, rb_intern("Factory"));
|
@@ -241,9 +239,6 @@ RGeo_Globals* rgeo_init_geos_factory()
|
|
241
239
|
VALUE wrapped_globals = Data_Wrap_Struct(rb_cObject, mark_globals_func, destroy_globals_func, globals);
|
242
240
|
rb_define_const(geos_factory_class, "INTERNAL_CGLOBALS", wrapped_globals);
|
243
241
|
|
244
|
-
// Default factory used internally.
|
245
|
-
globals->default_factory = rb_funcall(geos_factory_class, rb_intern("create"), 0);
|
246
|
-
|
247
242
|
return globals;
|
248
243
|
}
|
249
244
|
|
@@ -336,12 +331,12 @@ const GEOSGeometry* rgeo_convert_to_geos_geometry(VALUE factory, VALUE obj, VALU
|
|
336
331
|
}
|
337
332
|
|
338
333
|
|
339
|
-
GEOSGeometry* rgeo_convert_to_detached_geos_geometry(
|
334
|
+
GEOSGeometry* rgeo_convert_to_detached_geos_geometry(VALUE obj, VALUE factory, VALUE type, VALUE* klasses)
|
340
335
|
{
|
341
336
|
if (klasses) {
|
342
337
|
*klasses = Qnil;
|
343
338
|
}
|
344
|
-
VALUE object = rb_funcall(
|
339
|
+
VALUE object = rb_funcall(RGEO_GLOBALS_FROM_FACTORY(factory)->features_module, rb_intern("cast"), 5, obj, factory, type, ID2SYM(rb_intern("force_new")), ID2SYM(rb_intern("keep_subtype")));
|
345
340
|
GEOSGeometry* geom = NULL;
|
346
341
|
if (!NIL_P(object)) {
|
347
342
|
geom = RGEO_GEOMETRY_DATA_PTR(object)->geom;
|
data/ext/geos_c_impl/factory.h
CHANGED
@@ -47,7 +47,6 @@ RGEO_BEGIN_C
|
|
47
47
|
// Per-interpreter globals
|
48
48
|
|
49
49
|
typedef struct {
|
50
|
-
VALUE default_factory;
|
51
50
|
VALUE features_module;
|
52
51
|
VALUE geos_module;
|
53
52
|
} RGeo_Globals;
|
@@ -164,21 +163,22 @@ VALUE rgeo_wrap_geos_geometry_clone(VALUE factory, const GEOSGeometry* geom, VAL
|
|
164
163
|
const GEOSGeometry* rgeo_convert_to_geos_geometry(VALUE factory, VALUE obj, VALUE type);
|
165
164
|
|
166
165
|
/*
|
167
|
-
Gets a GEOS geometry for a given ruby Geometry object.
|
168
|
-
|
169
|
-
|
166
|
+
Gets a GEOS geometry for a given ruby Geometry object. You must provide
|
167
|
+
a GEOS factory for the geometry; the object is cast to that factory if
|
168
|
+
it is not already of it. You may also optionally cast it to a type,
|
170
169
|
specified by an appropriate feature module. Passing Qnil for the type
|
171
170
|
disables this auto-cast. The returned GEOS geometry is owned by the
|
172
|
-
caller-- that is, if the original ruby object is
|
173
|
-
the returned GEOS geometry is a clone of the original.
|
174
|
-
|
171
|
+
caller-- that is, if the original ruby object is already of the desired
|
172
|
+
factory, the returned GEOS geometry is a clone of the original.
|
173
|
+
|
174
|
+
If the klasses parameter is not NULL, its referent is set to the
|
175
175
|
klasses saved in the original ruby Geometry object (if any), or else to
|
176
176
|
the class of the converted GEOS object. This is so that you can use the
|
177
177
|
result of this function to build a GEOS-backed clone of the original
|
178
178
|
geometry, or to include the given geometry in a collection while keeping
|
179
179
|
the klasses intact.
|
180
180
|
*/
|
181
|
-
GEOSGeometry* rgeo_convert_to_detached_geos_geometry(
|
181
|
+
GEOSGeometry* rgeo_convert_to_detached_geos_geometry(VALUE obj, VALUE factory, VALUE type, VALUE* klasses);
|
182
182
|
|
183
183
|
/*
|
184
184
|
Returns 1 if the given ruby object is a GEOS Geometry implementation,
|
data/ext/geos_c_impl/geometry.c
CHANGED
@@ -161,7 +161,18 @@ static VALUE method_geometry_envelope(VALUE self)
|
|
161
161
|
VALUE result = Qnil;
|
162
162
|
const GEOSGeometry* self_geom = RGEO_GET_GEOS_GEOMETRY(self);
|
163
163
|
if (self_geom) {
|
164
|
-
|
164
|
+
GEOSGeometry* envelope = GEOSEnvelope_r(RGEO_CONTEXT_FROM_GEOMETRY(self), self_geom);
|
165
|
+
// GEOS returns an "empty" point for an empty collection's envelope.
|
166
|
+
// We don't allow that type, so we replace it with an empty collection.
|
167
|
+
if (!envelope ||
|
168
|
+
GEOSGeomTypeId_r(RGEO_CONTEXT_FROM_GEOMETRY(self), envelope) == GEOS_POINT &&
|
169
|
+
GEOSGetNumCoordinates_r(RGEO_CONTEXT_FROM_GEOMETRY(self), envelope) == 0) {
|
170
|
+
if (envelope) {
|
171
|
+
GEOSGeom_destroy_r(RGEO_CONTEXT_FROM_GEOMETRY(self), envelope);
|
172
|
+
}
|
173
|
+
envelope = GEOSGeom_createCollection_r(RGEO_CONTEXT_FROM_GEOMETRY(self), GEOS_GEOMETRYCOLLECTION, NULL, 0);
|
174
|
+
}
|
175
|
+
result = rgeo_wrap_geos_geometry(RGEO_FACTORY_FROM_GEOMETRY(self), envelope, Qnil);
|
165
176
|
}
|
166
177
|
return result;
|
167
178
|
}
|
@@ -172,7 +183,13 @@ static VALUE method_geometry_boundary(VALUE self)
|
|
172
183
|
VALUE result = Qnil;
|
173
184
|
const GEOSGeometry* self_geom = RGEO_GET_GEOS_GEOMETRY(self);
|
174
185
|
if (self_geom) {
|
175
|
-
|
186
|
+
GEOSGeometry* boundary = GEOSBoundary_r(RGEO_CONTEXT_FROM_GEOMETRY(self), self_geom);
|
187
|
+
// GEOS returns NULL for the boundary of an empty collection.
|
188
|
+
// Replace that with an empty collection.
|
189
|
+
if (!boundary) {
|
190
|
+
boundary = GEOSGeom_createCollection_r(RGEO_CONTEXT_FROM_GEOMETRY(self), GEOS_GEOMETRYCOLLECTION, NULL, 0);
|
191
|
+
}
|
192
|
+
result = rgeo_wrap_geos_geometry(RGEO_FACTORY_FROM_GEOMETRY(self), boundary, Qnil);
|
176
193
|
}
|
177
194
|
return result;
|
178
195
|
}
|
@@ -80,7 +80,7 @@ static VALUE create_geometry_collection(VALUE module, int type, VALUE factory, V
|
|
80
80
|
break;
|
81
81
|
}
|
82
82
|
for (i=0; i<len; ++i) {
|
83
|
-
GEOSGeometry* geom = rgeo_convert_to_detached_geos_geometry(
|
83
|
+
GEOSGeometry* geom = rgeo_convert_to_detached_geos_geometry(rb_ary_entry(array, i), factory, cast_type, &klass);
|
84
84
|
if (!geom) {
|
85
85
|
break;
|
86
86
|
}
|
data/ext/geos_c_impl/polygon.c
CHANGED
@@ -165,7 +165,7 @@ static VALUE cmethod_create(VALUE module, VALUE factory, VALUE exterior, VALUE i
|
|
165
165
|
{
|
166
166
|
Check_Type(interior_array, T_ARRAY);
|
167
167
|
VALUE linear_ring_type = rb_const_get_at(RGEO_GLOBALS_FROM_FACTORY(factory)->features_module, rb_intern("LinearRing"));
|
168
|
-
GEOSGeometry* exterior_geom = rgeo_convert_to_detached_geos_geometry(
|
168
|
+
GEOSGeometry* exterior_geom = rgeo_convert_to_detached_geos_geometry(exterior, factory, linear_ring_type, NULL);
|
169
169
|
if (exterior_geom) {
|
170
170
|
unsigned int len = (unsigned int)RARRAY_LEN(interior_array);
|
171
171
|
GEOSGeometry** interior_geoms = ALLOC_N(GEOSGeometry*, len == 0 ? 1 : len);
|
@@ -173,7 +173,7 @@ static VALUE cmethod_create(VALUE module, VALUE factory, VALUE exterior, VALUE i
|
|
173
173
|
unsigned int actual_len = 0;
|
174
174
|
unsigned int i;
|
175
175
|
for (i=0; i<len; ++i) {
|
176
|
-
GEOSGeometry* interior_geom = rgeo_convert_to_detached_geos_geometry(
|
176
|
+
GEOSGeometry* interior_geom = rgeo_convert_to_detached_geos_geometry(rb_ary_entry(interior_array, i), factory, linear_ring_type, NULL);
|
177
177
|
if (interior_geom) {
|
178
178
|
interior_geoms[actual_len++] = interior_geom;
|
179
179
|
}
|
@@ -38,12 +38,14 @@ require 'rgeo/active_record/mysql_common'
|
|
38
38
|
require 'active_record/connection_adapters/mysql2_adapter'
|
39
39
|
|
40
40
|
|
41
|
-
module ActiveRecord
|
41
|
+
module ActiveRecord
|
42
42
|
|
43
|
-
class Base
|
43
|
+
class Base
|
44
44
|
|
45
45
|
|
46
|
-
|
46
|
+
# Create a mysql2spatial connection adapter
|
47
|
+
|
48
|
+
def self.mysql2spatial_connection(config_)
|
47
49
|
config_[:username] = 'root' if config_[:username].nil?
|
48
50
|
if ::Mysql2::Client.const_defined?(:FOUND_ROWS)
|
49
51
|
config_[:flags] = ::Mysql2::Client::FOUND_ROWS
|
@@ -57,12 +59,12 @@ module ActiveRecord # :nodoc:
|
|
57
59
|
end
|
58
60
|
|
59
61
|
|
60
|
-
module ConnectionAdapters
|
62
|
+
module ConnectionAdapters # :nodoc:
|
61
63
|
|
62
|
-
class Mysql2SpatialAdapter < Mysql2Adapter
|
64
|
+
class Mysql2SpatialAdapter < Mysql2Adapter # :nodoc:
|
63
65
|
|
64
66
|
|
65
|
-
class SpatialColumn < ConnectionAdapters::Mysql2Column
|
67
|
+
class SpatialColumn < ConnectionAdapters::Mysql2Column # :nodoc:
|
66
68
|
|
67
69
|
include ::RGeo::ActiveRecord::MysqlCommon::ColumnMethods
|
68
70
|
|
@@ -38,12 +38,14 @@ require 'rgeo/active_record/mysql_common'
|
|
38
38
|
require 'active_record/connection_adapters/mysql_adapter'
|
39
39
|
|
40
40
|
|
41
|
-
module ActiveRecord
|
41
|
+
module ActiveRecord
|
42
42
|
|
43
|
-
class Base
|
43
|
+
class Base
|
44
44
|
|
45
45
|
|
46
|
-
|
46
|
+
# Create a mysqlspatial connection adapter
|
47
|
+
|
48
|
+
def self.mysqlspatial_connection(config_)
|
47
49
|
unless defined?(::Mysql)
|
48
50
|
begin
|
49
51
|
require 'mysql'
|
@@ -67,12 +69,12 @@ module ActiveRecord # :nodoc:
|
|
67
69
|
end
|
68
70
|
|
69
71
|
|
70
|
-
module ConnectionAdapters
|
72
|
+
module ConnectionAdapters # :nodoc:
|
71
73
|
|
72
|
-
class MysqlSpatialAdapter < MysqlAdapter
|
74
|
+
class MysqlSpatialAdapter < MysqlAdapter # :nodoc:
|
73
75
|
|
74
76
|
|
75
|
-
class SpatialColumn < ConnectionAdapters::MysqlColumn
|
77
|
+
class SpatialColumn < ConnectionAdapters::MysqlColumn # :nodoc:
|
76
78
|
|
77
79
|
include ::RGeo::ActiveRecord::MysqlCommon::ColumnMethods
|
78
80
|
|
@@ -37,24 +37,57 @@
|
|
37
37
|
require 'active_record'
|
38
38
|
|
39
39
|
|
40
|
-
|
40
|
+
# RGeo extensions to ActiveRecord are installed when one of the spatial
|
41
|
+
# connection adapters is needed. These modifications require ActiveRecord
|
42
|
+
# 3.0.3 or later.
|
43
|
+
|
44
|
+
module ActiveRecord
|
45
|
+
|
46
|
+
|
47
|
+
# RGeo extends ActiveRecord::Base to include the following new class
|
48
|
+
# attributes. These attributes are inherited by subclasses, and can
|
49
|
+
# be overridden in subclasses.
|
50
|
+
#
|
51
|
+
# === ActiveRecord::Base::rgeo_factory_generator
|
52
|
+
#
|
53
|
+
# The value of this attribute is a RGeo::Features::FactoryGenerator
|
54
|
+
# that is used to generate the proper factory when loading geometry
|
55
|
+
# objects from the database. For example, if the data being loaded
|
56
|
+
# has M but not Z coordinates, and an embedded SRID, then this
|
57
|
+
# FactoryGenerator is called with the appropriate configuration to
|
58
|
+
# obtain a factory with those properties. This factory is the one
|
59
|
+
# associated with the actual geometry properties of the ActiveRecord
|
60
|
+
# object.
|
61
|
+
#
|
62
|
+
# === ActiveRecord::Base::rgeo_default_factory
|
63
|
+
#
|
64
|
+
# The default factory used to load RGeo geometry objects from the
|
65
|
+
# database. This is used when there is no rgeo_factory_generator.
|
41
66
|
|
42
|
-
class Base
|
67
|
+
class Base
|
68
|
+
|
43
69
|
|
44
70
|
self.attribute_types_cached_by_default << :geometry
|
45
71
|
|
72
|
+
|
46
73
|
class_attribute :rgeo_default_factory, :instance_writer => false
|
47
74
|
self.rgeo_default_factory = nil
|
48
75
|
|
49
76
|
class_attribute :rgeo_factory_generator, :instance_writer => false
|
50
77
|
self.rgeo_factory_generator = nil
|
51
78
|
|
79
|
+
|
80
|
+
# This is a convenient way to set the rgeo_factory_generator by
|
81
|
+
# passing a block.
|
82
|
+
|
52
83
|
def self.to_generate_rgeo_factory(&block_)
|
53
84
|
self.rgeo_factory_generator = block_
|
54
85
|
end
|
55
86
|
|
87
|
+
|
56
88
|
class << self
|
57
89
|
|
90
|
+
# :stopdoc:
|
58
91
|
alias_method :columns_without_rgeo_modification, :columns
|
59
92
|
def columns
|
60
93
|
unless defined?(@columns) && @columns
|
@@ -64,9 +97,11 @@ module ActiveRecord # :nodoc:
|
|
64
97
|
end
|
65
98
|
@columns
|
66
99
|
end
|
100
|
+
# :startdoc:
|
67
101
|
|
68
102
|
end
|
69
103
|
|
70
104
|
end
|
71
105
|
|
106
|
+
|
72
107
|
end
|
data/lib/rgeo/cartesian.rb
CHANGED
@@ -41,28 +41,11 @@ require 'rgeo'
|
|
41
41
|
module RGeo
|
42
42
|
|
43
43
|
|
44
|
-
# The Cartesian module
|
45
|
-
#
|
46
|
-
#
|
47
|
-
#
|
48
|
-
#
|
49
|
-
# The Cartesian implementation can handle all the SFS 1.1 types, and
|
50
|
-
# provides extensions for Z and M coordinates. It also provides WKT
|
51
|
-
# and WKB serialization using the WKRep module.
|
52
|
-
#
|
53
|
-
# However, the Cartesian implementation does not implement many of
|
54
|
-
# the more advanced geometric operations. Limitations include:
|
55
|
-
# * relational operators such as Features::Geometry#intersects? are
|
56
|
-
# not implemented for most types.
|
57
|
-
# * relational constructors such as Features::Geometry#union are
|
58
|
-
# not implemented for most types.
|
59
|
-
# * buffer, boundary, and convex hull calculation are not implemented
|
60
|
-
# for most types.
|
61
|
-
# * distance and area calculation are not implemented for most types,
|
62
|
-
# though length for LineStrings is implemented.
|
63
|
-
# * equality and simplicity evaluation are implemented for some types
|
64
|
-
# but not all types.
|
65
|
-
# * assertions for polygons and multipolygons are not implemented.
|
44
|
+
# The Cartesian module is a gateway to implementations that use the
|
45
|
+
# Cartesian (i.e. flat) coordinate system. It provides convenient
|
46
|
+
# access to Cartesian factories such as the Geos implementation and
|
47
|
+
# the simple Cartesian implementation. It also provides a namespace
|
48
|
+
# for Cartesian-specific analysis tools.
|
66
49
|
|
67
50
|
module Cartesian
|
68
51
|
end
|
@@ -82,4 +65,5 @@ require 'rgeo/cartesian/feature_methods'
|
|
82
65
|
require 'rgeo/cartesian/feature_classes'
|
83
66
|
require 'rgeo/cartesian/factory'
|
84
67
|
require 'rgeo/cartesian/interface'
|
68
|
+
require 'rgeo/cartesian/bounding_box'
|
85
69
|
require 'rgeo/cartesian/analysis'
|