New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Separate geom from data calcs #267
Conversation
talos
commented
Mar 9, 2017
•
edited
edited
- Use a CTE to perform geometry intersections between user geometries and Observatory geometries
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michellemho Take a look at the code changes!
@@ -536,9 +536,12 @@ RETURNS TABLE ( | |||
) | |||
AS $$ | |||
DECLARE |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michellemho Starting here is where I made changes to use a CTE to do geometry intersections.
@@ -579,7 +582,20 @@ BEGIN | |||
(unnest($1))->>'api_method' api_method, | |||
(unnest($1))->'api_args' api_args | |||
) | |||
SELECT String_Agg( | |||
SELECT |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michellemho This is where the geometry intersections are defined.
' / Nullif(ST_Area(' || geom_tablename || '.' || geom_colname || '), 0))' || | ||
' END), 0) ' || | ||
' / (COUNT(*) / COUNT(distinct ' || geom_tablename || '.' || geom_geomref_colname || ')) ' | ||
' * pct_' || geom_tablename || |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These parts where a lot of code was removed are possible because the geometry intersections were done in the CTE.
SELECT _geoms.id::INT, Array_to_JSON(ARRAY[%s]::JSON[]) | ||
FROM _geoms, %s | ||
FROM _raw_geoms), | ||
_procgeoms AS (SELECT _geoms.id, _geoms.geom, %s %s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this is the CTE!