From 17364b3dfaf19ff9cd4d79106553a3b55c02b794 Mon Sep 17 00:00:00 2001 From: aasedor Date: Sat, 21 Nov 2026 09:39:36 -0700 Subject: [PATCH 1/4] Tighten catalogue building placement and show quantities --- .../data/catalogue_dwelling_programmes.json | 141 +++++++++++++++++- backend/app/services/model_contract.py | 16 +- backend/app/services/student_report.py | 43 ++++-- backend/tests/test_student_report.py | 27 ++++ frontend/scripts/check-model-contract.mjs | 21 +++ frontend/scripts/packed-catalogue.mjs | 4 +- frontend/scripts/packed-catalogue.test.mjs | 3 +- .../globe/buildingPlotLandscape.test.ts | 16 +- .../viewer/globe/buildingPlotLandscape.ts | 8 +- .../src/data/catalogueBuildingQuantities.json | 138 +++++++++++++++++ frontend/src/data/runtimeAssetManifest.json | 1 + .../pickPlace/CanonicalCatalogueCard.test.tsx | 8 + .../pickPlace/CanonicalCatalogueCard.tsx | 24 +++ .../src/features/pickPlace/ReshapePanel.tsx | 7 +- .../src/features/pickPlace/assetRegistry.ts | 6 +- .../pickPlace/buildingOnlyFootprint.ts | 25 +++- .../pickPlace/buildingOnlyFootprints.test.ts | 12 +- frontend/src/features/pickPlace/catalogue.ts | 1 + .../src/features/pickPlace/catalogueFacets.ts | 3 +- .../src/features/pickPlace/geometry.test.ts | 16 ++ .../releaseCandidateContracts.test.ts | 11 +- .../features/pickPlace/savedModelRevision.ts | 1 + frontend/src/types/index.ts | 2 + 23 files changed, 487 insertions(+), 47 deletions(-) create mode 100644 frontend/src/data/catalogueBuildingQuantities.json diff --git a/backend/app/data/catalogue_dwelling_programmes.json b/backend/app/data/catalogue_dwelling_programmes.json index a95340878..d94cc1baa 100644 --- a/backend/app/data/catalogue_dwelling_programmes.json +++ b/backend/app/data/catalogue_dwelling_programmes.json @@ -1,11 +1,138 @@ { - "source": "Exact authored affordable-housing programmes in frontend/src/data/buildingArchetypes.json, reviewed 2026-10-07; revision-locked bungalow programme in docs/CLASSROOM_STARTER_ACCEPTANCE_2026-09-24.md. Concept dwellings, not occupancy approval or measured floor area.", + "source": "Concept quantities for exact catalogue revisions, based on authored floor plates and documented building programmes.", "records": [ - {"variant_id":"affordable_porchlight_original","revision":"affordable-porchlight-clay-v004","dwellings":4}, - {"variant_id":"affordable_juniper_original","revision":"affordable-juniper-clay-v006","dwellings":4}, - {"variant_id":"affordable_stackyard_original","revision":"affordable-stackyard-clay-v003","dwellings":6}, - {"variant_id":"affordable_aspen_original","revision":"affordable-aspen-clay-v003","dwellings":12}, - {"variant_id":"affordable_switchback_original","revision":"affordable-switchback-clay-v003","dwellings":24}, - {"variant_id":"bungalow_postwar_ranch","revision":"calgary-inner-city-bungalow-clay-v005","dwellings":1,"retail_units":0,"allow_exact_flexible_native_revision":true,"development_type":"residential_single_family","source_title":"Post-war bungalow · reviewed single-home programme","source":"docs/CLASSROOM_STARTER_ACCEPTANCE_2026-09-24.md#bungalow_postwar_ranch","source_excerpt":"Native dimensions 10.898324 × 16.050000 × 6.360000 m, one floor, one home. The reviewed source is a single-family residential home, with no retail programme."} + { + "variant_id": "affordable_porchlight_original", + "revision": "affordable-porchlight-clay-v004", + "dwellings": 4, + "gross_floor_area_m2": 396, + "source": "Two enclosed 22 × 9 m rowhouse floors. Front and rear gardens are outside the floor area." + }, + { + "variant_id": "affordable_juniper_original", + "revision": "affordable-juniper-clay-v006", + "dwellings": 4, + "gross_floor_area_m2": 196, + "source": "Four one-storey cottages with 49 m² each. Shared garden and private patios are outside the floor area." + }, + { + "variant_id": "affordable_stackyard_original", + "revision": "affordable-stackyard-clay-v003", + "dwellings": 6, + "gross_floor_area_m2": 462, + "source": "Two enclosed 21 × 11 m floors. The external gallery and stairs are outside the floor area." + }, + { + "variant_id": "affordable_aspen_original", + "revision": "affordable-aspen-clay-v003", + "dwellings": 12, + "gross_floor_area_m2": 936, + "source": "Three enclosed 24 × 13 m apartment floors, including shared circulation." + }, + { + "variant_id": "affordable_switchback_original", + "revision": "affordable-switchback-clay-v003", + "dwellings": 24, + "gross_floor_area_m2": 1344, + "source": "Four enclosed 24 × 14 m studio apartment floors, including shared circulation." + }, + { + "variant_id": "bungalow_postwar_ranch", + "revision": "calgary-inner-city-bungalow-clay-v005", + "dwellings": 1, + "retail_units": 0, + "allow_exact_flexible_native_revision": true, + "development_type": "residential_single_family", + "source_title": "Post-war bungalow · reviewed single-home programme", + "source": "docs/CLASSROOM_STARTER_ACCEPTANCE_2026-09-24.md#bungalow_postwar_ranch", + "source_excerpt": "Native dimensions 10.898324 × 16.050000 × 6.360000 m, one floor, one home. The reviewed source is a single-family residential home, with no retail programme." + }, + { + "variant_id": "reference_charcoal_gable_fourplex_v1", + "revision": "22538e0683d0ee64995c5c24d20972c9b86ca84fa615ca20fec346a908bb1732", + "requires_placement_plot": true, + "dwellings": 4, + "development_type": "residential" + }, + { + "variant_id": "london-crescent-terrace-bath-stone", + "revision": "crescent-terrace-bath-stone-clay-v006", + "requires_placement_plot": true, + "dwellings": 18, + "development_type": "residential" + }, + { + "variant_id": "infill_duplex", + "revision": "calgary-side-by-side-duplex-clay-v004", + "requires_placement_plot": true, + "dwellings": 2, + "development_type": "residential" + }, + { + "variant_id": "montreal_duplex_plateau", + "revision": "montreal-plateau-duplex-clay-v004", + "requires_placement_plot": true, + "dwellings": 2, + "development_type": "residential" + }, + { + "variant_id": "brick_timber_two_storey_office", + "revision": "brick-timber-courtyard-office-clay-v004", + "requires_placement_plot": true, + "gross_floor_area_m2": 224, + "development_type": "commercial_office", + "source": "Two authored 112 m² floor plates, including circulation." + }, + { + "variant_id": "garden_mews_six_homes", + "revision": "garden-mews-courtyard-housing-clay-v003", + "requires_placement_plot": true, + "dwellings": 6, + "gross_floor_area_m2": 504, + "development_type": "residential", + "source": "Six two-storey 6 × 7 m homes. The shared court and patios are outside the floor area." + }, + { + "variant_id": "horizon_double_section", + "revision": "horizon-manufactured-home-clay-v003", + "requires_placement_plot": true, + "dwellings": 1, + "gross_floor_area_m2": 97.92, + "development_type": "residential_single_family", + "source": "One 13.6 × 7.2 m enclosed storey. The roof step is unoccupied." + }, + { + "variant_id": "maple_porch_sage", + "revision": "maple-porch-manufactured-cottage-clay-v004", + "requires_placement_plot": true, + "dwellings": 1, + "gross_floor_area_m2": 67.2, + "development_type": "residential_single_family", + "source": "One 14 × 4.8 m enclosed storey. The front porch is open." + }, + { + "variant_id": "brick_timber_craftsman", + "revision": "narrow-lot-craftsman-cottage-clay-v003", + "requires_placement_plot": true, + "dwellings": 1, + "gross_floor_area_m2": 92.16, + "development_type": "residential_single_family", + "source": "One 7.2 × 12.8 m enclosed storey. The porch and unoccupied attic are outside the floor area." + }, + { + "variant_id": "folded_roof_market_hall", + "revision": "599cd816bf995ab20eece3731602d2148d15eb9c8605ff84b6e7fb102ee3dcf7", + "requires_placement_plot": true, + "gross_floor_area_m2": 243.5, + "development_type": "commercial_retail", + "source": "Five enclosed ground-floor workshops measured to glazing and outside walls. The open market canopy is outside the floor area." + }, + { + "variant_id": "montreal_depanneur_modern", + "revision": "brick-corner-grocery-clay-v002", + "requires_placement_plot": true, + "dwellings": 1, + "development_type": "mixed_use" + } ] } diff --git a/backend/app/services/model_contract.py b/backend/app/services/model_contract.py index 7a35cfb66..756f1b91e 100644 --- a/backend/app/services/model_contract.py +++ b/backend/app/services/model_contract.py @@ -89,12 +89,12 @@ def uses_placement_plot(properties: dict[str, Any]) -> bool: @lru_cache(maxsize=1) -def _dwelling_programmes() -> tuple[dict, ...]: +def _quantity_records() -> tuple[dict, ...]: return tuple(json.loads((DATA / "catalogue_dwelling_programmes.json").read_text(encoding="utf-8"))["records"]) -def catalogue_housing_programme(properties: dict[str, Any]) -> dict | None: - """Return only a reviewed programme for the unchanged native revision.""" +def catalogue_building_quantities(properties: dict[str, Any]) -> dict | None: + """Return reviewed quantities for the matching catalogue revision and storeys.""" facts = native_model_facts(properties) if not facts: return None @@ -103,13 +103,17 @@ def catalogue_housing_programme(properties: dict[str, Any]) -> dict | None: programme = next( ( row - for row in _dwelling_programmes() + for row in _quantity_records() if row["variant_id"] == facts["variant_id"] and row["revision"] == facts["revision"] ), None, ) if not programme: return None + # Some saved allocation shapes use a catalogue variant as a design + # reference. Description quantities describe a single placed model. + if programme.get("requires_placement_plot") and properties.get("building_geometry_basis") != "placement_plot": + return None # A model capable of student edits is still its reviewed native home when # saved with this exact revision and native storeys. Future/edited house # assemblies receive no programme merely from a shared parent archetype. @@ -122,5 +126,5 @@ def catalogue_housing_programme(properties: dict[str, Any]) -> dict | None: def catalogue_dwellings(properties: dict[str, Any]) -> int | None: - programme = catalogue_housing_programme(properties) - return programme["dwellings"] if programme else None + programme = catalogue_building_quantities(properties) + return programme.get("dwellings") if programme else None diff --git a/backend/app/services/student_report.py b/backend/app/services/student_report.py index 3f361cc11..1bdaa37b4 100644 --- a/backend/app/services/student_report.py +++ b/backend/app/services/student_report.py @@ -20,7 +20,7 @@ from app.services.plan_metrics import DerivedMetric from app.services.saved_site_assessment import matching_assessment -from app.services.model_contract import uses_placement_plot, catalogue_dwellings, catalogue_housing_programme +from app.services.model_contract import catalogue_building_quantities, catalogue_dwellings, uses_placement_plot from app.services.lego_assembly import DETACHED_ARCHETYPE_IDS, catalog_parent_archetype_id from app.services.residual_landscape import community_3d_source_hash from app.services.policy_intelligence.retrieval import ( @@ -689,6 +689,22 @@ def union_area(records: list[dict]) -> float | None: str(bid) for z in plot_zones for bid in ([z["building_id"]] if z["building_id"] else []) + z["building_ids"] } plot_shapes = [measured[z["id"]] for z in plot_zones if z["id"] in measured] + catalogue_floor_areas = {} + for zone in plot_zones: + props = zone["properties"] + if ( + zone["zone_type"] != "building" + or zone["id"] not in measured + or props.get("building_geometry_basis") != "placement_plot" + or props.get("native_home_plot") is True + or props.get("building_footprint_scale", 1) != 1 + ): + continue + linked_keys = set(([zone["building_id"]] if zone["building_id"] else []) + zone["building_ids"]) + quantities = catalogue_building_quantities(props) or {} + floor_area = positive(quantities.get("gross_floor_area_m2")) + if len(linked_keys) <= 1 and floor_area is not None: + catalogue_floor_areas.setdefault(next(iter(linked_keys), zone["id"]), floor_area) metric( "building_placement_plot_m2", "Building placement plots", @@ -713,9 +729,14 @@ def union_area(records: list[dict]) -> float | None: or building["id"] in plot_ids or building["id"] in plot_building_ids ): - # A detached recipe is anchored to its whole plot, including - # yards. That parent polygon is never a building floor plate. - missing_floors.append(building) + # A catalogue estimate comes from the model record. A saved + # placement plot supplies neither a footprint nor a floor plate. + floor_area = catalogue_floor_areas.get(building["id"]) + if floor_area is None: + missing_floors.append(building) + else: + gfa += floor_area + measured_floor_plates += 1 continue geom = _shape(building) if geom is None: @@ -730,13 +751,13 @@ def union_area(records: list[dict]) -> float | None: gfa += area * floors measured_floor_plates += 1 unresolved_development = any(not z["building_id"] and not z["building_ids"] for z in development_areas) - has_unknown_buildings = bool(missing_floors or unresolved_development) + has_unknown_buildings = bool(missing_floors or unresolved_development or plot_ids or plot_building_ids) metric( "building_footprint_m2", "Known building footprints (incomplete)" if has_unknown_buildings else "Known building footprints", unary_union(areas).area if areas else None if has_unknown_buildings else 0, "m²", - "Union of drawn building footprints and linked footprint records; excludes development allocations and authored-model placement plots whose individual floor plates are unmeasured.", + "Union of drawn building footprints and linked footprint records. Catalogue placement plots do not supply building footprints.", ) complete = not missing_floors and all(z["building_id"] or z["building_ids"] for z in development_areas) metric( @@ -744,7 +765,7 @@ def union_area(records: list[dict]) -> float | None: "Floor-area estimate" if complete else "Known floor area (incomplete)", gfa if measured_floor_plates or complete else None, "m²", - "Estimate from drawn footprints × recorded storeys, assuming equal floor plates. Excludes unknown floors, unresolved allocations and authored-model placement plots. Model bounding rectangles are not measured floor plates.", + "Estimate from reviewed catalogue quantities and drawn footprints × recorded storeys, assuming equal drawn floor plates. Excludes unmeasured plots, unknown floors and unresolved allocations.", 0.7, ) if missing_floors or not complete: @@ -792,7 +813,7 @@ def recorded_count(value): number = 0.0 if value == 0 and not isinstance(value, bool) else positive(value) return int(number) if number is not None and number.is_integer() else None - programme_zones = {zone["id"]: catalogue_housing_programme(zone["properties"]) for zone in quantity_zones} + programme_zones = {zone["id"]: catalogue_building_quantities(zone["properties"]) for zone in quantity_zones} for zone in quantity_zones: programme = programme_zones[zone["id"]] if programme and programme.get("source_title"): @@ -991,7 +1012,11 @@ def recorded_count(value): "Sum of current server-certified detached recipe dwelling counts, deduplicated by linked building. Repeated podium/floor/roof modules represent one dwelling per segment, not additional units.", 0.95, ) - programme_resolved_zone_ids = {zone_id for zone_id, programme in programme_zones.items() if programme} + programme_resolved_zone_ids = { + zone_id + for zone_id, programme in programme_zones.items() + if programme and programme.get("dwellings") is not None + } unresolved_zone_ids = detached_zone_ids - compiled_detached_zone_ids - programme_resolved_zone_ids pending = len(unresolved_zone_ids) pending_zones = [zone for zone in zones if zone["id"] in unresolved_zone_ids] diff --git a/backend/tests/test_student_report.py b/backend/tests/test_student_report.py index 9ca5ff7e3..10de119c2 100644 --- a/backend/tests/test_student_report.py +++ b/backend/tests/test_student_report.py @@ -138,6 +138,33 @@ def test_exact_catalogue_dwelling_programmes_are_counted_without_plot_floor_area assert values(analyze_snapshot(plan))["catalogue_dwellings"] is None +def test_native_office_estimate_counts_its_floor_area_once_after_compilation(): + compiled = SimpleNamespace( + id=uuid.uuid4(), + name="Courtyard office", + footprint=rectangle(), + height_meters=7.4, + floor_count=2, + specifications={}, + ) + office = zone( + "building", + building_geometry_basis="placement_plot", + pick_place_asset="clay_brick_timber_two_storey_office", + development_selected_variant_id="brick_timber_two_storey_office", + pick_place_model_revision="brick-timber-courtyard-office-clay-v004", + floor_count=2, + ) + office.building_id = compiled.id + plan = snapshot([office], [compiled]) + result = values(analyze_snapshot(plan)) + assert result["gfa_m2"] == 224 + assert result["gfa_ft2"] == pytest.approx(2411.12, abs=0.01) + assert result["building_footprint_m2"] is None + plan["zones"][0]["properties"]["pick_place_model_revision"] = "old-revision" + assert values(analyze_snapshot(plan))["gfa_m2"] is None + + def test_proposed_study_area_is_separate_clipped_and_deduplicated(): boundary = zone("site_boundary") collection = { diff --git a/frontend/scripts/check-model-contract.mjs b/frontend/scripts/check-model-contract.mjs index 2c52b8825..29c1a13ec 100644 --- a/frontend/scripts/check-model-contract.mjs +++ b/frontend/scripts/check-model-contract.mjs @@ -41,3 +41,24 @@ const content = JSON.stringify({schema:'cityprompt.native-model-contract@1',reco if(process.argv.includes('--write')) writeFileSync(target,content); else if(readFileSync(target,'utf8').replace(/\r\n/g,'\n') !== content) throw new Error('Backend model contract is stale; run node scripts/check-model-contract.mjs --write'); console.log('Backend model contract matches authored catalogue: '+fileURLToPath(target)); + +const quantities = read('../src/data/catalogueBuildingQuantities.json'); +const quantityIdentities = new Set(); +for (const { variant_id, revision, gross_floor_area_m2, dwellings } of quantities.records) { + const identity = `${variant_id}@${revision}`; + if (quantityIdentities.has(identity) || !records.some(record => record.variant_id === variant_id && record.revision === revision)) { + throw new Error(`Invalid or duplicate catalogue quantity identity: ${identity}`); + } + if ((gross_floor_area_m2 == null && dwellings == null) + || (gross_floor_area_m2 != null && (!Number.isFinite(gross_floor_area_m2) || gross_floor_area_m2 <= 0)) + || (dwellings != null && (!Number.isInteger(dwellings) || dwellings < 0))) { + throw new Error(`Invalid catalogue quantity: ${identity}`); + } + quantityIdentities.add(identity); +} +const quantityTarget = new URL('../../backend/app/data/catalogue_dwelling_programmes.json', import.meta.url); +const quantityContent = JSON.stringify(quantities, null, 2) + '\n'; +if (process.argv.includes('--write')) writeFileSync(quantityTarget, quantityContent); +else if (readFileSync(quantityTarget, 'utf8').replace(/\r\n/g, '\n') !== quantityContent) { + throw new Error('Backend catalogue quantities are stale; run node scripts/check-model-contract.mjs --write'); +} diff --git a/frontend/scripts/packed-catalogue.mjs b/frontend/scripts/packed-catalogue.mjs index f736b4156..6e3850cbf 100644 --- a/frontend/scripts/packed-catalogue.mjs +++ b/frontend/scripts/packed-catalogue.mjs @@ -10,9 +10,9 @@ const FEATURE_CATALOGUES = /\/src\/features\/(?:parks\/(?:detailCatalogueExtras| // Keep this allowlist explicit so unrelated JSON retains Vite's normal exports. const HANDOFF_CATALOGUES = /\/src\/(?:data\/(?:cataloguePlanningHistory|catalogueTeaching|localTeachingBuildings|classroomStarter|buildingPlacementEdges|catalogueHeroImages|claudeAssetLocalTrial)|features\/(?:legoAssembly\/buildingOnlyContracts|parks\/(?:curbBulbContracts|calgarySafetyCatalogue)|zoningCatalogue\/parkUseRules|pickPlace\/publicRealmOwnershipContracts)|components\/viewer\/globe\/publicRealmTrialAssets)\.json$/; -const STATIC_METADATA = /\/src\/(?:data\/(?:archetypeVisualSystem|catalogueOctober2026|claudeBuildingRelease|claudeFiveTrial|courtOnlySports|finalFiveBuildingBatch|flexibleParks|localTowerStoreyPrograms|neighborhoodParkV0StickerKit|parkadeFamilyTrial|stickerMethodPilots|transportStandardEntries|aiRenderStylePresets|streetViewStylePresets)|features\/(?:policyPlans\/data\/(?:beltlinePlanIndex|localPlanIndex)|referenceLayers\/calgaryBylawCatalogue))\.json$/; +const STATIC_METADATA = /\/src\/(?:data\/(?:archetypeVisualSystem|catalogueBuildingQuantities|catalogueOctober2026|claudeBuildingRelease|claudeFiveTrial|courtOnlySports|finalFiveBuildingBatch|flexibleParks|localTowerStoreyPrograms|neighborhoodParkV0StickerKit|parkadeFamilyTrial|stickerMethodPilots|transportStandardEntries|aiRenderStylePresets|streetViewStylePresets)|features\/(?:policyPlans\/data\/(?:beltlinePlanIndex|localPlanIndex)|referenceLayers\/calgaryBylawCatalogue))\.json$/; -const Z85_CATALOGUES = /\/src\/(?:data\/(?:buildingArchetypes|nativeStreetPilots|openSpaceArchetypes)|features\/parks\/detailCatalogueExtras)\.json$/; +const Z85_CATALOGUES = /\/src\/(?:data\/(?:buildingArchetypes|cataloguePlanningHistory|nativeStreetPilots|openSpaceArchetypes)|features\/parks\/detailCatalogueExtras)\.json$/; /** Retain all legacy IDs, reference paths and prompts without compiling several * megabytes of JSON into JavaScript object literals. Three already ships this diff --git a/frontend/scripts/packed-catalogue.test.mjs b/frontend/scripts/packed-catalogue.test.mjs index 63d6ff09f..301514747 100644 --- a/frontend/scripts/packed-catalogue.test.mjs +++ b/frontend/scripts/packed-catalogue.test.mjs @@ -14,6 +14,7 @@ const inflater = pathToFileURL(resolve('node_modules/three/examples/jsm/libs/ffl for (const [filename, minimumSaving] of [ ['data/buildingArchetypes.json', 20000], + ['data/cataloguePlanningHistory.json', 1900], ['data/nativeStreetPilots.json', 4000], ['data/openSpaceArchetypes.json', 8000], ['features/parks/detailCatalogueExtras.json', 2500], @@ -69,7 +70,7 @@ for (const relative of [ 'features/zoningCatalogue/parkUseRules.json', 'features/pickPlace/publicRealmOwnershipContracts.json', 'components/viewer/globe/publicRealmTrialAssets.json', - 'data/archetypeVisualSystem.json', 'data/catalogueOctober2026.json', + 'data/archetypeVisualSystem.json', 'data/catalogueBuildingQuantities.json', 'data/catalogueOctober2026.json', 'data/claudeBuildingRelease.json', 'data/claudeFiveTrial.json', 'data/courtOnlySports.json', 'data/finalFiveBuildingBatch.json', 'data/flexibleParks.json', diff --git a/frontend/src/components/viewer/globe/buildingPlotLandscape.test.ts b/frontend/src/components/viewer/globe/buildingPlotLandscape.test.ts index 76f169cdc..00f658e8b 100644 --- a/frontend/src/components/viewer/globe/buildingPlotLandscape.test.ts +++ b/frontend/src/components/viewer/globe/buildingPlotLandscape.test.ts @@ -20,13 +20,23 @@ const zone = (id: string, width: number, depth: number, properties = {}, degrees }); const boundary: SiteZone = { ...zone('site', 500, 500, { community_3d_mask_existing_tiles: true, terrain_elevation_m: 1000 }), zone_type: 'site_boundary', is_active_boundary: true }; const home = buildings.find(a => a.id === 'validation_reference_charcoal_gable_fourplex_v1')!; -const homeZone = (width = home.width, depth = home.depth, degrees = 0) => zone('home', width, depth, placementProperties(home), degrees); +const legacyPlotProperties = (asset: PlaceAsset) => { + const properties = placementProperties(asset); + delete properties.building_plot_landscaping; + return properties; +}; +const homeZone = (width = home.width, depth = home.depth, degrees = 0) => zone('home', width, depth, legacyPlotProperties(home), degrees); describe('shared building plot landscaping', () => { - it('covers every current building choice without changing its model, plot or persisted properties', () => { + it('leaves the site surface visible under a new catalogue office placement', () => { + const office = buildings.find(asset => asset.id === 'clay_brick_timber_two_storey_office')!; + const placed = zone('office', office.width, office.depth, placementProperties(office)); + expect(buildingPlotLandscapes([boundary, placed], 0)).toEqual([]); + }); + it('preserves plot landscaping for existing catalogue placements', () => { expect(buildings.length).toBeGreaterThanOrEqual(32); for (const asset of buildings) { - const placed = zone(asset.id, asset.width, asset.depth, placementProperties(asset)); + const placed = zone(asset.id, asset.width, asset.depth, legacyPlotProperties(asset)); const before = JSON.stringify(placed); const plans = buildingPlotLandscapes([boundary, placed], 0); expect(plans, asset.label).toHaveLength(1); diff --git a/frontend/src/components/viewer/globe/buildingPlotLandscape.ts b/frontend/src/components/viewer/globe/buildingPlotLandscape.ts index 865d8efe9..edf425b5a 100644 --- a/frontend/src/components/viewer/globe/buildingPlotLandscape.ts +++ b/frontend/src/components/viewer/globe/buildingPlotLandscape.ts @@ -85,6 +85,9 @@ export function buildingPlotLandscapes(zones: SiteZone[], terrainHeight: number, const linkedBuildings = new Map(buildings.map(building => [building.id, building])); return physical.flatMap(zone => { if (resolveCommunity3DKind(zone) !== 'building') return []; + const landscapePlot = zone.properties?.building_plot_landscaping !== false; + const authoredGround = reviewBuildingLandscapeContract(zone); + if (!landscapePlot && !authoredGround) return []; const height = resolvePreparedSiteTerrainForZone(zone, zones, terrainHeight); if (height === null) return []; const origin: Pair = [zone.coordinates.reduce((s, p) => s + p[0], 0) / zone.coordinates.length, @@ -100,11 +103,10 @@ export function buildingPlotLandscapes(zones: SiteZone[], terrainHeight: number, if (!surface.length) return []; const style = buildingGardenStyle(zone); const result: BuildingPlotLandscape = { zoneId: zone.id, style, design: buildingLandscapeNotes(zone), - drawSurface: !recipe, origin, height, surface, beds: [], shrubs: [] }; - const authoredGround = reviewBuildingLandscapeContract(zone); + drawSurface: landscapePlot && !recipe, origin, height, surface, beds: [], shrubs: [] }; if (authoredGround) { const placement = reviewBuildingLandscapePlacement(zone, linkedBuildings.get(zone.building_id ?? '')); - if (!placement) return [result]; + if (!placement) return landscapePlot ? [result] : []; const rotate = (x: number, z: number): Pair => { const point = new Vector3(x, 0, z).applyMatrix4(placement.matrix); return [point.x, point.y]; diff --git a/frontend/src/data/catalogueBuildingQuantities.json b/frontend/src/data/catalogueBuildingQuantities.json new file mode 100644 index 000000000..d94cc1baa --- /dev/null +++ b/frontend/src/data/catalogueBuildingQuantities.json @@ -0,0 +1,138 @@ +{ + "source": "Concept quantities for exact catalogue revisions, based on authored floor plates and documented building programmes.", + "records": [ + { + "variant_id": "affordable_porchlight_original", + "revision": "affordable-porchlight-clay-v004", + "dwellings": 4, + "gross_floor_area_m2": 396, + "source": "Two enclosed 22 × 9 m rowhouse floors. Front and rear gardens are outside the floor area." + }, + { + "variant_id": "affordable_juniper_original", + "revision": "affordable-juniper-clay-v006", + "dwellings": 4, + "gross_floor_area_m2": 196, + "source": "Four one-storey cottages with 49 m² each. Shared garden and private patios are outside the floor area." + }, + { + "variant_id": "affordable_stackyard_original", + "revision": "affordable-stackyard-clay-v003", + "dwellings": 6, + "gross_floor_area_m2": 462, + "source": "Two enclosed 21 × 11 m floors. The external gallery and stairs are outside the floor area." + }, + { + "variant_id": "affordable_aspen_original", + "revision": "affordable-aspen-clay-v003", + "dwellings": 12, + "gross_floor_area_m2": 936, + "source": "Three enclosed 24 × 13 m apartment floors, including shared circulation." + }, + { + "variant_id": "affordable_switchback_original", + "revision": "affordable-switchback-clay-v003", + "dwellings": 24, + "gross_floor_area_m2": 1344, + "source": "Four enclosed 24 × 14 m studio apartment floors, including shared circulation." + }, + { + "variant_id": "bungalow_postwar_ranch", + "revision": "calgary-inner-city-bungalow-clay-v005", + "dwellings": 1, + "retail_units": 0, + "allow_exact_flexible_native_revision": true, + "development_type": "residential_single_family", + "source_title": "Post-war bungalow · reviewed single-home programme", + "source": "docs/CLASSROOM_STARTER_ACCEPTANCE_2026-09-24.md#bungalow_postwar_ranch", + "source_excerpt": "Native dimensions 10.898324 × 16.050000 × 6.360000 m, one floor, one home. The reviewed source is a single-family residential home, with no retail programme." + }, + { + "variant_id": "reference_charcoal_gable_fourplex_v1", + "revision": "22538e0683d0ee64995c5c24d20972c9b86ca84fa615ca20fec346a908bb1732", + "requires_placement_plot": true, + "dwellings": 4, + "development_type": "residential" + }, + { + "variant_id": "london-crescent-terrace-bath-stone", + "revision": "crescent-terrace-bath-stone-clay-v006", + "requires_placement_plot": true, + "dwellings": 18, + "development_type": "residential" + }, + { + "variant_id": "infill_duplex", + "revision": "calgary-side-by-side-duplex-clay-v004", + "requires_placement_plot": true, + "dwellings": 2, + "development_type": "residential" + }, + { + "variant_id": "montreal_duplex_plateau", + "revision": "montreal-plateau-duplex-clay-v004", + "requires_placement_plot": true, + "dwellings": 2, + "development_type": "residential" + }, + { + "variant_id": "brick_timber_two_storey_office", + "revision": "brick-timber-courtyard-office-clay-v004", + "requires_placement_plot": true, + "gross_floor_area_m2": 224, + "development_type": "commercial_office", + "source": "Two authored 112 m² floor plates, including circulation." + }, + { + "variant_id": "garden_mews_six_homes", + "revision": "garden-mews-courtyard-housing-clay-v003", + "requires_placement_plot": true, + "dwellings": 6, + "gross_floor_area_m2": 504, + "development_type": "residential", + "source": "Six two-storey 6 × 7 m homes. The shared court and patios are outside the floor area." + }, + { + "variant_id": "horizon_double_section", + "revision": "horizon-manufactured-home-clay-v003", + "requires_placement_plot": true, + "dwellings": 1, + "gross_floor_area_m2": 97.92, + "development_type": "residential_single_family", + "source": "One 13.6 × 7.2 m enclosed storey. The roof step is unoccupied." + }, + { + "variant_id": "maple_porch_sage", + "revision": "maple-porch-manufactured-cottage-clay-v004", + "requires_placement_plot": true, + "dwellings": 1, + "gross_floor_area_m2": 67.2, + "development_type": "residential_single_family", + "source": "One 14 × 4.8 m enclosed storey. The front porch is open." + }, + { + "variant_id": "brick_timber_craftsman", + "revision": "narrow-lot-craftsman-cottage-clay-v003", + "requires_placement_plot": true, + "dwellings": 1, + "gross_floor_area_m2": 92.16, + "development_type": "residential_single_family", + "source": "One 7.2 × 12.8 m enclosed storey. The porch and unoccupied attic are outside the floor area." + }, + { + "variant_id": "folded_roof_market_hall", + "revision": "599cd816bf995ab20eece3731602d2148d15eb9c8605ff84b6e7fb102ee3dcf7", + "requires_placement_plot": true, + "gross_floor_area_m2": 243.5, + "development_type": "commercial_retail", + "source": "Five enclosed ground-floor workshops measured to glazing and outside walls. The open market canopy is outside the floor area." + }, + { + "variant_id": "montreal_depanneur_modern", + "revision": "brick-corner-grocery-clay-v002", + "requires_placement_plot": true, + "dwellings": 1, + "development_type": "mixed_use" + } + ] +} diff --git a/frontend/src/data/runtimeAssetManifest.json b/frontend/src/data/runtimeAssetManifest.json index 967d6e192..6a67fd9f2 100644 --- a/frontend/src/data/runtimeAssetManifest.json +++ b/frontend/src/data/runtimeAssetManifest.json @@ -291,6 +291,7 @@ "src/data/buildingPlacementEdges.json", "src/data/buildingWalkDoors.json", "src/data/canalRoutePolicy.json", + "src/data/catalogueBuildingQuantities.json", "src/data/catalogueHeroImages.json", "src/data/catalogueOctober2026.json", "src/data/cataloguePlanningHistory.json", diff --git a/frontend/src/features/pickPlace/CanonicalCatalogueCard.test.tsx b/frontend/src/features/pickPlace/CanonicalCatalogueCard.test.tsx index 1deb9278a..68af527c0 100644 --- a/frontend/src/features/pickPlace/CanonicalCatalogueCard.test.tsx +++ b/frontend/src/features/pickPlace/CanonicalCatalogueCard.test.tsx @@ -8,6 +8,14 @@ import { pickerHeroImage } from './pickerHeroImages'; import { cataloguePresentationFor } from './cataloguePresentation'; afterEach(cleanup); +it('shows estimated floor area and FAR using the reference lot of a compact building', () => { + const choice = CANONICAL_CHOICES.find(item => item.placements[0]?.id === 'clay_brick_timber_two_storey_office')!; + render(); + fireEvent.click(screen.getByRole('button', { name: 'Expand details for Brick-and-Timber Courtyard Office' })); + expect(screen.getByText('Estimated FAR on reference lot')).toBeVisible(); + expect(screen.getByText(/0\.78.*288 m²/)).toBeVisible(); + expect(screen.getByText(/224 m².*2,411 ft²/)).toBeVisible(); +}); it('keeps court-only as a base-card variant and places its original geometry and thumbnail', () => { const choice = CANONICAL_CHOICES.find(choice => choice.option.id === 'basketball_court')!; const court = choice.placements.find(asset => asset.model.variantId === 'court_only_basketball_v1')!; diff --git a/frontend/src/features/pickPlace/CanonicalCatalogueCard.tsx b/frontend/src/features/pickPlace/CanonicalCatalogueCard.tsx index fe3fb9b28..b07781b9c 100644 --- a/frontend/src/features/pickPlace/CanonicalCatalogueCard.tsx +++ b/frontend/src/features/pickPlace/CanonicalCatalogueCard.tsx @@ -8,9 +8,12 @@ import type { CanonicalChoice, CanonicalSelection } from './canonicalCatalogue'; import { pickerHeroImage } from './pickerHeroImages'; import { cataloguePresentationFor } from './cataloguePresentation'; import { catalogueSizeLabel, catalogueStyleIds, catalogueStyleLabel } from './catalogueFacets'; +import catalogueQuantities from '@/data/catalogueBuildingQuantities.json'; import { lessonForChoice } from '@/features/catalogueLearning/teaching'; import { CatalogueTeachingDetails } from '@/features/catalogueLearning/CatalogueTeachingDetails'; +const quantityNumber = new Intl.NumberFormat('en-CA', { maximumFractionDigits: 0 }); + function CatalogueThumbnail({ sources, label }: { sources: string[]; label: string }) { const [index, setIndex] = useState(0); return index < sources.length @@ -31,6 +34,11 @@ export function CanonicalCatalogueCard({ choice, selected, activeStreetVariant, const [variantId, setVariantId] = useState(initialVariantId ?? placements[0]?.model.variantId ?? option.variants?.[0]?.id ?? ''); const variant = option.variants?.find(v => v.id === variantId); const placement = placements.find(a => a.model.variantId === variantId); + const building = choice.domain === 'building' && placement?.kind === 'object' ? placement : undefined; + const quantities = building && catalogueQuantities.records.find(record => + record.variant_id === building.model.variantId && record.revision === building.model.revision); + const grossFloorArea = quantities?.gross_floor_area_m2; + const referenceLotArea = building && (building.referenceLotAreaM2 ?? building.width * building.depth); const variantGuide = classifyCalgaryVariant(option.id, variantId); const thumbnail = pickerHeroImage(placement?.id, (choice.groupedVariants ? variant?.thumbnailUrl || placement?.thumbnail : undefined) @@ -64,6 +72,22 @@ export function CanonicalCatalogueCard({ choice, selected, activeStreetVariant,

{presentation?.description ?? placement?.description ?? variant?.description ?? option.description}

{placement?.kind === 'object' && placement.properties.pick_place_flexible_park ? 'Flexible 3D · draw your outline' : placement ? 'Detailed 3D' : choice.domain === 'building' ? 'Design massing · detailed model depends on size and availability' : 'Design reference · layout depends on available 3D support'}

{catalogueSizeLabel(placement)}

+ {building &&
+ {grossFloorArea != null &&
+
Estimated gross floor area
+
{quantityNumber.format(grossFloorArea)} m² · {quantityNumber.format(grossFloorArea * 10.7639104167)} ft²
+
} + {quantities?.dwellings != null &&
+
Modelled dwellings
+
{quantityNumber.format(quantities.dwellings)}
+
} +
+
Estimated FAR on reference lot
+
{grossFloorArea != null && referenceLotArea + ? `${(grossFloorArea / referenceLotArea).toFixed(2)} on ${quantityNumber.format(referenceLotArea)} m²` + : 'Floor area pending'}
+
+
} {choice.domain === 'building' && !lesson &&

{styles.map(id => catalogueStyleLabel(id)).join(' · ') || 'Style not catalogued'}

} {Boolean(option.variants?.length) &&