goat-community / goat

This is the home of Geo Open Accessibility Tool (GOAT)
GNU General Public License v3.0
89 stars 47 forks source link

Finish new heatmap schema #1786

Closed EPajares closed 1 year ago

EPajares commented 1 year ago

Goal of this issue

For each calculation types for heat-maps (#1783), we need different settings. For example for modified_gaussian_per_grid(), we need sensitivity and cutoff. We need to check these settings.

Resources

Examples of configs: Config for gravity:

{
   "supermarket":{
      "max_traveltime":10,
      "sensitivity":250000,
      "weight":1
   },
   "tram_stop":{
      "max_traveltime":15,
      "sensitivity":250000,
      "weight":1
   }
}

Config for closest:

{
   "supermarket":{
      "max_traveltime":5,
      "weight":1
   },
   "tram_stop":{
      "max_traveltime":10,
      "weight":1
   }
}

Deliverables

Branch to derive

metemaddar commented 1 year ago

I think the config is better to be like:

[
    {
      "category": "supermarket",
      "max_traveltime":10,
      "sensitivity":250000,
      "weight":1
   },
   {
      "category": "tram_stop",
      "max_traveltime":15,
      "sensitivity":250000,
      "weight":1
   }
]

Then we can use a general Config schema for them. And validate based on term category.

metemaddar commented 1 year ago

Of course this can have a con that the input can have multiple values for single category :thinking:

EPajares commented 1 year ago

Hard decision. I think your idea makes sense. But maybe we could make sure that the category is only used once. So we avoid that the user defines two configs for one category.

metemaddar commented 1 year ago

So we can create a Pydantic model per heat-map type (closest, gravity, etc.) and based on type, validate each configurations against it's related Pydantic class.

EPajares commented 1 year ago

Sounds great

metemaddar commented 1 year ago

Implemented (Initiated) for gravity and closest: 5c9e5cec01b541d384ae1188104294ed1f8f3a8e We need to add others as well.

metemaddar commented 1 year ago

https://github.com/goat-community/goat/blob/9c05fa5c6b68357ed2af591190bcc8b25c840d8c/app/api/src/crud/crud_heatmap.py#L678

metemaddar commented 1 year ago

I think it's also good to use some type key for poi/aoi/... This approach makes code cleaner for validation.

{
   "supermarket":{
      "max_traveltime": 5,
      "weight": 1,
      "type": "aoi"
   },
   "park":{
      "max_traveltime": 10,
      "weight": 1
      "type": "poi"
   }
}
metemaddar commented 1 year ago

Of course this also has cons 🤔 As we may have different pydantic class for poi or aoi But we can also make fields optional and then do validation based on type.

EPajares commented 1 year ago

I agree. Or should we make poi/aoi as parent key like:

{ "aoi": {} "poi": {} }

p4b-bro[bot] commented 11 months ago

This task/issue closed on Tue Jun 06 2023 ✅