Skip to content

Commit

Permalink
Updated README
Browse files Browse the repository at this point in the history
  • Loading branch information
ezrasingh committed Aug 5, 2024
1 parent a744e21 commit 91bac85
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ just geoprox help encode

### Using Docker

Geoprox image is published to both [`docker.io`](https://hub.docker.com/repository/docker/ezrasingh/geoprox/) and [`ghcr.io`](https://github.com/ezrasingh/geoprox/pkgs/container/geoprox) registries.
The Geoprox Docker image(`ezrasingh/geoprox`) is published to both [`docker.io`](https://hub.docker.com/repository/docker/ezrasingh/geoprox/) and [`ghcr.io`](https://github.com/ezrasingh/geoprox/pkgs/container/geoprox) registries.

For more details check out the [Docker Guide](contrib/docker/README.md).

Expand Down
29 changes: 19 additions & 10 deletions geoprox-core/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Geoprox Core

A Rust crate designed for geospatial indexing and sharding. It includes two primary modules: `cache` and `shard`. These modules facilitate efficient geospatial queries and indexing for applications such as food delivery services, real-time inventory tracking, and more.
A Rust crate designed for geospatial indexing and sharding. It includes two primary modules: `cache` and `shard`. These modules provide efficient geospatial queries and indexing for applications such as food delivery services, real-time inventory tracking, and more.

> **Looking for an API implementation?** See, [`geoprox-server`](https://crates.io/crates/geoprox-server/) for the HTTP API version of this service and [`contrib/client-sdk`](https://github.com/ezrasingh/geoprox/tree/main/contrib/client-sdk) for HTTP client libraries.
Expand All @@ -9,11 +9,13 @@ A Rust crate designed for geospatial indexing and sharding. It includes two prim
- **Geospatial Indexing**: Efficiently index and search for resources based on their geographic location.
- **Geospatial Sharding**: Manage and query distributed datasets with geospatial awareness.

## Modules
## Data Stuctures

### SpatialIndex

The `cache` module, implemented as `SpatialIndex`, allows for placing and searching resources based on their geohash-encoded locations. Key features include:
The `cache` module implements the `SpatialIndex` data structure, enabling efficient placement and searching of resources based on their geohash-encoded locations.

Key features include:

- **Placing Resources**: Add resources to the index with their geohash-encoded locations.
- **Searching Resources**: Perform range queries to find resources within a specified distance from a given location.
Expand All @@ -25,27 +27,32 @@ extern crate geoprox_core;

let mut geo_index = geoprox_core::SpatialIndex::default();

// ? place elements into index
// ? place object keys into index
geo_index.place_resource("player1", &geohash::encode([40.7129, 74.007].into(), depth).unwrap());
geo_index.place_resource("player2", &geohash::encode([40.7127, 74.005].into(), depth).unwrap());

// ? search index for elements near New York
// ? search index for objects near New York
let nearby: LatLngCoord = [40.7128, 74.006];
let within: f64 = 200.0; // 200km radius
let count = 100; // return up to 100 results
let sorted = true; // sort results by distance
let depth = 6; // ? determines geohash length (i.e precision)
let res = geo_index.search(nearby, range, count, sorted, Some(depth)).unwrap();
let res = geo_index.search(nearby, within, count, sorted, Some(depth)).unwrap();

println!("found: {:#?}", res);

assert_eq!(res.len(), 2);

res.iter().for_each(|neighbor| {
assert!(neighbor.distance <= range);
assert!(neighbor.distance <= within);
});
```

### GeoShard

The `shard` module, implemented as `GeoShard`, provides a mechanism for sharding datasets geographically and performing range queries. Key features include:
The `shard` module implements the `GeoShard` data structure, which facilitates geographical sharding of datasets and enables efficient range queries.

Key features include:

- **Creating Indexes**: Initialize geospatial indexes for different datasets.
- **Inserting Keys**: Insert keys into the geospatial index with their corresponding locations.
Expand All @@ -58,18 +65,20 @@ The `shard` module, implemented as `GeoShard`, provides a mechanism for sharding
extern crate geoprox_core;

let mut shard = geoprox_core::GeoShard::default();
// ? create an index to store driver coordinates
shard.create_index("drivers").unwrap();

// ? place drivers in index
// ? place drivers into index
shard.insert_key("drivers", "alice", [36.2049, 138.253]).unwrap();
shard.insert_key("drivers", "bob", [36.2047, 138.2528]).unwrap();

// ? search 'drivers' near Japan
// ? search drivers near Japan
let nearby: LatLngCoord = [36.2048, 138.2529];
let within: f64 = 50.0; // 50km radius
let count = 100; // return up to 100 results
let sorted = true; // sort results by distance
let res = shard.query_range("drivers", nearby, within, count, sorted).unwrap();

println!("found: {:#?}", res);
```

Expand Down
4 changes: 3 additions & 1 deletion geoprox/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Geoprox

A standalone runtime for the [Geoprox project](https://github.com/ezrasingh/geoprox/). This crate exposes the CLI runtime, enabling easy integration and usage for geo-aware applications such as rideshare pairing services.
A standalone runtime for the [Geoprox project](https://github.com/ezrasingh/geoprox/).

This crate offers a command-line tool for launching and managing the Geoprox server.

## Installation

Expand Down

0 comments on commit 91bac85

Please sign in to comment.