Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : KA Maps Engine9// File : sdk/ios/Example/App/Scenarios6.swift10// Module : sdk11// Repository : https://git.spboucher.ai/ka-maps-engine12// Created : 2026-12-0113// Last Modified : 2026-12-0114//15// =============================================================================16// AUTHOR & PROFESSIONAL AFFILIATION17// =============================================================================18//19// Author : Simon-Pierre Boucher20// Position : Professor of Finance21// Institution : Université du Québec en Outaouais (UQO)22// Department : Département des sciences administratives23// Organization : SP Boucher24//25// Website : https://spboucher.ai26// Git : https://git.spboucher.ai27//28// =============================================================================29// OFFICIAL CONTACT DIRECTORY30// =============================================================================31//32// General : info@spboucher.ai33// Professional : contact@spboucher.ai34// Direct : simon@spboucher.ai35// Research : research@spboucher.ai36// Development : dev@spboucher.ai37// Support : support@spboucher.ai38// Security/Admin : admin@spboucher.ai39// Notifications : notifications@spboucher.ai40//41// Preferred Contact: support@spboucher.ai42//43// =============================================================================44// COPYRIGHT & INTELLECTUAL PROPERTY45// =============================================================================46//47// Copyright (c) 202648// Simon-Pierre Boucher49//50// All rights reserved where applicable.51//52// This file is governed by the applicable project license,53// copyright notices, institutional agreements and relevant law.54//55// Unless expressly authorized by the applicable license or56// rights holder, copying, redistribution, sublicensing,57// publication and commercial exploitation are not permitted.58//59// Existing third-party rights and notices remain unaffected.60//61// =============================================================================62// CONFIDENTIALITY & SECURITY63// =============================================================================64//65// Classification : Public66// Distribution : Public repository; use is governed by the project license67// Security Contact : admin@spboucher.ai68//69// Access to this source does not independently grant permission70// to redistribute or disclose confidential materials.71//72// Do not embed credentials, private keys, access tokens,73// certificates or confidential personal information.74//75// =============================================================================76// LICENSE & MAINTENANCE77// =============================================================================78//79// License : None specified (no license file in this repository)80// Maintainer : Simon-Pierre Boucher81// Technical Contact: dev@spboucher.ai82//83// =============================================================================84// END OF SP BOUCHER SOURCE HEADER85// =============================================================================8687import CoreLocation88import KAMaps89import UIKit9091/// SDK 0.4.1 : interroger la carte ou la toucher dans la même trame qu'un remplacement ou un retrait de couche —92/// ce que fait une application quand un filtre change pendant que le doigt est posé. Sur le moteur de la 0.4.0 le93/// processus s'arrête (« index out of bounds » dans le moteur, compilé en `panic = abort`).94extension ScenarioRunner {95 static var round6: [String] { ["staleframe"] }9697 func staleFrame() async throws {98 try await reset(.montreal, zoom: 14.2)99 guard let v = map.mapView else { throw ScenarioFailure("vue absente") }100 let c = DemoPlace.montreal.coordinate101 let many = DemoData.markers(around: c, count: 180, brand: .louka, spread: 0.02, seed: 13)102 var probes = 0103 // `-tolerant 1` : les erreurs rendues sont comptées au lieu d'arrêter le scénario (pour mesurer la 0.4.0).104 let tolerant = ProcessInfo.processInfo.arguments.contains("-tolerant")105 var thrown: [String] = []106 func q(_ body: () throws -> Void) throws {107 do { try body() } catch {108 if !tolerant { throw error }109 thrown.append("\(error)")110 }111 }112 let errors0 = model.log.filter { if case .error = $0.event { return true } else { return false } }.count113114 // A. Données remplacées par un tableau plus court (filtre), puis interrogation et toucher sans attendre la trame.115 for round in 0..<6 {116 try await settle { map.addLayer(.markers(id: "filtre", many, cluster: round % 2 == 0 ? nil : KAClusterOptions(), density: .off)) }117 await sleep(0.2)118 let drawn = try map.renderedMarkers(layer: "filtre")119 try check(drawn.count >= 3, "trop peu de signes dessinés pour l'essai : \(drawn.count)")120 map.addLayer(.markers(id: "filtre", Array(many.prefix(2)), cluster: round % 2 == 0 ? nil : KAClusterOptions(), density: .off))121 // Même trame : la carte n'a pas redessiné.122 try q { _ = try map.renderedMarkers(layer: "filtre") }123 try q { _ = try map.renderedMarkers() }124 for d in drawn.suffix(12) {125 try q { _ = try map.queryRendered(at: d.center) }126 try q { _ = try map.queryRendered(at: d.center, layers: ["filtre"]) }127 v.simulateTap(at: d.center)128 probes += 4129 }130 _ = map.renderedMarker(layer: "filtre", id: many[100].id)131 _ = v.accessibilityElements132 }133 fact("apresRemplacement", .number(Double(probes)))134135 // B. Couche retirée (elle était la dernière : son rang n'existe plus), puis interrogation et toucher.136 for _ in 0..<6 {137 try await settle { map.addLayer(.markers(id: "filtre", many, cluster: nil, density: .off)) }138 await sleep(0.2)139 let drawn = try map.renderedMarkers(layer: "filtre")140 map.removeLayer("filtre")141 try q { _ = try map.renderedMarkers() }142 for d in drawn.suffix(12) {143 try q { _ = try map.queryRendered(at: d.center) }144 v.simulateTap(at: d.center)145 probes += 2146 }147 _ = v.accessibilityElements148 }149 fact("sondes", .number(Double(probes)))150 fact("erreursRendues", .number(Double(thrown.count)))151 fact("premiereErreur", .string(thrown.first ?? ""))152 fact("evenementsErreur", .number(Double(model.log.filter { if case .error = $0.event { return true } else { return false } }.count - errors0)))153 // La carte vit toujours et redessine.154 try await settle { map.addLayer(.markers(id: "filtre", many, cluster: nil, density: .off)) }155 await sleep(0.2)156 try check(try map.renderedMarkers(layer: "filtre").count > 10, "la carte doit redessiner la couche après les sondes")157 map.removeLayer("filtre")158 await checkpoint("staleframe")159 }160}161