mWater / mwater-forms

Forms controls for mWater
GNU Lesser General Public License v3.0
3 stars 5 forks source link

Add admin region option to location questions #163

Closed grassick closed 8 years ago

grassick commented 8 years ago

select code, (select full_name from admin_regions where leaf and st_intersects(shape, st_transform(wp.location, 3857)) limit 1) as ar from entities.water_point as wp limit 1000

1098 ms

create index on admin_regions using gist (shape) where leaf;

636ms

Call it calculateAdminRegion as option of location question.

grassick commented 8 years ago

Massively slow on server:

select alias_main."_id" as "id", -1 as "subtable", 

(select alias_admin_region."full_name" from admin_regions as "alias_admin_region" 
    where (alias_admin_region."leaf" and ST_Intersects(ST_Transform(ST_SetSRID(ST_MakePoint(((alias_main."data" #>> '{e506c671a2d34895a6652e39c68722bc,value,longitude}')::decimal), ((alias_main.
    "data" #>> '{e506c671a2d34895a6652e39c68722bc,value,latitude}')::decimal)), 4326), 3857), alias_admin_region."shape"))) as "c0" 

from (select * from responses where form = 'e24f0a0ec11643cab3c21c07de2f6889' and exists (select null from jsonb_array_elements(roles) as r where r->>'id'= any(array['user:grassick']))) as alias_main