Skip to content

Commit 7e29b04

Browse files
authored
Merge pull request #47 from OpenSPP/feat/gis-indicators-hxl
feat: add HXL modules and GIS indicator layers
2 parents 628fc1a + 5b18879 commit 7e29b04

84 files changed

Lines changed: 12249 additions & 0 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ fastapi>=0.110.0
99
geojson
1010
httpx
1111
jwcrypto
12+
libhxl
1213
numpy>=1.22.2
1314
openpyxl
1415
parse-accept-language

spp_gis_indicators/README.rst

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
.. image:: https://odoo-community.org/readme-banner-image
2+
:target: https://odoo-community.org/get-involved?utm_source=readme
3+
:alt: Odoo Community Association
4+
5+
======================
6+
OpenSPP GIS Indicators
7+
======================
8+
9+
..
10+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
11+
!! This file is generated by oca-gen-addon-readme !!
12+
!! changes will be overwritten. !!
13+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
14+
!! source digest: sha256:3e0d3c935187c1430aaa36bc854f98fde0d3ffa19bf8bafb7b342ebb706da310
15+
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16+
17+
.. |badge1| image:: https://img.shields.io/badge/maturity-Alpha-red.png
18+
:target: https://odoo-community.org/page/development-status
19+
:alt: Alpha
20+
.. |badge2| image:: https://img.shields.io/badge/license-LGPL--3-blue.png
21+
:target: http://www.gnu.org/licenses/lgpl-3.0-standalone.html
22+
:alt: License: LGPL-3
23+
.. |badge3| image:: https://img.shields.io/badge/github-OpenSPP%2FOpenSPP2-lightgray.png?logo=github
24+
:target: https://github.com/OpenSPP/OpenSPP2/tree/19.0/spp_gis_indicators
25+
:alt: OpenSPP/OpenSPP2
26+
27+
|badge1| |badge2| |badge3|
28+
29+
Choropleth visualization for area-level indicators on GIS maps. Maps
30+
indicator values from CEL variables to colors using configurable
31+
classification methods and ColorBrewer-based color scales. Supports
32+
quantile, equal interval, and manual break classification with automatic
33+
legend generation.
34+
35+
Key Capabilities
36+
~~~~~~~~~~~~~~~~
37+
38+
- Define indicator layer configurations that link CEL variables to color
39+
scales and classification methods
40+
- Classify continuous indicator values into discrete color classes using
41+
quantile, equal interval, or manual breaks
42+
- Apply preset ColorBrewer color scales (sequential, diverging,
43+
categorical) or define custom scales
44+
- Compute break values automatically based on actual data distribution
45+
- Generate HTML legends showing color-to-value mappings
46+
- Map area features to colors for choropleth rendering in GIS data
47+
layers
48+
- Filter indicators by period and hazard incident context
49+
50+
Key Models
51+
~~~~~~~~~~
52+
53+
+-----------------------------+----------------------------------------+
54+
| Model | Description |
55+
+=============================+========================================+
56+
| ``spp.gis.indicator.layer`` | Configuration linking a CEL variable |
57+
| | to color scale and classification |
58+
| | settings |
59+
+-----------------------------+----------------------------------------+
60+
| ``spp.gis.color.scale`` | Color scheme definition with JSON |
61+
| | array of hex colors |
62+
+-----------------------------+----------------------------------------+
63+
| ``spp.gis.data.layer`` | Extended with ``choropleth`` geo |
64+
| | representation option |
65+
+-----------------------------+----------------------------------------+
66+
67+
Configuration
68+
~~~~~~~~~~~~~
69+
70+
After installing:
71+
72+
1. Navigate to **Settings > GIS Configuration > Color Scales**
73+
2. Review preset ColorBrewer scales (Blues, Greens, Red-Yellow-Green,
74+
etc.) or create custom scales
75+
3. Navigate to **Settings > GIS Configuration > Indicator Layers**
76+
4. Create an indicator layer specifying the CEL variable, period key,
77+
color scale, and classification method
78+
5. In an existing GIS data layer, set ``geo_repr`` to ``choropleth`` and
79+
select the indicator layer to visualize
80+
81+
UI Location
82+
~~~~~~~~~~~
83+
84+
- **Menu**: Settings > GIS Configuration > Indicator Layers
85+
- **Menu**: Settings > GIS Configuration > Color Scales
86+
87+
Security
88+
~~~~~~~~
89+
90+
================================== =============================
91+
Group Access
92+
================================== =============================
93+
``spp_security.group_spp_user`` Read
94+
``spp_security.group_spp_manager`` Read/write/create (no delete)
95+
``spp_security.group_spp_admin`` Full CRUD
96+
================================== =============================
97+
98+
Extension Points
99+
~~~~~~~~~~~~~~~~
100+
101+
- Override ``_compute_quantile_breaks()`` or
102+
``_compute_equal_interval_breaks()`` in ``spp.gis.indicator.layer`` to
103+
add custom classification algorithms
104+
- Inherit ``spp.gis.color.scale`` and override ``get_color_for_value()``
105+
to implement custom color mapping logic
106+
- Extend ``spp.gis.indicator.layer._get_indicator_values()`` to support
107+
additional data sources beyond ``spp.hxl.area.indicator``
108+
109+
Dependencies
110+
~~~~~~~~~~~~
111+
112+
``spp_gis``, ``spp_hxl_area``
113+
114+
.. IMPORTANT::
115+
This is an alpha version, the data model and design can change at any time without warning.
116+
Only for development or testing purpose, do not use in production.
117+
`More details on development status <https://odoo-community.org/page/development-status>`_
118+
119+
**Table of contents**
120+
121+
.. contents::
122+
:local:
123+
124+
Bug Tracker
125+
===========
126+
127+
Bugs are tracked on `GitHub Issues <https://github.com/OpenSPP/OpenSPP2/issues>`_.
128+
In case of trouble, please check there if your issue has already been reported.
129+
If you spotted it first, help us to smash it by providing a detailed and welcomed
130+
`feedback <https://github.com/OpenSPP/OpenSPP2/issues/new?body=module:%20spp_gis_indicators%0Aversion:%2019.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**>`_.
131+
132+
Do not contact contributors directly about support or help with technical issues.
133+
134+
Credits
135+
=======
136+
137+
Authors
138+
-------
139+
140+
* OpenSPP.org
141+
142+
Maintainers
143+
-----------
144+
145+
This module is part of the `OpenSPP/OpenSPP2 <https://github.com/OpenSPP/OpenSPP2/tree/19.0/spp_gis_indicators>`_ project on GitHub.
146+
147+
You are welcome to contribute.

spp_gis_indicators/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.
2+
3+
from . import models

spp_gis_indicators/__manifest__.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.
2+
3+
{
4+
"name": "OpenSPP GIS Indicators",
5+
"summary": "Choropleth visualization for area-level indicators",
6+
"version": "19.0.2.0.0",
7+
"category": "OpenSPP/GIS",
8+
"author": "OpenSPP.org",
9+
"website": "https://github.com/OpenSPP/OpenSPP2",
10+
"license": "LGPL-3",
11+
"development_status": "Alpha",
12+
"depends": [
13+
"spp_gis",
14+
"spp_hxl_area",
15+
"spp_registry",
16+
],
17+
"data": [
18+
"security/ir.model.access.csv",
19+
"data/color_scales.xml",
20+
"views/menu.xml",
21+
"views/indicator_layer_views.xml",
22+
"views/color_scale_views.xml",
23+
"views/data_layer_views.xml",
24+
],
25+
"application": False,
26+
"installable": True,
27+
"auto_install": False,
28+
}
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
<?xml version="1.0" encoding="utf-8" ?>
2+
<odoo noupdate="1">
3+
<!-- Sequential Color Scales -->
4+
5+
<record id="color_scale_blues" model="spp.gis.color.scale">
6+
<field name="name">Blues (Sequential)</field>
7+
<field name="scale_type">sequential</field>
8+
<field
9+
name="colors_json"
10+
>["#f7fbff", "#deebf7", "#c6dbef", "#9ecae1", "#6baed6", "#4292c6", "#2171b5", "#08519c", "#08306b"]</field>
11+
<field
12+
name="description"
13+
>Sequential blue color scale from light to dark. Good for showing increasing values like population density or service coverage.</field>
14+
<field name="sequence">10</field>
15+
</record>
16+
17+
<record id="color_scale_greens" model="spp.gis.color.scale">
18+
<field name="name">Greens (Sequential)</field>
19+
<field name="scale_type">sequential</field>
20+
<field
21+
name="colors_json"
22+
>["#f7fcf5", "#e5f5e0", "#c7e9c0", "#a1d99b", "#74c476", "#41ab5d", "#238b45", "#006d2c", "#00441b"]</field>
23+
<field
24+
name="description"
25+
>Sequential green color scale from light to dark. Good for showing environmental or health indicators.</field>
26+
<field name="sequence">20</field>
27+
</record>
28+
29+
<record id="color_scale_reds" model="spp.gis.color.scale">
30+
<field name="name">Reds (Sequential)</field>
31+
<field name="scale_type">sequential</field>
32+
<field
33+
name="colors_json"
34+
>["#fff5f0", "#fee0d2", "#fcbba1", "#fc9272", "#fb6a4a", "#ef3b2c", "#cb181d", "#a50f15", "#67000d"]</field>
35+
<field
36+
name="description"
37+
>Sequential red color scale from light to dark. Good for showing risk, danger, or negative indicators.</field>
38+
<field name="sequence">30</field>
39+
</record>
40+
41+
<record id="color_scale_oranges" model="spp.gis.color.scale">
42+
<field name="name">Oranges (Sequential)</field>
43+
<field name="scale_type">sequential</field>
44+
<field
45+
name="colors_json"
46+
>["#fff5eb", "#fee6ce", "#fdd0a2", "#fdae6b", "#fd8d3c", "#f16913", "#d94801", "#a63603", "#7f2704"]</field>
47+
<field
48+
name="description"
49+
>Sequential orange color scale from light to dark. Good for showing moderate risk or attention areas.</field>
50+
<field name="sequence">40</field>
51+
</record>
52+
53+
<record id="color_scale_purples" model="spp.gis.color.scale">
54+
<field name="name">Purples (Sequential)</field>
55+
<field name="scale_type">sequential</field>
56+
<field
57+
name="colors_json"
58+
>["#fcfbfd", "#efedf5", "#dadaeb", "#bcbddc", "#9e9ac8", "#807dba", "#6a51a3", "#54278f", "#3f007d"]</field>
59+
<field
60+
name="description"
61+
>Sequential purple color scale from light to dark. Good for showing education or program enrollment indicators.</field>
62+
<field name="sequence">50</field>
63+
</record>
64+
65+
<!-- Diverging Color Scales -->
66+
67+
<record id="color_scale_rdylgn" model="spp.gis.color.scale">
68+
<field name="name">Red-Yellow-Green (Diverging)</field>
69+
<field name="scale_type">diverging</field>
70+
<field
71+
name="colors_json"
72+
>["#d73027", "#f46d43", "#fdae61", "#fee08b", "#ffffbf", "#d9ef8b", "#a6d96a", "#66bd63", "#1a9850"]</field>
73+
<field
74+
name="description"
75+
>Diverging scale from red (negative) through yellow to green (positive). Good for showing progress against targets or deviations from a norm.</field>
76+
<field name="sequence">60</field>
77+
</record>
78+
79+
<record id="color_scale_rdbu" model="spp.gis.color.scale">
80+
<field name="name">Red-Blue (Diverging)</field>
81+
<field name="scale_type">diverging</field>
82+
<field
83+
name="colors_json"
84+
>["#67001f", "#b2182b", "#d6604d", "#f4a582", "#fddbc7", "#d1e5f0", "#92c5de", "#4393c3", "#2166ac", "#053061"]</field>
85+
<field
86+
name="description"
87+
>Diverging scale from red to blue. Good for showing opposing conditions or bidirectional change.</field>
88+
<field name="sequence">70</field>
89+
</record>
90+
91+
<record id="color_scale_spectral" model="spp.gis.color.scale">
92+
<field name="name">Spectral (Diverging)</field>
93+
<field name="scale_type">diverging</field>
94+
<field
95+
name="colors_json"
96+
>["#9e0142", "#d53e4f", "#f46d43", "#fdae61", "#fee08b", "#e6f598", "#abdda4", "#66c2a5", "#3288bd", "#5e4fa2"]</field>
97+
<field
98+
name="description"
99+
>Spectral diverging scale across the color spectrum. Good for showing complex diverging patterns.</field>
100+
<field name="sequence">80</field>
101+
</record>
102+
103+
<record id="color_scale_brbg" model="spp.gis.color.scale">
104+
<field name="name">Brown-Green (Diverging)</field>
105+
<field name="scale_type">diverging</field>
106+
<field
107+
name="colors_json"
108+
>["#8c510a", "#bf812d", "#dfc27d", "#f6e8c3", "#f5f5f5", "#c7eae5", "#80cdc1", "#35978f", "#01665e"]</field>
109+
<field
110+
name="description"
111+
>Diverging scale from brown to green. Good for environmental indicators or land use changes.</field>
112+
<field name="sequence">90</field>
113+
</record>
114+
115+
<!-- Categorical Color Scales -->
116+
117+
<record id="color_scale_set1" model="spp.gis.color.scale">
118+
<field name="name">Set1 (Categorical)</field>
119+
<field name="scale_type">categorical</field>
120+
<field
121+
name="colors_json"
122+
>["#e41a1c", "#377eb8", "#4daf4a", "#984ea3", "#ff7f00", "#ffff33", "#a65628", "#f781bf"]</field>
123+
<field
124+
name="description"
125+
>Categorical color set with distinct colors. Good for showing different types or categories.</field>
126+
<field name="sequence">100</field>
127+
</record>
128+
129+
<record id="color_scale_paired" model="spp.gis.color.scale">
130+
<field name="name">Paired (Categorical)</field>
131+
<field name="scale_type">categorical</field>
132+
<field
133+
name="colors_json"
134+
>["#a6cee3", "#1f78b4", "#b2df8a", "#33a02c", "#fb9a99", "#e31a1c", "#fdbf6f", "#ff7f00"]</field>
135+
<field
136+
name="description"
137+
>Paired categorical colors with light and dark variants. Good for comparing similar categories.</field>
138+
<field name="sequence">110</field>
139+
</record>
140+
</odoo>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Part of OpenSPP. See LICENSE file for full copyright and licensing details.
2+
3+
from . import color_scale
4+
from . import data_layer
5+
from . import indicator_layer

0 commit comments

Comments
 (0)