GMSPath.h 3.7 KB

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