iOS高德轻量版地图SDK  1.2.0
MAGeometry.h
Go to the documentation of this file.
1 //
2 // MAGeometry.h
3 // MAMapKit
4 //
5 // Created by AutoNavi.
6 // Copyright (c) 2013年 Amap. All rights reserved.
7 //
8 
9 #import <CoreGraphics/CoreGraphics.h>
10 #import <CoreLocation/CoreLocation.h>
11 #import <UIKit/UIKit.h>
12 
13 
14 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
19  typedef struct MACoordinateBounds{
20  CLLocationCoordinate2D northEast;
21  CLLocationCoordinate2D southWest;
23 
25  typedef struct MACoordinateSpan{
26  CLLocationDegrees latitudeDelta;
27  CLLocationDegrees longitudeDelta;
29 
31  typedef struct MACoordinateRegion{
32  CLLocationCoordinate2D center;
35 
37  typedef struct MAMapPoint{
38  double x;
39  double y;
41 
43  typedef struct MAMapSize{
44  double width;
45  double height;
47 
49  typedef struct MAMapRect{
53 
54  typedef NS_OPTIONS(NSUInteger, MAMapRectCorner) {
55  MAMapRectCornerTopLeft = 1 << 0,
56  MAMapRectCornerTopRight = 1 << 1,
57  MAMapRectCornerBottomLeft = 1 << 2,
58  MAMapRectCornerBottomRight = 1 << 3,
59  MAMapRectCornerAllCorners = ~0UL
60  };
61 
63  typedef double MAZoomScale;
64 
66  extern const MAMapSize MAMapSizeWorld;
68  extern const MAMapRect MAMapRectWorld;
70  extern const MAMapRect MAMapRectNull;
72  extern const MAMapRect MAMapRectZero;
73 
74  static inline MACoordinateBounds MACoordinateBoundsMake(CLLocationCoordinate2D northEast,CLLocationCoordinate2D southWest)
75  {
76  return (MACoordinateBounds){northEast, southWest};
77  }
78 
79  static inline MACoordinateSpan MACoordinateSpanMake(CLLocationDegrees latitudeDelta, CLLocationDegrees longitudeDelta)
80  {
81  return (MACoordinateSpan){latitudeDelta, longitudeDelta};
82  }
83 
84  static inline MACoordinateRegion MACoordinateRegionMake(CLLocationCoordinate2D centerCoordinate, MACoordinateSpan span)
85  {
86  return (MACoordinateRegion){centerCoordinate, span};
87  }
88 
96  extern MACoordinateRegion MACoordinateRegionMakeWithDistance(CLLocationCoordinate2D centerCoordinate, CLLocationDistance latitudinalMeters, CLLocationDistance longitudinalMeters);
97 
103  extern MAMapPoint MAMapPointForCoordinate(CLLocationCoordinate2D coordinate);
104 
110  extern CLLocationCoordinate2D MACoordinateForMapPoint(MAMapPoint mapPoint);
111 
118 
125 
131  extern CLLocationDistance MAMetersPerMapPointAtLatitude(CLLocationDegrees latitude);
132 
138  extern double MAMapPointsPerMeterAtLatitude(CLLocationDegrees latitude);
139 
146  extern CLLocationDistance MAMetersBetweenMapPoints(MAMapPoint a, MAMapPoint b);
147 
154  extern double MAAreaBetweenCoordinates(CLLocationCoordinate2D northEast, CLLocationCoordinate2D southWest);
155 
163  extern MAMapRect MAMapRectInset(MAMapRect rect, double dx, double dy);
164 
172 
179  extern BOOL MAMapSizeContainsSize(MAMapSize size1, MAMapSize size2);
180 
187  extern BOOL MAMapRectContainsPoint(MAMapRect rect, MAMapPoint point);
188 
195  extern BOOL MAMapRectIntersectsRect(MAMapRect rect1, MAMapRect rect2);
196 
203  extern BOOL MAMapRectContainsRect(MAMapRect rect1, MAMapRect rect2);
204 
212  extern BOOL MACircleContainsPoint(MAMapPoint point, MAMapPoint center, double radius);
213 
221  extern BOOL MACircleContainsCoordinate(CLLocationCoordinate2D point, CLLocationCoordinate2D center, double radius);
222 
230  extern MAMapPoint MAGetNearestMapPointFromPolyline(MAMapPoint point, MAMapPoint *polyline, NSUInteger count);
231 
239  extern BOOL MAPolygonContainsPoint(MAMapPoint point, MAMapPoint *polygon, NSUInteger count);
240 
248  extern BOOL MAPolygonContainsCoordinate(CLLocationCoordinate2D point, CLLocationCoordinate2D *polygon, NSUInteger count);
249 
258 
268  typedef void (^AMapTileProjectionBlock)(int offsetX, int offsetY, int minX, int maxX, int minY, int maxY);
269 
276  extern void MAGetTileProjectionFromBounds(MACoordinateBounds bounds, int levelOfDetails, AMapTileProjectionBlock tileProjection);
277 
284  extern double MAAreaForPolygon(CLLocationCoordinate2D *coordinates, int count);
285 
286  static inline MAMapPoint MAMapPointMake(double x, double y)
287  {
288  return (MAMapPoint){x, y};
289  }
290 
291  static inline MAMapSize MAMapSizeMake(double width, double height)
292  {
293  return (MAMapSize){width, height};
294  }
295 
296  static inline MAMapRect MAMapRectMake(double x, double y, double width, double height)
297  {
298  return (MAMapRect){MAMapPointMake(x, y), MAMapSizeMake(width, height)};
299  }
300 
301  static inline double MAMapRectGetMinX(MAMapRect rect)
302  {
303  return rect.origin.x;
304  }
305 
306  static inline double MAMapRectGetMinY(MAMapRect rect)
307  {
308  return rect.origin.y;
309  }
310 
311  static inline double MAMapRectGetMidX(MAMapRect rect)
312  {
313  return rect.origin.x + rect.size.width / 2.0;
314  }
315 
316  static inline double MAMapRectGetMidY(MAMapRect rect)
317  {
318  return rect.origin.y + rect.size.height / 2.0;
319  }
320 
321  static inline double MAMapRectGetMaxX(MAMapRect rect)
322  {
323  return rect.origin.x + rect.size.width;
324  }
325 
326  static inline double MAMapRectGetMaxY(MAMapRect rect)
327  {
328  return rect.origin.y + rect.size.height;
329  }
330 
331  static inline double MAMapRectGetWidth(MAMapRect rect)
332  {
333  return rect.size.width;
334  }
335 
336  static inline double MAMapRectGetHeight(MAMapRect rect)
337  {
338  return rect.size.height;
339  }
340 
341  static inline BOOL MAMapPointEqualToPoint(MAMapPoint point1, MAMapPoint point2) {
342  return point1.x == point2.x && point1.y == point2.y;
343  }
344 
345  static inline BOOL MAMapSizeEqualToSize(MAMapSize size1, MAMapSize size2) {
346  return size1.width == size2.width && size1.height == size2.height;
347  }
348 
349  static inline BOOL MAMapRectEqualToRect(MAMapRect rect1, MAMapRect rect2) {
350  return
351  MAMapPointEqualToPoint(rect1.origin, rect2.origin) &&
352  MAMapSizeEqualToSize(rect1.size, rect2.size);
353  }
354 
355  static inline BOOL MAMapRectIsNull(MAMapRect rect) {
356  return isinf(rect.origin.x) || isinf(rect.origin.y);
357  }
358 
359  static inline BOOL MAMapRectIsEmpty(MAMapRect rect) {
360  return MAMapRectIsNull(rect) || (rect.size.width == 0.0 && rect.size.height == 0.0);
361  }
362 
363  static inline NSString *MAStringFromMapPoint(MAMapPoint point) {
364  return [NSString stringWithFormat:@"{%.1f, %.1f}", point.x, point.y];
365  }
366 
367  static inline NSString *MAStringFromMapSize(MAMapSize size) {
368  return [NSString stringWithFormat:@"{%.1f, %.1f}", size.width, size.height];
369  }
370 
371  static inline NSString *MAStringFromMapRect(MAMapRect rect) {
372  return [NSString stringWithFormat:@"{%@, %@}", MAStringFromMapPoint(rect.origin), MAStringFromMapSize(rect.size)];
373  }
374 
376  typedef NS_ENUM(NSUInteger, MACoordinateType)
377  {
378  MACoordinateTypeBaidu = 0,
379  MACoordinateTypeMapBar,
380  MACoordinateTypeMapABC,
381  MACoordinateTypeSoSoMap,
382  MACoordinateTypeAliYun,
383  MACoordinateTypeGoogle,
384  MACoordinateTypeGPS,
385  };
386 
393  extern CLLocationCoordinate2D MACoordinateConvert(CLLocationCoordinate2D coordinate, MACoordinateType type) __attribute((deprecated("已废弃,使用AMapFoundation中关于坐标转换的接口")));
394 
401  extern CLLocationDirection MAGetDirectionFromCoords(CLLocationCoordinate2D fromCoord, CLLocationCoordinate2D toCoord);
402 
409  extern CLLocationDirection MAGetDirectionFromPoints(MAMapPoint fromPoint, MAMapPoint toPoint);
410 
418  extern double MAGetDistanceFromPointToLine(MAMapPoint point, MAMapPoint lineBegin, MAMapPoint lineEnd);
419 
428  extern BOOL MAPolylineHitTest(MAMapPoint *linePoints, NSUInteger count, MAMapPoint tappedPoint, CGFloat lineWidth);
429 
430 #ifdef __cplusplus
431 }
432 #endif
433 
436 
442 + (NSValue *)valueWithMAMapPoint:(MAMapPoint)mapPoint;
443 
449 + (NSValue *)valueWithMAMapSize:(MAMapSize)mapSize;
450 
456 + (NSValue *)valueWithMAMapRect:(MAMapRect)mapRect;
457 
463 + (NSValue *)valueWithMACoordinate:(CLLocationCoordinate2D)coordinate;
464 
470 
476 
482 
487 - (CLLocationCoordinate2D)MACoordinateValue;
488 
489 @end
MAGetDirectionFromCoords
CLLocationDirection MAGetDirectionFromCoords(CLLocationCoordinate2D fromCoord, CLLocationCoordinate2D toCoord)
获取矢量坐标方向
MAMapSize
平面投影大小结构定义
Definition: MAGeometry.h:43
MACoordinateBounds
struct MACoordinateBounds MACoordinateBounds
东北、西南两个点定义的四边形经纬度范围
MACoordinateRegion::center
CLLocationCoordinate2D center
中心点经纬度
Definition: MAGeometry.h:32
MACoordinateSpan::latitudeDelta
CLLocationDegrees latitudeDelta
纬度跨度
Definition: MAGeometry.h:26
MAMapRectInset
MAMapRect MAMapRectInset(MAMapRect rect, double dx, double dy)
获取Inset后的MAMapRect
MAGetTileProjectionFromBounds
void MAGetTileProjectionFromBounds(MACoordinateBounds bounds, int levelOfDetails, AMapTileProjectionBlock tileProjection)
根据所给经纬度区域获取墨卡托投影切块信息
MAGetNearestMapPointFromLine
MAMapPoint MAGetNearestMapPointFromLine(MAMapPoint lineStart, MAMapPoint lineEnd, MAMapPoint point)
取在lineStart和lineEnd组成的线段上距离point距离最近的点
MAMapRectContainsRect
BOOL MAMapRectContainsRect(MAMapRect rect1, MAMapRect rect2)
判断矩形rect1是否包含矩形rect2
NS_OPTIONS
typedef NS_OPTIONS(NSUInteger, MAMapRectCorner)
Definition: MAGeometry.h:54
MAMapPoint
struct MAMapPoint MAMapPoint
平面投影坐标结构定义
MACoordinateConvert
CLLocationCoordinate2D MACoordinateConvert(CLLocationCoordinate2D coordinate, MACoordinateType type) __attribute((deprecated("已废弃,使用AMapFoundation中关于坐标转换的接口")))
转换目标经纬度为高德坐标系
AMapTileProjectionBlock
void(^ AMapTileProjectionBlock)(int offsetX, int offsetY, int minX, int maxX, int minY, int maxY)
获取墨卡托投影切块回调block,如果是无效的映射,则返回(-1, -1, 0, 0, 0, 0)
Definition: MAGeometry.h:268
-[NSValue(NSValueMAGeometryExtensions) MAMapRectValue]
MAMapRect MAMapRectValue()
返回NSValue对象包含的MAMapRect结构体对象
NSValue(NSValueMAGeometryExtensions)
utils方法,方便c结构体对象和NSValue对象间相互转化
Definition: MAGeometry.h:435
MACoordinateSpan
经度、纬度定义的经纬度跨度范围
Definition: MAGeometry.h:25
MAMapRectUnion
MAMapRect MAMapRectUnion(MAMapRect rect1, MAMapRect rect2)
合并两个MAMapRect
MAMapRectContainsPoint
BOOL MAMapRectContainsPoint(MAMapRect rect, MAMapPoint point)
判断点是否在矩形内
MACircleContainsCoordinate
BOOL MACircleContainsCoordinate(CLLocationCoordinate2D point, CLLocationCoordinate2D center, double radius)
判断经纬度点是否在圆内
MAMapPointsPerMeterAtLatitude
double MAMapPointsPerMeterAtLatitude(CLLocationDegrees latitude)
1米对应的投影
MAAreaBetweenCoordinates
double MAAreaBetweenCoordinates(CLLocationCoordinate2D northEast, CLLocationCoordinate2D southWest)
经纬度间的面积(单位 平方米)
MAMapRect
struct MAMapRect MAMapRect
平面投影矩形结构定义
MACoordinateSpan
struct MACoordinateSpan MACoordinateSpan
经度、纬度定义的经纬度跨度范围
MACoordinateBounds
东北、西南两个点定义的四边形经纬度范围
Definition: MAGeometry.h:19
MAMapSize::height
double height
高度
Definition: MAGeometry.h:45
-[NSValue(NSValueMAGeometryExtensions) MAMapSizeValue]
MAMapSize MAMapSizeValue()
返回NSValue对象包含的MAMapSize结构体对象
MAMapRect
平面投影矩形结构定义
Definition: MAGeometry.h:49
MAMapPoint::x
double x
x坐标
Definition: MAGeometry.h:38
MAMapPoint::y
double y
y坐标
Definition: MAGeometry.h:39
MACoordinateBounds::southWest
CLLocationCoordinate2D southWest
西南角经纬度
Definition: MAGeometry.h:21
MAPolygonContainsPoint
BOOL MAPolygonContainsPoint(MAMapPoint point, MAMapPoint *polygon, NSUInteger count)
判断点是否在多边形内
MAMapRectNull
const MAMapRect MAMapRectNull
(MAMapRect){{INFINITY, INFINITY}, {0, 0}};
MACoordinateBounds::northEast
CLLocationCoordinate2D northEast
东北角经纬度
Definition: MAGeometry.h:20
MAPolylineHitTest
BOOL MAPolylineHitTest(MAMapPoint *linePoints, NSUInteger count, MAMapPoint tappedPoint, CGFloat lineWidth)
判断线是否被点击选中
MACoordinateRegionMakeWithDistance
MACoordinateRegion MACoordinateRegionMakeWithDistance(CLLocationCoordinate2D centerCoordinate, CLLocationDistance latitudinalMeters, CLLocationDistance longitudinalMeters)
生成一个新的MACoordinateRegion
MAMapSize::width
double width
宽度
Definition: MAGeometry.h:44
MAMapRect::size
MAMapSize size
大小
Definition: MAGeometry.h:51
MACoordinateRegion
struct MACoordinateRegion MACoordinateRegion
中心点、跨度范围定义的四边形经纬度范围
MACoordinateForMapPoint
CLLocationCoordinate2D MACoordinateForMapPoint(MAMapPoint mapPoint)
平面投影坐标转经纬度坐标
MAMapRect::origin
MAMapPoint origin
左上角坐标
Definition: MAGeometry.h:50
MAMapRectIntersectsRect
BOOL MAMapRectIntersectsRect(MAMapRect rect1, MAMapRect rect2)
判断两矩形是否相交
MACircleContainsPoint
BOOL MACircleContainsPoint(MAMapPoint point, MAMapPoint center, double radius)
判断点是否在圆内
MAMetersPerMapPointAtLatitude
CLLocationDistance MAMetersPerMapPointAtLatitude(CLLocationDegrees latitude)
单位投影的距离
MAPolygonContainsCoordinate
BOOL MAPolygonContainsCoordinate(CLLocationCoordinate2D point, CLLocationCoordinate2D *polygon, NSUInteger count)
判断经纬度点是否在多边形内
MAAreaForPolygon
double MAAreaForPolygon(CLLocationCoordinate2D *coordinates, int count)
计算多边形面积,点与点之间按顺序尾部相连, 第一个点与最后一个点相连
MAGetDistanceFromPointToLine
double MAGetDistanceFromPointToLine(MAMapPoint point, MAMapPoint lineBegin, MAMapPoint lineEnd)
获取点到线的垂直距离
MAMapPointForCoordinate
MAMapPoint MAMapPointForCoordinate(CLLocationCoordinate2D coordinate)
经纬度坐标转平面投影坐标
MAMapSizeWorld
const MAMapSize MAMapSizeWorld
世界范围大小
MAMapRectZero
const MAMapRect MAMapRectZero
(MAMapRect){{0, 0}, {0, 0}}
-[NSValue(NSValueMAGeometryExtensions) MAMapPointValue]
MAMapPoint MAMapPointValue()
返回NSValue对象包含的MAMapPoint结构体对象
MAZoomScale
double MAZoomScale
比例关系:MAZoomScale = Screen Point / MAMapPoint, 当MAZoomScale = 1时, 1 screen point = 1 MAMapPoint,...
Definition: MAGeometry.h:60
MAMapRectWorld
const MAMapRect MAMapRectWorld
世界范围四边形
MAMapRectForCoordinateRegion
MAMapRect MAMapRectForCoordinateRegion(MACoordinateRegion region)
region转平面投影矩形
MAMapSize
struct MAMapSize MAMapSize
平面投影大小结构定义
MACoordinateRegion
中心点、跨度范围定义的四边形经纬度范围
Definition: MAGeometry.h:31
MACoordinateRegionForMapRect
MACoordinateRegion MACoordinateRegionForMapRect(MAMapRect rect)
平面投影矩形转region
-[NSValue(NSValueMAGeometryExtensions) MACoordinateValue]
CLLocationCoordinate2D MACoordinateValue()
返回NSValue对象包含的CLLocationCoordinate2D结构体对象
MAGetNearestMapPointFromPolyline
MAMapPoint MAGetNearestMapPointFromPolyline(MAMapPoint point, MAMapPoint *polyline, NSUInteger count)
获取某坐标点距线上最近的坐标点
MACoordinateRegion::span
MACoordinateSpan span
跨度范围
Definition: MAGeometry.h:33
MAGetDirectionFromPoints
CLLocationDirection MAGetDirectionFromPoints(MAMapPoint fromPoint, MAMapPoint toPoint)
获取矢量坐标方向
NS_ENUM
typedef NS_ENUM(NSUInteger, MACoordinateType)
坐标系类型枚举
Definition: MAGeometry.h:376
MAMapSizeContainsSize
BOOL MAMapSizeContainsSize(MAMapSize size1, MAMapSize size2)
判断size1是否包含size2
MAMapPoint
平面投影坐标结构定义
Definition: MAGeometry.h:37
MACoordinateSpan::longitudeDelta
CLLocationDegrees longitudeDelta
经度跨度
Definition: MAGeometry.h:27
MAMetersBetweenMapPoints
CLLocationDistance MAMetersBetweenMapPoints(MAMapPoint a, MAMapPoint b)
投影两点之间的距离
© 2020 高德信息技术有限公司版权所有,保留所有权利。