johan/consolidate-ipe-data #5
4 changed files with 52 additions and 41 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
.idea
|
|
@ -31,7 +31,12 @@ EOF
|
||||||
done
|
done
|
||||||
echo ""
|
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."
|
echo "[+] Ingesting spatial data."
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ def getEligData():
|
||||||
args = request.args
|
args = request.args
|
||||||
valid_args = True
|
valid_args = True
|
||||||
processed_args = {}
|
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
|
valid_args = valid_args and k in args
|
||||||
if valid_args:
|
if valid_args:
|
||||||
try:
|
try:
|
||||||
|
@ -51,18 +51,20 @@ 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
|
# Need to narrow coordinates for Liazo API call
|
||||||
# wide_coordinates=AreaCoordinates(
|
|
||||||
# swx=processed_args['swx'],
|
# computes center
|
||||||
# swy=processed_args['swy'],
|
centerx = (processed_args['swx'] + processed_args['nex']) / 2
|
||||||
# nex=processed_args['nex'],
|
centery = (processed_args['swy'] + processed_args['ney']) / 2
|
||||||
# ney=processed_args['ney'],
|
|
||||||
# )
|
narrow_x = 0.0022
|
||||||
|
narrow_y = 0.0011
|
||||||
|
|
||||||
narrow_coordinates = AreaCoordinates(
|
narrow_coordinates = AreaCoordinates(
|
||||||
swx=processed_args['centerlng']-0.0022,
|
swx=centerx - narrow_x,
|
||||||
swy=processed_args['centerlat']-0.0011,
|
swy=centery - narrow_y,
|
||||||
nex=processed_args['centerlng']+0.0022,
|
nex=centerx + narrow_x,
|
||||||
ney=processed_args['centerlat']+0.0011,
|
ney=centery + narrow_y,
|
||||||
)
|
)
|
||||||
buildings = dict()
|
buildings = dict()
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -72,6 +72,7 @@ streetTypeConversion.set("zone industrielle", "zi")
|
||||||
streetTypeConversion.set("zone", "zone")
|
streetTypeConversion.set("zone", "zone")
|
||||||
|
|
||||||
let markers = [];
|
let markers = [];
|
||||||
|
|
||||||
function initMap(btn) {
|
function initMap(btn) {
|
||||||
// Init map position/zoom. Potentially using what's in the URL search string.
|
// Init map position/zoom. Potentially using what's in the URL search string.
|
||||||
const params = new URLSearchParams(window.location.search);
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
@ -153,8 +154,8 @@ function updateEligData(map, eligData) {
|
||||||
messageElig = `<p class=deployeeAquilenet>Fibre deployee et disponible par Aquilenet !</p>`
|
messageElig = `<p class=deployeeAquilenet>Fibre deployee et disponible par Aquilenet !</p>`
|
||||||
const zip = encodeURIComponent(building.codePostal);
|
const zip = encodeURIComponent(building.codePostal);
|
||||||
const idImm = encodeURIComponent(building.idImm);
|
const idImm = encodeURIComponent(building.idImm);
|
||||||
messageElig += `<br/><a href=${urlTestFTTH}?ftth=1&axione=1&adsltel=NOUVEAU&cp=${zip}&refimmeuble=${idImm}`
|
messageElig += `<br/><a href=${urlTestFTTH}?ftth=1&axione=1&adsltel=NOUVEAU&cp=${zip}&refimmeuble=${idImm}` +
|
||||||
+ `>Tester l'éligibilité</a>`
|
`>Tester l'éligibilité</a>`
|
||||||
colorMarker = 'green'
|
colorMarker = 'green'
|
||||||
// pas de données Axione mais Kosc nous renvoie qque chose à cette adresse (fdnEligStatus)
|
// pas de données Axione mais Kosc nous renvoie qque chose à cette adresse (fdnEligStatus)
|
||||||
// c'est peut être OK, on croise avec les données ARCEP (othersEligStatus)
|
// c'est peut être OK, on croise avec les données ARCEP (othersEligStatus)
|
||||||
|
@ -178,8 +179,8 @@ function updateEligData(map, eligData) {
|
||||||
}
|
}
|
||||||
const street = encodeURIComponent(`${convertType} ${building.nomVoieImm}`)
|
const street = encodeURIComponent(`${convertType} ${building.nomVoieImm}`)
|
||||||
const street_nb = encodeURIComponent(building.numVoieImm)
|
const street_nb = encodeURIComponent(building.numVoieImm)
|
||||||
messageElig += `<br/><a href=${urlADSL}?zip=${zip}&city=${comm}&street=${street}&street_nb=${street_nb}&gps=&do=1&submit=Valider`
|
messageElig += `<br/><a href=${urlADSL}?zip=${zip}&city=${comm}&street=${street}&street_nb=${street_nb}&gps=&do=1&submit=Valider` +
|
||||||
+ `>Tester ADSL a cette adresse</a>`
|
`>Tester ADSL a cette adresse</a>`
|
||||||
if (building.othersEligStatus.reasonNotEligible != "") {
|
if (building.othersEligStatus.reasonNotEligible != "") {
|
||||||
messageElig += `<br/><br/>Status general ARCEP: ${building.othersEligStatus.reasonNotEligible}`
|
messageElig += `<br/><br/>Status general ARCEP: ${building.othersEligStatus.reasonNotEligible}`
|
||||||
}
|
}
|
||||||
|
@ -196,9 +197,11 @@ function updateEligData(map, eligData) {
|
||||||
popupAnchor: [1, -34],
|
popupAnchor: [1, -34],
|
||||||
shadowSize: [41, 41]
|
shadowSize: [41, 41]
|
||||||
});
|
});
|
||||||
const marker = new L.marker(latlng, {icon: markerIcon})
|
const marker = new L.marker(latlng, {
|
||||||
.bindPopup(`${addrImm}<br/>${building.codePostal} ${building.commune}`
|
icon: markerIcon
|
||||||
+ `<br/><br/>${messageElig}<br/><br/>Ref Immeuble: ${building.idImm}`, {
|
})
|
||||||
|
.bindPopup(`${addrImm}<br/>${building.codePostal} ${building.commune}` +
|
||||||
|
`<br/><br/>${messageElig}<br/><br/>Ref Immeuble: ${building.idImm}`, {
|
||||||
maxWidth: 560
|
maxWidth: 560
|
||||||
});
|
});
|
||||||
map.addLayer(marker);
|
map.addLayer(marker);
|
||||||
|
@ -214,13 +217,12 @@ function updateUrl(map) {
|
||||||
async function fetchEligData(map) {
|
async function fetchEligData(map) {
|
||||||
const zoom = map.getZoom();
|
const zoom = map.getZoom();
|
||||||
if (zoom >= minZoomForRequest) {
|
if (zoom >= minZoomForRequest) {
|
||||||
const mc = map.getCenter();
|
|
||||||
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");
|
const btn = document.getElementById("btn-load-elig-data");
|
||||||
waitBtn(btn);
|
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}`);
|
||||||
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);
|
||||||
|
@ -246,6 +248,7 @@ 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) {
|
function waitBtn(btn) {
|
||||||
btn.disabled = true;
|
btn.disabled = true;
|
||||||
btn.title = "Chargement des batiments...";
|
btn.title = "Chargement des batiments...";
|
||||||
|
|
Loading…
Reference in a new issue