M .env => .env +3 -3
@@ 44,7 44,7 @@ DEFAULT_WEB_EDITOR=id
# Optional server settings.
#
SERVER_SUB=server
-DAMN_SERVER_VERSION=v0.9.3
+DAMN_SERVER_VERSION=v0.10.1
DAMN_CLIENTS=*,
DB_HOST=damndb_server
WWW_SUB=www
@@ 53,10 53,10 @@ WWW_SUB=www
#
CLIENT_SUB=client
DAMN_CLIENT_REPO=https://gitlab.com/damn-project/damn_client
-DAMN_CLIENT_VERSION=v0.14.0
+DAMN_CLIENT_VERSION=v0.14.1
MANAGER_SUB=manager
DAMN_MANAGER_REPO=https://gitlab.com/damn-project/damn_jsonmanager
-DAMN_MANAGER_VERSION=v0.1.5
+DAMN_MANAGER_VERSION=v0.2.0
PANEL_SUB=panel
DAMN_PANEL_REPO=https://git.sr.ht/~qeef/damn-panel.js
DAMN_PANEL_VERSION=v0.1.0
M CHANGELOG.md => CHANGELOG.md +15 -0
@@ 12,6 12,21 @@ The format is based on [Keep a Changelog][] and this project adheres to
Unreleased
==========
+Upgraded
+--------
+
+- Server to v0.10.1.
+- Client to v0.14.1.
+- Manager to v0.2.0.
+
+Added
+-----
+
+- PostGIS function to split area with custom square size. You need to update
+ database manually. Please, see [Upgrade to `v0.12.0`][] section in readme.
+
+[Upgrade to `v0.12.0`](https://git.sr.ht/~qeef/damn-deploy#upgrade-to-codev080code)
+
0.11.0 - 2020-12-06
===================
M README.md => README.md +40 -0
@@ 312,6 312,46 @@ volume:
docker volume rm damn_deploy_damndb-volume
+Upgrade to `v0.12.0`
+--------------------
+
+This upgrade introduces custom square width and height when creating areas. The
+function is stored in `damndb/72_st_area_split_custom_square_size.sql` file.
+The steps to upgrade follow.
+
+Stop the damn service and update the repository:
+
+ systemctl stop damn.service
+ git stash
+ git pull
+ git stash pop
+
+Run the database:
+
+ docker-compose up -d db
+
+Import the new function into the database (you will be asked for the password
+stored in `.env` file):
+
+ export DB_HOST=$(docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}}' damndb)
+ psql -h $DB_HOST -d damndb -U damnuser < damndb/72_st_area_split_custom_square_size.sql
+
+Stop the database container:
+
+ docker-compose down
+
+Finally, there is no need to build the database container again. The database
+is created only once anyway. However, `server`, `client`, and `manager` need to
+be updated:
+
+ docker-compose -f server.yml build --no-cache api
+ docker-compose -f clients.yml build --no-cache client
+ docker-compose -f clients.yml build --no-cache manager
+
+Finally, run the damn service again:
+
+ systemctl start damn.service
+
Damn upkeep
===========
A damndb/72_st_area_split_custom_square_size.sql => damndb/72_st_area_split_custom_square_size.sql +54 -0
@@ 0,0 1,54 @@
+CREATE FUNCTION public.st_area_split(ar public.geometry, ssh DOUBLE PRECISION, ssw DOUBLE PRECISION, OUT public.geometry) RETURNS SETOF public.geometry
+ LANGUAGE plpgsql IMMUTABLE STRICT
+ AS $$
+DECLARE
+ jmax INTEGER := 32;
+ imax INTEGER := 32;
+ srid INTEGER := 4326;
+ ss_def geometry;
+BEGIN
+ CASE ST_SRID(ar) WHEN 0 THEN
+ ar := ST_SetSRID(ar, srid);
+ RAISE NOTICE'SRID Not Found.';
+ ELSE
+ RAISE NOTICE'SRID Found.';
+ END CASE;
+
+ IF ssw < 0.004 THEN
+ ssw := 0.004;
+ jmax := floor((ST_XMax(ar) - ST_XMin(ar)) / ssw) + 1;
+ END IF;
+ IF ssh < 0.004 THEN
+ ssh := 0.004;
+ imax := floor((ST_YMax(ar) - ST_YMin(ar)) / ssh) + 1;
+ END IF;
+ ss_def := ST_GeomFromText(
+ FORMAT(
+ 'POLYGON((0 0, 0 %s, %s %s, %s 0, 0 0))',
+ ssh, ssw, ssh, ssw
+ ),
+ srid
+ );
+ RETURN QUERY WITH foo AS (
+ SELECT
+ ST_Translate(
+ ss_def,
+ ST_XMin(ar) + j * ssw,
+ ST_YMin(ar) + i * ssh
+ ) AS ss
+ FROM
+ generate_series(0, imax) AS i,
+ generate_series(0, jmax) AS j
+ )
+ SELECT
+ ST_Intersection(ss, ar)
+ FROM
+ foo
+ WHERE
+ ST_intersects(ss, ar)
+ ;
+END;
+$$;
+
+
+ALTER FUNCTION public.st_area_split(ar public.geometry, OUT public.geometry) OWNER TO damnuser;