forked from edisongz/IndoorMapScene
-
Notifications
You must be signed in to change notification settings - Fork 0
/
IndoorMapPath.m
56 lines (42 loc) · 1.38 KB
/
IndoorMapPath.m
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
//
// IndoorMapPath.m
// WisdomMallAPP
//
// Created by apple on 13-12-18.
// Copyright (c) 2013年 apple. All rights reserved.
//
#import "IndoorMapPath.h"
#import "Constants.h"
@implementation IndoorMapPath
@synthesize mapArea = _mapArea;
-(id)initWithPrimitives:(NSMutableArray *)primitives
areaLocation:(NSString *)areaLocation
{
self = [super init];
if(self != nil)
{
// set area id
CGFloat _offset_y = OFFSET_Y;
self.areaLocation = areaLocation;
// add points to bezier path
UIBezierPath *path = [UIBezierPath new];
if (primitives != nil) {
for (int i = 0; i < primitives.count; i++) {
MPoint *point = [primitives objectAtIndex:i];
if (i == 0) {
[path moveToPoint:CGPointMake((point.x - OFFSET_X) * RATIO, (MAP_HEIGHT - point.y) * RATIO + _offset_y)];
continue;
}
[path addLineToPoint:CGPointMake((point.x - OFFSET_X) * RATIO, (MAP_HEIGHT - point.y) * RATIO + _offset_y)];
}
[path closePath];
self.mapArea = path;
}
}
return self;
}
-(BOOL)isAreaSelected:(CGPoint)inPointTouch
{
return CGPathContainsPoint(self.mapArea.CGPath, NULL, inPointTouch, false);
}
@end