Skip to content

Commit

Permalink
Changed all is_*? method names to *? (#268)
Browse files Browse the repository at this point in the history
* Changed all occurrences of is_empty? to empty?

* Changed all occurrences of is_simple? to simple?

* Changed all occurrences of is_closed? to closed?

* Changed all occurrences of is_point? to point?

* Changed all occurrences of is_ring? to ring?

* Changed all occurrences of is_capi_geos? to capi_geos?

* Changed all occurrences of is_ffi_geos? to ffi_geos?

* Changed all occurrences of is_geos? to geos?

* Changed mind on test names

* create alias methods

* I think this will work?

* Think I got it this time

* disable Naming/PredicateName cop

* make magic comments inline

* revert History.md
  • Loading branch information
stephenandersondev committed Jul 20, 2021
1 parent 6f24106 commit 334f908
Show file tree
Hide file tree
Showing 39 changed files with 322 additions and 143 deletions.
14 changes: 7 additions & 7 deletions Spatial_Programming_With_RGeo.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,29 +390,29 @@ defined functions.

Most geometry types have a "degenerate" form representing no geometry. For
example, a GeometryCollection may contain no items, or a LineString may
contain no points. This state is indicated by the `Geometry#is_empty?` method.
contain no points. This state is indicated by the `Geometry#empty?` method.
In RGeo, any geometry type except Point may be empty.

factory = RGeo::Cartesian.preferred_factory
factory.point(1, 2).is_empty? # returns false
factory.collection([]).is_empty? # returns true
factory.point(1, 2).empty? # returns false
factory.collection([]).empty? # returns true

A second common property of geometry objects is "simplicity", which basically
means the geometry doesn't intersect or repeat itself. For example, a
LineString that intersects itself is not simple, nor is a MultiPoint that
contains the same point more than once. Sometimes, a geometric analysis
algorithm will have simplicity as a precondition. This property is indicated
by the `Geometry#is_simple?` method.
by the `Geometry#simple?` method.

factory = RGeo::Cartesian.preferred_factory
p00 = factory.point(0, 0)
p01 = factory.point(0, 1)
p11 = factory.point(1, 1)
p10 = factory.point(1, 0)
zigzag_line = factory.line_string([p00, p10, p01, p11])
zigzag_line.is_simple? # returns true
zigzag_line.simple? # returns true
self_crossing_line = factory.line_string([p00, p11, p01, p10])
self_crossing_line.is_simple? # returns false
self_crossing_line.simple? # returns false

All geometry objects also contain a "spatial reference ID", returned by the
`Geometry#srid` method. This is an external ID reference indicating the
Expand Down Expand Up @@ -485,7 +485,7 @@ interfaces, RGeo provides operators for some of these calculations.
union.geometry_type # returns RGeo::Feature::MultiPoint
union.num_geometries # returns 2
diff = p1.difference(p2) # or p1 - p2
diff.is_empty? # returns true
diff.empty? # returns true

### 3.4. Unary Spatial Operations

Expand Down
14 changes: 7 additions & 7 deletions doc/An-Introduction-to-Spatial-Programming-With-RGeo.md
Original file line number Diff line number Diff line change
Expand Up @@ -390,29 +390,29 @@ defined functions.

Most geometry types have a "degenerate" form representing no geometry. For
example, a GeometryCollection may contain no items, or a LineString may
contain no points. This state is indicated by the `Geometry#is_empty?` method.
contain no points. This state is indicated by the `Geometry#empty?` method.
In RGeo, any geometry type except Point may be empty.

factory = RGeo::Cartesian.preferred_factory
factory.point(1, 2).is_empty? # returns false
factory.collection([]).is_empty? # returns true
factory.point(1, 2).empty? # returns false
factory.collection([]).empty? # returns true

A second common property of geometry objects is "simplicity", which basically
means the geometry doesn't intersect or repeat itself. For example, a
LineString that intersects itself is not simple, nor is a MultiPoint that
contains the same point more than once. Sometimes, a geometric analysis
algorithm will have simplicity as a precondition. This property is indicated
by the `Geometry#is_simple?` method.
by the `Geometry#simple?` method.

factory = RGeo::Cartesian.preferred_factory
p00 = factory.point(0, 0)
p01 = factory.point(0, 1)
p11 = factory.point(1, 1)
p10 = factory.point(1, 0)
zigzag_line = factory.line_string([p00, p10, p01, p11])
zigzag_line.is_simple? # returns true
zigzag_line.simple? # returns true
self_crossing_line = factory.line_string([p00, p11, p01, p10])
self_crossing_line.is_simple? # returns false
self_crossing_line.simple? # returns false

All geometry objects also contain a "spatial reference ID", returned by the
`Geometry#srid` method. This is an external ID reference indicating the
Expand Down Expand Up @@ -485,7 +485,7 @@ interfaces, RGeo provides operators for some of these calculations.
union.geometry_type # returns RGeo::Feature::MultiPoint
union.num_geometries # returns 2
diff = p1.difference(p2) # or p1 - p2
diff.is_empty? # returns true
diff.empty? # returns true

### 3.4. Unary Spatial Operations

Expand Down
24 changes: 12 additions & 12 deletions doc/Examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
- [as_binary](#as_binary)
- [Predicates and Relationships](#predicates-and-relationships)
- [ccw?](#ccw)
- [is_simple?](#is_simple)
- [is_empty?](#is_empty)
- [simple?](#simple)
- [empty?](#empty)
- [contains?](#contains)
- [crosses?](#crosses)
- [disjoint?](#disjoint)
Expand Down Expand Up @@ -318,9 +318,9 @@ pt4 = factory.point(2, 6)
linearring = factory.linear_ring([pt1, pt2, pt3, pt4, pt1])
p linearring
# => #<RGeo::Geos::CAPILinearRingImpl "LINESTRING (2.0 2.0, 4.0 2.0, 4.0 4.0, 2.0 6.0, 2.0 2.0)">
p linearring.is_closed?
p linearring.closed?
#=> true
p linearring.is_simple?
p linearring.simple?
#=> true
```

Expand Down Expand Up @@ -689,7 +689,7 @@ p RGeo::Feature::Point.check_type(pt)
p RGeo::Feature::Point.check_type(linestring)
# => false

def is_point?(feature)
def point?(feature)
case feature
when RGeo::Feature::Point
p "It's a Point!"
Expand All @@ -700,10 +700,10 @@ def is_point?(feature)
end
end

is_point?(pt)
point?(pt)
# => "It's a Point!"

is_point?(linestring)
point?(linestring)
# => "It's not a Point"
```

Expand Down Expand Up @@ -767,7 +767,7 @@ p factory.linear_ring([pt1, pt2, pt3, pt4, pt1]).ccw?
# => true
```

### is_simple?
### simple?

```ruby
factory = RGeo::Cartesian.factory
Expand All @@ -777,11 +777,11 @@ pt2 = factory.point(1, 0)
pt3 = factory.point(1, 1)
pt4 = factory.point(0, 1)

p factory.linear_ring([pt1, pt2, pt3, pt4, pt1]).is_simple?
p factory.linear_ring([pt1, pt2, pt3, pt4, pt1]).simple?
# => true
```

### is_empty?
### empty?

Returns `true` if the object is the empty set.

Expand All @@ -793,10 +793,10 @@ pt2 = factory.point(1, 0)
pt3 = factory.point(1, 1)
pt4 = factory.point(0, 1)

p factory.linear_ring([pt1, pt2, pt3, pt4, pt1]).is_empty?
p factory.linear_ring([pt1, pt2, pt3, pt4, pt1]).empty?
# => false

p factory.multi_point([]).is_empty?
p factory.multi_point([]).empty?
# => true
```

Expand Down
32 changes: 16 additions & 16 deletions doc/Factory-Compatibility.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ _Note: This list is not exhaustive of all the methods defined by each factory. T
| `Point#envelope` ||||||||
| `Point#as_text` ||||||||
| `Point#as_binary` ||||||||
| `Point#is_empty?` ||||||||
| `Point#is_simple?` ||||||||
| `Point#empty?` ||||||||
| `Point#simple?` ||||||||
| `Point#boundary` ||||||||
| `Point#convex_hull` ||||||||
| `Point#buffer` ||||||||
Expand Down Expand Up @@ -129,8 +129,8 @@ _Note: This list is not exhaustive of all the methods defined by each factory. T
| `LineString#envelope` ||||||||
| `LineString#as_text` ||||||||
| `LineString#as_binary` ||||||||
| `LineString#is_empty?` ||||||||
| `LineString#is_simple?` ||||||||
| `LineString#empty?` ||||||||
| `LineString#simple?` ||||||||
| `LineString#boundary` ||||||||
| `LineString#convex_hull` ||||||||
| `LineString#buffer` ||||||||
Expand Down Expand Up @@ -221,8 +221,8 @@ _Note: This list is not exhaustive of all the methods defined by each factory. T
| `LinearRing#envelope` ||||||||
| `LinearRing#as_text` ||||||||
| `LinearRing#as_binary` ||||||||
| `LinearRing#is_empty?` ||||||||
| `LinearRing#is_simple?` ||||||||
| `LinearRing#empty?` ||||||||
| `LinearRing#simple?` ||||||||
| `LinearRing#boundary` ||||||||
| `LinearRing#convex_hull` ||||||||
| `LinearRing#buffer` ||||||||
Expand Down Expand Up @@ -313,8 +313,8 @@ _Note: This list is not exhaustive of all the methods defined by each factory. T
| `Polygon#envelope` ||||||||
| `Polygon#as_text` ||||||||
| `Polygon#as_binary` ||||||||
| `Polygon#is_empty?` ||||||||
| `Polygon#is_simple?` ||||||||
| `Polygon#empty?` ||||||||
| `Polygon#simple?` ||||||||
| `Polygon#boundary` ||||||||
| `Polygon#convex_hull` ||||||||
| `Polygon#buffer` ||||||||
Expand Down Expand Up @@ -405,8 +405,8 @@ _Note: This list is not exhaustive of all the methods defined by each factory. T
| `Collection#envelope` ||||||||
| `Collection#as_text` ||||||||
| `Collection#as_binary` ||||||||
| `Collection#is_empty?` ||||||||
| `Collection#is_simple?` ||||||||
| `Collection#empty?` ||||||||
| `Collection#simple?` ||||||||
| `Collection#boundary` ||||||||
| `Collection#convex_hull` ||||||||
| `Collection#buffer` ||||||||
Expand Down Expand Up @@ -497,8 +497,8 @@ _Note: This list is not exhaustive of all the methods defined by each factory. T
| `MultiPoint#envelope` ||||||||
| `MultiPoint#as_text` ||||||||
| `MultiPoint#as_binary` ||||||||
| `MultiPoint#is_empty?` ||||||||
| `MultiPoint#is_simple?` ||||||||
| `MultiPoint#empty?` ||||||||
| `MultiPoint#simple?` ||||||||
| `MultiPoint#boundary` ||||||||
| `MultiPoint#convex_hull` ||||||||
| `MultiPoint#buffer` ||||||||
Expand Down Expand Up @@ -589,8 +589,8 @@ _Note: This list is not exhaustive of all the methods defined by each factory. T
| `MultiLineString#envelope` ||||||||
| `MultiLineString#as_text` ||||||||
| `MultiLineString#as_binary` ||||||||
| `MultiLineString#is_empty?` ||||||||
| `MultiLineString#is_simple?` ||||||||
| `MultiLineString#empty?` ||||||||
| `MultiLineString#simple?` ||||||||
| `MultiLineString#boundary` ||||||||
| `MultiLineString#convex_hull` ||||||||
| `MultiLineString#buffer` ||||||||
Expand Down Expand Up @@ -681,8 +681,8 @@ _Note: This list is not exhaustive of all the methods defined by each factory. T
| `MultiPolygon#envelope` ||||||||
| `MultiPolygon#as_text` ||||||||
| `MultiPolygon#as_binary` ||||||||
| `MultiPolygon#is_empty?` ||||||||
| `MultiPolygon#is_simple?` ||||||||
| `MultiPolygon#empty?` ||||||||
| `MultiPolygon#simple?` ||||||||
| `MultiPolygon#boundary` ||||||||
| `MultiPolygon#convex_hull` ||||||||
| `MultiPolygon#buffer` ||||||||
Expand Down
4 changes: 2 additions & 2 deletions ext/geos_c_impl/geometry.c
Original file line number Diff line number Diff line change
Expand Up @@ -1095,8 +1095,8 @@ void rgeo_init_geos_geometry(RGeo_Globals* globals)
rb_define_method(geos_geometry_methods, "boundary", method_geometry_boundary, 0);
rb_define_method(geos_geometry_methods, "_as_text", method_geometry_as_text, 0);
rb_define_method(geos_geometry_methods, "as_binary", method_geometry_as_binary, 0);
rb_define_method(geos_geometry_methods, "is_empty?", method_geometry_is_empty, 0);
rb_define_method(geos_geometry_methods, "is_simple?", method_geometry_is_simple, 0);
rb_define_method(geos_geometry_methods, "empty?", method_geometry_is_empty, 0);
rb_define_method(geos_geometry_methods, "simple?", method_geometry_is_simple, 0);
rb_define_method(geos_geometry_methods, "equals?", method_geometry_equals, 1);
rb_define_method(geos_geometry_methods, "==", method_geometry_equals, 1);
rb_define_method(geos_geometry_methods, "rep_equals?", method_geometry_eql, 1);
Expand Down
2 changes: 1 addition & 1 deletion ext/geos_c_impl/geometry_collection.c
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ void rgeo_init_geos_geometry_collection(RGeo_Globals* globals)
geos_multi_line_string_methods = rb_define_module_under(globals->geos_module, "CAPIMultiLineStringMethods");
rb_define_method(geos_multi_line_string_methods, "geometry_type", method_multi_line_string_geometry_type, 0);
rb_define_method(geos_multi_line_string_methods, "length", method_multi_line_string_length, 0);
rb_define_method(geos_multi_line_string_methods, "is_closed?", method_multi_line_string_is_closed, 0);
rb_define_method(geos_multi_line_string_methods, "closed?", method_multi_line_string_is_closed, 0);
rb_define_method(geos_multi_line_string_methods, "hash", method_multi_line_string_hash, 0);
rb_define_method(geos_multi_line_string_methods, "coordinates", method_multi_line_string_coordinates, 0);

Expand Down
4 changes: 2 additions & 2 deletions ext/geos_c_impl/line_string.c
Original file line number Diff line number Diff line change
Expand Up @@ -663,8 +663,8 @@ void rgeo_init_geos_line_string(RGeo_Globals* globals)
rb_define_method(geos_line_string_methods, "end_point", method_line_string_end_point, 0);
rb_define_method(geos_line_string_methods, "project_point", method_line_string_project_point, 1);
rb_define_method(geos_line_string_methods, "interpolate_point", method_line_string_interpolate_point, 1);
rb_define_method(geos_line_string_methods, "is_closed?", method_line_string_is_closed, 0);
rb_define_method(geos_line_string_methods, "is_ring?", method_line_string_is_ring, 0);
rb_define_method(geos_line_string_methods, "closed?", method_line_string_is_closed, 0);
rb_define_method(geos_line_string_methods, "ring?", method_line_string_is_ring, 0);
rb_define_method(geos_line_string_methods, "coordinates", method_line_string_coordinates, 0);

// CAPILinearRingMethods module
Expand Down
Loading

0 comments on commit 334f908

Please sign in to comment.