Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : KA Maps Engine8 * File : sdk/web/demo/data.ts9 * Module : sdk10 * Repository : https://git.spboucher.ai/ka-maps-engine11 * Created : 2026-12-0112 * Last Modified : 2026-12-0113 *14 * Author : Simon-Pierre Boucher15 * Position : Professor of Finance16 * Institution : Université du Québec en Outaouais (UQO)17 * Organization : SP Boucher18 * Website : https://spboucher.ai19 * Git : https://git.spboucher.ai20 *21 * Preferred Contact: support@spboucher.ai22 * Development : dev@spboucher.ai23 * Support : support@spboucher.ai24 * Security/Admin : admin@spboucher.ai25 *26 * Copyright (c) 202627 * Simon-Pierre Boucher28 * All rights reserved where applicable. This file is governed by the29 * applicable project license, copyright notices and relevant law.30 * Existing third-party rights and notices remain unaffected.31 *32 * License : None specified (no license file in this repository)33 *34 * Do not embed credentials, private keys, access tokens,35 * certificates or confidential personal information.36 *37 * =============================================================================38 * END OF SP BOUCHER SOURCE HEADER39 * =============================================================================40 */4142// Données de DÉMONSTRATION : générées par un tirage pseudo-aléatoire à graine fixe.43// Aucune de ces valeurs n'est une annonce, un loyer ou une évaluation réels.4445import type { BuildingDatum, ColumnDatum, GeoJSONInput, HeatDatum, LngLat, MarkerDatum, PointDatum, Scale, SurfaceGrid } from '@ka/maps';4647export const MONTREAL: LngLat = [-73.5674, 45.5019];48export const QUEBEC: LngLat = [-71.208, 46.8139];49export const RURAL: LngLat = [-71.9, 48.5];5051function rng(seed: number): () => number {52 let s = seed >>> 0;53 return () => {54 s = (s + 0x6d2b79f5) | 0;55 let t = Math.imul(s ^ (s >>> 15), 1 | s);56 t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;57 return ((t ^ (t >>> 14)) >>> 0) / 4294967296;58 };59}6061function gauss(r: () => number): number {62 return Math.sqrt(-2 * Math.log(1 - r())) * Math.cos(2 * Math.PI * r());63}6465export const RENT_SCALE: Scale = {66 type: 'steps',67 stops: [68 [0, '#2c7fb8'],69 [1200, '#41b6c4'],70 [1600, '#a1dab4'],71 [2000, '#fecc5c'],72 [2400, '#fd8d3c'],73 [2800, '#e31a1c'],74 ],75 nullColor: '#9aa0a6',76};7778export const VALUE_SCALE: Scale = {79 type: 'linear',80 stops: [81 [2500, '#f7fbff'],82 [4500, '#9ecae1'],83 [6500, '#4292c6'],84 [9000, '#08306b'],85 ],86 nullColor: '#cccccc',87};8889/** Pastilles de loyer fictives autour d'un centre (grappes aux petits zooms). */90export function demoMarkers(center: LngLat, n = 400, seed = 7): MarkerDatum[] {91 const r = rng(seed);92 const out: MarkerDatum[] = [];93 for (let i = 0; i < n; i++) {94 const lon = center[0] + gauss(r) * 0.035;95 const lat = center[1] + gauss(r) * 0.022;96 const value = Math.round((950 + r() * 2100) / 25) * 25;97 const p = r();98 out.push({99 id: `demo-${i}`,100 lon,101 lat,102 value,103 label: `${value.toLocaleString('fr-CA')} $`,104 nature: p < 0.8 ? 'observe' : p < 0.93 ? 'estime' : 'hypothese',105 kind: r() < 0.5 ? 'appartement' : 'condo',106 });107 }108 return out;109}110111export function demoPoints(center: LngLat, n = 300, seed = 11): PointDatum[] {112 const r = rng(seed);113 return Array.from({ length: n }, (_, i) => ({114 id: i,115 lon: center[0] + gauss(r) * 0.03,116 lat: center[1] + gauss(r) * 0.02,117 value: Math.round(900 + r() * 2200),118 }));119}120121export function demoHeat(center: LngLat, n = 1500, seed = 13): HeatDatum[] {122 const r = rng(seed);123 const hubs: LngLat[] = [center, [center[0] + 0.03, center[1] + 0.015], [center[0] - 0.035, center[1] - 0.01]];124 return Array.from({ length: n }, () => {125 const h = hubs[Math.floor(r() * hubs.length)];126 return { lon: h[0] + gauss(r) * 0.012, lat: h[1] + gauss(r) * 0.008, weight: 0.3 + r() };127 });128}129130/** Trois secteurs fictifs (rectangles tournés), chacun avec une valeur. */131export function demoPolygons(center: LngLat): GeoJSONInput {132 const mk = (dx: number, dy: number, w: number, h: number, rot: number, name: string, value: number) => {133 const c = Math.cos(rot);134 const s = Math.sin(rot);135 const pts = [136 [-w, -h],137 [w, -h],138 [w, h],139 [-w, h],140 [-w, -h],141 ].map(([x, y]) => [center[0] + dx + (x * c - y * s), center[1] + dy + (x * s + y * c) * 0.7]);142 return { type: 'Feature', id: name, properties: { name, value, demo: true }, geometry: { type: 'Polygon', coordinates: [pts] } };143 };144 return {145 type: 'FeatureCollection',146 features: [mk(-0.02, 0.012, 0.012, 0.01, 0.5, 'Secteur démo A', 1350), mk(0.012, 0.016, 0.014, 0.009, 0.5, 'Secteur démo B', 1900), mk(0.004, -0.014, 0.016, 0.008, 0.5, 'Secteur démo C', 2550)],147 };148}149150export function demoLine(center: LngLat): GeoJSONInput {151 const pts: LngLat[] = [];152 for (let i = 0; i <= 40; i++) {153 const t = i / 40;154 pts.push([center[0] - 0.03 + t * 0.06, center[1] - 0.012 + Math.sin(t * Math.PI * 2) * 0.006 + t * 0.02]);155 }156 return { type: 'Feature', properties: { name: 'Trajet de démonstration' }, geometry: { type: 'LineString', coordinates: pts } };157}158159/** Points posés sur le centre-ville : le moteur les rattache aux VRAIES empreintes du fond. */160export function demoBuildings(center: LngLat, n = 60, seed = 17): BuildingDatum[] {161 const r = rng(seed);162 return Array.from({ length: n }, (_, i) => ({163 id: `bat-${i}`,164 lon: center[0] + (r() - 0.5) * 0.012,165 lat: center[1] + (r() - 0.5) * 0.008,166 value: Math.round(900 + r() * 2200),167 nature: 'estime' as const,168 }));169}170171export function demoColumns(center: LngLat, seed = 19): ColumnDatum[] {172 const r = rng(seed);173 const out: ColumnDatum[] = [];174 for (let i = 0; i < 6; i++) {175 for (let j = 0; j < 5; j++) {176 const value = Math.round(2500 + r() * 6500);177 out.push({ id: `col-${i}-${j}`, lon: center[0] - 0.02 + i * 0.008, lat: center[1] - 0.03 + j * 0.004, value, height: 40 + (value - 2500) / 30 });178 }179 }180 return out;181}182183export function demoSurface(center: LngLat, seed = 23): SurfaceGrid {184 const r = rng(seed);185 const cols = 24;186 const rows = 24;187 const values: (number | null)[] = [];188 for (let y = 0; y < rows; y++) {189 for (let x = 0; x < cols; x++) {190 const dx = (x - cols / 2) / cols;191 const dy = (y - rows / 2) / rows;192 const d = Math.hypot(dx, dy);193 values.push(d > 0.55 ? null : Math.round(9000 - d * 11000 + r() * 500));194 }195 }196 return { o: center[0] - 0.05, s: center[1] - 0.032, e: center[0] + 0.05, n: center[1] + 0.032, cols, rows, values };197}198