atviriduomenys / spinta

Spinta is a framework to describe, extract and publish data (a DEP Framework).
MIT License
13 stars 4 forks source link

Summary for geometry type #451

Closed sirex closed 1 year ago

sirex commented 1 year ago

The idea is to provide summarized data for geometry types, that can be easily displayed on the map.

Basically we need to calculate centroids of each geometry object and create clusters. This is needed, because the can be large number of objects, and we don't want to load all the data into map.

This function should accept bounding box to select data from and return up do 100 objects of clusters. If an object is not in any cluster, then it should be returned as individual object.

We can return data like this:

http GET /datasets/gov/example/City/:summary/geom
{
    "_data": [
        {
            "_type": "datasets/gov/example/City/:summary/geom",
            "centroid": "POINT (1 2)",
            "cluster": 100
        },
        {
            "_type": "datasets/gov/example/City/:summary/geom",
            "_id": "dcffa0c0-421b-4d0b-ac6f-1b4a9df9b47c",
            "centroid": "POINT (3 4)",
            "cluster": 1
        }
    ]
}

Here, we call :summary endpoint is called with geom argument, which is a property of City model. This call should return up to 100 records of geom centroids, clustered into clusters if needed.

When cluster consists only of one object, we should also include _id in order to provide link to the object directly.

Resources

sirex commented 1 year ago

Kadangi duomenų kiekiai gali būti dideli, tai agregavimas bus daromas Saugyklos pusėje, kuo labiau pritraukiamas žemėlapis, daromas nauja užklausa į Saugyklą ir gaunami tikslesni duomenys, su mažesnėmis grupėmis. -- https://github.com/atviriduomenys/katalogas/issues/339

It looks, that this part was forgotten. We need to add bbox(xmin, ymin, xmax, ymax), to show summary only within specified bounding box.

sirex commented 1 year ago

The issue is related to incorrect database schema: