// // Created by Yohom Bao on 2019/11/22. // #import #import "CLLocationCoordinate2DHandler.h" extern NSMutableDictionary *STACK; extern NSMutableDictionary *HEAP; extern BOOL enableLog; void CLLocationCoordinate2DHandler(NSString *method, id rawArgs, FlutterResult methodResult) { if ([@"CLLocationCoordinate2D::get_latitude" isEqualToString:method]) { NSDictionary *args = (NSDictionary *) rawArgs; NSValue *dataValue = (NSValue *) args[@"__this__"]; if (dataValue != nil && (NSNull *) dataValue != [NSNull null]) { CLLocationCoordinate2D _structValue; [dataValue getValue:&_structValue]; methodResult(@(_structValue.latitude)); } else { methodResult([FlutterError errorWithCode:@"目标对象为null" message:@"目标对象为null" details:@"目标对象为null"]); } } else if ([@"CLLocationCoordinate2D::get_longitude" isEqualToString:method]) { NSDictionary *args = (NSDictionary *) rawArgs; NSValue *dataValue = (NSValue *) args[@"__this__"]; if (dataValue != nil && (NSNull *) dataValue != [NSNull null]) { CLLocationCoordinate2D _structValue; [dataValue getValue:&_structValue]; methodResult(@(_structValue.longitude)); } else { methodResult([FlutterError errorWithCode:@"目标对象为null" message:@"目标对象为null" details:@"目标对象为null"]); } } else if ([@"CLLocationCoordinate2D::get_latitude_batch" isEqualToString:method]) { NSArray *> *args = (NSArray *> *) rawArgs; NSMutableArray *result = [NSMutableArray arrayWithCapacity:args.count]; for (NSUInteger i = 0; i < args.count; i++) { NSValue *dataValue = (NSValue *) args[i][@"__this__"]; CLLocationCoordinate2D _structValue; [dataValue getValue:&_structValue]; [result addObject:@(_structValue.latitude)]; } methodResult(result); } else if ([@"CLLocationCoordinate2D::get_longitude_batch" isEqualToString:method]) { NSArray *> *args = (NSArray *> *) rawArgs; NSMutableArray *result = [NSMutableArray arrayWithCapacity:args.count]; for (NSUInteger i = 0; i < args.count; i++) { NSValue *dataValue = (NSValue *) args[i][@"__this__"]; CLLocationCoordinate2D _structValue; [dataValue getValue:&_structValue]; [result addObject:@(_structValue.longitude)]; } methodResult(result); } else if ([@"CLLocationCoordinate2D::createCLLocationCoordinate2D" isEqualToString:method]) { NSDictionary *args = (NSDictionary *) rawArgs; CLLocationDegrees latitude = [args[@"latitude"] doubleValue]; CLLocationDegrees longitude = [args[@"longitude"] doubleValue]; CLLocationCoordinate2D data = CLLocationCoordinate2DMake(latitude, longitude); NSValue *dataValue = [NSValue value:&data withObjCType:@encode(CLLocationCoordinate2D)]; methodResult(dataValue); } else if ([@"CLLocationCoordinate2D::create_batchCLLocationCoordinate2D" isEqualToString:method]) { NSDictionary *args = (NSDictionary *) rawArgs; NSArray *latitudeBatch = (NSArray *) args[@"latitude_batch"]; NSArray *longitudeBatch = (NSArray *) args[@"longitude_batch"]; NSMutableArray *resultBatch = [NSMutableArray arrayWithCapacity:latitudeBatch.count]; for (NSUInteger i = 0; i < latitudeBatch.count; i++) { CLLocationDegrees latitude = [latitudeBatch[i] doubleValue]; CLLocationDegrees longitude = [longitudeBatch[i] doubleValue]; CLLocationCoordinate2D data = CLLocationCoordinate2DMake(latitude, longitude); NSValue *dataValue = [NSValue value:&data withObjCType:@encode(CLLocationCoordinate2D)]; [resultBatch addObject:dataValue]; } methodResult(resultBatch); } else { methodResult(FlutterMethodNotImplemented); } }