高德地图SDK(导航) V11.2.000
Loading...
Searching...
No Matches
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 "MAConfig.h"
10#import <CoreGraphics/CoreGraphics.h>
11#import <CoreLocation/CoreLocation.h>
12#import <UIKit/UIKit.h>
13
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
21 typedef struct MACoordinateBounds{
22 CLLocationCoordinate2D northEast;
23 CLLocationCoordinate2D southWest;
25
28 typedef struct MACoordinateSpan{
29 CLLocationDegrees latitudeDelta;
30 CLLocationDegrees longitudeDelta;
32
35 typedef struct MACoordinateRegion{
36 CLLocationCoordinate2D center;
39
42 typedef struct MAMapPoint{
43 double x;
44 double y;
46
49 typedef struct MAMapSize{
50 double width;
51 double height;
53
60
61 typedef NS_OPTIONS(NSUInteger, MAMapRectCorner) {
62 MAMapRectCornerTopLeft = 1 << 0,
63 MAMapRectCornerTopRight = 1 << 1,
64 MAMapRectCornerBottomLeft = 1 << 2,
65 MAMapRectCornerBottomRight = 1 << 3,
66 MAMapRectCornerAllCorners = ~0UL
67 };
68
71 typedef double MAZoomScale;
72
75 extern const MAMapSize MAMapSizeWorld;
78 extern const MAMapRect MAMapRectWorld;
80 extern const MAMapRect MAMapRectNull;
82 extern const MAMapRect MAMapRectZero;
83
84 static inline MACoordinateBounds MACoordinateBoundsMake(CLLocationCoordinate2D northEast,CLLocationCoordinate2D southWest)
85 {
86 return (MACoordinateBounds){northEast, southWest};
87 }
88
89 static inline MACoordinateSpan MACoordinateSpanMake(CLLocationDegrees latitudeDelta, CLLocationDegrees longitudeDelta)
90 {
91 return (MACoordinateSpan){latitudeDelta, longitudeDelta};
92 }
93
94 static inline MACoordinateRegion MACoordinateRegionMake(CLLocationCoordinate2D centerCoordinate, MACoordinateSpan span)
95 {
96 return (MACoordinateRegion){centerCoordinate, span};
97 }
98
111 extern MACoordinateRegion MACoordinateRegionMakeWithDistance(CLLocationCoordinate2D centerCoordinate, CLLocationDistance latitudinalMeters, CLLocationDistance longitudinalMeters);
112
121 extern MAMapPoint MAMapPointForCoordinate(CLLocationCoordinate2D coordinate);
122
131 extern CLLocationCoordinate2D MACoordinateForMapPoint(MAMapPoint mapPoint);
132
141
151
160 extern CLLocationDistance MAMetersPerMapPointAtLatitude(CLLocationDegrees latitude);
161
170 extern double MAMapPointsPerMeterAtLatitude(CLLocationDegrees latitude);
171
182 extern CLLocationDistance MAMetersBetweenMapPoints(MAMapPoint a, MAMapPoint b);
183
194 extern double MAAreaBetweenCoordinates(CLLocationCoordinate2D northEast, CLLocationCoordinate2D southWest);
195
206 extern MAMapRect MAMapRectInset(MAMapRect rect, double dx, double dy);
207
217
226 extern BOOL MAMapSizeContainsSize(MAMapSize size1, MAMapSize size2);
227
239
248 extern BOOL MAMapRectIntersectsRect(MAMapRect rect1, MAMapRect rect2);
249
258 extern BOOL MAMapRectContainsRect(MAMapRect rect1, MAMapRect rect2);
259
272 extern BOOL MACircleContainsPoint(MAMapPoint point, MAMapPoint center, double radius);
273
286 extern BOOL MACircleContainsCoordinate(CLLocationCoordinate2D point, CLLocationCoordinate2D center, double radius);
287
300 extern MAMapPoint MAGetNearestMapPointFromPolyline(MAMapPoint point, MAMapPoint *polyline, NSUInteger count);
301
314 extern BOOL MAPolygonContainsPoint(MAMapPoint point, MAMapPoint *polygon, NSUInteger count);
315
328 extern BOOL MAPolygonContainsCoordinate(CLLocationCoordinate2D point, CLLocationCoordinate2D *polygon, NSUInteger count);
329
343
360 typedef void (^AMapTileProjectionBlock)(int offsetX, int offsetY, int minX, int maxX, int minY, int maxY);
361
372 extern void MAGetTileProjectionFromBounds(MACoordinateBounds bounds, int levelOfDetails, AMapTileProjectionBlock tileProjection);
373
384 extern double MAAreaForPolygon(CLLocationCoordinate2D *coordinates, int count);
385
386 static inline MAMapPoint MAMapPointMake(double x, double y)
387 {
388 return (MAMapPoint){x, y};
389 }
390
391 static inline MAMapSize MAMapSizeMake(double width, double height)
392 {
393 return (MAMapSize){width, height};
394 }
395
396 static inline MAMapRect MAMapRectMake(double x, double y, double width, double height)
397 {
398 return (MAMapRect){MAMapPointMake(x, y), MAMapSizeMake(width, height)};
399 }
400
401 static inline double MAMapRectGetMinX(MAMapRect rect)
402 {
403 return rect.origin.x;
404 }
405
406 static inline double MAMapRectGetMinY(MAMapRect rect)
407 {
408 return rect.origin.y;
409 }
410
411 static inline double MAMapRectGetMidX(MAMapRect rect)
412 {
413 return rect.origin.x + rect.size.width / 2.0;
414 }
415
416 static inline double MAMapRectGetMidY(MAMapRect rect)
417 {
418 return rect.origin.y + rect.size.height / 2.0;
419 }
420
421 static inline double MAMapRectGetMaxX(MAMapRect rect)
422 {
423 return rect.origin.x + rect.size.width;
424 }
425
426 static inline double MAMapRectGetMaxY(MAMapRect rect)
427 {
428 return rect.origin.y + rect.size.height;
429 }
430
431 static inline double MAMapRectGetWidth(MAMapRect rect)
432 {
433 return rect.size.width;
434 }
435
436 static inline double MAMapRectGetHeight(MAMapRect rect)
437 {
438 return rect.size.height;
439 }
440
441 static inline BOOL MAMapPointEqualToPoint(MAMapPoint point1, MAMapPoint point2) {
442 return point1.x == point2.x && point1.y == point2.y;
443 }
444
445 static inline BOOL MAMapSizeEqualToSize(MAMapSize size1, MAMapSize size2) {
446 return size1.width == size2.width && size1.height == size2.height;
447 }
448
449 static inline BOOL MAMapRectEqualToRect(MAMapRect rect1, MAMapRect rect2) {
450 return
451 MAMapPointEqualToPoint(rect1.origin, rect2.origin) &&
452 MAMapSizeEqualToSize(rect1.size, rect2.size);
453 }
454
455 static inline BOOL MAMapRectIsNull(MAMapRect rect) {
456 return isinf(rect.origin.x) || isinf(rect.origin.y);
457 }
458
459 static inline BOOL MAMapRectIsEmpty(MAMapRect rect) {
460 return MAMapRectIsNull(rect) || (rect.size.width == 0.0 && rect.size.height == 0.0);
461 }
462
463 static inline NSString *MAStringFromMapPoint(MAMapPoint point) {
464 return [NSString stringWithFormat:@"{%.1f, %.1f}", point.x, point.y];
465 }
466
467 static inline NSString *MAStringFromMapSize(MAMapSize size) {
468 return [NSString stringWithFormat:@"{%.1f, %.1f}", size.width, size.height];
469 }
470
471 static inline NSString *MAStringFromMapRect(MAMapRect rect) {
472 return [NSString stringWithFormat:@"{%@, %@}", MAStringFromMapPoint(rect.origin), MAStringFromMapSize(rect.size)];
473 }
474
487
498 extern CLLocationCoordinate2D MACoordinateConvert(CLLocationCoordinate2D coordinate, MACoordinateType type) __attribute((deprecated("Deprecated, use the coordinate conversion interface in AMapFoundation")));
499
510 extern CLLocationDirection MAGetDirectionFromCoords(CLLocationCoordinate2D fromCoord, CLLocationCoordinate2D toCoord);
511
522 extern CLLocationDirection MAGetDirectionFromPoints(MAMapPoint fromPoint, MAMapPoint toPoint);
523
536 extern double MAGetDistanceFromPointToLine(MAMapPoint point, MAMapPoint lineBegin, MAMapPoint lineEnd);
537
552 extern BOOL MAPolylineHitTest(MAMapPoint *linePoints, NSUInteger count, MAMapPoint tappedPoint, CGFloat lineWidth);
553
554#ifdef __cplusplus
555}
556#endif
557
560@interface NSValue (NSValueMAGeometryExtensions)
561
570+ (NSValue *)valueWithMAMapPoint:(MAMapPoint)mapPoint;
571
580+ (NSValue *)valueWithMAMapSize:(MAMapSize)mapSize;
581
590+ (NSValue *)valueWithMAMapRect:(MAMapRect)mapRect;
591
600+ (NSValue *)valueWithMACoordinate:(CLLocationCoordinate2D)coordinate;
601
609
617
625
632- (CLLocationCoordinate2D)MACoordinateValue;
633
634@end
double MAMapPointsPerMeterAtLatitude(CLLocationDegrees latitude)
1米对应的投影 Projection corresponding to 1 meter
MAMapRect MAMapRectInset(MAMapRect rect, double dx, double dy)
获取Inset后的MAMapRect Get the MAMapRect after Inset
double MAZoomScale
Definition MAGeometry.h:71
const MAMapSize MAMapSizeWorld
CLLocationCoordinate2D MACoordinateConvert(CLLocationCoordinate2D coordinate, MACoordinateType type) __attribute((deprecated("Deprecated
转换目标经纬度为高德坐标系 Convert target coordinates to AutoNavi coordinate system
MAMapPoint MAMapPointForCoordinate(CLLocationCoordinate2D coordinate)
经纬度坐标转平面投影坐标 Convert latitude and longitude coordinates to planar projection coordinates
const MAMapRect MAMapRectWorld
BOOL MACircleContainsCoordinate(CLLocationCoordinate2D point, CLLocationCoordinate2D center, double radius)
判断经纬度点是否在圆内 Determine if a latitude and longitude point is within a circle
BOOL MAPolylineHitTest(MAMapPoint *linePoints, NSUInteger count, MAMapPoint tappedPoint, CGFloat lineWidth)
判断线是否被点击选中 Determine if the line is clicked and selected
void(^ AMapTileProjectionBlock)(int offsetX, int offsetY, int minX, int maxX, int minY, int maxY)
获取墨卡托投影切块回调block,如果是无效的映射,则返回(-1, -1, 0, 0, 0, 0) Get the Mercator projection tile callback block,...
Definition MAGeometry.h:360
MAMapPoint MAGetNearestMapPointFromPolyline(MAMapPoint point, MAMapPoint *polyline, NSUInteger count)
获取某坐标点距线上最近的坐标点 Get the nearest point on a line from a coordinate point
BOOL MACircleContainsPoint(MAMapPoint point, MAMapPoint center, double radius)
判断点是否在圆内 Determine if a point is inside a circle
MAMapPoint MAGetNearestMapPointFromLine(MAMapPoint lineStart, MAMapPoint lineEnd, MAMapPoint point)
取在lineStart和lineEnd组成的线段上距离point距离最近的点 Take the point on the line segment formed by lineStart and lin...
CLLocationDirection MAGetDirectionFromCoords(CLLocationCoordinate2D fromCoord, CLLocationCoordinate2D toCoord)
获取矢量坐标方向 Get vector coordinate direction
MAMapRect MAMapRectUnion(MAMapRect rect1, MAMapRect rect2)
合并两个MAMapRect Merge two MAMapRects
MAMapRect MAMapRectForCoordinateRegion(MACoordinateRegion region)
region转平面投影矩形 Region to planar projection rectangle
CLLocationCoordinate2D MACoordinateForMapPoint(MAMapPoint mapPoint)
平面投影坐标转经纬度坐标 Convert planar projection coordinates to latitude and longitude coordinates
void MAGetTileProjectionFromBounds(MACoordinateBounds bounds, int levelOfDetails, AMapTileProjectionBlock tileProjection)
根据所给经纬度区域获取墨卡托投影切块信息 Obtain Mercator projection tile information based on the given latitude and long...
BOOL MAPolygonContainsPoint(MAMapPoint point, MAMapPoint *polygon, NSUInteger count)
判断点是否在多边形内 Determine if a point is inside a polygon
BOOL MAMapSizeContainsSize(MAMapSize size1, MAMapSize size2)
判断size1是否包含size2 Determine if size1 contains size2
double MAAreaBetweenCoordinates(CLLocationCoordinate2D northEast, CLLocationCoordinate2D southWest)
经纬度间的面积(单位 平方米) Area between latitude and longitude (unit: square meters)
const MAMapRect MAMapRectZero
(MAMapRect){{0, 0}, {0, 0}}
const MAMapRect MAMapRectNull
(MAMapRect){{INFINITY, INFINITY}, {0, 0}};
typedef NS_OPTIONS(NSUInteger, MAMapRectCorner)
Definition MAGeometry.h:61
MACoordinateRegion MACoordinateRegionMakeWithDistance(CLLocationCoordinate2D centerCoordinate, CLLocationDistance latitudinalMeters, CLLocationDistance longitudinalMeters)
生成一个新的MACoordinateRegion Generate a new MACoordinateRegion
CLLocationDirection MAGetDirectionFromPoints(MAMapPoint fromPoint, MAMapPoint toPoint)
获取矢量坐标方向 Get vector coordinate direction
BOOL MAMapRectIntersectsRect(MAMapRect rect1, MAMapRect rect2)
判断两矩形是否相交 Determine if two rectangles intersect
double MAGetDistanceFromPointToLine(MAMapPoint point, MAMapPoint lineBegin, MAMapPoint lineEnd)
获取点到线的垂直距离 Get perpendicular distance from point to line
BOOL MAMapRectContainsRect(MAMapRect rect1, MAMapRect rect2)
判断矩形rect1是否包含矩形rect2 Determine if rectangle rect1 contains rectangle rect2
MACoordinateRegion MACoordinateRegionForMapRect(MAMapRect rect)
平面投影矩形转region Planar projection rectangle to region
CLLocationDistance MAMetersPerMapPointAtLatitude(CLLocationDegrees latitude)
单位投影的距离 Unit projection distance
BOOL MAMapRectContainsPoint(MAMapRect rect, MAMapPoint point)
判断点是否在矩形内 Determine if the point is inside the rectangle
MACoordinateType
Definition MAGeometry.h:478
@ MACoordinateTypeMapABC
MapABC.
Definition MAGeometry.h:481
@ MACoordinateTypeBaidu
Baidu.
Definition MAGeometry.h:479
@ MACoordinateTypeAliYun
AliYun.
Definition MAGeometry.h:483
@ MACoordinateTypeGoogle
Google.
Definition MAGeometry.h:484
@ MACoordinateTypeSoSoMap
SoSoMap.
Definition MAGeometry.h:482
@ MACoordinateTypeMapBar
MapBar.
Definition MAGeometry.h:480
@ MACoordinateTypeGPS
GPS.
Definition MAGeometry.h:485
BOOL MAPolygonContainsCoordinate(CLLocationCoordinate2D point, CLLocationCoordinate2D *polygon, NSUInteger count)
判断经纬度点是否在多边形内 Determine if a latitude and longitude point is inside a polygon
CLLocationDistance MAMetersBetweenMapPoints(MAMapPoint a, MAMapPoint b)
投影两点之间的距离 Distance between two projection points
double MAAreaForPolygon(CLLocationCoordinate2D *coordinates, int count)
计算多边形面积,点与点之间按顺序尾部相连, 第一个点与最后一个点相连 Calculate the area of a polygon, where points are connected sequen...
MAMapRect MAMapRectValue()
返回NSValue对象包含的MAMapRect结构体对象 Returns the MAMapRect structure contained in the NSValue object
MAMapPoint MAMapPointValue()
返回NSValue对象包含的MAMapPoint结构体对象 Returns the MAMapPoint structure contained in the NSValue object
MAMapSize MAMapSizeValue()
返回NSValue对象包含的MAMapSize结构体对象 Returns the MAMapSize structure contained in the NSValue object
CLLocationCoordinate2D MACoordinateValue()
返回NSValue对象包含的CLLocationCoordinate2D结构体对象 Returns the CLLocationCoordinate2D structure contained in t...
Definition MAGeometry.h:21
CLLocationCoordinate2D northEast
东北角经纬度 Latitude and longitude of the northeast corner
Definition MAGeometry.h:22
CLLocationCoordinate2D southWest
西南角经纬度 Latitude and longitude of the southwest corner
Definition MAGeometry.h:23
Definition MAGeometry.h:35
CLLocationCoordinate2D center
中心点经纬度 Center point latitude and longitude
Definition MAGeometry.h:36
MACoordinateSpan span
跨度范围 Span range
Definition MAGeometry.h:37
Definition MAGeometry.h:28
CLLocationDegrees latitudeDelta
纬度跨度 Latitude span
Definition MAGeometry.h:29
CLLocationDegrees longitudeDelta
经度跨度 Longitude span
Definition MAGeometry.h:30
Definition MAGeometry.h:42
double x
x坐标 x coordinate
Definition MAGeometry.h:43
double y
y坐标 y coordinate
Definition MAGeometry.h:44
Definition MAGeometry.h:56
MAMapPoint origin
左上角坐标 Top-left corner coordinates
Definition MAGeometry.h:57
MAMapSize size
大小 Size
Definition MAGeometry.h:58
Definition MAGeometry.h:49
double width
宽度 Width
Definition MAGeometry.h:50
double height
高度 Height
Definition MAGeometry.h:51
© 2017 高德信息技术有限公司 版权所有,保留所有权利。