From 7835e8c01250cc8931d55d92bde6fdc8ace32f2e Mon Sep 17 00:00:00 2001 From: Esteban Zimanyi Date: Thu, 19 Nov 2026 19:11:00 +0100 Subject: [PATCH] Give the statistics of a raster band a class raster_summary_stats answers a BandStats, the record PostGIS's ST_SummaryStats states, and the object model held no class over it, so its six accessors, bandstats_count, _sum, _mean, _stddev, _min and _max, belonged to none and a binding projecting the model carried none of them. meta/object-model.json declares BandStats a leaf of Value with the prefix bandstats, beside Raster, naming no MeosType as Raster names none; the accessors are its members count, sum, mean, stddev, min and max. Witness: test_the_statistics_of_a_band_are_a_class_of_their_own classifies bandstats_count and bandstats_mean into BandStats as count and mean; it fails without the node. test_a_type_meos_registers_in_no_enum_still_gets_a_class lists BandStats among the classes naming no MeosType. Measured: over the catalog derived from MobilityDB master 2880c4adee the object model of this branch and of master differ in the six accessors alone, joining BandStats, whose cType is BandStats; every other key of the catalog is equal; the suite passes, 702 passed and 31 skipped. Why: the summary statistics of a band are part of the raster surface every binding carries (MobilityDB #3775), and a binding generated from the object model reaches them only through a class. --- meta/object-model.json | 10 ++++++++++ tests/test_object_model.py | 17 +++++++++++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/meta/object-model.json b/meta/object-model.json index df4b553..56f8339 100644 --- a/meta/object-model.json +++ b/meta/object-model.json @@ -911,6 +911,16 @@ "conditional": "RASTER", "doc": "A georeferenced raster of one or more bands, the value every raster accessor, clip, warp and polygonization takes. MEOS registers it in no enum, so it names no temptype." }, + "BandStats": { + "kind": "leaf", + "parent": "Value", + "prefixes": [ + "bandstats" + ], + "temptype": null, + "conditional": "RASTER", + "doc": "What a raster band's pixels amount to, taken in one pass: how many pixels hold a value and their sum, mean, standard deviation, least and greatest, the record PostGIS's ST_SummaryStats states. Raster.summaryStats answers one and the summaryStats aggregate gathers one over rasters; MEOS registers it in no enum, so it names no temptype." + }, "Pcschema": { "kind": "leaf", "parent": "Value", diff --git a/tests/test_object_model.py b/tests/test_object_model.py index e7e7086..ecd917c 100644 --- a/tests/test_object_model.py +++ b/tests/test_object_model.py @@ -447,6 +447,19 @@ def test_a_member_of_a_leafs_box_is_named_with_its_value_type(self): "tbigintbox_expand": "expandBigint"}) self.assertEqual(om["functionToClass"]["tintbox_expand"]["class"], "TBox") + def test_the_statistics_of_a_band_are_a_class_of_their_own(self): + # As #test_the_ever_and_always_forms_of_a_member_stand_beside_it: the record + # raster_summary_stats answers is the class BandStats, whose accessors are + # its members named by what they read. + idl = attach_object_model({"functions": [ + self._fn("bandstats_count", "const BandStats *"), + self._fn("bandstats_mean", "const BandStats *", "double *"), + ]}, MODEL, None) + om = idl["objectModel"] + names = {m["function"]: m["ooName"] for m in om["classes"]["BandStats"]["methods"]} + self.assertEqual(names, {"bandstats_count": "count", "bandstats_mean": "mean"}) + self.assertEqual(om["functionToClass"]["bandstats_mean"]["class"], "BandStats") + def test_the_ever_and_always_forms_of_a_member_stand_beside_it(self): # As #test_a_member_of_a_leafs_box_is_named_with_its_value_type, for the # e and a forms #_candidates derives: eraster_value is the @@ -743,8 +756,8 @@ def test_a_type_meos_registers_in_no_enum_still_gets_a_class(self): unregistered = {n for n, s in nodes.items() if s["kind"] == "leaf" and s["temptype"] is None} self.assertEqual(unregistered, - {"Pcschema", "Raster", "RTree", "RTreeNNCursor", "SPTree", - "SPNNCursor", "MeosArray", "SkipList"}) + {"Pcschema", "Raster", "BandStats", "RTree", "RTreeNNCursor", + "SPTree", "SPNNCursor", "MeosArray", "SkipList"}) def test_the_aggregate_state_is_a_class_and_numeric_is_none(self): # A SkipList is what every temporal aggregate's transition function