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
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
MGLMultiPolygon doesn't support coordinate property #7070
-[MGLMultiPolygon coordinate] should be implemented in order to avoid the exception in MGLShape. For now, we can have it return the first coordinate, as MGLPolyline and MGLPolygon do.
-[MGLPolyline coordinate], -[MGLPolygon coordinate], and -[MGLMultiPolygon coordinate] should return the centroid. This is a larger task that would require Polylabel.
I would argue that the problem here is that -coordinate is even in the interface of MGLShape and subclasses. It should be in the interface of MGLPointAnnotation only. The artificial definition of a "coordinate" for polygons, multipolygons, line strings -- and the lengths we will need to go through to implement it -- are signs that this is a design error.
To expand on #7070 (comment), having coordinate return something meaningful for the more exotic shape types is just icing on the cake. The real bug here is that -[MGLMultiPolygon coordinate] is unimplemented, leading to a crash. Even having -[MGLMultiPolygon coordinate] return the first coordinate of the first polygon would’ve been fine, but #8713 goes the extra mile to return something more meaningful.
If you find yourself implementing methods where the implementation is arbitrary, then something is off about your class design.
That’s a good argument for making the coordinate property optional in the MGLAnnotation protocol, so that it would only be provided by the classes where it makes sense.
I would contend that it should be possible to implement a non-arbitrary coordinate for every shape type – after all, we do that for labeling features in vector sources – but that it isn’t a priority for the more exotic shape types. The highest priority is fixing the crash, and I believe that’s why this issue is on the v3.6.0 milestone. A secondary priority would be to implement a sensible coordinate for MGLPolyline and MGLPolygon specifically, to simplify the task in #2082/#5502.
Changing either MGLShape’s protocol conformance or making MGLAnnotation.coordinate optional would be a major, backwards-incompatible change. We’d want to track that separately and maybe consider it at the same time as #7454.
Activity
1ec5 commentedon Jan 13, 2017
There are two issues here:
-[MGLMultiPolygon coordinate]should be implemented in order to avoid the exception in MGLShape. For now, we can have it return the first coordinate, as MGLPolyline and MGLPolygon do.-[MGLPolyline coordinate],-[MGLPolygon coordinate], and-[MGLMultiPolygon coordinate]should return the centroid. This is a larger task that would require Polylabel./cc @mourner
mourner commentedon Jan 13, 2017
@1ec5 wasn't Polylabel already integrated recently by @jfirebaugh?
1ec5 commentedon Jan 13, 2017
Ah, I missed that it got integrated (for label placement) in #7465. We'll have to figure out a way to make it accessible to SDK code as well.
jfirebaugh commentedon Apr 13, 2017
I would argue that the problem here is that
-coordinateis even in the interface ofMGLShapeand subclasses. It should be in the interface ofMGLPointAnnotationonly. The artificial definition of a "coordinate" for polygons, multipolygons, line strings -- and the lengths we will need to go through to implement it -- are signs that this is a design error.1ec5 commentedon Apr 13, 2017
coordinateis defined on the MGLAnnotation protocol, so any class that conforms to it must implement the property. This is consistent with MapKit.1ec5 commentedon Apr 13, 2017
To expand on #7070 (comment), having
coordinatereturn something meaningful for the more exotic shape types is just icing on the cake. The real bug here is that-[MGLMultiPolygon coordinate]is unimplemented, leading to a crash. Even having-[MGLMultiPolygon coordinate]return the first coordinate of the first polygon would’ve been fine, but #8713 goes the extra mile to return something more meaningful./cc @fabian-guerra
jfirebaugh commentedon Apr 13, 2017
Right -- I'm suggesting that either:
MGLShapeshould not conform toMGLAnnotation, orMGLAnnotationshould not definecoordinate.If you find yourself implementing methods where the implementation is arbitrary, then something is off about your class design.
1ec5 commentedon Apr 13, 2017
That’s a good argument for making the
coordinateproperty optional in the MGLAnnotation protocol, so that it would only be provided by the classes where it makes sense.I would contend that it should be possible to implement a non-arbitrary
coordinatefor every shape type – after all, we do that for labeling features in vector sources – but that it isn’t a priority for the more exotic shape types. The highest priority is fixing the crash, and I believe that’s why this issue is on the v3.6.0 milestone. A secondary priority would be to implement a sensiblecoordinatefor MGLPolyline and MGLPolygon specifically, to simplify the task in #2082/#5502.Changing either MGLShape’s protocol conformance or making
MGLAnnotation.coordinateoptional would be a major, backwards-incompatible change. We’d want to track that separately and maybe consider it at the same time as #7454.1ec5 commentedon May 23, 2017
Fixed in #8713 on the release-ios-v3.6.0-android-v5.1.0 branch.