選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

ZXGeoParsedResult.m 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright 2012 ZXing authors
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import "ZXGeoParsedResult.h"
  17. #import "ZXParsedResultType.h"
  18. @implementation ZXGeoParsedResult
  19. - (id)initWithLatitude:(double)latitude longitude:(double)longitude altitude:(double)altitude query:(NSString *)query {
  20. if (self = [super initWithType:kParsedResultTypeGeo]) {
  21. _latitude = latitude;
  22. _longitude = longitude;
  23. _altitude = altitude;
  24. _query = query;
  25. }
  26. return self;
  27. }
  28. + (id)geoParsedResultWithLatitude:(double)latitude longitude:(double)longitude altitude:(double)altitude query:(NSString *)query {
  29. return [[self alloc] initWithLatitude:latitude longitude:longitude altitude:altitude query:query];
  30. }
  31. - (NSString *)geoURI {
  32. NSMutableString *result = [NSMutableString string];
  33. [result appendFormat:@"geo:%f,%f", self.latitude, self.longitude];
  34. if (self.altitude > 0) {
  35. [result appendFormat:@",%f", self.altitude];
  36. }
  37. if (self.query != nil) {
  38. [result appendFormat:@"?%@", self.query];
  39. }
  40. return result;
  41. }
  42. - (NSString *)displayResult {
  43. NSMutableString *result = [NSMutableString string];
  44. [result appendFormat:@"%f, %f", self.latitude, self.longitude];
  45. if (self.altitude > 0.0) {
  46. [result appendFormat:@", %f", self.altitude];
  47. [result appendString:@"m"];
  48. }
  49. if (self.query != nil) {
  50. [result appendFormat:@" (%@)", self.query];
  51. }
  52. return result;
  53. }
  54. @end