Skip to content

Commit

Permalink
Calculating area and centroid during geometry insert
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiobogossian committed Oct 5, 2020
1 parent 92ff8c7 commit d574988
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions forest_monitor/monitor/business.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
''')

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setup(
name='Forest-Monitor',
version="1.1.5",
version="1.1.6",
description='Forest Monitor Package',
author='Admin',
author_email='[email protected]',
Expand Down

0 comments on commit d574988

Please sign in to comment.