Skip to content

Support empty GeoPoint #318

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/geo-point.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class GeoPoint implements Serializable {
* `${data.google.longitude}`);
* });
*/
constructor(latitude, longitude) {
constructor(latitude: number, longitude: number) {
validate.isNumber('latitude', latitude, -90, 90);
validate.isNumber('longitude', longitude, -180, 180);

Expand All @@ -65,7 +65,7 @@ export class GeoPoint implements Serializable {
* @name GeoPoint#latitude
* @readonly
*/
get latitude() {
get latitude(): number {
return this._latitude;
}

Expand All @@ -76,7 +76,7 @@ export class GeoPoint implements Serializable {
* @name GeoPoint#longitude
* @readonly
*/
get longitude() {
get longitude(): number {
return this._longitude;
}

Expand Down Expand Up @@ -121,6 +121,6 @@ export class GeoPoint implements Serializable {
* @private
*/
static fromProto(proto: google.type.ILatLng): GeoPoint {
return new GeoPoint(proto.latitude, proto.longitude);
return new GeoPoint(proto.latitude || 0, proto.longitude || 0);
}
}
2 changes: 2 additions & 0 deletions system-test/firestore.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,13 @@ describe('DocumentReference class', function() {
objectValue: {foo: 'bar', '😀': '😜'},
emptyObject: {},
dateValue: new Firestore.Timestamp(479978400, 123000000),
zeroDateValue: new Firestore.Timestamp(0, 0),
pathValue: firestore.doc('col1/ref1'),
arrayValue: ['foo', 42, 'bar'],
emptyArray: [],
nilValue: null,
geoPointValue: new Firestore.GeoPoint(50.1430847, -122.947778),
zeroGeoPointValue: new Firestore.GeoPoint(0, 0),
bytesValue: Buffer.from([0x01, 0x02]),
};
let ref = randomCol.doc('doc');
Expand Down