Skip to content

MapLayer model #5

@finnus

Description

@finnus

I open this issue just for a discussion and to organize my thoughts. Any comments are welcome. This is early-stage WIP!

Main idea: Put all data for the creation of maplayers in a model to have it in the DB. IMO it would be the best to include an abstract model with the needed fields (as such, custom additional fields can easily be added).

In my first approach, I just added a model to configure choropleths (with popups), see: #3

However this is somehow unsatisfying as you still edit the config in base.py to add the base layers, which is cumbersome and means that you have now two (model and config file) for maplayers.

So the new approach would be to also replace the full layers.py and generate the output from the model.

I would suggest not to separate choropleth/popups and base layers as they are mostly the same thing.

IMO, we would need the following fields. As you will see, they are closely linked to the maplibre types:
name (Text): name the layer
slug (Slugfield): autogenerate a unique name from "name" field to use internally as reference
type (icon, cluster, cluster_count, line, fill, choropleth, label, outline)
geom_layer / source (FK self, null):
geom_layer_model / source_model: give the source model for the data (only needed if geom_layer/source is null)
colors: (ArrayField: used to give one or multiple hex colors, for color-coding like in choropleths or to color a line etc.)
color_coding_data (data field that colors the map, e.g. for choropleths)
icon (ImageField)
popup_fields (null, blank)
popup_title (null, blank)
popup_description (null, blank)
paint_overwrite: paint properties can be manually set here. otherwise, a default will be used. this should provide flexibility for non-standard use-cases (e.g. painting lines in different colors when having different values)
layout_overwrite: layout (text) properties can be manually set here. otherwise, a default will be used
display_order (SmallInt): to order displaying order of the layers (can be of importance when you want to show icons above an not below a choropleth map)

Of course, if needed, more fields can be added. Eg. (used for displaying the control buttons in the frontend to toggle a layer):
description, category, sub_category, fe_display_order, scenario, ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions