From d5749883b148934aac97623d82b51619ab475c56 Mon Sep 17 00:00:00 2001 From: Claudio Henrique Bogossian Date: Mon, 5 Oct 2020 17:31:10 -0300 Subject: [PATCH] Calculating area and centroid during geometry insert --- forest_monitor/monitor/business.py | 11 +++++++---- setup.py | 2 +- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/forest_monitor/monitor/business.py b/forest_monitor/monitor/business.py index c920349..17d953e 100644 --- a/forest_monitor/monitor/business.py +++ b/forest_monitor/monitor/business.py @@ -79,14 +79,17 @@ def add(cls, values, user_id=None): FROM converted_geom, result_collect r ) INSERT INTO ''' + destinationTable + ''' (classname, quadrant, path_row, view_date, sensor, - satellite, areauckm, uc, areamunkm, municipali, - uf, geom, scene_id, source, user_id, created_at, image_date, project) + satellite, areauckm, uc, municipali, + uf, geom, scene_id, source, user_id, created_at, image_date, centroid_x, centroid_y, areamunkm, areatotalk, project) SELECT :classname AS classname, :quadrant AS quadrant, :path_row AS path_row, :view_date AS view_date, :sensor AS sensor, :satellite AS satellite, :areauckm AS areauckm, - :uc AS uc, :areamunkm AS areamunkm, :municipali AS municipali, + :uc AS uc, :municipali AS municipali, :uf AS uf, st_multi(st_collectionextract(st_makevalid(geom),3)), :scene_id AS scene_id, :source AS source, - :user_id AS user_id, :created_at as created_at, :image_date AS image_date, :project AS project + :user_id AS user_id, :created_at as created_at, :image_date AS image_date, + ST_X(ST_PointOnSurface(geom)) as centroid_x, ST_Y(ST_PointOnSurface(geom)) as centroid_y, + (st_area(geom::geography)/1000000) as areamunkm, (st_area(geom::geography)/1000000) as areatotalk, + :project AS project FROM result ''') diff --git a/setup.py b/setup.py index b17092b..223734e 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name='Forest-Monitor', - version="1.1.5", + version="1.1.6", description='Forest Monitor Package', author='Admin', author_email='admin@admin.com',