-
Notifications
You must be signed in to change notification settings - Fork 8.5k
[Maps] Auto generate legends and styles from mvt data #94811
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
thomasneirynck
merged 92 commits into
elastic:master
from
thomasneirynck:maps/metadata_counts
Jul 8, 2021
Merged
Changes from all commits
Commits
Show all changes
92 commits
Select commit
Hold shift + click to select a range
d0c462b
init boilerplate
thomasneirynck e68ecf0
more boilerplate
thomasneirynck 54b8429
boilerplate for doc_count
thomasneirynck c9e0d4f
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck 14c40b0
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck a4d7370
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck 18d6ecd
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck 5f930ff
cleanup
thomasneirynck ee10a58
more boiler
thomasneirynck 410276e
edits
thomasneirynck 40ac552
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck fe3bfbf
boiler for style
thomasneirynck 40c0680
boiler for icon
thomasneirynck 405a9df
minor fixes
thomasneirynck 977b9e2
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck bddeb59
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck f506db2
improve typing
thomasneirynck 94f2a15
formatting snafu
thomasneirynck ae19c61
improve typing
thomasneirynck f87ce95
type fix
thomasneirynck 35258a0
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck 135bdb4
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck 15cd4fd
type fixes
thomasneirynck 2e5d037
more fixes
thomasneirynck 65543b7
add incomplete results icon
thomasneirynck 50c49e4
add no results icon
thomasneirynck 8578ba2
extract commonalities
thomasneirynck 664ab18
remove typo
thomasneirynck c429b09
typo
thomasneirynck 4c98eb7
remove unused
thomasneirynck beaa7cd
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck b78fd7f
feedback
thomasneirynck dd2a830
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck f0594ff
feedback
thomasneirynck 1bd388c
feedback
thomasneirynck 0a838c0
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck 58033f2
type fixes
thomasneirynck 64702d2
fix test
thomasneirynck f1f3060
update snapshot
thomasneirynck b5cf12a
fix tests
thomasneirynck 9a64f91
update functional test
thomasneirynck 0609f57
rename
thomasneirynck 3ea92fc
fix tests
thomasneirynck f660e0f
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck 150c8dd
update test
thomasneirynck a4d10f7
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck 80fa1a0
fix test
thomasneirynck 6d1c76f
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck 2ffb088
fix test
thomasneirynck 6cc7b82
fix test
thomasneirynck 90f00cf
feedback
thomasneirynck 09d4fe7
fix typo
thomasneirynck 99d3edd
add comment
thomasneirynck c7f463d
add unit test
thomasneirynck 5999da5
add test
thomasneirynck 2b9d545
fix impl/test
thomasneirynck 72d8f1f
fix trimmed icon
thomasneirynck e3d4095
hide data-mapper ux for counts
thomasneirynck e695621
fieldMeta fix
thomasneirynck 15730d6
do not allow for toggling get-from-data switch
thomasneirynck 32ab71f
fix tests
thomasneirynck 0e14370
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck 4ebc17e
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck a258dfe
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck 48ccd8b
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck 10eb35f
fix edge cases
thomasneirynck bad6921
remove obsolete test
thomasneirynck 6aa0f51
extract style-meta code to common
thomasneirynck b7dc391
reuse in tile-gen
thomasneirynck 3246976
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck a047002
improve typing
thomasneirynck fb8b836
rewrite for clarity
thomasneirynck 90377cc
fix delete
thomasneirynck 8d25600
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck 5872b08
type field-stylemeta
thomasneirynck 1d3a276
add tilemetafeature type for clarity
thomasneirynck 33fde42
tighten types
thomasneirynck cf77f83
align implementations
thomasneirynck ba79ed5
get categories from tilemeta
thomasneirynck 4ad1ae7
add category-rollups
thomasneirynck 3828671
move shape-counts
thomasneirynck f80aa2a
type fix
thomasneirynck 35a5b60
add metadata to features
thomasneirynck df555e2
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck 415959a
fix test
thomasneirynck bbd1403
fix test
thomasneirynck 5f3ba8e
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck ff94926
feedback
thomasneirynck 83a728b
type cleanup
thomasneirynck 778775e
update snapshot
thomasneirynck ef41ff2
Merge branch 'master' of github.com:elastic/kibana into maps/metadata…
thomasneirynck c1bcdd1
feedback
thomasneirynck File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import { Feature } from 'geojson'; | ||
| import { GEO_JSON_TYPE, VECTOR_SHAPE_TYPE } from './constants'; | ||
|
|
||
| export interface VectorShapeTypeCounts { | ||
| [VECTOR_SHAPE_TYPE.POINT]: number; | ||
| [VECTOR_SHAPE_TYPE.LINE]: number; | ||
| [VECTOR_SHAPE_TYPE.POLYGON]: number; | ||
| } | ||
|
|
||
| export function countVectorShapeTypes(features: Feature[]): VectorShapeTypeCounts { | ||
| const vectorShapeTypeCounts: VectorShapeTypeCounts = { | ||
| [VECTOR_SHAPE_TYPE.POINT]: 0, | ||
| [VECTOR_SHAPE_TYPE.LINE]: 0, | ||
| [VECTOR_SHAPE_TYPE.POLYGON]: 0, | ||
| }; | ||
|
|
||
| for (let i = 0; i < features.length; i++) { | ||
| const feature: Feature = features[i]; | ||
| if ( | ||
| feature.geometry.type === GEO_JSON_TYPE.POINT || | ||
| feature.geometry.type === GEO_JSON_TYPE.MULTI_POINT | ||
| ) { | ||
| vectorShapeTypeCounts[VECTOR_SHAPE_TYPE.POINT] += 1; | ||
| } else if ( | ||
| feature.geometry.type === GEO_JSON_TYPE.LINE_STRING || | ||
| feature.geometry.type === GEO_JSON_TYPE.MULTI_LINE_STRING | ||
| ) { | ||
| vectorShapeTypeCounts[VECTOR_SHAPE_TYPE.LINE] += 1; | ||
| } else if ( | ||
| feature.geometry.type === GEO_JSON_TYPE.POLYGON || | ||
| feature.geometry.type === GEO_JSON_TYPE.MULTI_POLYGON | ||
| ) { | ||
| vectorShapeTypeCounts[VECTOR_SHAPE_TYPE.POLYGON] += 1; | ||
| } | ||
| } | ||
|
|
||
| return vectorShapeTypeCounts; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import { Feature } from 'geojson'; | ||
| import { CategoryFieldMeta } from './descriptor_types'; | ||
|
|
||
| export function pluckCategoryFieldMeta( | ||
| features: Feature[], | ||
| name: string, | ||
| size: number | ||
| ): CategoryFieldMeta | null { | ||
| const counts = new Map(); | ||
| for (let i = 0; i < features.length; i++) { | ||
| const feature = features[i]; | ||
| const term = feature.properties ? feature.properties[name] : undefined; | ||
| // properties object may be sparse, so need to check if the field is effectively present | ||
| if (typeof term !== undefined) { | ||
| if (counts.has(term)) { | ||
| counts.set(term, counts.get(term) + 1); | ||
| } else { | ||
| counts.set(term, 1); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| return trimCategories(counts, size); | ||
| } | ||
|
|
||
| export function trimCategories(counts: Map<string, number>, size: number): CategoryFieldMeta { | ||
| const ordered = []; | ||
| for (const [key, value] of counts) { | ||
| ordered.push({ key, count: value }); | ||
| } | ||
|
|
||
| ordered.sort((a, b) => { | ||
| return b.count - a.count; | ||
| }); | ||
| const truncated = ordered.slice(0, size); | ||
| return { | ||
| categories: truncated, | ||
| } as CategoryFieldMeta; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| /* | ||
| * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
| * or more contributor license agreements. Licensed under the Elastic License | ||
| * 2.0; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import { Feature } from 'geojson'; | ||
| import { RangeFieldMeta } from './descriptor_types'; | ||
|
|
||
| export function pluckRangeFieldMeta( | ||
| features: Feature[], | ||
| name: string, | ||
| parseValue: (rawValue: unknown) => number | ||
| ): RangeFieldMeta | null { | ||
| let min = Infinity; | ||
| let max = -Infinity; | ||
| for (let i = 0; i < features.length; i++) { | ||
| const feature = features[i]; | ||
| const newValue = feature.properties ? parseValue(feature.properties[name]) : NaN; | ||
| if (!isNaN(newValue)) { | ||
| min = Math.min(min, newValue); | ||
| max = Math.max(max, newValue); | ||
| } | ||
| } | ||
|
|
||
| return min === Infinity || max === -Infinity | ||
| ? null | ||
| : ({ | ||
| min, | ||
| max, | ||
| delta: max - min, | ||
| } as RangeFieldMeta); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.