项目作者: mrlotfi

项目描述 :
mirrored from https://gitlab.com/mrlotfi/gquery
高级语言: Rust
项目地址: git://github.com/mrlotfi/gquery.git
创建时间: 2020-10-09T16:44:03Z
项目社区:https://github.com/mrlotfi/gquery

开源协议:

下载


GQuery

An in-memory database for geographic/geometric queries with experimental support for persistence. Currently the only way to interact with gquery is via it’s HTTP REST apis.

Getting started

Docker

To run the latest version in a docker container:
```shell script
docker pull mrlotfi/gquery
docker run -p 6985:6985 mrlotfi/gquery

  1. #### Manual build
  2. Get a working rust environment ([rustup is recommended](https://rustup.rs/)). It should be compilable on most
  3. supported platforms as it has no platform specific dependency. To build an optimized version run
  4. ```cargo build --release```. Binary will be accessible on ```./target/release/gquery```.
  5. #### Binary releases
  6. To be announced.
  7. ## Running
  8. Just run `gquery`. No additional parameter is required for running with default configuration. But you can take a look at `gquery --help`.
  9. ## Storage API
  10. Items are stored in different namespaced collections. Each item has a unique id which is provided by you or automatically selected and returned by server.
  11. #### Adding a new item
  12. Path:

POST /{collection_name}

  1. Request body example:
  2. ```json
  3. {
  4. "id": "abc",
  5. "geojson": {
  6. "coordinates": [
  7. [
  8. [-1.0, 1.0],
  9. [0.0, -1.0],
  10. [1.0, 1.0]
  11. ]
  12. ],
  13. "properties": {
  14. "name": "hassan"
  15. },
  16. "type": "MultiLineString"
  17. }
  18. }

Response:
Id of the added item is returned as plain text. It is either provided by you or automatically generated by the server.

Deleting an item

Path:

  1. DELETE /{collection_name}/{id}/

such as http://localhost:6985/abc/efg/

Dropping an entire collection

Path:

  1. DELETE /{collection_name}/

such as http://localhost:6985/abc

Retrieving an item by id

Path:

  1. GET /{collection_name}/{id}/

such as http://localhost:6985/abc/efg/

Reponse body example:

  1. {
  2. "id": "123123",
  3. "geojson": {
  4. "coordinates": [
  5. [
  6. [-1.0, 1.0],
  7. [0.0, -1.0],
  8. [1.0, 1.0]
  9. ]
  10. ],
  11. "properties": {
  12. "name": "hassan"
  13. },
  14. "type": "MultiLineString"
  15. }
  16. }

Retrieving list of all collections

Path:

  1. GET /

Response body example:

  1. [
  2. "abc",
  3. "my_awesome_collection"
  4. ]

(Experimental) Persisting the current snapshot

Path:

  1. PUT /save

Returns 200 in case of succession.

Query API

Retrieving the nearest geometry

Path:

  1. GET /{collection_name}/nearby?long=-0.1&lat=0.122

Query Params:

  • long (x) of desired query point
  • lat (y) of desired query point
    Returns 404 if collection doesn’t exist or empty.

Response body example:

  1. {
  2. "id": "abc",
  3. "geojson": {
  4. "coordinates": [
  5. [
  6. [-1.0, 1.0],
  7. [0.0, -1.0],
  8. [1.0, 1.0]
  9. ]
  10. ],
  11. "properties": {
  12. "name": "hassan"
  13. },
  14. "type": "MultiLineString"
  15. }
  16. }

Retrieving the intersecting geometry

Path:

  1. GET /{collection_name}/intersect?long=-0.1&lat=0.122

Query Params:

  • long (x) of desired query point
  • lat (y) of desired query point
    Returns 404 if collection doesn’t exist or empty or no object containing this point is found.

Response body example:

  1. {
  2. "id": "hiva",
  3. "geojson": {
  4. "coordinates": [
  5. [
  6. [-1.0, -1.0],
  7. [-1.0, 1.0],
  8. [1.0, 1.0],
  9. [1.0, -1.0],
  10. [-1.0, -1.0]
  11. ]
  12. ],
  13. "properties": {
  14. "name": "hassan"
  15. },
  16. "type": "Polygon"
  17. }
  18. }

TODO

  • Implement a stable and well-defined persistence method
  • Basic leader/follower replication support
  • Ability to get N nearest/intersecintg docs
  • Arbitrary query shapes (instead of only points)