[ios] Add debug descriptions to shapes and features

This commit is contained in:
Jason Wray
2017-07-18 19:17:11 -04:00
parent 1188707dc3
commit cd36ec00bc
3 changed files with 69 additions and 0 deletions

View File

@@ -42,6 +42,15 @@ MGL_DEFINE_FEATURE_IS_EQUAL();
return mbglFeature({[self geometryObject]}, identifier, self.attributes);
}
- (NSString *)description
{
return [NSString stringWithFormat:@"<%@: %p; identifier = %@, coordinate = %f, %f, attributes = %@>",
NSStringFromClass([self class]), (void *)self,
self.identifier ? [NSString stringWithFormat:@"\"%@\"", self.identifier] : self.identifier,
self.coordinate.latitude, self.coordinate.longitude,
self.attributes.count ? self.attributes : @"none"];
}
@end
@interface MGLPolylineFeature ()
@@ -68,6 +77,16 @@ MGL_DEFINE_FEATURE_IS_EQUAL();
return mbglFeature({[self geometryObject]}, identifier, self.attributes);
}
- (NSString *)description
{
return [NSString stringWithFormat:@"<%@: %p; identifier = %@, count = %lu, bounds = %@, attributes = %@>",
NSStringFromClass([self class]), (void *)self,
self.identifier ? [NSString stringWithFormat:@"\"%@\"", self.identifier] : self.identifier,
(unsigned long)[self pointCount],
MGLStringFromCoordinateBounds(self.overlayBounds),
self.attributes.count ? self.attributes : @"none"];
}
@end
@interface MGLPolygonFeature ()
@@ -94,6 +113,16 @@ MGL_DEFINE_FEATURE_IS_EQUAL();
return mbglFeature({[self geometryObject]}, identifier, self.attributes);
}
- (NSString *)description
{
return [NSString stringWithFormat:@"<%@: %p; identifier = %@, count = %lu, bounds = %@, attributes = %@>",
NSStringFromClass([self class]), (void *)self,
self.identifier ? [NSString stringWithFormat:@"\"%@\"", self.identifier] : self.identifier,
(unsigned long)[self pointCount],
MGLStringFromCoordinateBounds(self.overlayBounds),
self.attributes.count ? self.attributes : @"none"];
}
@end
@interface MGLPointCollectionFeature ()
@@ -146,6 +175,16 @@ MGL_DEFINE_FEATURE_IS_EQUAL();
return mbglFeature({[self geometryObject]}, identifier, self.attributes);
}
- (NSString *)description
{
return [NSString stringWithFormat:@"<%@: %p; identifier = %@, count = %lu, bounds = %@, attributes = %@>",
NSStringFromClass([self class]), (void *)self,
self.identifier ? [NSString stringWithFormat:@"\"%@\"", self.identifier] : self.identifier,
(unsigned long)self.polylines.count,
MGLStringFromCoordinateBounds(self.overlayBounds),
self.attributes.count ? self.attributes : @"none"];
}
@end
@interface MGLMultiPolygonFeature ()
@@ -172,6 +211,16 @@ MGL_DEFINE_FEATURE_IS_EQUAL();
return mbglFeature({[self geometryObject]}, identifier, self.attributes);
}
- (NSString *)description
{
return [NSString stringWithFormat:@"<%@: %p; identifier = %@, count = %lu, bounds = %@, attributes = %@>",
NSStringFromClass([self class]), (void *)self,
self.identifier ? [NSString stringWithFormat:@"\"%@\"", self.identifier] : self.identifier,
(unsigned long)self.polygons.count,
MGLStringFromCoordinateBounds(self.overlayBounds),
self.attributes.count ? self.attributes : @"none"];
}
@end
@interface MGLShapeCollectionFeature ()

View File

@@ -200,4 +200,14 @@
@"coordinates": coordinates};
}
- (NSString *)description
{
return [NSString stringWithFormat:@"<%@: %p; title = %@, subtitle: = %@, count = %lu; bounds = %@>",
NSStringFromClass([self class]), (void *)self,
self.title ? [NSString stringWithFormat:@"\"%@\"", self.title] : self.title,
self.subtitle ? [NSString stringWithFormat:@"\"%@\"", self.subtitle] : self.subtitle,
(unsigned long)self.polygons.count,
MGLStringFromCoordinateBounds(self.overlayBounds)];
}
@end

View File

@@ -201,4 +201,14 @@
@"coordinates": coordinates};
}
- (NSString *)description
{
return [NSString stringWithFormat:@"<%@: %p; title = %@, subtitle: = %@, count = %lu; bounds = %@>",
NSStringFromClass([self class]), (void *)self,
self.title ? [NSString stringWithFormat:@"\"%@\"", self.title] : self.title,
self.subtitle ? [NSString stringWithFormat:@"\"%@\"", self.subtitle] : self.subtitle,
(unsigned long)self.polylines.count,
MGLStringFromCoordinateBounds(self.overlayBounds)];
}
@end