Skip to content

Commit 0b8f271

Browse files
Support empty GeoPoint (#318)
1 parent c52451f commit 0b8f271

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/geo-point.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export class GeoPoint implements Serializable {
5050
* `${data.google.longitude}`);
5151
* });
5252
*/
53-
constructor(latitude, longitude) {
53+
constructor(latitude: number, longitude: number) {
5454
validate.isNumber('latitude', latitude, -90, 90);
5555
validate.isNumber('longitude', longitude, -180, 180);
5656

@@ -65,7 +65,7 @@ export class GeoPoint implements Serializable {
6565
* @name GeoPoint#latitude
6666
* @readonly
6767
*/
68-
get latitude() {
68+
get latitude(): number {
6969
return this._latitude;
7070
}
7171

@@ -76,7 +76,7 @@ export class GeoPoint implements Serializable {
7676
* @name GeoPoint#longitude
7777
* @readonly
7878
*/
79-
get longitude() {
79+
get longitude(): number {
8080
return this._longitude;
8181
}
8282

@@ -121,6 +121,6 @@ export class GeoPoint implements Serializable {
121121
* @private
122122
*/
123123
static fromProto(proto: google.type.ILatLng): GeoPoint {
124-
return new GeoPoint(proto.latitude, proto.longitude);
124+
return new GeoPoint(proto.latitude || 0, proto.longitude || 0);
125125
}
126126
}

system-test/firestore.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,11 +170,13 @@ describe('DocumentReference class', function() {
170170
objectValue: {foo: 'bar', '😀': '😜'},
171171
emptyObject: {},
172172
dateValue: new Firestore.Timestamp(479978400, 123000000),
173+
zeroDateValue: new Firestore.Timestamp(0, 0),
173174
pathValue: firestore.doc('col1/ref1'),
174175
arrayValue: ['foo', 42, 'bar'],
175176
emptyArray: [],
176177
nilValue: null,
177178
geoPointValue: new Firestore.GeoPoint(50.1430847, -122.947778),
179+
zeroGeoPointValue: new Firestore.GeoPoint(0, 0),
178180
bytesValue: Buffer.from([0x01, 0x02]),
179181
};
180182
let ref = randomCol.doc('doc');

0 commit comments

Comments
 (0)