-
-
Notifications
You must be signed in to change notification settings - Fork 9
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
Document and simplify clusterproperties interface #237
Draft
westnordost
wants to merge
10
commits into
main
Choose a base branch
from
geojson-simple-clusterProperties
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+42
−18
Draft
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
68b1378
document and correct clusterProperties of GeoJsonSource (part of #80)
westnordost 6c8e83b
Merge branch 'main' into geojson-simple-clusterProperties
westnordost 29f6872
revert naming
westnordost d2a08b0
revert deletion of unusable function
westnordost 24cb739
sp
westnordost 4e03ee7
correct gbfs parsing
westnordost 3fbbbe3
correct documentation comment
westnordost 6a6903e
reformat comment
westnordost f5da48e
that dog...
westnordost 3b13ca1
Update lib/maplibre-compose/src/commonMain/kotlin/dev/sargunv/maplibr…
westnordost 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 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 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 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 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 | ||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -1,7 +1,6 @@ | ||||||||||||||||||||||||
package dev.sargunv.maplibrecompose.core.source | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
import androidx.compose.runtime.Immutable | ||||||||||||||||||||||||
import dev.sargunv.maplibrecompose.expressions.ast.Expression | ||||||||||||||||||||||||
|
||||||||||||||||||||||||
/** | ||||||||||||||||||||||||
* @param minZoom Minimum zoom level at which to create vector tiles (lower means more field of view | ||||||||||||||||||||||||
|
@@ -16,11 +15,12 @@ import dev.sargunv.maplibrecompose.expressions.ast.Expression | |||||||||||||||||||||||
* @param cluster If the data is a collection of point features, setting this to `true` clusters the | ||||||||||||||||||||||||
* points by radius into groups. Cluster groups become new `Point` features in the source with | ||||||||||||||||||||||||
* additional properties: | ||||||||||||||||||||||||
* * `cluster`: Is `true` if the point is a cluster | ||||||||||||||||||||||||
* * `cluster_id`: A unique id for the cluster to be used in conjunction with the cluster | ||||||||||||||||||||||||
* inspection methods. (TODO which are not implemented yet on [GeoJsonSource] - #80) | ||||||||||||||||||||||||
* * `point_count`: Number of original points grouped into this cluster | ||||||||||||||||||||||||
* * `point_count_abbreviated`: An abbreviated point count | ||||||||||||||||||||||||
* | ||||||||||||||||||||||||
* - `cluster`: Is `true` if the point is a cluster | ||||||||||||||||||||||||
* - `cluster_id`: A unique id for the cluster to be used in conjunction with the cluster | ||||||||||||||||||||||||
* inspection methods. | ||||||||||||||||||||||||
* - `point_count`: Number of original points grouped into this cluster | ||||||||||||||||||||||||
* - `point_count_abbreviated`: An abbreviated point count | ||||||||||||||||||||||||
Comment on lines
+18
to
+23
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [spotless] reported by reviewdog 🐶
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change would break formatting this as a list in Android Studio. Bad dog! |
||||||||||||||||||||||||
* | ||||||||||||||||||||||||
* @param clusterRadius Radius of each cluster when clustering points, measured in 1/512ths of a | ||||||||||||||||||||||||
* tile. I.e. a value of 512 indicates a radius equal to the width of a tile. | ||||||||||||||||||||||||
|
@@ -33,10 +33,19 @@ import dev.sargunv.maplibrecompose.expressions.ast.Expression | |||||||||||||||||||||||
* Minimum number of points necessary to form a cluster if clustering is enabled. | ||||||||||||||||||||||||
* | ||||||||||||||||||||||||
* @param clusterProperties A map defining custom properties on the generated clusters if clustering | ||||||||||||||||||||||||
* is enabled, aggregating values from clustered points. The keys are the property names, the | ||||||||||||||||||||||||
* values are expressions. | ||||||||||||||||||||||||
* is enabled, aggregating values from clustered features. The keys are the property names, the | ||||||||||||||||||||||||
* values define how the value should be aggregated from the features within one cluster. | ||||||||||||||||||||||||
* | ||||||||||||||||||||||||
* Example: | ||||||||||||||||||||||||
* ```kt | ||||||||||||||||||||||||
* mapOf( | ||||||||||||||||||||||||
* "totalCapacity" to ClusterAggregation("+", "capacity") | ||||||||||||||||||||||||
* ) | ||||||||||||||||||||||||
* ``` | ||||||||||||||||||||||||
* | ||||||||||||||||||||||||
* TODO examples missing, see https://maplibre.org/maplibre-style-spec/sources/#clusterproperties | ||||||||||||||||||||||||
* Let's assume a geojson source consisting of points for parking lots in which each parking lot has | ||||||||||||||||||||||||
* a `capacity` property. The code above adds the `capacity` values of all parking lots within one | ||||||||||||||||||||||||
* cluster together into a property named `totalCapacity` of the cluster point. | ||||||||||||||||||||||||
* | ||||||||||||||||||||||||
* @param lineMetrics Whether to calculate line distance metrics. This is required for | ||||||||||||||||||||||||
* [LineLayer][dev.sargunv.maplibrecompose.compose.layer.LineLayer]s that specify a `gradient`. | ||||||||||||||||||||||||
|
@@ -54,6 +63,16 @@ public data class GeoJsonOptions( | |||||||||||||||||||||||
val clusterProperties: Map<String, ClusterProperty> = emptyMap(), | ||||||||||||||||||||||||
val lineMetrics: Boolean = false, | ||||||||||||||||||||||||
) { | ||||||||||||||||||||||||
// TODO seems to contradict https://maplibre.org/maplibre-style-spec/sources/#clusterproperties | ||||||||||||||||||||||||
public data class ClusterProperty(val operator: String, val mapper: Expression<*>) | ||||||||||||||||||||||||
/** | ||||||||||||||||||||||||
* Defines how the values from the features within a cluster should be aggregated into a cluster | ||||||||||||||||||||||||
* property. | ||||||||||||||||||||||||
* | ||||||||||||||||||||||||
* @param operator Expression name to aggregate the values from the feature properties. This can | ||||||||||||||||||||||||
* be any expression function that accepts at least 2 operands but typically is a math function | ||||||||||||||||||||||||
* like `"+"` or `"max"`. See | ||||||||||||||||||||||||
* [MapLibre Style Spec][https://maplibre.org/maplibre-style-spec/expressions/#math] for valid | ||||||||||||||||||||||||
* names for the operator. | ||||||||||||||||||||||||
* @param property name of the feature property whose value should be aggregated. | ||||||||||||||||||||||||
*/ | ||||||||||||||||||||||||
public data class ClusterProperty(val operator: String, val property: String) | ||||||||||||||||||||||||
} |
This file contains 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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[spotless] reported by reviewdog 🐶
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change would break formatting this as a list in Android Studio.
Bad dog!