Module: RGeo::Geos::CAPIGeometryMethods
- Includes:
- Feature::Instance
- Included in:
- CAPIGeometryCollectionImpl, CAPIGeometryImpl, CAPILineImpl, CAPILineStringImpl, CAPILinearRingImpl, CAPIMultiLineStringImpl, CAPIMultiPointImpl, CAPIMultiPolygonImpl, CAPIPointImpl, CAPIPolygonImpl
- Defined in:
- lib/rgeo/geos/capi_feature_classes.rb,
ext/geos_c_impl/geometry.c
Instance Method Summary collapse
- #*(rhs) ⇒ Object
- #+(rhs) ⇒ Object
- #-(rhs) ⇒ Object
- #==(rhs) ⇒ Object
- #_as_text ⇒ Object
- #_steal(orig) ⇒ Object
- #as_binary ⇒ Object
- #as_text ⇒ Object (also: #to_s)
- #boundary ⇒ Object
- #buffer(distance) ⇒ Object
- #buffer_with_style(distance, endCapStyle, joinStyle, mitreLimit) ⇒ Object
- #contains?(rhs) ⇒ Boolean
- #convex_hull ⇒ Object
- #coordinate_dimension ⇒ Object
- #crosses?(rhs) ⇒ Boolean
- #difference(rhs) ⇒ Object
- #dimension ⇒ Object
- #disjoint?(rhs) ⇒ Boolean
- #distance(rhs) ⇒ Object
- #empty? ⇒ Boolean
-
#encode_with(coder) ⇒ Object
Psych support.
- #envelope ⇒ Object
- #eql?(rhs) ⇒ Boolean
- #equals?(rhs) ⇒ Boolean
- #factory ⇒ Object
- #factory=(factory) ⇒ Object
- #geometry_type ⇒ Object
-
#init_with(coder) ⇒ Object
:nodoc:.
- #initialize_copy(orig) ⇒ Object
-
#initialized? ⇒ Boolean
** RUBY METHOD DEFINITIONS ***.
- #inspect ⇒ Object
- #intersection(rhs) ⇒ Object
- #intersects?(rhs) ⇒ Boolean
- #invalid_reason ⇒ Object
- #invalid_reason_location ⇒ Object
- #is_3d? ⇒ Boolean
- #make_valid ⇒ Object
-
#marshal_dump ⇒ Object
Marshal support.
-
#marshal_load(data_) ⇒ Object
:nodoc:.
- #measured? ⇒ Boolean
- #overlaps?(rhs) ⇒ Boolean
- #point_on_surface ⇒ Object
-
#polygonize ⇒ RGeo::Feature::GeometryCollection
Polygonizes a set of Geometries which contain linework that represents the edges of a planar graph.
- #prepare! ⇒ Object
- #prepared? ⇒ Boolean
- #relate?(rhs, pattern) ⇒ Boolean
- #rep_equals?(rhs) ⇒ Boolean
- #segmentize(max_segment_length) ⇒ Object
- #simple? ⇒ Boolean
- #simplify(tolerance) ⇒ Object
- #simplify_preserve_topology(tolerance) ⇒ Object
- #spatial_dimension ⇒ Object
- #srid ⇒ Object
- #sym_difference(rhs) ⇒ Object
- #touches?(rhs) ⇒ Boolean
- #unary_union ⇒ Object
- #union(rhs) ⇒ Object
- #valid? ⇒ Boolean
- #within?(rhs) ⇒ Boolean
Instance Method Details
#*(rhs) ⇒ Object
851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 |
# File 'ext/geos_c_impl/geometry.c', line 851
static VALUE
method_geometry_intersection(VALUE self, VALUE rhs)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
VALUE factory;
const GEOSGeometry* rhs_geom;
int state = 0;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
factory = self_data->factory;
rhs_geom = rgeo_convert_to_geos_geometry(factory, rhs, Qnil, &state);
if (state) {
rb_jump_tag(state);
}
result = rgeo_wrap_geos_geometry(
factory, GEOSIntersection(self_geom, rhs_geom), Qnil);
}
return result;
}
|
#+(rhs) ⇒ Object
877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 |
# File 'ext/geos_c_impl/geometry.c', line 877
static VALUE
method_geometry_union(VALUE self, VALUE rhs)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
VALUE factory;
const GEOSGeometry* rhs_geom;
int state = 0;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
factory = self_data->factory;
rhs_geom = rgeo_convert_to_geos_geometry(factory, rhs, Qnil, &state);
if (state) {
rb_jump_tag(state);
}
result =
rgeo_wrap_geos_geometry(factory, GEOSUnion(self_geom, rhs_geom), Qnil);
}
return result;
}
|
#-(rhs) ⇒ Object
921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 |
# File 'ext/geos_c_impl/geometry.c', line 921
static VALUE
method_geometry_difference(VALUE self, VALUE rhs)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
VALUE factory;
const GEOSGeometry* rhs_geom;
int state = 0;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
factory = self_data->factory;
rhs_geom = rgeo_convert_to_geos_geometry(factory, rhs, Qnil, &state);
if (state) {
rb_jump_tag(state);
}
result = rgeo_wrap_geos_geometry(
factory, GEOSDifference(self_geom, rhs_geom), Qnil);
}
return result;
}
|
#==(rhs) ⇒ Object
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
# File 'ext/geos_c_impl/geometry.c', line 365
static VALUE
method_geometry_equals(VALUE self, VALUE rhs)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
const GEOSGeometry* rhs_geom;
// Shortcut when self and rhs are the same object.
if (self == rhs) {
return Qtrue;
}
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
rhs_geom = rgeo_get_geos_geometry_safe(rhs);
if (rhs_geom) {
// GEOS has a bug where empty geometries are not spatially equal
// to each other. Work around this case first.
if (GEOSisEmpty(self_geom) == 1 && GEOSisEmpty(rhs_geom) == 1) {
result = Qtrue;
} else {
result = GEOSEquals(self_geom, rhs_geom) ? Qtrue : Qfalse;
}
}
}
return result;
}
|
#_as_text ⇒ Object
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'ext/geos_c_impl/geometry.c', line 246
static VALUE
method_geometry_as_text(VALUE self)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
RGeo_FactoryData* factory_data;
VALUE wkt_generator;
GEOSWKTWriter* wkt_writer;
char* str;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
factory_data = RGEO_FACTORY_DATA_PTR(self_data->factory);
wkt_generator = factory_data->wkrep_wkt_generator;
if (!NIL_P(wkt_generator)) {
result = rb_funcall(wkt_generator, rb_intern("generate"), 1, self);
} else {
wkt_writer = factory_data->wkt_writer;
if (!wkt_writer) {
wkt_writer = GEOSWKTWriter_create();
GEOSWKTWriter_setOutputDimension(wkt_writer, 2);
GEOSWKTWriter_setTrim(wkt_writer, 1);
factory_data->wkt_writer = wkt_writer;
}
str = GEOSWKTWriter_write(wkt_writer, self_geom);
if (str) {
result = rb_str_new2(str);
GEOSFree(str);
}
}
}
return result;
}
|
#_steal(orig) ⇒ Object
1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 |
# File 'ext/geos_c_impl/geometry.c', line 1019
static VALUE
method_geometry_steal(VALUE self, VALUE orig)
{
RGeo_GeometryData* self_data;
const GEOSPreparedGeometry* prep;
const GEOSGeometry* geom;
RGeo_GeometryData* orig_data;
geom = rgeo_get_geos_geometry_safe(orig);
if (geom) {
// Clear out any existing value
self_data = RGEO_GEOMETRY_DATA_PTR(self);
if (self_data->geom) {
GEOSGeom_destroy(self_data->geom);
}
prep = self_data->prep;
if (prep && prep != (GEOSPreparedGeometry*)1 &&
prep != (GEOSPreparedGeometry*)2) {
GEOSPreparedGeom_destroy(prep);
}
// Steal value from orig
orig_data = RGEO_GEOMETRY_DATA_PTR(orig);
self_data->geom = orig_data->geom;
self_data->prep = orig_data->prep;
self_data->factory = orig_data->factory;
self_data->klasses = orig_data->klasses;
// Clear out orig
orig_data->geom = NULL;
orig_data->prep = NULL;
orig_data->factory = Qnil;
orig_data->klasses = Qnil;
}
return self;
}
|
#as_binary ⇒ Object
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
# File 'ext/geos_c_impl/geometry.c', line 283
static VALUE
method_geometry_as_binary(VALUE self)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
RGeo_FactoryData* factory_data;
VALUE wkb_generator;
GEOSWKBWriter* wkb_writer;
size_t size;
char* str;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
factory_data = RGEO_FACTORY_DATA_PTR(self_data->factory);
wkb_generator = factory_data->wkrep_wkb_generator;
if (!NIL_P(wkb_generator)) {
result = rb_funcall(wkb_generator, rb_intern("generate"), 1, self);
} else {
wkb_writer = factory_data->wkb_writer;
if (!wkb_writer) {
wkb_writer = GEOSWKBWriter_create();
GEOSWKBWriter_setOutputDimension(wkb_writer, 2);
factory_data->wkb_writer = wkb_writer;
}
str = (char*)GEOSWKBWriter_write(wkb_writer, self_geom, &size);
if (str) {
result = rb_str_new(str, size);
GEOSFree(str);
}
}
}
return result;
}
|
#as_text ⇒ Object Also known as: to_s
66 67 68 69 70 |
# File 'lib/rgeo/geos/capi_feature_classes.rb', line 66 def as_text str = _as_text str.force_encoding("US-ASCII") if str.respond_to?(:force_encoding) str end |
#boundary ⇒ Object
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'ext/geos_c_impl/geometry.c', line 226
static VALUE
method_geometry_boundary(VALUE self)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
GEOSGeometry* boundary;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
boundary = GEOSBoundary(self_geom);
if (boundary) {
result = rgeo_wrap_geos_geometry(self_data->factory, boundary, Qnil);
}
}
return result;
}
|
#buffer(distance) ⇒ Object
720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 |
# File 'ext/geos_c_impl/geometry.c', line 720
static VALUE
method_geometry_buffer(VALUE self, VALUE distance)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
VALUE factory;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
factory = self_data->factory;
result = rgeo_wrap_geos_geometry(
factory,
GEOSBuffer(self_geom,
rb_num2dbl(distance),
RGEO_FACTORY_DATA_PTR(factory)->buffer_resolution),
Qnil);
}
return result;
}
|
#buffer_with_style(distance, endCapStyle, joinStyle, mitreLimit) ⇒ Object
764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 |
# File 'ext/geos_c_impl/geometry.c', line 764
static VALUE
method_geometry_buffer_with_style(VALUE self,
VALUE distance,
VALUE endCapStyle,
VALUE joinStyle,
VALUE mitreLimit)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
VALUE factory;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
factory = self_data->factory;
result = rgeo_wrap_geos_geometry(
factory,
GEOSBufferWithStyle(self_geom,
rb_num2dbl(distance),
RGEO_FACTORY_DATA_PTR(factory)->buffer_resolution,
RB_NUM2INT(endCapStyle),
RB_NUM2INT(joinStyle),
rb_num2dbl(mitreLimit)),
Qnil);
}
return result;
}
|
#contains?(rhs) ⇒ Boolean
587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 |
# File 'ext/geos_c_impl/geometry.c', line 587
static VALUE
method_geometry_contains(VALUE self, VALUE rhs)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
const GEOSGeometry* rhs_geom;
char val;
int state = 0;
#ifdef RGEO_GEOS_SUPPORTS_PREPARED1
const GEOSPreparedGeometry* prep;
#endif
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
rhs_geom =
rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil, &state);
if (state) {
rb_jump_tag(state);
}
#ifdef RGEO_GEOS_SUPPORTS_PREPARED1
prep = rgeo_request_prepared_geometry(self_data);
if (prep)
val = GEOSPreparedContains(prep, rhs_geom);
else
#endif
val = GEOSContains(self_geom, rhs_geom);
if (val == 0) {
result = Qfalse;
} else if (val == 1) {
result = Qtrue;
}
}
return result;
}
|
#convex_hull ⇒ Object
834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 |
# File 'ext/geos_c_impl/geometry.c', line 834
static VALUE
method_geometry_convex_hull(VALUE self)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
result = rgeo_wrap_geos_geometry(
self_data->factory, GEOSConvexHull(self_geom), Qnil);
}
return result;
}
|
#coordinate_dimension ⇒ Object
16 17 18 19 20 21 |
# File 'lib/rgeo/geos/capi_feature_classes.rb', line 16 def coordinate_dimension dim = 2 dim += 1 if factory.supports_z? dim += 1 if factory.supports_m? dim end |
#crosses?(rhs) ⇒ Boolean
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 |
# File 'ext/geos_c_impl/geometry.c', line 511
static VALUE
method_geometry_crosses(VALUE self, VALUE rhs)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
const GEOSGeometry* rhs_geom;
char val;
int state = 0;
#ifdef RGEO_GEOS_SUPPORTS_PREPARED2
const GEOSPreparedGeometry* prep;
#endif
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
rhs_geom =
rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil, &state);
if (state) {
rb_jump_tag(state);
}
#ifdef RGEO_GEOS_SUPPORTS_PREPARED2
prep = rgeo_request_prepared_geometry(self_data);
if (prep)
val = GEOSPreparedCrosses(prep, rhs_geom);
else
#endif
val = GEOSCrosses(self_geom, rhs_geom);
if (val == 0) {
result = Qfalse;
} else if (val == 1) {
result = Qtrue;
}
}
return result;
}
|
#difference(rhs) ⇒ Object
921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 |
# File 'ext/geos_c_impl/geometry.c', line 921
static VALUE
method_geometry_difference(VALUE self, VALUE rhs)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
VALUE factory;
const GEOSGeometry* rhs_geom;
int state = 0;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
factory = self_data->factory;
rhs_geom = rgeo_convert_to_geos_geometry(factory, rhs, Qnil, &state);
if (state) {
rb_jump_tag(state);
}
result = rgeo_wrap_geos_geometry(
factory, GEOSDifference(self_geom, rhs_geom), Qnil);
}
return result;
}
|
#dimension ⇒ Object
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'ext/geos_c_impl/geometry.c', line 159
static VALUE
method_geometry_dimension(VALUE self)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
result = INT2NUM(compute_dimension(self_geom));
}
return result;
}
|
#disjoint?(rhs) ⇒ Boolean
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 |
# File 'ext/geos_c_impl/geometry.c', line 403
static VALUE
method_geometry_disjoint(VALUE self, VALUE rhs)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
const GEOSGeometry* rhs_geom;
int state = 0;
#ifdef RGEO_GEOS_SUPPORTS_PREPARED2
const GEOSPreparedGeometry* prep;
#endif
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
rhs_geom =
rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil, &state);
if (state) {
rb_jump_tag(state);
}
#ifdef RGEO_GEOS_SUPPORTS_PREPARED2
prep = rgeo_request_prepared_geometry(self_data);
if (prep)
result = GEOSPreparedDisjoint(prep, rhs_geom) ? Qtrue : Qfalse;
else
#endif
result = GEOSDisjoint(self_geom, rhs_geom) ? Qtrue : Qfalse;
}
return result;
}
|
#distance(rhs) ⇒ Object
693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 |
# File 'ext/geos_c_impl/geometry.c', line 693
static VALUE
method_geometry_distance(VALUE self, VALUE rhs)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
const GEOSGeometry* rhs_geom;
double dist;
int state = 0;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
rhs_geom =
rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil, &state);
if (state) {
rb_jump_tag(state);
}
if (GEOSDistance(self_geom, rhs_geom, &dist)) {
result = rb_float_new(dist);
}
}
return result;
}
|
#empty? ⇒ Boolean
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 |
# File 'ext/geos_c_impl/geometry.c', line 321
static VALUE
method_geometry_is_empty(VALUE self)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
char val;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
val = GEOSisEmpty(self_geom);
if (val == 0) {
result = Qfalse;
} else if (val == 1) {
result = Qtrue;
}
}
return result;
}
|
#encode_with(coder) ⇒ Object
Psych support
53 54 55 56 57 58 59 |
# File 'lib/rgeo/geos/capi_feature_classes.rb', line 53 def encode_with(coder) # :nodoc: my_factory = factory coder["factory"] = my_factory str = my_factory.write_for_psych(self) str = str.encode("US-ASCII") if str.respond_to?(:encode) coder["wkt"] = str end |
#envelope ⇒ Object
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 |
# File 'ext/geos_c_impl/geometry.c', line 205
static VALUE
method_geometry_envelope(VALUE self)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
GEOSGeometry* envelope;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
envelope = GEOSEnvelope(self_geom);
if (!envelope) {
envelope = GEOSGeom_createCollection(GEOS_GEOMETRYCOLLECTION, NULL, 0);
}
result = rgeo_wrap_geos_geometry(self_data->factory, envelope, Qnil);
}
return result;
}
|
#eql?(rhs) ⇒ Boolean
396 397 398 399 400 401 |
# File 'ext/geos_c_impl/geometry.c', line 396
static VALUE
method_geometry_eql(VALUE self, VALUE rhs)
{
// This should be overridden by the subclass.
return self == rhs ? Qtrue : Qfalse;
}
|
#equals?(rhs) ⇒ Boolean
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
# File 'ext/geos_c_impl/geometry.c', line 365
static VALUE
method_geometry_equals(VALUE self, VALUE rhs)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
const GEOSGeometry* rhs_geom;
// Shortcut when self and rhs are the same object.
if (self == rhs) {
return Qtrue;
}
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
rhs_geom = rgeo_get_geos_geometry_safe(rhs);
if (rhs_geom) {
// GEOS has a bug where empty geometries are not spatially equal
// to each other. Work around this case first.
if (GEOSisEmpty(self_geom) == 1 && GEOSisEmpty(rhs_geom) == 1) {
result = Qtrue;
} else {
result = GEOSEquals(self_geom, rhs_geom) ? Qtrue : Qfalse;
}
}
}
return result;
}
|
#factory ⇒ Object
111 112 113 114 115 |
# File 'ext/geos_c_impl/geometry.c', line 111
static VALUE
method_geometry_factory(VALUE self)
{
return RGEO_GEOMETRY_DATA_PTR(self)->factory;
}
|
#factory=(factory) ⇒ Object
117 118 119 120 121 122 |
# File 'ext/geos_c_impl/geometry.c', line 117
static VALUE
method_geometry_set_factory(VALUE self, VALUE factory)
{
RGEO_GEOMETRY_DATA_PTR(self)->factory = factory;
return factory;
}
|
#geometry_type ⇒ Object
175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File 'ext/geos_c_impl/geometry.c', line 175
static VALUE
method_geometry_geometry_type(VALUE self)
{
VALUE result;
RGeo_GeometryData* self_data;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
if (self_data->geom) {
result = rgeo_feature_geometry_module;
}
return result;
}
|
#init_with(coder) ⇒ Object
:nodoc:
61 62 63 64 |
# File 'lib/rgeo/geos/capi_feature_classes.rb', line 61 def init_with(coder) # :nodoc: obj = coder["factory"].read_for_psych(coder["wkt"]) _steal(obj) end |
#initialize_copy(orig) ⇒ Object
973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 |
# File 'ext/geos_c_impl/geometry.c', line 973
static VALUE
method_geometry_initialize_copy(VALUE self, VALUE orig)
{
RGeo_GeometryData* self_data;
const GEOSPreparedGeometry* prep;
const GEOSGeometry* geom;
RGeo_GeometryData* orig_data;
GEOSGeometry* clone_geom;
RGeo_FactoryData* factory_data;
// Clear out any existing value
self_data = RGEO_GEOMETRY_DATA_PTR(self);
if (self_data->geom) {
GEOSGeom_destroy(self_data->geom);
self_data->geom = NULL;
}
prep = self_data->prep;
if (prep && prep != (GEOSPreparedGeometry*)1 &&
prep != (GEOSPreparedGeometry*)2) {
GEOSPreparedGeom_destroy(prep);
}
self_data->prep = NULL;
self_data->factory = Qnil;
self_data->klasses = Qnil;
// Copy value from orig
geom = rgeo_get_geos_geometry_safe(orig);
if (geom) {
orig_data = RGEO_GEOMETRY_DATA_PTR(orig);
clone_geom = GEOSGeom_clone(geom);
if (clone_geom) {
factory_data = RGEO_FACTORY_DATA_PTR(orig_data->factory);
GEOSSetSRID(clone_geom, GEOSGetSRID(geom));
self_data->geom = clone_geom;
self_data->prep =
factory_data &&
((factory_data->flags & RGEO_FACTORYFLAGS_PREPARE_HEURISTIC) != 0)
? (GEOSPreparedGeometry*)1
: NULL;
self_data->factory = orig_data->factory;
self_data->klasses = orig_data->klasses;
}
}
return self;
}
|
#initialized? ⇒ Boolean
** RUBY METHOD DEFINITIONS ***
105 106 107 108 109 |
# File 'ext/geos_c_impl/geometry.c', line 105
static VALUE
method_geometry_initialized_p(VALUE self)
{
return RGEO_GEOMETRY_DATA_PTR(self)->geom ? Qtrue : Qfalse;
}
|
#inspect ⇒ Object
35 36 37 |
# File 'lib/rgeo/geos/capi_feature_classes.rb', line 35 def inspect "#<#{self.class}:0x#{object_id.to_s(16)} #{as_text.inspect}>" end |
#intersection(rhs) ⇒ Object
851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 |
# File 'ext/geos_c_impl/geometry.c', line 851
static VALUE
method_geometry_intersection(VALUE self, VALUE rhs)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
VALUE factory;
const GEOSGeometry* rhs_geom;
int state = 0;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
factory = self_data->factory;
rhs_geom = rgeo_convert_to_geos_geometry(factory, rhs, Qnil, &state);
if (state) {
rb_jump_tag(state);
}
result = rgeo_wrap_geos_geometry(
factory, GEOSIntersection(self_geom, rhs_geom), Qnil);
}
return result;
}
|
#intersects?(rhs) ⇒ Boolean
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 |
# File 'ext/geos_c_impl/geometry.c', line 435
static VALUE
method_geometry_intersects(VALUE self, VALUE rhs)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
const GEOSGeometry* rhs_geom;
char val;
int state = 0;
#ifdef RGEO_GEOS_SUPPORTS_PREPARED1
const GEOSPreparedGeometry* prep;
#endif
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
rhs_geom =
rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil, &state);
if (state) {
rb_jump_tag(state);
}
#ifdef RGEO_GEOS_SUPPORTS_PREPARED1
prep = rgeo_request_prepared_geometry(self_data);
if (prep)
val = GEOSPreparedIntersects(prep, rhs_geom);
else
#endif
val = GEOSIntersects(self_geom, rhs_geom);
if (val == 0) {
result = Qfalse;
} else if (val == 1) {
result = Qtrue;
}
}
return result;
}
|
#invalid_reason ⇒ Object
1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 |
# File 'ext/geos_c_impl/geometry.c', line 1078
static VALUE
method_geometry_invalid_reason(VALUE self)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
char* str;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
// We use NULL there to tell GEOS that we don't care about the position.
switch (GEOSisValidDetail(self_geom, 0, &str, NULL)) {
case 0: // invalid
result = rb_utf8_str_new_cstr(str);
case 1: // valid
break;
case 2: // exception
default:
result = rb_utf8_str_new_cstr("Exception");
break;
};
if (str)
GEOSFree(str);
}
return result;
}
|
#invalid_reason_location ⇒ Object
1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 |
# File 'ext/geos_c_impl/geometry.c', line 1107
static VALUE
method_geometry_invalid_reason_location(VALUE self)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
GEOSGeometry* location = NULL;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
// We use NULL there to tell GEOS that we don't care about the reason.
switch (GEOSisValidDetail(self_geom, 0, NULL, &location)) {
case 0: // invalid
result = rgeo_wrap_geos_geometry(self_data->factory, location, Qnil);
case 1: // valid
break;
case 2: // exception
break;
default:
break;
};
}
return result;
}
|
#is_3d? ⇒ Boolean
27 28 29 |
# File 'lib/rgeo/geos/capi_feature_classes.rb', line 27 def is_3d? factory.supports_z? end |
#make_valid ⇒ Object
1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 |
# File 'ext/geos_c_impl/geometry.c', line 1134
static VALUE
method_geometry_make_valid(VALUE self)
{
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
GEOSGeometry* valid_geom;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (!self_geom)
return Qnil;
// According to GEOS implementation, MakeValid always returns.
valid_geom = GEOSMakeValid(self_geom);
if (!valid_geom) {
rb_raise(rb_eRGeoInvalidGeometry,
"%" PRIsVALUE,
method_geometry_invalid_reason(self));
}
return rgeo_wrap_geos_geometry(self_data->factory, valid_geom, Qnil);
}
|
#marshal_dump ⇒ Object
Marshal support
41 42 43 44 |
# File 'lib/rgeo/geos/capi_feature_classes.rb', line 41 def marshal_dump # :nodoc: my_factory = factory [my_factory, my_factory.write_for_marshal(self)] end |
#marshal_load(data_) ⇒ Object
:nodoc:
46 47 48 49 |
# File 'lib/rgeo/geos/capi_feature_classes.rb', line 46 def marshal_load(data_) # :nodoc: obj = data_[0].read_for_marshal(data_[1]) _steal(obj) end |
#measured? ⇒ Boolean
31 32 33 |
# File 'lib/rgeo/geos/capi_feature_classes.rb', line 31 def measured? factory.supports_m? end |
#overlaps?(rhs) ⇒ Boolean
625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 |
# File 'ext/geos_c_impl/geometry.c', line 625
static VALUE
method_geometry_overlaps(VALUE self, VALUE rhs)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
const GEOSGeometry* rhs_geom;
char val;
int state = 0;
#ifdef RGEO_GEOS_SUPPORTS_PREPARED2
const GEOSPreparedGeometry* prep;
#endif
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
rhs_geom =
rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil, &state);
if (state) {
rb_jump_tag(state);
}
#ifdef RGEO_GEOS_SUPPORTS_PREPARED2
prep = rgeo_request_prepared_geometry(self_data);
if (prep)
val = GEOSPreparedOverlaps(prep, rhs_geom);
else
#endif
val = GEOSOverlaps(self_geom, rhs_geom);
if (val == 0) {
result = Qfalse;
} else if (val == 1) {
result = Qtrue;
}
}
return result;
}
|
#point_on_surface ⇒ Object
1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 |
# File 'ext/geos_c_impl/geometry.c', line 1155
static VALUE
method_geometry_point_on_surface(VALUE self)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
result = rgeo_wrap_geos_geometry(
self_data->factory, GEOSPointOnSurface(self_geom), Qnil);
}
return result;
}
|
#polygonize ⇒ RGeo::Feature::GeometryCollection
Polygonizes a set of Geometries which contain linework that represents the edges of a planar graph.
All types of Geometry are accepted as input; the constituent linework is extracted as the edges to be polygonized.
The edges must be correctly noded; that is, they must only meet at their endpoints and not overlap anywhere.
libgeos.org/doxygen/geos__c_8h.html#a9d98e448d3b846d591c726d1c0000d25 GEOSPolygonize
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 |
# File 'ext/geos_c_impl/geometry.c', line 1189
static VALUE
method_geometry_polygonize(VALUE self)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
GEOSGeometry* geos_polygon_collection;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
geos_polygon_collection = GEOSPolygonize(&self_geom, 1);
if (geos_polygon_collection == NULL) {
rb_raise(rb_eGeosError, "GEOS can't polygonize this geometry.");
}
result = rgeo_wrap_geos_geometry(
self_data->factory, geos_polygon_collection, Qnil);
}
return result;
}
|
#prepare! ⇒ Object
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 |
# File 'ext/geos_c_impl/geometry.c', line 137
static VALUE
method_geometry_prepare(VALUE self)
{
RGeo_GeometryData* self_data;
const GEOSPreparedGeometry* prep;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
if (self_data->geom) {
prep = self_data->prep;
if (!prep || prep == (const GEOSPreparedGeometry*)1 ||
prep == (const GEOSPreparedGeometry*)2) {
prep = GEOSPrepare(self_data->geom);
if (prep) {
self_data->prep = prep;
} else {
self_data->prep = (const GEOSPreparedGeometry*)3;
}
}
}
return self;
}
|
#prepared? ⇒ Boolean
124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'ext/geos_c_impl/geometry.c', line 124
static VALUE
method_geometry_prepared_p(VALUE self)
{
const GEOSPreparedGeometry* prep;
prep = RGEO_GEOMETRY_DATA_PTR(self)->prep;
return (prep && prep != (const GEOSPreparedGeometry*)1 &&
prep != (const GEOSPreparedGeometry*)2 &&
prep != (GEOSPreparedGeometry*)3)
? Qtrue
: Qfalse;
}
|
#relate?(rhs, pattern) ⇒ Boolean
663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 |
# File 'ext/geos_c_impl/geometry.c', line 663
static VALUE
method_geometry_relate(VALUE self, VALUE rhs, VALUE pattern)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
const GEOSGeometry* rhs_geom;
char val;
int state = 0;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
rhs_geom =
rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil, &state);
if (state) {
rb_jump_tag(state);
}
val = GEOSRelatePattern(self_geom, rhs_geom, StringValuePtr(pattern));
if (val == 0) {
result = Qfalse;
} else if (val == 1) {
result = Qtrue;
}
}
return result;
}
|
#rep_equals?(rhs) ⇒ Boolean
396 397 398 399 400 401 |
# File 'ext/geos_c_impl/geometry.c', line 396
static VALUE
method_geometry_eql(VALUE self, VALUE rhs)
{
// This should be overridden by the subclass.
return self == rhs ? Qtrue : Qfalse;
}
|
#segmentize(max_segment_length) ⇒ Object
744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 |
# File 'ext/geos_c_impl/geometry.c', line 744
static VALUE
method_geometry_segmentize(VALUE self, VALUE max_segment_length)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
VALUE factory;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
factory = self_data->factory;
result = rgeo_wrap_geos_geometry(
factory, GEOSDensify(self_geom, rb_num2dbl(max_segment_length)), Qnil);
}
return result;
}
|
#simple? ⇒ Boolean
343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 |
# File 'ext/geos_c_impl/geometry.c', line 343
static VALUE
method_geometry_is_simple(VALUE self)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
char val;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
val = GEOSisSimple(self_geom);
if (val == 0) {
result = Qfalse;
} else if (val == 1) {
result = Qtrue;
}
}
return result;
}
|
#simplify(tolerance) ⇒ Object
794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 |
# File 'ext/geos_c_impl/geometry.c', line 794
static VALUE
method_geometry_simplify(VALUE self, VALUE tolerance)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
VALUE factory;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
factory = self_data->factory;
result = rgeo_wrap_geos_geometry(
factory, GEOSSimplify(self_geom, rb_num2dbl(tolerance)), Qnil);
}
return result;
}
|
#simplify_preserve_topology(tolerance) ⇒ Object
813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 |
# File 'ext/geos_c_impl/geometry.c', line 813
static VALUE
method_geometry_simplify_preserve_topology(VALUE self, VALUE tolerance)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
VALUE factory;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
factory = self_data->factory;
result = rgeo_wrap_geos_geometry(
factory,
GEOSTopologyPreserveSimplify(self_geom, rb_num2dbl(tolerance)),
Qnil);
}
return result;
}
|
#spatial_dimension ⇒ Object
23 24 25 |
# File 'lib/rgeo/geos/capi_feature_classes.rb', line 23 def spatial_dimension factory.supports_z? ? 3 : 2 end |
#srid ⇒ Object
189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'ext/geos_c_impl/geometry.c', line 189
static VALUE
method_geometry_srid(VALUE self)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
result = INT2NUM(GEOSGetSRID(self_geom));
}
return result;
}
|
#sym_difference(rhs) ⇒ Object
947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 |
# File 'ext/geos_c_impl/geometry.c', line 947
static VALUE
method_geometry_sym_difference(VALUE self, VALUE rhs)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
VALUE factory;
const GEOSGeometry* rhs_geom;
int state = 0;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
factory = self_data->factory;
rhs_geom = rgeo_convert_to_geos_geometry(factory, rhs, Qnil, &state);
if (state) {
rb_jump_tag(state);
}
result = rgeo_wrap_geos_geometry(
factory, GEOSSymDifference(self_geom, rhs_geom), Qnil);
}
return result;
}
|
#touches?(rhs) ⇒ Boolean
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 |
# File 'ext/geos_c_impl/geometry.c', line 473
static VALUE
method_geometry_touches(VALUE self, VALUE rhs)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
const GEOSGeometry* rhs_geom;
char val;
int state = 0;
#ifdef RGEO_GEOS_SUPPORTS_PREPARED2
const GEOSPreparedGeometry* prep;
#endif
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
rhs_geom =
rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil, &state);
if (state) {
rb_jump_tag(state);
}
#ifdef RGEO_GEOS_SUPPORTS_PREPARED2
prep = rgeo_request_prepared_geometry(self_data);
if (prep)
val = GEOSPreparedTouches(prep, rhs_geom);
else
#endif
val = GEOSTouches(self_geom, rhs_geom);
if (val == 0) {
result = Qfalse;
} else if (val == 1) {
result = Qtrue;
}
}
return result;
}
|
#unary_union ⇒ Object
903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 |
# File 'ext/geos_c_impl/geometry.c', line 903
static VALUE
method_geometry_unary_union(VALUE self)
{
#ifdef RGEO_GEOS_SUPPORTS_UNARYUNION
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
return rgeo_wrap_geos_geometry(
self_data->factory, GEOSUnaryUnion(self_geom), Qnil);
}
#endif
return Qnil;
}
|
#union(rhs) ⇒ Object
877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 |
# File 'ext/geos_c_impl/geometry.c', line 877
static VALUE
method_geometry_union(VALUE self, VALUE rhs)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
VALUE factory;
const GEOSGeometry* rhs_geom;
int state = 0;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
factory = self_data->factory;
rhs_geom = rgeo_convert_to_geos_geometry(factory, rhs, Qnil, &state);
if (state) {
rb_jump_tag(state);
}
result =
rgeo_wrap_geos_geometry(factory, GEOSUnion(self_geom, rhs_geom), Qnil);
}
return result;
}
|
#valid? ⇒ Boolean
1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 |
# File 'ext/geos_c_impl/geometry.c', line 1056
static VALUE
method_geometry_is_valid(VALUE self)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
char val;
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
val = GEOSisValid(self_geom);
if (val == 0) {
result = Qfalse;
} else if (val == 1) {
result = Qtrue;
}
}
return result;
}
|
#within?(rhs) ⇒ Boolean
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 |
# File 'ext/geos_c_impl/geometry.c', line 549
static VALUE
method_geometry_within(VALUE self, VALUE rhs)
{
VALUE result;
RGeo_GeometryData* self_data;
const GEOSGeometry* self_geom;
const GEOSGeometry* rhs_geom;
char val;
int state = 0;
#ifdef RGEO_GEOS_SUPPORTS_PREPARED2
const GEOSPreparedGeometry* prep;
#endif
result = Qnil;
self_data = RGEO_GEOMETRY_DATA_PTR(self);
self_geom = self_data->geom;
if (self_geom) {
rhs_geom =
rgeo_convert_to_geos_geometry(self_data->factory, rhs, Qnil, &state);
if (state) {
rb_jump_tag(state);
}
#ifdef RGEO_GEOS_SUPPORTS_PREPARED2
prep = rgeo_request_prepared_geometry(self_data);
if (prep)
val = GEOSPreparedWithin(prep, rhs_geom);
else
#endif
val = GEOSWithin(self_geom, rhs_geom);
if (val == 0) {
result = Qfalse;
} else if (val == 1) {
result = Qtrue;
}
}
return result;
}
|