feat: 220 colonias reales de Celaya mapeadas a 15 rutas con Haversine
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -128,6 +128,20 @@ def get_eta(domicilio_id: int,
|
|||||||
raise HTTPException(status_code=404, detail="Ruta no encontrada")
|
raise HTTPException(status_code=404, detail="Ruta no encontrada")
|
||||||
return {**eta, "route_id": dom.route_id, "colonia": dom.colonia}
|
return {**eta, "route_id": dom.route_id, "colonia": dom.colonia}
|
||||||
|
|
||||||
|
@app.get("/colonias-por-cp")
|
||||||
|
def colonias_por_cp(
|
||||||
|
codigo_postal: str,
|
||||||
|
current_user=Depends(auth.get_current_user)
|
||||||
|
):
|
||||||
|
colonias = [
|
||||||
|
v["colonia"] for v in simulator.COLONIAS_COMPLETAS.values()
|
||||||
|
if v.get("cp") == codigo_postal
|
||||||
|
]
|
||||||
|
return {
|
||||||
|
"colonias": sorted(set(colonias)),
|
||||||
|
"encontrado": len(colonias) > 0
|
||||||
|
}
|
||||||
|
|
||||||
@app.post("/reportes")
|
@app.post("/reportes")
|
||||||
def crear_reporte(
|
def crear_reporte(
|
||||||
domicilio_id: int,
|
domicilio_id: int,
|
||||||
|
|||||||
@@ -16,6 +16,14 @@ with open(os.path.join(BASE_DIR, "data", "colonias-rutas.json")) as f:
|
|||||||
for item in json.load(f):
|
for item in json.load(f):
|
||||||
COLONIAS[item["colonia"].lower()] = item
|
COLONIAS[item["colonia"].lower()] = item
|
||||||
|
|
||||||
|
COLONIAS_COMPLETAS = {}
|
||||||
|
try:
|
||||||
|
with open(os.path.join(BASE_DIR, "data", "colonias-rutas-completo.json")) as f:
|
||||||
|
for item in json.load(f):
|
||||||
|
COLONIAS_COMPLETAS[item["colonia"].lower()] = item
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
def init_rutas(db: Session):
|
def init_rutas(db: Session):
|
||||||
for ruta in RUTAS:
|
for ruta in RUTAS:
|
||||||
existe = db.query(models.EstadoRuta).filter_by(route_id=ruta["routeId"]).first()
|
existe = db.query(models.EstadoRuta).filter_by(route_id=ruta["routeId"]).first()
|
||||||
|
|||||||
1762
data/colonias-rutas-completo.json
Normal file
1762
data/colonias-rutas-completo.json
Normal file
File diff suppressed because it is too large
Load Diff
1790
data/colonias_celaya.json
Normal file
1790
data/colonias_celaya.json
Normal file
File diff suppressed because it is too large
Load Diff
1322
data/colonias_celaya_coords.json
Normal file
1322
data/colonias_celaya_coords.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user