Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Add MGLPointCollection for GeoJSON multipoints #6742

Merged
merged 17 commits into from
Oct 21, 2016

Conversation

boundsj
Copy link
Contributor

@boundsj boundsj commented Oct 18, 2016

Fixes #5201

Context from #5201 (comment)

Stop overloading MGLMultiPoint for GeoJSON multipoints, instead creating a new class for this purpose, as suggested in #5201 (comment). This would be backwards-compatible and allow us to remove various isMemberOfClass checks.

@boundsj boundsj added iOS Mapbox Maps SDK for iOS ⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold annotations Annotations on iOS and macOS or markers on Android runtime styling labels Oct 18, 2016
@boundsj boundsj added this to the ios-v3.4.0 milestone Oct 18, 2016
@boundsj boundsj self-assigned this Oct 18, 2016
@mention-bot
Copy link

@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.

Copy link
Contributor

@1ec5 1ec5 left a 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
Copy link
Contributor

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
Copy link
Contributor

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.

Copy link
Contributor Author

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
Copy link
Contributor

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
Copy link
Contributor

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;

Copy link
Contributor

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.

Copy link
Contributor Author

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;

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor

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"
Copy link
Contributor

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
Copy link
Contributor

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.
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 5813f4f

@boundsj
Copy link
Contributor Author

boundsj commented Oct 19, 2016

Fixes #6764

@boundsj boundsj added ✓ ready for review and removed ⚠️ DO NOT MERGE Work in progress, proof of concept, or on hold labels Oct 19, 2016
@boundsj
Copy link
Contributor Author

boundsj commented Oct 19, 2016

@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.
Copy link
Contributor Author

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.
@boundsj boundsj force-pushed the boundsj-stop-overloading-multipoint branch from a777c16 to c6288a7 Compare October 19, 2016 22:56
Copy link
Contributor

@1ec5 1ec5 left a 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.
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

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".

@boundsj
Copy link
Contributor Author

boundsj commented Oct 20, 2016

Thanks @1ec5! I think this is ready to go.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
annotations Annotations on iOS and macOS or markers on Android iOS Mapbox Maps SDK for iOS runtime styling
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants