-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add MGLPointCollection for GeoJSON multipoints #6742
Add MGLPointCollection for GeoJSON multipoints #6742
Conversation
@boundsj, thanks for your PR! By analyzing the history of the files in this pull request, we identified @ituaijagbone, @1ec5 and @rmnblm to be potential reviewers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also update the iOS and macOS changelogs to note that we fixed a bug in which feature querying returned abstract MGLMultiPointFeature objects for multipoint features; now it returns concrete MGLPointCollectionFeature objects instead.
@@ -129,7 +130,7 @@ NS_ASSUME_NONNULL_BEGIN | |||
The `MGLMultiPointFeature` class represents a multipoint in a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Update this comment.
@@ -14,17 +14,6 @@ NS_ASSUME_NONNULL_BEGIN | |||
@interface MGLMultiPoint : MGLShape |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Revert this class’s comment to what it used to say.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 95d8c15
|
||
#import "MGLShape.h" | ||
|
||
@interface MGLPointCollection : MGLShape |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document this class.
|
||
#import "MGLShape.h" | ||
|
||
@interface MGLPointCollection : MGLShape |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this class conform to MGLOverlay? (Intriguingly, we could have this class be a subclass of MGLMultiPoint, in order to share mutable coordinate code. But best to leave this as is for now.)
|
||
/** The number of coordinates associated with the shape. */ | ||
@property (nonatomic, readonly) NSUInteger pointCount; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a getter for the coordinates.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 2ad5889
@return A new multipoint object. | ||
*/ | ||
+ (instancetype)pointCollectionWithCoordinates:(CLLocationCoordinate2D *)coords count:(NSUInteger)count; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a public initializer to go with the factory method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have public initializers for any of the other shapes. Why add one in this case? Especially since MGLPointCollection
currently can't be added to the map as an since there is no representation for that sort of annotation in mbgl core.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, OK, whatever's consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, OK, whatever's consistent.
@@ -6,7 +6,7 @@ | |||
<BreakpointProxy | |||
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint"> | |||
<BreakpointContent | |||
shouldBeEnabled = "No" | |||
shouldBeEnabled = "Yes" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Back out this change.
@@ -30,10 +30,11 @@ custom_categories: | |||
- MGLAnnotationView | |||
- MGLCalloutView | |||
- MGLCalloutViewDelegate | |||
- MGLMultiPoint | |||
- MGLMultiPoint |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: trailing whitespace.
@@ -2855,13 +2855,6 @@ - (void)addAnnotations:(NS_ARRAY_OF(id <MGLAnnotation>) *)annotations | |||
|
|||
if ([annotation isKindOfClass:[MGLMultiPoint class]]) | |||
{ | |||
// Actual multipoints aren’t supported as annotations. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make the same change on the macOS side.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 5813f4f
Fixes #6764 |
@1ec5 @friedbunny I still need to add the changelog entries but this is ready for review (thanks @1ec5 for the early review!) |
|
||
/** | ||
The `MGLPointCollection` class is used to define shapes composed of multiple | ||
points. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@1ec5 I'm thinking about mentioning that this class is really only useful as an MGLPointCollectionFeature
in an MGLGeoJSONSource
. What do you think?
This moves the method that creates a "multi point" object in the GeoJSON sense to MGLPointCollection. The methods for creating mbgl::Feature and GeoJSON dictionary representations are also moved.
- Add WIP description for MGLPointCollection class - Change the name of MGLPointCollectionFeature description - Update MGLMultiPoint class description - Add NSObject description method to MGLPointCollection - Update jazzy yml rename of multipoint feature to point collection feature
We don't want MGLMultiPoints to be used directly. Again.
This matches the multipoint implementation
This updates the iOS and macOS annotation adding logic so that unwanted shapes really are avoided. Previously the combined OR conditions meant that an annotation had to logically be NOT a kind of all three types so the check always let the annotation slip through. This also expands the guard to deflect the recently introduced MGLPointCollection. This removes the check in the macOS SDK for multipoints as annotations for the polygon and polyline case so this logic now matches iOS. Finally, this fixes up the macOS project so that MGLPointCollection is linked correctly.
a777c16
to
c6288a7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few minor things, but this is looking great.
#import "MGLShape.h" | ||
|
||
/** | ||
The `MGLPointCollection` class is used to define an array of coordinates. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Emphasize that these coordinates are disconnected (as opposed to MGLMultiPoint).
@param coords The array of coordinates defining the shape. The data in this | ||
array is copied to the new object. | ||
@param count The number of items in the `coords` array. | ||
@return A new multipoint object. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/multipoint/point collection/
@note `MGLMultiPolyline`, `MGLMultiPolygon`, `MGLShapeCollection`, and | ||
`MGLPointCollection` objects cannot be added to the map view at this time. | ||
Any multipoint, multipolyline, multipolygon, shape collection or point | ||
collection, object that is specified is silently ignored. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: remove comma after "collection".
Thanks @1ec5! I think this is ready to go. |
Fixes #5201
Context from #5201 (comment)