diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..723ef36 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea \ No newline at end of file diff --git a/data-ingest/ingest b/data-ingest/ingest index e78fa28..13578e9 100755 --- a/data-ingest/ingest +++ b/data-ingest/ingest @@ -31,7 +31,12 @@ EOF done echo "" -sqlite3 "${fullDbPath}" < "${tmpSql}" +rc=0 +sqlite3 "${fullDbPath}" < "${tmpSql}" 2>&1 | grep -v "filling the rest with NULL" || rc="${PIPESTATUS[0]}" +if [[ $rc -ne 0 ]]; then + echo "Error executing sqlite import" + exit "$rc" +fi echo "[+] Ingesting spatial data." diff --git a/webapp/main.py b/webapp/main.py index efb1a9a..3297793 100644 --- a/webapp/main.py +++ b/webapp/main.py @@ -43,7 +43,7 @@ def getEligData(): args = request.args valid_args = True processed_args = {} - for k in ["swx", "swy", "nex", "ney", "centerlat", "centerlng"]: + for k in ["swx", "swy", "nex", "ney"]: valid_args = valid_args and k in args if valid_args: try: @@ -51,18 +51,20 @@ def getEligData(): except ValueError: valid_args = False if valid_args: - ## Need to narrow coordinates for Liazo API call - # wide_coordinates=AreaCoordinates( - # swx=processed_args['swx'], - # swy=processed_args['swy'], - # nex=processed_args['nex'], - # ney=processed_args['ney'], - # ) - narrow_coordinates=AreaCoordinates( - swx=processed_args['centerlng']-0.0022, - swy=processed_args['centerlat']-0.0011, - nex=processed_args['centerlng']+0.0022, - ney=processed_args['centerlat']+0.0011, + # Need to narrow coordinates for Liazo API call + + # computes center + centerx = (processed_args['swx'] + processed_args['nex']) / 2 + centery = (processed_args['swy'] + processed_args['ney']) / 2 + + narrow_x = 0.0022 + narrow_y = 0.0011 + + narrow_coordinates = AreaCoordinates( + swx=centerx - narrow_x, + swy=centery - narrow_y, + nex=centerx + narrow_x, + ney=centery + narrow_y, ) buildings = dict() try: diff --git a/webapp/templates/app.js b/webapp/templates/app.js index f59ca18..1d9c066 100644 --- a/webapp/templates/app.js +++ b/webapp/templates/app.js @@ -1,6 +1,6 @@ const minZoomForRequest = 17; -const urlADSL='https://tools.aquilenet.fr/cgi-bin/recherchend.cgi' -const urlTestFTTH='https://tools.aquilenet.fr/cgi-bin/test.cgi' +const urlADSL = 'https://tools.aquilenet.fr/cgi-bin/recherchend.cgi' +const urlTestFTTH = 'https://tools.aquilenet.fr/cgi-bin/test.cgi' const streetTypeConversion = new Map(); streetTypeConversion.set("aire", "aire") @@ -72,6 +72,7 @@ streetTypeConversion.set("zone industrielle", "zi") streetTypeConversion.set("zone", "zone") let markers = []; + function initMap(btn) { // Init map position/zoom. Potentially using what's in the URL search string. const params = new URLSearchParams(window.location.search); @@ -147,39 +148,39 @@ function updateEligData(map, eligData) { } let colorMarker = 'black' let messageElig = `` - eligTestApi=`eligtest/ftth?idImm=${building.idImm}&codePostal=${building.codePostal}&axione=${building.aquilenetEligStatus.isEligible}&liazo=${building.fdnEligStatus.isEligible}` + eligTestApi = `eligtest/ftth?idImm=${building.idImm}&codePostal=${building.codePostal}&axione=${building.aquilenetEligStatus.isEligible}&liazo=${building.fdnEligStatus.isEligible}` // éligible chez Aquilenet, lien pour le test if (building.aquilenetEligStatus.isEligible) { messageElig = `
Fibre deployee et disponible par Aquilenet !
` - const zip=encodeURIComponent(building.codePostal); - const idImm=encodeURIComponent(building.idImm); - messageElig += `Fibre deployee mais pas chez Axione !`
messageElig += `
Tester l'eligibilite par Kosc et Bouygues
Fibre deployee mais non eligible Aquilenet, desole :(
` colorMarker = 'red' - // Pas de fibre il semblerait, proposer un test ADSL Aquilenet + // Pas de fibre il semblerait, proposer un test ADSL Aquilenet } else { messageElig = `Fibre non deployee :(
` - const zip=encodeURIComponent(building.codePostal); - const comm=encodeURIComponent(building.commune); + const zip = encodeURIComponent(building.codePostal); + const comm = encodeURIComponent(building.commune); let convertType = streetTypeConversion.get(building.typeVoieImm.toLowerCase()); - if (! convertType) { + if (!convertType) { convertType = building.typeVoieImm; } - const street=encodeURIComponent(`${convertType} ${building.nomVoieImm}`) - const street_nb=encodeURIComponent(building.numVoieImm) - messageElig += `