Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mongiris
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Duchateau Fabien
mongiris
Commits
1810676c
Commit
1810676c
authored
4 years ago
by
Duchateau Fabien
Browse files
Options
Downloads
Patches
Plain Diff
[M] added coll_indic to constructor signature
parent
2a63a2c7
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mongiris/api.py
+9
-7
9 additions, 7 deletions
mongiris/api.py
mongiris/data/example-neighbourhood.json
+0
-0
0 additions, 0 deletions
mongiris/data/example-neighbourhood.json
with
9 additions
and
7 deletions
mongiris/api.py
+
9
−
7
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
):
...
...
This diff is collapsed.
Click to expand it.
mongiris/data/example-
iris
.json
→
mongiris/data/example-
neighbourhood
.json
+
0
−
0
View file @
1810676c
File moved
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment