From ae562943a5f1b6693331bffae1450ccd0f9d1d07 Mon Sep 17 00:00:00 2001 From: Duchateau Fabien <fabien.duchateau@univ-lyon1.fr> Date: Mon, 8 Apr 2019 22:53:46 +0200 Subject: [PATCH] version 0.12 - working --- mapiris/main.py | 25 ++----------------------- mapiris/model.py | 11 +++++++---- mapiris/templates/header.html | 2 +- setup.cfg | 12 ++++++------ 4 files changed, 16 insertions(+), 34 deletions(-) diff --git a/mapiris/main.py b/mapiris/main.py index 9f0a362..3915c45 100644 --- a/mapiris/main.py +++ b/mapiris/main.py @@ -11,34 +11,13 @@ import os, json from mapiris import model app = Flask(__name__) -url = 'http://127.0.0.1:8080' +url = 'http://127.0.0.1:8081' @app.route('/', defaults={'page': None}) #@app.route('/<page>', methods=["GET", "POST"]) def index(page): - print(page) return render_template('index.html') - """ - if page is not None: - return render_template(page) - else: - return render_template('index.html') - """ - """ - if request.method == "POST": - if page is None: - return render_template('index.html') - # TODO remove the next lines - elif page.find('recommendation.html') > -1: # there is an argument POST - return render_template('recommendation.html') - elif page.find('clustering.html') > -1: # there is an argument POST - return render_template('clustering.html') - else: - return render_template(page) - else: # to avoid : Method Not Allowed The method is not allowed for the requested URL. - return render_template('index.html') - """ @app.route('/details-iris.html', methods=["GET"]) @@ -107,5 +86,5 @@ if __name__ == '__main__': webbrowser.open_new(url) app.config['SEND_FILE_MAX_AGE_DEFAULT'] = 0 # do not cache files, especially static files such as JS app.secret_key = 's3k_5Et#fL45k_#ranD0m-(StuF7)' - app.run(port=8080) # debug = True + app.run(port=8081) # debug = True diff --git a/mapiris/model.py b/mapiris/model.py index 8139768..cc20818 100644 --- a/mapiris/model.py +++ b/mapiris/model.py @@ -4,17 +4,20 @@ # model.py: methods for getting data from MongoDB (using mongiris) and transforming it # ============================================================================= -from mongiris import Mongiris -import re, json +from mongiris.main import Mongiris +import re +import json # connection to the IRIS collection in MongoDB db = Mongiris() -iris_collection = db.iris_collection +iris_collection = db.collection_iris db.init_connection() json_iris_indicator_code_to_label = 'static/data/dictionnaire-indicateurs.json' + def get_iris_for_polygon(lat1, lng1, lat2, lng2): - polygon = db.convert_geojson_box_to_polygon(lng1, lat1, lng2, lat2) + #polygon = db.convert_geojson_box_to_polygon(lng1, lat1, lng2, lat2) + polygon = Mongiris.convert_geojson_box_to_polygon(lng1, lat1, lng2, lat2) #iris = db.geo_within(iris_collection, polygon) iris = db.intersect(iris_collection, polygon) return iris diff --git a/mapiris/templates/header.html b/mapiris/templates/header.html index 8a8e2eb..3cba80f 100644 --- a/mapiris/templates/header.html +++ b/mapiris/templates/header.html @@ -1,5 +1,5 @@ <header class="mb-3"> - <h1><img src="{{url_for('static', filename='img/favicon.png')}}"> mapiris</h1> + <h1><a href="/"><img src="{{url_for('static', filename='img/favicon.png')}}"></a> mapiris</h1> <em>Un outil de visualisation des IRIS</em> <hr> </header> \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index 58a36ef..ad4581b 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = mapiris -version = 0.1 +version = 0.12 description = This package aims at searching and printing IRIS on a map. author = Fabien Duchateau author_email = fabien.duchateau@univ-lyon1.fr @@ -15,9 +15,9 @@ include_package_data = True zip_safe = False install_requires = flask >= 1.0.2 - mongiris >= 0.21 + mongiris >= 0.3 dependency_links = - git+https://fduchate@gitlab.liris.cnrs.fr/fduchate/mongiris.git#egg=mongiris-0.21 + git+https://fduchate@gitlab.liris.cnrs.fr/fduchate/mongiris.git#egg=mongiris-0.3 #[options.packages.find] #exclude = @@ -27,9 +27,9 @@ dependency_links = [options.package_data] # package_data is ignored when a MANIFEST.in is provided . = README.md, -mapiris/static = vizliris/static/** -mapiris/templates = vizliris/templates/* -mapiris/data = vizliris/data/** +mapiris/static = mapiris/static/** +mapiris/templates = mapiris/templates/* +mapiris/data = mapiris/data/** [bdist_wheel] universal = 1 -- GitLab