//
//  ApplyModel.m
//  gaotingshan
//
//  Created by MacBook Dq01 on 16/3/30.
//  Copyright © 2016年 Mac Book DQ02. All rights reserved.
//

#import "ApplyModel.h"

@implementation ApplyModel

- (id)initWithInforDic:(NSDictionary *)inforDic {
    if (self = [super init]) {
        [self setValuesForKeysWithDictionary:inforDic];

        //如果是官方赛事，要把中继点的物理线路线先计算出来
        if ([[inforDic objectForKey:@"eventType"] intValue] ==0 || [[inforDic objectForKey:@"eventType"] intValue] ==1) {
            
            NSArray *repeaterStr = inforDic[@"repeaterAxisList"];
//            NSData *repeaterD = [[NSData alloc] initWithData:[repeaterStr dataUsingEncoding:NSUTF8StringEncoding]];
//            NSArray *repeaterArr = [NSJSONSerialization JSONObjectWithData:repeaterD options:NSJSONReadingMutableLeaves error:nil];
            NSMutableArray *pointA = [NSMutableArray array];
            
            for (NSString *innerStr in repeaterStr) {
                NSData *innerData = [[NSData alloc] initWithData:[innerStr dataUsingEncoding:NSUTF8StringEncoding]];
                NSDictionary *innerDic = [NSJSONSerialization JSONObjectWithData:innerData options:NSJSONReadingMutableLeaves error:nil];
                AGSPoint *point = [[AGSPoint alloc]initWithX:[[innerDic objectForKey:@"axisX"] doubleValue]  y:[[innerDic objectForKey:@"axisY"] doubleValue] spatialReference:[AGSSpatialReference wgs84SpatialReference]];
                [pointA addObject:point];
               
            }
            
            AGSGraphic *gra = [[[FMDataBaseTool alloc]init] graphicWithPointArr:pointA];
            self.evStart = [FMDataBaseTool getMarkSymGraphic:[pointA firstObject] type:1];
            self.evEnd = [FMDataBaseTool getMarkSymGraphic:[pointA lastObject] type:2];
        
            self.officalRG = gra;
        }
        
    }
    return self;
}



#pragma mark - KVC
//使用KVC赋值, 没有找到对应的key
- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
//    NSLog(@"不能识别%@", key);
    //字典中是id，属性中是ID
//    if ([key isEqualToString:@"id"]) {
//        self.ID = value;
//    }
}

//使用KVC取值, 没有找到对应的key
- (id)valueForUndefinedKey:(NSString *)key {
//    NSLog(@"不能识别%@", key);
    return nil;
}


@end
