-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapGeometryExternalProxy.m
More file actions
110 lines (95 loc) · 3.07 KB
/
Copy pathMapGeometryExternalProxy.m
File metadata and controls
110 lines (95 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
//
// MapGeometryExternalProxy.m
// MapClueCD
//
// Created by Gaige B. Paulsen on 12/29/19. See accompanying LICENSE document.
// Copyright 2019, ClueTrust.
//
#import "MapGeometryExternalProxy.h"
@implementation MapGeometryExternalProxy
- (instancetype)initWithMapGeometryArray:(NSArray<MapGeometry*>*)geometries
{
self = [super init];
if (self) {
_geometries = geometries;
}
return self;
}
+ (instancetype)mapGeometryExternalProxyWithMapGeometryArray:(NSArray<MapGeometry*>*)geometries;
{
return [[self alloc] initWithMapGeometryArray: geometries];
}
+(instancetype)mapGeometryExternalProxyWithMapGeometry:(MapGeometry *)geometry
{
return [[self alloc] initWithMapGeometryArray: @[geometry]];
}
- (void)pointCountOfGeometry:(NSUInteger)geometryIndex withReply:(void (^)(NSNumber *))reply
{
NSNumber *result = nil;
if (geometryIndex<_geometries.count)
result = @(_geometries[geometryIndex].pointCount);
reply(result);
}
- (void)partCountOfGeometry:(NSUInteger)geometryIndex withReply:(void (^)(NSNumber *))reply
{
NSNumber *result = nil;
if (geometryIndex<_geometries.count)
result = @(_geometries[geometryIndex].partCount);
reply(result);
}
- (void)areaOfGeometry:(NSUInteger)geometryIndex asBase:(BOOL)isBase withReply:(void (^)(NSNumber *))reply
{
NSNumber *result = nil;
if (geometryIndex<_geometries.count) {
if (isBase)
result = @(_geometries[geometryIndex].baseArea);
else
result = @(_geometries[geometryIndex].area);
}
reply(result);
}
- (void)boundingBoxOfGeometry:(NSUInteger)geometryIndex asBase:(BOOL)isBase withReply:(void (^)(NSValue *))reply
{
NSValue *result = nil;
if (geometryIndex<_geometries.count) {
if (_geometries[geometryIndex].pointCount>0) {
if (isBase)
result = @(_geometries[geometryIndex].baseBoundingBox);
else
result = @(_geometries[geometryIndex].boundingBox);
}
}
reply(result);
}
- (void)centroidOfGeometry:(NSUInteger)geometryIndex asBase:(BOOL)isBase withReply:(void (^)(NSValue *))reply
{
NSValue *result = nil;
if (geometryIndex<_geometries.count) {
if (isBase)
result = @(_geometries[geometryIndex].baseCentroid);
else
result = @(_geometries[geometryIndex].centroid);
}
reply(result);
}
- (void)distanceOfGeometry:(NSUInteger)geometryIndex asBase:(BOOL)isBase withReply:(void (^)(NSNumber *))reply
{
NSNumber *result = nil;
if (geometryIndex<_geometries.count) {
if (isBase) {
result = @([_geometries[geometryIndex] baseDistanceWithSegmentLengths: NULL]);
} else {
result = @([_geometries[geometryIndex] projectedDistanceWithSegmentLengths: NULL]);
}
}
reply(result);
}
- (void)midpointOfGeometry:(NSUInteger)geometryIndex asBase:(BOOL)isBase withReply:(void (^)(NSValue *))reply
{
NSValue *result = nil;
if (geometryIndex<_geometries.count) {
// midpoint inappropriate for rectangle (only lines)
}
reply(result);
}
@end