display per result
This commit is contained in:
parent
58bb3e0d1b
commit
e6d6ba013b
9 changed files with 113 additions and 24 deletions
|
@ -1,2 +1,4 @@
|
||||||
from .axione import *
|
from .axione import *
|
||||||
from .liazo import *
|
from .liazo import *
|
||||||
|
from .arcep import *
|
||||||
|
from .model import *
|
|
@ -42,7 +42,9 @@ class Arcep:
|
||||||
num_voie,
|
num_voie,
|
||||||
type_voie,
|
type_voie,
|
||||||
nom_voie,
|
nom_voie,
|
||||||
batiment
|
batiment,
|
||||||
|
code_poste,
|
||||||
|
nom_com
|
||||||
FROM {self.db_name}
|
FROM {self.db_name}
|
||||||
WHERE ROWID IN (
|
WHERE ROWID IN (
|
||||||
SELECT ROWID FROM SpatialIndex
|
SELECT ROWID FROM SpatialIndex
|
||||||
|
@ -63,7 +65,8 @@ class Arcep:
|
||||||
typeVoieImm=b[5]
|
typeVoieImm=b[5]
|
||||||
nomVoieImm=b[6]
|
nomVoieImm=b[6]
|
||||||
bat_info=b[7]
|
bat_info=b[7]
|
||||||
|
codePostal=b[8]
|
||||||
|
commune=b[9]
|
||||||
isEligible = etatImm == ARCEP_ETAT_DEPLOYE
|
isEligible = etatImm == ARCEP_ETAT_DEPLOYE
|
||||||
othersEligStatus = FAIEligibilityStatus(
|
othersEligStatus = FAIEligibilityStatus(
|
||||||
isEligible=isEligible,
|
isEligible=isEligible,
|
||||||
|
@ -85,8 +88,12 @@ class Arcep:
|
||||||
numVoieImm=numVoieImm,
|
numVoieImm=numVoieImm,
|
||||||
typeVoieImm=typeVoieImm,
|
typeVoieImm=typeVoieImm,
|
||||||
nomVoieImm=nomVoieImm,
|
nomVoieImm=nomVoieImm,
|
||||||
|
codePostal=codePostal,
|
||||||
|
commune=commune,
|
||||||
bat_info=bat_info,
|
bat_info=bat_info,
|
||||||
found_in = ["arcep"],
|
found_in = ["arcep"],
|
||||||
|
aquilenetEligStatus=FAIEligibilityStatus(isEligible=False, reasonNotEligible="", ftthStatus=""),
|
||||||
|
fdnEligStatus=FAIEligibilityStatus(isEligible=False, reasonNotEligible="", ftthStatus=""),
|
||||||
othersEligStatus=othersEligStatus,
|
othersEligStatus=othersEligStatus,
|
||||||
)
|
)
|
||||||
buildings[idImm] = building
|
buildings[idImm] = building
|
||||||
|
|
|
@ -48,7 +48,9 @@ class Axione:
|
||||||
EtatImmeuble,
|
EtatImmeuble,
|
||||||
NumeroVoieImmeuble,
|
NumeroVoieImmeuble,
|
||||||
TypeVoieImmeuble,
|
TypeVoieImmeuble,
|
||||||
NomVoieImmeuble
|
NomVoieImmeuble,
|
||||||
|
CodePostalImmeuble,
|
||||||
|
CommuneImmeuble
|
||||||
FROM {self.db_name}
|
FROM {self.db_name}
|
||||||
WHERE ROWID IN (
|
WHERE ROWID IN (
|
||||||
SELECT ROWID FROM SpatialIndex
|
SELECT ROWID FROM SpatialIndex
|
||||||
|
@ -68,7 +70,7 @@ class Axione:
|
||||||
aquilenetEligStatus = FAIEligibilityStatus(
|
aquilenetEligStatus = FAIEligibilityStatus(
|
||||||
isEligible=isEligible,
|
isEligible=isEligible,
|
||||||
ftthStatus=etatImm,
|
ftthStatus=etatImm,
|
||||||
reasonNotEligible=None if isEligible else "Pas encore deploye",
|
reasonNotEligible="" if isEligible else "Pas encore deploye",
|
||||||
)
|
)
|
||||||
if buildings.get(idImm):
|
if buildings.get(idImm):
|
||||||
buildings[idImm]["aquilenetEligStatus"] = aquilenetEligStatus
|
buildings[idImm]["aquilenetEligStatus"] = aquilenetEligStatus
|
||||||
|
@ -85,9 +87,13 @@ class Axione:
|
||||||
numVoieImm=b[4],
|
numVoieImm=b[4],
|
||||||
typeVoieImm=b[5],
|
typeVoieImm=b[5],
|
||||||
nomVoieImm=b[6],
|
nomVoieImm=b[6],
|
||||||
|
codePostal=b[7],
|
||||||
|
commune=b[8],
|
||||||
bat_info="",
|
bat_info="",
|
||||||
found_in = ["axione"],
|
found_in = ["axione"],
|
||||||
aquilenetEligStatus=aquilenetEligStatus,
|
aquilenetEligStatus=aquilenetEligStatus,
|
||||||
|
fdnEligStatus=FAIEligibilityStatus(isEligible=False, reasonNotEligible="", ftthStatus=""),
|
||||||
|
othersEligStatus=FAIEligibilityStatus(isEligible=False, reasonNotEligible="", ftthStatus=""),
|
||||||
)
|
)
|
||||||
buildings[idImm] = building
|
buildings[idImm] = building
|
||||||
return buildings
|
return buildings
|
||||||
|
|
|
@ -7,16 +7,16 @@ class Liazo:
|
||||||
self.https_conn = httplib.HTTPSConnection("vador.fdn.fr")
|
self.https_conn = httplib.HTTPSConnection("vador.fdn.fr")
|
||||||
|
|
||||||
def getAreaBuildings(
|
def getAreaBuildings(
|
||||||
self, center_lat: float, center_lng: float, existing_buildings: dict
|
self, narrow_coordinates: AreaCoordinates(), existing_buildings: dict
|
||||||
) -> dict:
|
) -> dict:
|
||||||
|
nc=narrow_coordinates
|
||||||
c = self.https_conn
|
c = self.https_conn
|
||||||
req = "/souscription/gps-batiments.cgi?etape=gps_batiments&lat1=%f&lat2=%f&lon1=%f&lon2=%f" % (center_lat-0.0011, center_lat+0.0011, center_lng-0.0022, center_lng+0.0022)
|
req = "/souscription/gps-batiments.cgi?etape=gps_batiments&lat1=%f&lat2=%f&lon1=%f&lon2=%f" % (nc['swy'],nc['ney'],nc['swx'],nc['nex'])
|
||||||
req = req.replace(" ", "%20")
|
req = req.replace(" ", "%20")
|
||||||
print("Req FDN with: ", req)
|
|
||||||
c.request("GET", req)
|
c.request("GET", req)
|
||||||
r = c.getresponse()
|
r = c.getresponse()
|
||||||
if r.status < 200 or r.status >= 300:
|
if r.status < 200 or r.status >= 300:
|
||||||
print("Erreur de serveur chez FDN. Merci de nous faire remonter le numéro de téléphone qui provoque cette erreur")
|
print("Erreur de serveur chez FDN.")
|
||||||
return
|
return
|
||||||
d = r.read()
|
d = r.read()
|
||||||
c.close()
|
c.close()
|
||||||
|
@ -27,7 +27,7 @@ class Liazo:
|
||||||
for building in v:
|
for building in v:
|
||||||
fdnEligStatus = FAIEligibilityStatus(
|
fdnEligStatus = FAIEligibilityStatus(
|
||||||
isEligible=True,
|
isEligible=True,
|
||||||
ftthStatus="DEPLOYE",
|
ftthStatus="DEPLOYE", # Pas de status donc on dit que c'est ok mais on check avec l'arcep si axione KO cote front
|
||||||
reasonNotEligible=None,
|
reasonNotEligible=None,
|
||||||
)
|
)
|
||||||
idImm=building.get('ref')
|
idImm=building.get('ref')
|
||||||
|
@ -46,9 +46,13 @@ class Liazo:
|
||||||
numVoieImm="",
|
numVoieImm="",
|
||||||
typeVoieImm="",
|
typeVoieImm="",
|
||||||
nomVoieImm="",
|
nomVoieImm="",
|
||||||
|
codePostal="",
|
||||||
|
commune="",
|
||||||
bat_info="",
|
bat_info="",
|
||||||
found_in = ["liazo"],
|
found_in = ["liazo"],
|
||||||
fdnEligStatus=fdnEligStatus,
|
fdnEligStatus=fdnEligStatus,
|
||||||
|
aquilenetEligStatus=FAIEligibilityStatus(isEligible=False, reasonNotEligible="", ftthStatus=""),
|
||||||
|
othersEligStatus=FAIEligibilityStatus(isEligible=False, reasonNotEligible="", ftthStatus=""),
|
||||||
)
|
)
|
||||||
print("add building ", building)
|
print("add building ", building)
|
||||||
buildings[idImm] = building
|
buildings[idImm] = building
|
||||||
|
|
|
@ -14,8 +14,10 @@ class Building(TypedDict):
|
||||||
numVoieImm: str
|
numVoieImm: str
|
||||||
typeVoieImm: str
|
typeVoieImm: str
|
||||||
nomVoieImm: str
|
nomVoieImm: str
|
||||||
|
codePostal: str
|
||||||
|
commune: str
|
||||||
bat_info: str
|
bat_info: str
|
||||||
found_in: list(str)
|
found_in: list[str]
|
||||||
aquilenetEligStatus: FAIEligibilityStatus
|
aquilenetEligStatus: FAIEligibilityStatus
|
||||||
fdnEligStatus: FAIEligibilityStatus
|
fdnEligStatus: FAIEligibilityStatus
|
||||||
othersEligStatus: FAIEligibilityStatus
|
othersEligStatus: FAIEligibilityStatus
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import sqlite3
|
import sqlite3
|
||||||
|
|
||||||
def getCursorWithSpatialite(db_path: str = None) -> sqlite3.Cursor:
|
def getCursorWithSpatialite(db_path: str = None) -> sqlite3.Cursor:
|
||||||
|
print(db_path)
|
||||||
db = sqlite3.connect(db_path)
|
db = sqlite3.connect(db_path)
|
||||||
cur = db.cursor()
|
cur = db.cursor()
|
||||||
db.enable_load_extension(True)
|
db.enable_load_extension(True)
|
||||||
|
|
|
@ -4,9 +4,12 @@ from typing import TypedDict
|
||||||
import configparser
|
import configparser
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import os
|
import os
|
||||||
from ipe_fetcher import Liazo,Axione,Arcep
|
from ipe_fetcher import Liazo,Axione,Arcep,AreaCoordinates
|
||||||
class Config(TypedDict):
|
class Config(TypedDict):
|
||||||
axione_ipe_path: str
|
axione_ipe_path: str
|
||||||
|
axione_ipe_db_name: str
|
||||||
|
arcep_ipe_path: str
|
||||||
|
arcep_ipe_db_name: str
|
||||||
|
|
||||||
|
|
||||||
def parseConfig() -> Config:
|
def parseConfig() -> Config:
|
||||||
|
@ -16,15 +19,17 @@ def parseConfig() -> Config:
|
||||||
cfg.read_file(f)
|
cfg.read_file(f)
|
||||||
return {
|
return {
|
||||||
"axione_ipe_path": cfg.get("DB", "axione_ipe_path"),
|
"axione_ipe_path": cfg.get("DB", "axione_ipe_path"),
|
||||||
"axione_ipe_path": cfg.get("DB", "axione_ipe_path"),
|
"axione_ipe_db_name": cfg.get("DB", "axione_ipe_db_name"),
|
||||||
|
"arcep_ipe_path": cfg.get("DB", "arcep_ipe_path"),
|
||||||
|
"arcep_ipe_db_name": cfg.get("DB", "arcep_ipe_db_name"),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
cfg: Config = parseConfig()
|
cfg: Config = parseConfig()
|
||||||
|
|
||||||
axione = Axione(cfg.get("axione_ipe_path"), "ipe")
|
axione = Axione(cfg.get("axione_ipe_path"), cfg.get("axione_ipe_db_name"))
|
||||||
arcep = Arcep()
|
arcep = Arcep(cfg.get("arcep_ipe_path"), cfg.get("arcep_ipe_db_name"))
|
||||||
liazo = Liazo()
|
liazo = Liazo()
|
||||||
|
|
||||||
|
|
||||||
|
@ -46,13 +51,27 @@ def getEligData():
|
||||||
except ValueError:
|
except ValueError:
|
||||||
valid_args = False
|
valid_args = False
|
||||||
if valid_args:
|
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,
|
||||||
|
)
|
||||||
buildings = dict()
|
buildings = dict()
|
||||||
try:
|
try:
|
||||||
buildings = axione.getAreaBuildings(processed_args, buildings)
|
buildings = arcep.getAreaBuildings(narrow_coordinates, buildings)
|
||||||
|
buildings = axione.getAreaBuildings(narrow_coordinates, buildings)
|
||||||
except ValueError as err:
|
except ValueError as err:
|
||||||
print("Could not get Axione data for this area:", err)
|
print("Could not get Axione data for this area:", err)
|
||||||
|
|
||||||
buildings = liazo.getAreaBuildings(processed_args["centerlat"], processed_args["centerlng"], buildings)
|
buildings = liazo.getAreaBuildings(narrow_coordinates, buildings)
|
||||||
|
|
||||||
return {"buildings": buildings}
|
return {"buildings": buildings}
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -21,3 +21,20 @@ body {
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
padding: .5em;
|
padding: .5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.deployeeAquilenet {
|
||||||
|
display: inline;
|
||||||
|
color: green;
|
||||||
|
}
|
||||||
|
.deployeeFDN {
|
||||||
|
display: inline;
|
||||||
|
color: orange;
|
||||||
|
}
|
||||||
|
.deployeeAutres {
|
||||||
|
display: inline;
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
.nonDeployee {
|
||||||
|
display: inline;
|
||||||
|
color: brown;
|
||||||
|
}
|
|
@ -10,7 +10,6 @@ function initMap(btn) {
|
||||||
if (x && y && z) {
|
if (x && y && z) {
|
||||||
map.setView([y, x], z);
|
map.setView([y, x], z);
|
||||||
fetchEligData(map);
|
fetchEligData(map);
|
||||||
displayBtn(btn);
|
|
||||||
} else {
|
} else {
|
||||||
map.setView([46.710, 3.669], 6);
|
map.setView([46.710, 3.669], 6);
|
||||||
}
|
}
|
||||||
|
@ -68,15 +67,40 @@ function initAddrSearch(map) {
|
||||||
function updateEligData(map, eligData) {
|
function updateEligData(map, eligData) {
|
||||||
markers.map(marker => map.removeLayer(marker));
|
markers.map(marker => map.removeLayer(marker));
|
||||||
let buildings = eligData.buildings;
|
let buildings = eligData.buildings;
|
||||||
console.log(buildings)
|
|
||||||
markers = Object.values(buildings).map(building => {
|
markers = Object.values(buildings).map(building => {
|
||||||
console.log(building.numVoieImm)
|
|
||||||
console.log("lat", building.y)
|
|
||||||
console.log("lng", building.x)
|
|
||||||
const latlng = new L.latLng(building.y, building.x);
|
const latlng = new L.latLng(building.y, building.x);
|
||||||
const addrImm = `${building.numVoieImm} ${building.typeVoieImm} ${building.nomVoieImm}`
|
let addrImm = `${building.numVoieImm} ${building.typeVoieImm} ${building.nomVoieImm}`
|
||||||
|
if (building.bat_info != "") {
|
||||||
|
addrImm += ` (Bat ${building.bat_info})`
|
||||||
|
}
|
||||||
|
let messageElig = ``
|
||||||
|
eligTestApi=`testeligibilite/immeuble?idImm=${building.idImm}&codePostal=${building.codePostal}`
|
||||||
|
if (building.aquilenetEligStatus.isEligible) {
|
||||||
|
messageElig = `<p class=deployeeAquilenet>Fibre deployee !`
|
||||||
|
messageElig += `<br/><a href=${eligTestApi}>Tester l'eligibilite par Aquilenet`
|
||||||
|
if (building.fdnEligStatus.isEligible) {
|
||||||
|
messageElig += " et FDN"
|
||||||
|
}
|
||||||
|
messageElig += "</a></p>"
|
||||||
|
} else if (building.fdnEligStatus.isEligible && building.othersEligStatus.isEligible) {
|
||||||
|
messageElig = `<p class=deployeeFDN>Fibre deployee mais pas chez Aquilenet !`
|
||||||
|
messageElig += `<br/><a href=${eligTestApi}>Tester l'eligibilite par FDN</a></p>`
|
||||||
|
} else if (building.othersEligStatus.isEligible) {
|
||||||
|
messageElig = `<p class=deployeeAutres>Fibre deployee mais non eligible Aquilenet, desole :(</p>`
|
||||||
|
} else {
|
||||||
|
messageElig = `<p class=nonDeployee>Fibre non deployee :(</p>`
|
||||||
|
if (building.othersEligStatus.reasonNotEligible != "") {
|
||||||
|
messageElig += `<br/><br/>Status general ARCEP: ${building.othersEligStatus.reasonNotEligible}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (building.aquilenetEligStatus.reasonNotEligible != "") {
|
||||||
|
messageElig += `<br/> Pour Aquilenet, raison non eligible: ${building.aquilenetEligStatus.reasonNotEligible}`
|
||||||
|
}
|
||||||
const marker = new L.marker(latlng)
|
const marker = new L.marker(latlng)
|
||||||
.bindPopup(`${addrImm}<br/>Etat: ${building.etatImm}<br/>Code Immeuble: ${building.idImm}`);
|
.bindPopup(`${addrImm}<br/>${building.codePostal} ${building.commune}`
|
||||||
|
+ `<br/><br/>${messageElig}<br/><br/>Ref Immeuble: ${building.idImm}`, {
|
||||||
|
maxWidth : 560
|
||||||
|
});
|
||||||
map.addLayer(marker);
|
map.addLayer(marker);
|
||||||
return marker
|
return marker
|
||||||
});
|
});
|
||||||
|
@ -94,11 +118,14 @@ async function fetchEligData(map) {
|
||||||
const bounds = map.getBounds();
|
const bounds = map.getBounds();
|
||||||
const sw = bounds.getSouthWest();
|
const sw = bounds.getSouthWest();
|
||||||
const ne = bounds.getNorthEast();
|
const ne = bounds.getNorthEast();
|
||||||
|
const btn = document.getElementById("btn-load-elig-data");
|
||||||
|
waitBtn(btn);
|
||||||
const reqUri = encodeURI(`eligdata?swx=${sw.lng}&swy=${sw.lat}&nex=${ne.lng}&ney=${ne.lat}¢erlat=${mc.lat}¢erlng=${mc.lng}`);
|
const reqUri = encodeURI(`eligdata?swx=${sw.lng}&swy=${sw.lat}&nex=${ne.lng}&ney=${ne.lat}¢erlat=${mc.lat}¢erlng=${mc.lng}`);
|
||||||
const source = await fetch(reqUri);
|
const source = await fetch(reqUri);
|
||||||
const eligData = await source.json();
|
const eligData = await source.json();
|
||||||
updateEligData(map, eligData);
|
updateEligData(map, eligData);
|
||||||
updateUrl(map);
|
updateUrl(map);
|
||||||
|
displayBtn(btn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,6 +146,10 @@ function hideBtn(btn) {
|
||||||
btn.disabled = true;
|
btn.disabled = true;
|
||||||
btn.title = "Veuillez zoomer plus la carte avant de lancer une recherche d'éligibilité.";
|
btn.title = "Veuillez zoomer plus la carte avant de lancer une recherche d'éligibilité.";
|
||||||
}
|
}
|
||||||
|
function waitBtn(btn) {
|
||||||
|
btn.disabled = true;
|
||||||
|
btn.title = "Chargement des batiments...";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const btn = initBtn();
|
const btn = initBtn();
|
||||||
|
|
Loading…
Reference in a new issue