Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | ACADEMIC RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * PROJECT METADATA8 * -----------------------------------------------------------------------------9 * Project : UQO Éval10 * File : src/app/api/nearby/route.ts11 * Module : app12 * Repository : https://git.spboucher.ai/uqo-eval13 * Project Website : https://www.uqo-eval.app14 * Created : 2026-08-1115 * Last Modified : 2026-08-2816 *17 * =============================================================================18 * SOFTWARE MAINTAINER & AFFILIATION19 * =============================================================================20 *21 * Maintainer : Simon-Pierre Boucher22 * Position : Professor of Finance23 * Institution : Université du Québec en Outaouais (UQO)24 * Department : Département des sciences administratives25 * Website : https://spboucher.ai26 * Git : https://git.spboucher.ai27 *28 * Research Contact : research@spboucher.ai29 * Direct Contact : simon@spboucher.ai30 * Security/Admin : admin@spboucher.ai31 *32 * The affiliation is descriptive. It is not an institutional endorsement,33 * a license grant or a determination of ownership.34 *35 * =============================================================================36 * COPYRIGHT, AUTHORSHIP & DATA37 * =============================================================================38 *39 * Copyright (c) the author(s) of this work.40 * Ownership is not asserted by this notice; see the repository records.41 *42 * This header identifies the maintainer of the software. Scientific43 * authorship of any associated paper is stated in the paper itself and44 * is not changed by this notice. Datasets and third-party materials45 * remain the property of their respective owners and licensors.46 *47 * This file is governed by the applicable project license, copyright48 * notices, institutional agreements and relevant law.49 *50 * =============================================================================51 * LICENSE & MAINTENANCE52 * =============================================================================53 *54 * License : None specified (no license file in this repository)55 * Classification : Public56 *57 * =============================================================================58 * END OF SP BOUCHER SOURCE HEADER59 * =============================================================================60 */6162// UQO Éval — laboratoire pédagogique d'évaluation immobilière63// Recherche par carte : unités d'évaluation autour d'un point (boîte englobante).64// Le rayon est plafonné côté serveur — la carte doit être assez zoomée.65import { NextRequest, NextResponse } from "next/server";66import { unitsNear } from "@/lib/db";6768// Plafonds relevés pour UQO Éval Maps (Ka Maps) : les valeurs par défaut69// restent inchangées — l'app iOS 1.1.0 en place reçoit exactement le même70// contrat (changement additif ; ses gouttières disparaissent même).71const MAX_HALF_LAT = 0.08; // ~8,9 km72const MAX_HALF_LNG = 0.12;73const MAX_LIMIT = 1500;7475export function GET(req: NextRequest) {76 const q = req.nextUrl.searchParams;77 const lat = Number(q.get("lat"));78 const lng = Number(q.get("lng"));79 if (!Number.isFinite(lat) || !Number.isFinite(lng)) {80 return NextResponse.json({ error: "lat et lng requis" }, { status: 400 });81 }82 const halfLat = Math.min(Math.abs(Number(q.get("halfLat")) || 0.008), MAX_HALF_LAT);83 const halfLng = Math.min(Math.abs(Number(q.get("halfLng")) || 0.012), MAX_HALF_LNG);84 const limit = Math.min(Math.abs(Number(q.get("limit")) || 300), MAX_LIMIT);85 try {86 const results = unitsNear(lat, lng, halfLat, halfLng, limit).map((u) => ({87 id: u.id_provinc,88 adresse: u.adresse,89 apt: u.apt,90 municipalite: u.municipalite,91 typeProp: u.type_prop,92 lat: u.lat,93 lng: u.lng,94 est2026: u.est_2026,95 }));96 return NextResponse.json({ results });97 } catch {98 return NextResponse.json({ results: [] });99 }100}101