Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mongiris
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Duchateau Fabien
mongiris
Commits
1810676c
Commit
1810676c
authored
Jan 04, 2021
by
Duchateau Fabien
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[M] added coll_indic to constructor signature
parent
2a63a2c7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
7 deletions
+9
-7
api.py
mongiris/api.py
+9
-7
example-neighbourhood.json
mongiris/data/example-neighbourhood.json
+0
-0
No files found.
mongiris/api.py
View file @
1810676c
...
...
@@ -15,10 +15,10 @@ max_timeout = 3 # delay before connection timeout
class
Mongiris
:
"""
The Mongiris class is an API to manipulate data from
the MongoDB `dbinsee` datatase
.
The Mongiris class is an API to manipulate data from
a MongoDB database containing neighbourhoods (GeoJSON format)
.
Several methods accepts a 'collection' parameter for flexibility (i.e., be able to query other collections than the
iri
s collection).
neighbourhood
s collection).
Most methods convert resulting documents from the BSON format (MongoDB) to JSON. This mainly avoids the issue of
ObjectId type (for MongoDB '_id' field).
...
...
@@ -29,11 +29,12 @@ class Mongiris:
Examples of usages, including testing geospatial queries, are available in `tests/api_tests.py`.
An example of
IRIS following the GeoJSON format is provided in `data/example-iris
.json`.
An example of
neighbourhood following the GeoJSON format is provided in `data/example-neighbourhood
.json`.
Args:
db: the database name to connect to (string)
collection: the collection name containing neighbourhoods (string)
db: the MongoDB database name to connect to (string)
coll_neighbourhoods: the name of the neighbourhoods collection, inside database db (string)
coll_indic: the name of the indicators collection, inside database db (string)
Additional resources:
...
...
@@ -45,13 +46,14 @@ class Mongiris:
"""
def
__init__
(
self
,
db
,
coll
ection
):
def
__init__
(
self
,
db
,
coll
_neighbourhoods
,
coll_indic
=
'collindic'
):
logging
.
basicConfig
(
format
=
'[
%(levelname)
s] -
%(name)
s -
%(asctime)
s :
%(message)
s'
)
self
.
logger
=
logging
.
getLogger
()
self
.
logger
.
setLevel
(
logging
.
INFO
)
self
.
connection
,
self
.
connection_status
=
self
.
init_connection
()
# default connection on 'localhost', 27017
self
.
database
=
self
.
connection
[
db
]
# link to database
self
.
collection_neighbourhoods
=
self
.
database
[
collection
]
# link to collection
self
.
collection_neighbourhoods
=
self
.
database
[
coll_neighbourhoods
]
# link to neighbourhoods collection
self
.
collection_indicators
=
self
.
database
[
coll_indic
]
# link to indicators collection (used for prediction)
@
staticmethod
def
bson_to_json
(
doc_bson
):
...
...
mongiris/data/example-
iris
.json
→
mongiris/data/example-
neighbourhood
.json
View file @
1810676c
File moved
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment