akvo / akvo-lumen

Make sense of your data
https://akvo.org/akvo-lumen
GNU Affero General Public License v3.0
63 stars 18 forks source link

Agree on multi-layer map spec format #1148

Closed gabemart closed 6 years ago

gabemart commented 7 years ago

Context

Currently maps only support a single layer, and the visualisation spec for maps reflects this.

As we begin working on multi-layer support in the client and the backend, we first need to agree how multi-layer maps are represented.

Let's start with an example single-layer map spec (made from a mock dataset):

{
  "id":"59fc30dd-6c38-4de0-af45-f0da8d76c3dc",
  "datasetId":"59fc3046-b161-4cf4-aecd-1c59b6c0e754",
  "name":"Map spec example",
  "visualisationType":"map",
  "created":1509699805110,
  "modified":1509699818173,
  "type":"visualisation",
  "status":"OK",  
  "spec":{
    "version":1,
    "baseLayer":"street",    
    "layers":[
      {
        "pointColorColumn":"c5",
        "datasetId":"59fc3046-b161-4cf4-aecd-1c59b6c0e754",
        "title":"Gepoints layer",        
        "pointSize":"2",    
        "visible":true,
        "geom":"d1",            
        "popup":[
          {
            "column":"c1"
          },
          {
            "column":"c5"
          },
          {
            "column":"c4"
          }
        ],
        "legend":{
          "title":"well_type",
          "visible":true,
          "position":"right"
        },
        "filters":[
          {
            "value":"AOX",
            "column":"c4",
            "origin":"filterMenu",
            "strategy":"is",
            "operation":"remove",
            "columnType":"text"
          },
          {
            "value":"machine dug",
            "column":"c5",
            "origin":"filterMenu",
            "strategy":"is",
            "operation":"remove",
            "columnType":"text"
          }
        ],
        "pointColorMapping":[
          {
            "op":"equals",
            "color":"#61b66f",
            "value":"borehole"
          },
          {
            "op":"equals",
            "color":"#bf2932",
            "value":"hand dug"
          },
          {
            "op":"equals",
            "color":"#61b66f",
            "value":"natural spring"
          },
          {
            "op":"equals",
            "color":"#feda77",
            "value":null
          }
        ],
      }
    ],
  },
}

The features which are either incompatible or potentially problematic with multi-layer are:

That being said, a "new" multilayer map spec might look like:

{
  "id":"59fc30dd-6c38-4de0-af45-f0da8d76c3dc",
  "name":"Map spec example",
  "visualisationType":"map",
  "created":1509699805110,
  "modified":1509699818173,
  "type":"visualisation",
  "status":"OK",
  "spec":{
    "version":2,
    "baseLayer":"street",    
    "visible":true,
    "geom":"d1",    
    "legend":{
      "position":"right"
    },
    "layers":[
      {
        "type": "geopoint",
        "pointSize":"2",  
        "pointColorColumn":"c5",
        "datasetId":"59fc3046-b161-4cf4-aecd-1c59b6c0e754",
        "title":"Geopoints layer",              
        "popup":[
          {
            "column":"c1"
          },
          {
            "column":"c5"
          },
          {
            "column":"c4"
          }
        ],
        "legend":{
          "title":"well_type",
          "visible":true,
        },
        "filters":[
          {
            "value":"AOX",
            "column":"c4",
            "origin":"filterMenu",
            "strategy":"is",
            "operation":"remove",
            "columnType":"text"
          },
          {
            "value":"machine dug",
            "column":"c5",
            "origin":"filterMenu",
            "strategy":"is",
            "operation":"remove",
            "columnType":"text"
          }
        ],
        "pointColorMapping":[
          {
            "op":"equals",
            "color":"#61b66f",
            "value":"borehole"
          },
          {
            "op":"equals",
            "color":"#bf2932",
            "value":"hand dug"
          },
          {
            "op":"equals",
            "color":"#61b66f",
            "value":"natural spring"
          },
          {
            "op":"equals",
            "color":"#feda77",
            "value":null
          }
        ],
      },
      {
        "type":"geoshape",
        "visible":true,
        "geom":"d3",
        "shapeColorColumn":"c5",
        "shapeColorMethod":"mean",
        "shapeBaseColor":"#FF0000",
        "datasetId":"59fc3046-b161-4cf4-aecd-1c59b6c0e754",
        "title":"Geoshape layer",        
        "popup":[
          {
            "column":"c8"
          },
          {
            "column":"c9"
          }
        ],
        "legend":{
          "title":"Average fluoride per county (ppm)",
          "visible":true,
        },
        "filters":[
          {
            "value":"7",
            "column":"c8",
            "origin":"filterMenu",
            "strategy":"is",
            "operation":"remove",
            "columnType":"number"
          },
        ],
      }      
    ],
  },
}

In every instance where I've come up with a new name for something, it's just a first attempt and shouldn't be taken too seriously

kardan commented 7 years ago

As discussed the status key is from the dataset and is always OK, we should remove it from responses.