TencentMapSDK_iOS_3D_v6.8.0

载入中...
搜索中...
未找到
QGeometry.h
1//
2// QGeometry.h
3// QMapKit
4//
5// Created by tabsong on 17/5/16.
6// Copyright © 2017年 tencent. All rights reserved.
7//
8
9#import <UIKit/UIKit.h>
10#import <CoreLocation/CoreLocation.h>
11
12#ifdef __cplusplus
13 extern "C" {
14#endif
15
21 typedef struct
22 {
23 CLLocationDegrees latitudeDelta;
24 CLLocationDegrees longitudeDelta;
25 } QCoordinateSpan;
26
30 typedef struct
31 {
32 CLLocationCoordinate2D center;
33 QCoordinateSpan span;
34 } QCoordinateRegion;
35
44 static inline QCoordinateSpan QCoordinateSpanMake(CLLocationDegrees latitudeDelta, CLLocationDegrees longitudeDelta)
45 {
46 return (QCoordinateSpan){latitudeDelta, longitudeDelta};
47 }
48
57 static inline QCoordinateRegion QCoordinateRegionMake(CLLocationCoordinate2D centerCoordinate, QCoordinateSpan span)
58 {
59 return (QCoordinateRegion){centerCoordinate, span};
60 }
61
65 typedef struct {
66 CLLocationCoordinate2D northEast;
67 CLLocationCoordinate2D southWest;
68 } QCoordinateBounds;
69
73 typedef struct
74 {
75 double x;
76 double y;
77 } QMapPoint;
78
82 typedef struct
83 {
84 double width;
85 double height;
86 } QMapSize;
87
91 typedef struct
92 {
93 QMapPoint origin;
94 QMapSize size;
95 } QMapRect;
96
100 extern const QMapRect QMapRectNull;
101
110 static inline QMapPoint QMapPointMake(double x, double y)
111 {
112 return (QMapPoint){x, y};
113 }
114
123 static inline QMapSize QMapSizeMake(double width, double height)
124 {
125 return (QMapSize){width, height};
126 }
127
138 static inline QMapRect QMapRectMake(double x, double y, double width, double height)
139 {
140 return (QMapRect){QMapPointMake(x, y), QMapSizeMake(width, height)};
141 }
142
150 static inline double QMapRectGetMinX(QMapRect rect)
151 {
152 return rect.origin.x;
153 }
154
162 static inline double QMapRectGetMinY(QMapRect rect)
163 {
164 return rect.origin.y;
165 }
166
174 static inline double QMapRectGetMidX(QMapRect rect)
175 {
176 return rect.origin.x + rect.size.width / 2.0;
177 }
178
186 static inline double QMapRectGetMidY(QMapRect rect)
187 {
188 return rect.origin.y + rect.size.height / 2.0;
189 }
190
198 static inline double QMapRectGetMaxX(QMapRect rect)
199 {
200 return rect.origin.x + rect.size.width;
201 }
202
210 static inline double QMapRectGetMaxY(QMapRect rect)
211 {
212 return rect.origin.y + rect.size.height;
213 }
214
222 static inline double QMapRectGetWidth(QMapRect rect)
223 {
224 return rect.size.width;
225 }
226
234 static inline double QMapRectGetHeight(QMapRect rect)
235 {
236 return rect.size.height;
237 }
238
247 static inline BOOL QMapPointEqualToPoint(QMapPoint point1, QMapPoint point2)
248 {
249 return point1.x == point2.x && point1.y == point2.y;
250 }
251
260 static inline BOOL QMapSizeEqualToSize(QMapSize size1, QMapSize size2)
261 {
262 return size1.width == size2.width && size1.height == size2.height;
263 }
264
273 static inline BOOL QMapRectEqualToRect(QMapRect rect1, QMapRect rect2)
274 {
275 return
276 QMapPointEqualToPoint(rect1.origin, rect2.origin) &&
277 QMapSizeEqualToSize(rect1.size, rect2.size);
278 }
279
287 static inline BOOL QMapRectIsNull(QMapRect rect)
288 {
289 return QMapPointEqualToPoint(rect.origin, QMapRectNull.origin);
290 }
291
299 static inline BOOL QMapRectIsEmpty(QMapRect rect)
300 {
301 return QMapRectIsNull(rect) || (rect.size.width == 0.0 && rect.size.height == 0.0);
302 }
303
312 extern BOOL QMapRectContainsPoint(QMapRect rect, QMapPoint point);
313
322 extern QMapRect QMapRectUnionPoint(QMapRect rect, QMapPoint point);
323
332 extern QMapRect QMapRectUnion(QMapRect rect1, QMapRect rect2);
333
342 extern BOOL QMapRectIntersectsRect(QMapRect rect1, QMapRect rect2);
343
352 extern BOOL QMapRectContainsRect(QMapRect rect1, QMapRect rect2);
353
365 extern QMapRect QMapRectInset(QMapRect rect, double dx, double dy);
366
374 static inline NSString *QStringFromMapPoint(QMapPoint point)
375 {
376 return [NSString stringWithFormat:@"{%.1f, %.1f}", point.x, point.y];
377 }
378
386 static inline NSString *QStringFromMapSize(QMapSize size)
387 {
388 return [NSString stringWithFormat:@"{%.1f, %.1f}", size.width, size.height];
389 }
390
398 static inline NSString *QStringFromMapRect(QMapRect rect)
399 {
400 return [NSString stringWithFormat:@"{%@, %@}", QStringFromMapPoint(rect.origin), QStringFromMapSize(rect.size)];
401 }
402
403
411 extern QMapPoint QMapPointForCoordinate(CLLocationCoordinate2D coordinate);
412
420 extern CLLocationCoordinate2D QCoordinateForMapPoint(QMapPoint mapPoint);
421
429 extern QCoordinateRegion QCoordinateRegionForMapRect(QMapRect rect);
430
438 extern QMapRect QMapRectForCoordinateRegion(QCoordinateRegion region);
439
447 extern QMapRect QMapRectForCoordinateBounds(QCoordinateBounds bounds);
448
456 extern QCoordinateBounds QCoordinateBoundsForMapRect(QMapRect rect);
457
465 extern CLLocationDistance QMetersPerMapPointAtLatitude(CLLocationDegrees latitude);
466
474 extern double QMapPointsPerMeterAtLatitude(CLLocationDegrees latitude);
475
485 static inline QCoordinateRegion QCoordinateRegionMakeWithDistance(CLLocationCoordinate2D centerCoordinate, CLLocationDistance latitudinalMeters, CLLocationDistance longitudinalMeters)
486 {
487 QMapSize spanSize = QMapSizeMake(QMapPointsPerMeterAtLatitude(centerCoordinate.latitude) * latitudinalMeters, QMapPointsPerMeterAtLatitude(centerCoordinate.latitude) * longitudinalMeters);
488
489 QMapPoint center = QMapPointForCoordinate(centerCoordinate);
490 QMapPoint leftTop = QMapPointMake(center.x - spanSize.width / 2.0, center.y - spanSize.height / 2.0);
491 QMapPoint rightBottom = QMapPointMake(center.x + spanSize.width / 2.0, center.y + spanSize.height / 2.0);
492
493 CLLocationCoordinate2D leftTopCoordinate = QCoordinateForMapPoint(leftTop);
494 CLLocationCoordinate2D rightBottomCoordinate = QCoordinateForMapPoint(rightBottom);
495
496 return QCoordinateRegionMake(centerCoordinate,
497 QCoordinateSpanMake(fabs(leftTopCoordinate.latitude - rightBottomCoordinate.latitude),
498 fabs(leftTopCoordinate.longitude - rightBottomCoordinate.longitude)));
499 }
500
510 extern BOOL QPolygonContainsPoint(QMapPoint point, QMapPoint *polygon, NSUInteger count);
511
519 extern BOOL QPolygonContainsCoordinate(CLLocationCoordinate2D coordinate, CLLocationCoordinate2D *polygon, NSUInteger count);
520
528 extern BOOL QCircleContainsPoint(QMapPoint point, QMapPoint center, double radius);
529
537 extern BOOL QCircleContainsCoordinate(CLLocationCoordinate2D point, CLLocationCoordinate2D center, double radius);
538
552 extern BOOL QPolylineHitTestPoint(QMapPoint point, QMapPoint *polyline, NSUInteger count, double lineWidth);
553
567 extern BOOL QPolylineHitTestCoordinate(CLLocationCoordinate2D coordinate, CLLocationCoordinate2D *polyline, NSUInteger count, double lineWidth);
568
577 extern CLLocationDistance QMetersBetweenMapPoints(QMapPoint a, QMapPoint b);
578
587 extern CLLocationDistance QMetersBetweenCoordinates(CLLocationCoordinate2D a, CLLocationCoordinate2D b);
588
597 extern QMapRect QBoundingMapRectWithPoints(QMapPoint *points, NSUInteger count);
598
608 extern QMapRect QBoundingMapRectWithPointsAndCenter(QMapPoint *points, NSUInteger count, QMapPoint centerPoint);
609
618 extern QCoordinateRegion QBoundingCoordinateRegionWithCoordinates(CLLocationCoordinate2D *coordinates, NSUInteger count);
619
629 extern QCoordinateRegion QBoundingCoordinateRegionWithCoordinatesAndCenter(CLLocationCoordinate2D *coordinates, NSUInteger count, CLLocationCoordinate2D centerCoordinate);
630
636 extern QMapRect QWorldMapRect(void);
637
644 extern double QAreaForPolygon(CLLocationCoordinate2D *coordinates, int count);
645
649 @interface NSValue (NSValueQGeometryExtensions)
650
658 + (NSValue *)valueWithQMapPoint:(QMapPoint)mapPoint;
659
667 + (NSValue *)valueWithQMapSize:(QMapSize)mapSize;
668
676 + (NSValue *)valueWithQMapRect:(QMapRect)mapRect;
677
685 + (NSValue *)valueWithCoordinate:(CLLocationCoordinate2D)coordinate;
686
692 - (QMapPoint)QMapPointValue;
693
699 - (QMapSize)QMapSizeValue;
700
706 - (QMapRect)QMapRectValue;
707
713 - (CLLocationCoordinate2D)coordinateValue;
714
715 @end
716
717
718#ifdef __cplusplus
719}
720#endif
-[NSValue(NSValueQGeometryExtensions) coordinateValue]
CLLocationCoordinate2D coordinateValue()
将NSValue对象解析成CLLocationCoordinate2D类型的值
-[NSValue(NSValueQGeometryExtensions) QMapSizeValue]
QMapSize QMapSizeValue()
将NSValue对象解析成QMapSize类型的值
-[NSValue(NSValueQGeometryExtensions) QMapPointValue]
QMapPoint QMapPointValue()
将NSValue对象解析成QMapPoint类型的值
-[NSValue(NSValueQGeometryExtensions) QMapRectValue]
QMapRect QMapRectValue()
将NSValue对象解析成QMapRect类型的值
QCoordinateBounds
经纬度区域结构定义
定义 QGeometry.h:65
QCoordinateBounds::southWest
CLLocationCoordinate2D southWest
东北角点经纬度坐标
定义 QGeometry.h:67
QCoordinateRegion
定义了地图的某一部份的数据结构
定义 QGeometry.h:31
QCoordinateSpan
定义了以 CLLocationDegree 为单位的矩形
定义 QGeometry.h:22
QMapPoint
平面投影坐标结构定义
定义 QGeometry.h:74
QMapRect
平面投影矩形结构定义
定义 QGeometry.h:92
QMapSize
平面投影大小结构定义
定义 QGeometry.h:83