Skip to content
Open
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
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ assert_eq!(
);
```

## Web Applications

When targetting for the browser (ie target="wasm*-unknown-unknown"), selecting a source of randomness is troublesome. This is how to include the geo library for the web.

```toml
geo = { path ="0.32", features = [ "earcutr", "spade", "multithreading"], default-features = false }
```

The rand crate is no longer a dependant and the functionality associated the kmeans module is removed.

## Contributing

Contributions are welcome! Have a look at the [issues](https://github.com/georust/geo/issues), and open a pull request if you'd like to add an algorithm or some functionality.
Expand Down
9 changes: 6 additions & 3 deletions geo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ rust-version = "1.85"
categories = ["science::geo"]

[features]
default = ["earcutr", "spade", "multithreading"]
default = ["rand", "earcutr", "spade", "multithreading"]
proj-network = ["proj", "proj/network"]
serde = ["dep:serde", "geo-types/serde"]
multithreading = ["i_overlay/allow_multithreading", "geo-types/multithreading"]

# Remove "rand" from the default feature set for enviromnents without a concrete source of randmonness
# for example targets like wasm*-unknown-unknown
# This will disable algorithm/kmean
rand = ["dep:rand"]
# Deprecated feature flags with "use-" prefix from the days before `dep:`
use-proj = ["proj"]
use-serde = ["serde"]
Expand All @@ -38,7 +41,7 @@ rstar = "0.12.0"
serde = { version = "1.0", optional = true, features = ["derive"] }
i_overlay = { version = "4.0.0, < 4.1.0", default-features = false }
sif-itree = "0.4.0"
rand = "0.8.0"
rand = { version = "0.8.0", optional=true }

[dev-dependencies]
approx = ">= 0.4.0, < 0.6.0"
Expand Down
2 changes: 2 additions & 0 deletions geo/src/algorithm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,9 @@ pub mod dbscan;
pub use dbscan::Dbscan;

/// Cluster points using [k-means clustering](https://en.wikipedia.org/wiki/K-means_clustering)
#[cfg(feature = "rand")]
pub mod kmeans;
#[cfg(feature = "rand")]
pub use kmeans::{KMeans, KMeansError, KMeansParams};

/// Monotonic polygon subdivision
Expand Down