From 6f533ab0d9a1583693e0182afe1ad9051c87f880 Mon Sep 17 00:00:00 2001 From: Suwako Moriya Date: Sun, 11 Nov 2018 14:22:57 +0100 Subject: [PATCH] [Plotgen] added support for polygons --- fetch.py | 7 +++---- plotgen.py | 37 +++++++++++++++++++++++++++++++++++++ requirements.txt | 3 +++ 3 files changed, 43 insertions(+), 4 deletions(-) create mode 100755 plotgen.py create mode 100644 requirements.txt diff --git a/fetch.py b/fetch.py index acd9599..db1ec97 100755 --- a/fetch.py +++ b/fetch.py @@ -3,7 +3,7 @@ """ Created on Mon Nov 5 20:55:36 2018 -@author: suwako +@author: suwako & thedevkiller """ import requests @@ -93,8 +93,7 @@ if __name__ == '__main__': # Print the dict (keep this code in the end of the file) print("===== Dict =====") for index, area in enumerate(diclist): - if index == 30: - print(f"\n-------------{index}----------------\n") - for element in area: + print(f"\n-------------{index}----------------\n") + for element in area: print(f" {element}: {diclist[index][element]}") print("\n") diff --git a/plotgen.py b/plotgen.py new file mode 100755 index 0000000..9d80c66 --- /dev/null +++ b/plotgen.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 + +import matplotlib.pyplot as plt +import mplleaflet +import fetch + + +def genplot(diclist): + for index, area in enumerate(diclist): + if index in [210,223]: + continue + for figure in area['zone']: + if figure[0] == 'cercle' : + print("cercle") + else: + print("polygone") + xcoords,ycoords=[],[] + for xaxis,yaxis in figure: + xcoords.append(xaxis) + ycoords.append(yaxis) + xcoords.append(xcoords[0]) + ycoords.append(ycoords[0]) + plt.plot(xcoords,ycoords,'b') + plt.plot(xcoords,ycoords,'rs') + plt.fill(xcoords,ycoords,'g') + return plt + + +#plt.plot([15,16,17,15],[6,7,18,6],'b') +#plt.plot(17,6,'b') +#plt.plot(16,7,'rs') +#plt.fill([15,16,17,15],[6,7,18,6]) +#mplleaflet.show() + +if __name__ == '__main__': + plt=genplot(fetch.fetch()) + mplleaflet.show() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..4be337d --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +requests +mplleaflet +matplotlib