Geomap: Fix geohash editor settings #54058

This commit is contained in:
Ryan McKinley 2022-08-22 14:12:21 -07:00 committed by GitHub
parent 657e1683d2
commit 13aacf3590
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 1 deletions

View File

@ -51,7 +51,7 @@ export function addLocationFields<TOptions>(
case FrameGeometrySourceMode.Geohash:
builder.addFieldNamePicker({
path: `${prefix}.geohash`,
path: `${prefix}geohash`,
name: 'Geohash field',
settings: {
filter: (f: Field) => f.type === FieldType.string,

View File

@ -67,4 +67,31 @@ describe('handle location parsing', () => {
]
`);
});
it('auto support geohash fields', async () => {
const frame = toDataFrame({
name: 'simple',
fields: [
{ name: 'name', type: FieldType.string, values: names },
{ name: 'geohash', type: FieldType.string, values: ['9q94r', 'dr5rs'] },
],
});
const matchers = await getLocationMatchers({
mode: FrameGeometrySourceMode.Geohash,
});
const geo = getGeometryField(frame, matchers).field!;
expect(geo.values.toArray().map((p) => toLonLat((p as Point).getCoordinates()))).toMatchInlineSnapshot(`
Array [
Array [
-122.01416015625001,
36.979980468750014,
],
Array [
-73.98193359375,
40.71533203125,
],
]
`);
});
});