GMSPath.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. //
  2. // GMSPath.h
  3. // Google Maps SDK for iOS
  4. //
  5. // Copyright 2013 Google Inc.
  6. //
  7. // Usage of this SDK is subject to the Google Maps/Google Earth APIs Terms of
  8. // Service: https://developers.google.com/maps/terms
  9. //
  10. #import <CoreLocation/CoreLocation.h>
  11. /**
  12. * GMSPath encapsulates an immutable array of CLLocationCooordinate2D. All the coordinates of a
  13. * GMSPath must be valid. The mutable counterpart is GMSMutablePath.
  14. */
  15. @interface GMSPath : NSObject <NSCopying, NSMutableCopying>
  16. /** Convenience constructor for an empty path. */
  17. + (instancetype)path;
  18. /** Initializes a newly allocated path with the contents of another GMSPath. */
  19. - (id)initWithPath:(GMSPath *)path;
  20. /** Get size of path. */
  21. - (NSUInteger)count;
  22. /** Returns kCLLocationCoordinate2DInvalid if |index| >= count. */
  23. - (CLLocationCoordinate2D)coordinateAtIndex:(NSUInteger)index;
  24. /**
  25. * Initializes a newly allocated path from |encodedPath|. This format is described at:
  26. * https://developers.google.com/maps/documentation/utilities/polylinealgorithm
  27. */
  28. + (instancetype)pathFromEncodedPath:(NSString *)encodedPath;
  29. /** Returns an encoded string of the path in the format described above. */
  30. - (NSString *)encodedPath;
  31. /**
  32. * Returns a new path obtained by adding |deltaLatitude| and |deltaLongitude| to each coordinate
  33. * of the current path. Does not modify the current path.
  34. */
  35. - (instancetype)pathOffsetByLatitude:(CLLocationDegrees)deltaLatitude
  36. longitude:(CLLocationDegrees)deltaLongitude;
  37. @end
  38. /**
  39. * kGMSEquatorProjectedMeter may be useful when specifying lengths for segment in "projected" units.
  40. * The value of kGMSEquatorProjectedMeter, 1/(pi * EarthRadius), represents the length of one meter
  41. * at the equator in projected units. For example to specify a projected length that corresponds
  42. * to 100km at the equator use 100000 * kGMSEquatorProjectedMeter.
  43. * See [GMSPath segmentsForLength:kind:], [GMSPath lengthOfKind:] and kGMSLengthProjected.
  44. */
  45. extern const double kGMSEquatorProjectedMeter;
  46. /**
  47. * GMSLengthKind indicates the type of a length value, which can be geodesic (in meters), rhumb
  48. * length (in meters) and projected length (in GMSMapPoint units).
  49. */
  50. typedef enum {
  51. /*
  52. * Geodesic length, in meters, along geodesic segments. May be useful, for example, to specify
  53. * lengths along the the trajectory of airplanes or ships.
  54. */
  55. kGMSLengthGeodesic,
  56. /*
  57. * Rhumb length, in meters, along rhumb (straight line) segments. May be useful, for example, to
  58. * draw a scale bar on a map. The visual size of a segment of a given length depens on the
  59. * latitude.
  60. */
  61. kGMSLengthRhumb,
  62. /*
  63. * Length in projected space, along rhumb segments. Projected length uses the same units as
  64. * GMSMapPoint - the Earth equator circumference has length 2. It is possible to specify projected
  65. * length in units corresponding to 1 meter at the equator by multiplying with
  66. * kGMSEquatorProjectedMeter, equal to 1/(pi * EarthRadius).
  67. *
  68. * Projected length may be useful, for example, to specify segments with the same visual length
  69. * regardless of latitude.
  70. */
  71. kGMSLengthProjected
  72. } GMSLengthKind;
  73. @interface GMSPath (GMSPathLength)
  74. /**
  75. * Returns the fractional number of segments along the path that correspond to |length|,
  76. * interpreted according to |kind|. See GMSLengthKind.
  77. */
  78. - (double)segmentsForLength:(CLLocationDistance)length kind:(GMSLengthKind)kind;
  79. /**
  80. * Returns the length of the path, according to |kind|. See GMSLengthKind.
  81. */
  82. - (CLLocationDistance)lengthOfKind:(GMSLengthKind)kind;
  83. @end