You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GeometryCollection is an Arrayable, and toArray() is the way to get the items from it. But then Other classes extend from GeometryCollection. Like MultiLineString or Polygon. They already have getLineStrings() to get its items but because they extend from GeometryCollection also they have the toArray() to get the same result.
The problem is how Eloquent works with Arrayables. For example, when using mutators, it returns the result of toArray() for Arrayable Classes.
Another example of strange behavior:
$polygon = new Polygon([new LineString([
new Point(40.74894149554006, -73.98615270853043),
new Point(40.74848633046773, -73.98648262023926),
new Point(40.747925497790725, -73.9851602911949),
new Point(40.74837050671544, -73.98482501506805),
new Point(40.74894149554006, -73.98615270853043)
])]);
I think it's the expected result for $polygon->getLineStrings() not toArray, which should just return an array representation of the polygon, something like:
Maybe it's posible to write a toArray() method for classes like MultiPoint, MultiLineString or Polygon in order to avoid side effects of the method inherited by GeometryCollection.
The text was updated successfully, but these errors were encountered:
GeometryCollection is an Arrayable, and toArray() is the way to get the items from it. But then Other classes extend from GeometryCollection. Like MultiLineString or Polygon. They already have getLineStrings() to get its items but because they extend from GeometryCollection also they have the toArray() to get the same result.
The problem is how Eloquent works with Arrayables. For example, when using mutators, it returns the result of toArray() for Arrayable Classes.
Another example of strange behavior:
If we make
$polygon->toArray()
, we get this:I think it's the expected result for
$polygon->getLineStrings()
not toArray, which should just return an array representation of the polygon, something like:Maybe it's posible to write a toArray() method for classes like MultiPoint, MultiLineString or Polygon in order to avoid side effects of the method inherited by GeometryCollection.
The text was updated successfully, but these errors were encountered: