BaiduMap_IOSSDK_v7.2.0_Docs 7.2.0

BMKGeometry.h
浏览该文件的文档.
1 /* BMKGeometry.h
2 * BMapKit
3 *
4 * Copyright 2011 Baidu Inc. All rights reserved.
5 *
6 */
7
8 #import <BaiduMapAPI_Base/BMKTypes.h>
9 #import <UIKit/UIKit.h>
10
11
12 #pragma mark -----坐标转换
13
18 UIKIT_EXTERN BMKMapPoint BMKMapPointForCoordinate(CLLocationCoordinate2D coordinate);
19
25 UIKIT_EXTERN CLLocationCoordinate2D BMKCoordinateForMapPoint(BMKMapPoint mapPoint);
26
27
33 UIKIT_EXTERN CGPoint BMKConvertToBaiduMercatorFromBD09LL(CLLocationCoordinate2D bd09llCoordinate);
34
40 UIKIT_EXTERN CLLocationCoordinate2D BMKConvertToBD09LLFromBaiduMercator(CGPoint bdMCTCoordinate);
41
52 UIKIT_EXTERN CLLocationCoordinate2D BMKCoordTrans(CLLocationCoordinate2D coordinate, BMK_COORD_TYPE fromType, BMK_COORD_TYPE toType);
53
60 FOUNDATION_EXTERN NSDictionary* BMKConvertBaiduCoorFrom(CLLocationCoordinate2D coordinate,BMK_COORD_TYPE type) __attribute__((deprecated("使用BMKCoordTrans方法代替")));
61
62 #pragma mark -----几何计算
63
68 UIKIT_EXTERN CLLocationDistance BMKMetersPerMapPointAtLatitude(CLLocationDegrees latitude);
69
75 UIKIT_EXTERN double BMKMapPointsPerMeterAtLatitude(CLLocationDegrees latitude);
76
83 UIKIT_EXTERN CLLocationDistance BMKMetersBetweenMapPoints(BMKMapPoint a, BMKMapPoint b);
84
91 UIKIT_EXTERN CLLocationDistance BMKMetersBetweenCoordinates(CLLocationCoordinate2D a, CLLocationCoordinate2D b);
92
93
99 UIKIT_STATIC_INLINE double BMKMapRectGetWidth(BMKMapRect rect) {
100 return rect.size.width;
101 }
102
108 UIKIT_STATIC_INLINE double BMKMapRectGetHeight(BMKMapRect rect) {
109 return rect.size.height;
110 }
111
118 UIKIT_STATIC_INLINE BOOL BMKMapPointEqualToPoint(BMKMapPoint point1, BMKMapPoint point2) {
119 return point1.x == point2.x && point1.y == point2.y;
120 }
121
129 UIKIT_EXTERN BMKMapPoint BMKGetNearestMapPointFromPolyline(BMKMapPoint point, BMKMapPoint* polyline, NSUInteger count);
137 UIKIT_EXTERN BMKMapPoint BMKGetPointToTheVerticalFootOfLine(BMKMapPoint point, BMKMapPoint lineStartPt, BMKMapPoint lineEndPt);
145 UIKIT_EXTERN CLLocationDistance BMKGetDistanceFromPointToLine(BMKMapPoint point, BMKMapPoint lineStartPt, BMKMapPoint lineEndPt);
146
147
155 UIKIT_EXTERN BMKCoordinateRegion BMKCoordinateRegionMakeWithDistance(CLLocationCoordinate2D centerCoordinate, CLLocationDistance latitudinalMeters, CLLocationDistance longitudinalMeters);
156
157 #pragma mark rect
158
164 UIKIT_STATIC_INLINE BOOL BMKMapSizeEqualToSize(BMKMapSize size1, BMKMapSize size2) {
165 return size1.width == size2.width && size1.height == size2.height;
166 }
167
174 UIKIT_STATIC_INLINE BOOL BMKMapRectEqualToRect(BMKMapRect rect1, BMKMapRect rect2) {
175 return
176 BMKMapPointEqualToPoint(rect1.origin, rect2.origin) &&
177 BMKMapSizeEqualToSize(rect1.size, rect2.size);
178 }
179
185 UIKIT_STATIC_INLINE BOOL BMKMapRectIsEmpty(BMKMapRect rect) {
186 return BMKMapRectIsNull(rect) || (rect.size.width == 0.0 && rect.size.height == 0.0);
187 }
188
189
190
197 UIKIT_EXTERN BMKMapRect BMKMapRectUnion(BMKMapRect rect1, BMKMapRect rect2);
198
205 UIKIT_EXTERN BMKMapRect BMKMapRectIntersection(BMKMapRect rect1, BMKMapRect rect2);
206
214 UIKIT_EXTERN BMKMapRect BMKMapRectInset(BMKMapRect rect, double dx, double dy);
215
223 UIKIT_EXTERN BMKMapRect BMKMapRectOffset(BMKMapRect rect, double dx, double dy);
224
233 UIKIT_EXTERN void BMKMapRectDivide(BMKMapRect rect, BMKMapRect *slice, BMKMapRect *remainder, double amount, CGRectEdge edge);
234
241 UIKIT_EXTERN BOOL BMKMapRectContainsPoint(BMKMapRect rect, BMKMapPoint point);
242
249 UIKIT_EXTERN BOOL BMKMapRectContainsRect(BMKMapRect rect1, BMKMapRect rect2);
250
257 UIKIT_EXTERN BOOL BMKMapRectIntersectsRect(BMKMapRect rect1, BMKMapRect rect2);
258
264 UIKIT_EXTERN BMKCoordinateRegion BMKCoordinateRegionForMapRect(BMKMapRect rect);
265
271 UIKIT_EXTERN BOOL BMKMapRectSpans180thMeridian(BMKMapRect rect);
272
278 UIKIT_EXTERN BMKMapRect BMKMapRectRemainder(BMKMapRect rect);
279
280 #pragma mark circle
281
288 UIKIT_EXTERN BOOL BMKCircleContainsPoint(BMKMapPoint point, BMKMapPoint center, double radius);
289
297 UIKIT_EXTERN BOOL BMKCircleContainsCoordinate(CLLocationCoordinate2D point, CLLocationCoordinate2D center, double radius);
298
299 #pragma mark polygon
300
307 UIKIT_EXTERN BOOL BMKPolygonContainsPoint(BMKMapPoint point, BMKMapPoint *polygon, NSUInteger count);
308
316 UIKIT_EXTERN BOOL BMKPolygonContainsCoordinate(CLLocationCoordinate2D point, CLLocationCoordinate2D *polygon, NSUInteger count);
317
318
319
326 UIKIT_EXTERN double BMKAreaBetweenCoordinates(CLLocationCoordinate2D leftTop, CLLocationCoordinate2D rightBottom);
327
328
336 UIKIT_EXTERN double BMKAreaForPolygon(CLLocationCoordinate2D *coordinates, int count);
337
338
339 #pragma mark -----Others
340
347 UIKIT_EXTERN CLLocationDirection BMKGetDirectionFromCoords(CLLocationCoordinate2D startCoord, CLLocationCoordinate2D endCoord);
354 UIKIT_EXTERN CLLocationDirection BMKGetDirectionFromPoints(BMKMapPoint startPt, BMKMapPoint endPt);
360 UIKIT_STATIC_INLINE NSString *BMKStringFromMapPoint(BMKMapPoint point) {
361 return [NSString stringWithFormat:@"{%.1f, %.1f}", point.x, point.y];
362 }
363
369 UIKIT_STATIC_INLINE NSString *BMKStringFromMapSize(BMKMapSize size) {
370 return [NSString stringWithFormat:@"{%.1f, %.1f}", size.width, size.height];
371 }
372
378 UIKIT_STATIC_INLINE NSString *BMKStringFromMapRect(BMKMapRect rect) {
379 return [NSString stringWithFormat:@"{%@, %@}", BMKStringFromMapPoint(rect.origin), BMKStringFromMapSize(rect.size)];
380 }
381
387 UIKIT_EXTERN CLLocationCoordinate2D BMKCoorDictionaryDecode(NSDictionary* dictionary);
388
393 UIKIT_EXTERN BMKMapRect BMKMapRectFromEncodedGeoPoints(NSString *encodedGeoPoints, BMKEncodePointType type);
394
400 UIKIT_EXTERN BOOL BMKEncodedGeoPointsContainsPoint(BMKMapPoint point,
401 NSString *encodedGeoPoints,
402 BMKEncodePointType type);
403
409 UIKIT_EXTERN BOOL BMKEncodedGeoPointsContainsCoordinate(CLLocationCoordinate2D point,
410 NSString *encodedGeoPoints,
411 BMKEncodePointType type);
412
414 @interface NSValue (BMKGeometryExtension)
415
419 + (NSValue *)valueWithBMKMapPoint:(BMKMapPoint)mapPoint;
420
424 + (NSValue *)valueWithBMKMapSize:(BMKMapSize)mapSize;
425
429 + (NSValue *)valueWithBMKMapRect:(BMKMapRect)mapRect;
430
434 + (NSValue *)valueWithCoordinate2D:(CLLocationCoordinate2D)coordinate;
435
436
439 - (BMKMapPoint)BMKMapPointValue;
440
443 - (BMKMapSize)BMKMapSizeValue;
444
447 - (BMKMapRect)BMKMapRectValue;
448
451 - (CLLocationCoordinate2D)Coordinate2DValue;
452
453 @end
BMKConvertToBaiduMercatorFromBD09LL
UIKIT_EXTERN CGPoint BMKConvertToBaiduMercatorFromBD09LL(CLLocationCoordinate2D bd09llCoordinate)
BMKConvertToBD09LLFromBaiduMercator
UIKIT_EXTERN CLLocationCoordinate2D BMKConvertToBD09LLFromBaiduMercator(CGPoint bdMCTCoordinate)
BMKCircleContainsCoordinate
UIKIT_EXTERN BOOL BMKCircleContainsCoordinate(CLLocationCoordinate2D point, CLLocationCoordinate2D center, double radius)
BMKMetersPerMapPointAtLatitude
UIKIT_EXTERN CLLocationDistance BMKMetersPerMapPointAtLatitude(CLLocationDegrees latitude)
BMKMapRectSpans180thMeridian
UIKIT_EXTERN BOOL BMKMapRectSpans180thMeridian(BMKMapRect rect)
BMKPolygonContainsCoordinate
UIKIT_EXTERN BOOL BMKPolygonContainsCoordinate(CLLocationCoordinate2D point, CLLocationCoordinate2D *polygon, NSUInteger count)
-[NSValue(BMKGeometryExtension) BMKMapSizeValue]
BMKMapSize BMKMapSizeValue()
BMKMetersBetweenCoordinates
UIKIT_EXTERN CLLocationDistance BMKMetersBetweenCoordinates(CLLocationCoordinate2D a, CLLocationCoordinate2D b)
BMKGetNearestMapPointFromPolyline
UIKIT_EXTERN BMKMapPoint BMKGetNearestMapPointFromPolyline(BMKMapPoint point, BMKMapPoint *polyline, NSUInteger count)
BMKMapRectContainsRect
UIKIT_EXTERN BOOL BMKMapRectContainsRect(BMKMapRect rect1, BMKMapRect rect2)
BMKAreaForPolygon
UIKIT_EXTERN double BMKAreaForPolygon(CLLocationCoordinate2D *coordinates, int count)
BMKMapPointForCoordinate
UIKIT_EXTERN BMKMapPoint BMKMapPointForCoordinate(CLLocationCoordinate2D coordinate)
BMKMapPoint
地理坐标点，用直角地理坐标表示
Definition: BMKTypes.h:249
BMKMapPointsPerMeterAtLatitude
UIKIT_EXTERN double BMKMapPointsPerMeterAtLatitude(CLLocationDegrees latitude)
BMKMapRectUnion
UIKIT_EXTERN BMKMapRect BMKMapRectUnion(BMKMapRect rect1, BMKMapRect rect2)
BMKMapRectEqualToRect
UIKIT_STATIC_INLINE BOOL BMKMapRectEqualToRect(BMKMapRect rect1, BMKMapRect rect2)
Definition: BMKGeometry.h:174
BMKMapRectIntersection
UIKIT_EXTERN BMKMapRect BMKMapRectIntersection(BMKMapRect rect1, BMKMapRect rect2)
BMKMapRectRemainder
UIKIT_EXTERN BMKMapRect BMKMapRectRemainder(BMKMapRect rect)
-[NSValue(BMKGeometryExtension) BMKMapRectValue]
BMKMapRect BMKMapRectValue()
BMKMapRectContainsPoint
UIKIT_EXTERN BOOL BMKMapRectContainsPoint(BMKMapRect rect, BMKMapPoint point)
BMKCoorDictionaryDecode
UIKIT_EXTERN CLLocationCoordinate2D BMKCoorDictionaryDecode(NSDictionary *dictionary)
BMKStringFromMapSize
UIKIT_STATIC_INLINE NSString * BMKStringFromMapSize(BMKMapSize size)
Definition: BMKGeometry.h:369
BMKGetPointToTheVerticalFootOfLine
UIKIT_EXTERN BMKMapPoint BMKGetPointToTheVerticalFootOfLine(BMKMapPoint point, BMKMapPoint lineStartPt, BMKMapPoint lineEndPt)
BMKMapPoint::y
double y
横坐标
Definition: BMKTypes.h:251
BMKMapPointEqualToPoint
UIKIT_STATIC_INLINE BOOL BMKMapPointEqualToPoint(BMKMapPoint point1, BMKMapPoint point2)
Definition: BMKGeometry.h:118
BMKEncodedGeoPointsContainsPoint
UIKIT_EXTERN BOOL BMKEncodedGeoPointsContainsPoint(BMKMapPoint point, NSString *encodedGeoPoints, BMKEncodePointType type)
BMKEncodedGeoPointsContainsCoordinate
UIKIT_EXTERN BOOL BMKEncodedGeoPointsContainsCoordinate(CLLocationCoordinate2D point, NSString *encodedGeoPoints, BMKEncodePointType type)
BMKStringFromMapRect
UIKIT_STATIC_INLINE NSString * BMKStringFromMapRect(BMKMapRect rect)
Definition: BMKGeometry.h:378
BMKMapRectIsNull
UIKIT_STATIC_INLINE BOOL BMKMapRectIsNull(BMKMapRect rect)
Definition: BMKTypes.h:323
BMKAreaBetweenCoordinates
UIKIT_EXTERN double BMKAreaBetweenCoordinates(CLLocationCoordinate2D leftTop, CLLocationCoordinate2D rightBottom)
BMKMapRectGetHeight
UIKIT_STATIC_INLINE double BMKMapRectGetHeight(BMKMapRect rect)
Definition: BMKGeometry.h:108
BMKMapRectFromEncodedGeoPoints
UIKIT_EXTERN BMKMapRect BMKMapRectFromEncodedGeoPoints(NSString *encodedGeoPoints, BMKEncodePointType type)
BMKMapSize::width
double width
Definition: BMKTypes.h:292
BMKCoordinateRegionForMapRect
UIKIT_EXTERN BMKCoordinateRegion BMKCoordinateRegionForMapRect(BMKMapRect rect)
BMKCoordinateRegion
表示一个经纬度区域
Definition: BMKTypes.h:226
BMKStringFromMapPoint
UIKIT_STATIC_INLINE NSString * BMKStringFromMapPoint(BMKMapPoint point)
Definition: BMKGeometry.h:360
BMKMapPoint::x
double x
Definition: BMKTypes.h:250
BMKMapRect::size
BMKMapSize size
屏幕左上点对应的直角地理坐标
Definition: BMKTypes.h:307
BMKCoordinateRegionMakeWithDistance
UIKIT_EXTERN BMKCoordinateRegion BMKCoordinateRegionMakeWithDistance(CLLocationCoordinate2D centerCoordinate, CLLocationDistance latitudinalMeters, CLLocationDistance longitudinalMeters)
BMKPolygonContainsPoint
UIKIT_EXTERN BOOL BMKPolygonContainsPoint(BMKMapPoint point, BMKMapPoint *polygon, NSUInteger count)
BMKCircleContainsPoint
UIKIT_EXTERN BOOL BMKCircleContainsPoint(BMKMapPoint point, BMKMapPoint center, double radius)
BMKCoordinateForMapPoint
UIKIT_EXTERN CLLocationCoordinate2D BMKCoordinateForMapPoint(BMKMapPoint mapPoint)
BMKMapSizeEqualToSize
UIKIT_STATIC_INLINE BOOL BMKMapSizeEqualToSize(BMKMapSize size1, BMKMapSize size2)
Definition: BMKGeometry.h:164
-[NSValue(BMKGeometryExtension) Coordinate2DValue]
CLLocationCoordinate2D Coordinate2DValue()
BMKMapRect
矩形，用直角地理坐标表示
Definition: BMKTypes.h:305
BMKMapRect::origin
BMKMapPoint origin
Definition: BMKTypes.h:306
BMKGetDirectionFromPoints
UIKIT_EXTERN CLLocationDirection BMKGetDirectionFromPoints(BMKMapPoint startPt, BMKMapPoint endPt)
BMKMapRectGetWidth
UIKIT_STATIC_INLINE double BMKMapRectGetWidth(BMKMapRect rect)
Definition: BMKGeometry.h:99
BMKMapRectOffset
UIKIT_EXTERN BMKMapRect BMKMapRectOffset(BMKMapRect rect, double dx, double dy)
BMKMetersBetweenMapPoints
UIKIT_EXTERN CLLocationDistance BMKMetersBetweenMapPoints(BMKMapPoint a, BMKMapPoint b)
BMKGetDirectionFromCoords
UIKIT_EXTERN CLLocationDirection BMKGetDirectionFromCoords(CLLocationCoordinate2D startCoord, CLLocationCoordinate2D endCoord)
BMKMapRectDivide
UIKIT_EXTERN void BMKMapRectDivide(BMKMapRect rect, BMKMapRect *slice, BMKMapRect *remainder, double amount, CGRectEdge edge)
BMKMapSize::height
double height
宽度
Definition: BMKTypes.h:293
BMKMapRectInset
UIKIT_EXTERN BMKMapRect BMKMapRectInset(BMKMapRect rect, double dx, double dy)
BMKMapRectIsEmpty
UIKIT_STATIC_INLINE BOOL BMKMapRectIsEmpty(BMKMapRect rect)
Definition: BMKGeometry.h:185
BMKCoordTrans
UIKIT_EXTERN CLLocationCoordinate2D BMKCoordTrans(CLLocationCoordinate2D coordinate, BMK_COORD_TYPE fromType, BMK_COORD_TYPE toType)
BMKConvertBaiduCoorFrom
FOUNDATION_EXTERN NSDictionary * BMKConvertBaiduCoorFrom(CLLocationCoordinate2D coordinate, BMK_COORD_TYPE type) __attribute__((deprecated("使用BMKCoordTrans方法代替")))
-[NSValue(BMKGeometryExtension) BMKMapPointValue]
BMKMapPoint BMKMapPointValue()
BMKMapRectIntersectsRect
UIKIT_EXTERN BOOL BMKMapRectIntersectsRect(BMKMapRect rect1, BMKMapRect rect2)
BMKMapSize
矩形大小，用直角地理坐标表示
Definition: BMKTypes.h:291
NSValue(BMKGeometryExtension)
地图中c结构体对象和NSValue对象间相互转化
Definition: BMKGeometry.h:414
BMKGetDistanceFromPointToLine
UIKIT_EXTERN CLLocationDistance BMKGetDistanceFromPointToLine(BMKMapPoint point, BMKMapPoint lineStartPt, BMKMapPoint lineEndPt)