Skip to content
Snippets Groups Projects
Commit 0a447191 authored by Duchateau Fabien's avatar Duchateau Fabien
Browse files

cleaning

parent 59007e02
No related branches found
No related tags found
No related merge requests found
......@@ -20,21 +20,24 @@ python3 -m pip install git+https://fduchate@gitlab.liris.cnrs.fr/fduchate/mongir
```
Next, you need to load the IRIS data into MongoDB (using the `mongorestore` tool):
Next, you need to load the IRIS data into MongoDB (using the `mongorestore` tool).
- download the [dump of the database](https://gitlab.liris.cnrs.fr/fduchate/mongiris/raw/master/mongiris/data/dump/dump-dbinsee.bin) (724 MB)
- open a terminal and run:
```
mongorestore --archive=/path/to/dump-dbinsee.bin
```
where `/path/to/` indicates the path to the dump database (provided with the source package mongiris in `mongiris/data/dump/dump-dbinsee.bin`). This restoration may take a few minutes as the geospatial indexes are rebuilt.
where `/path/to/` indicates the path to the downloaded dump database. <!--(provided with the source package mongiris in `mongiris/data/dump/dump-dbinsee.bin`).-->
This restoration may take a few minutes as the geospatial indexes are rebuilt.
## Usage
In MongoDB, the database is named `dbinsee`. It contains three collections:
- `collsources` stores information about original data sources (title, release date, geographical information)
- `collindic` stores information about indicators (short label, full label, data sources in which it appears).
- `colliris` is the main collection, which stores each IRIS with its indicators (according to the [GeoJSON format](https://geojson.org/))
## Usage
To manipulate the database, simply connect to MongoDB by creating an object of the `Mongiris` class.
Using this object, twenty methods are available for querying the data.
......@@ -52,7 +55,7 @@ counts = db.count_documents(db.collection_indic, {})
iris = db.find_one_document(db.collection_iris, {"properties.CODE_IRIS": "593500203"})
# get iris which contains coordinates 3.685111, 46.514643
doc = db.point_in_which_iris([3.685111, 46.514643])
iris = db.point_in_which_iris([3.685111, 46.514643])
```
More examples, including testing geospatial queries, are available in the `tests/mongiris_test.py` file.
......
This diff is collapsed.
......@@ -6,8 +6,6 @@
# Some methods are not static because they require a valid DB connection (performed in __init__)
# =============================================================================
# =============================================================================
import pymongo
from bson import json_util # used to convert BSON to JSON (especially ObjectId type of "_id")
import json
......
......@@ -2,8 +2,6 @@
from mongiris.main import Mongiris
#if __name__ == "__main__":
db = Mongiris()
# return the number of documents in a collection
......@@ -13,8 +11,10 @@ counts = db.count_documents(db.collection_indic, {})
iris = db.find_one_document(db.collection_iris, {"properties.CODE_IRIS": "593500203"})
# get iris which contains coordinates 3.685111, 46.514643
doc = db.point_in_which_iris([3.685111, 46.514643])
iris2 = db.point_in_which_iris([3.685111, 46.514643])
print(counts)
print(iris)
print(doc)
\ No newline at end of file
print(iris2)
......@@ -19,8 +19,6 @@ install_requires =
[options.packages.find]
exclude =
tests
tests.*
data.*
[options.package_data]
......
......@@ -16,7 +16,7 @@ def delete_dir(directories): # delete directories (ignore errors such as read-o
# delete build/config directories because egg-info only updates config files for new versions
delete_dir(['./mongiris.egg-info/', './build/', './dist/'])
delete_dir(['./mongiris.egg-info/', 'pip-wheel-metadata', './build/', './dist/'])
readme = open("README.md").read()
......@@ -26,6 +26,8 @@ print("""Mongiris has been installed.
Do not forget to load the 'dbinsee' database into MongoDB:
\t\tmongorestore --archive=/path/to/dump-dbinsee.bin
\t\tDownload the dump from https://gitlab.liris.cnrs.fr/fduchate/mongiris/raw/master/mongiris/data/dump/dump-dbinsee.bin
\t\tRun in a terminal: mongorestore --archive=/path/to/dump-dbinsee.bin
""")
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment