geo-point.d.ts 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*!
  2. * Copyright 2018 Google Inc. All Rights Reserved.
  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 * as firestore from '@google-cloud/firestore';
  17. import { google } from '../protos/firestore_v1_proto_api';
  18. import { Serializable } from './serializer';
  19. import api = google.firestore.v1;
  20. /**
  21. * An immutable object representing a geographic location in Firestore. The
  22. * location is represented as a latitude/longitude pair.
  23. *
  24. * @class
  25. */
  26. export declare class GeoPoint implements Serializable, firestore.GeoPoint {
  27. private readonly _latitude;
  28. private readonly _longitude;
  29. /**
  30. * Creates a [GeoPoint]{@link GeoPoint}.
  31. *
  32. * @param {number} latitude The latitude as a number between -90 and 90.
  33. * @param {number} longitude The longitude as a number between -180 and 180.
  34. *
  35. * @example
  36. * ```
  37. * let data = {
  38. * google: new Firestore.GeoPoint(37.422, 122.084)
  39. * };
  40. *
  41. * firestore.doc('col/doc').set(data).then(() => {
  42. * console.log(`Location is ${data.google.latitude}, ` +
  43. * `${data.google.longitude}`);
  44. * });
  45. * ```
  46. */
  47. constructor(latitude: number, longitude: number);
  48. /**
  49. * The latitude as a number between -90 and 90.
  50. *
  51. * @type {number}
  52. * @name GeoPoint#latitude
  53. * @readonly
  54. */
  55. get latitude(): number;
  56. /**
  57. * The longitude as a number between -180 and 180.
  58. *
  59. * @type {number}
  60. * @name GeoPoint#longitude
  61. * @readonly
  62. */
  63. get longitude(): number;
  64. /**
  65. * Returns true if this `GeoPoint` is equal to the provided value.
  66. *
  67. * @param {*} other The value to compare against.
  68. * @return {boolean} true if this `GeoPoint` is equal to the provided value.
  69. */
  70. isEqual(other: firestore.GeoPoint): boolean;
  71. /**
  72. * Converts the GeoPoint to a google.type.LatLng proto.
  73. * @private
  74. * @internal
  75. */
  76. toProto(): api.IValue;
  77. /**
  78. * Converts a google.type.LatLng proto to its GeoPoint representation.
  79. * @private
  80. * @internal
  81. */
  82. static fromProto(proto: google.type.ILatLng): GeoPoint;
  83. }