Created
November 23, 2015 21:49
-
-
Save Linell/ad89b43b4075569cad4b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Works perfectly! | |
SELECT COUNT(*), | |
ST_Union(geom) as location_union, | |
ST_SnapToGrid(ST_Transform(ST_SnapToGrid(ST_Transform(geom, _ST_BestSRID(geom)), 10,10),4326),0.0001, 0.0001) AS snap_pt | |
FROM locations | |
GROUP BY snap_pt | |
HAVING COUNT(*) > 1; | |
-- But what's a decent way to figure out which groups contain a given user? | |
-- I can use the following query to get the list of users in an example ST_Union from above: | |
select distinct(user_id) | |
from locations | |
where ST_Contains('0104000020E610000003000000010100000074EFE192E38656C019E25817B735404001010000006284F068E38656C019E25817B735404001010000002D431CEBE28656C068B3EA73B5354040', geom); | |
-- If it was only valid SQL | |
SELECT COUNT(*), | |
ST_Union(geom) as location_union, | |
ST_SnapToGrid(ST_Transform(ST_SnapToGrid(ST_Transform(geom, _ST_BestSRID(geom)), 10,10),4326),0.0001, 0.0001) AS snap_pt | |
FROM locations | |
GROUP BY snap_pt | |
HAVING COUNT(*) > 1 | |
and '1' in ( | |
select user_id from locations where ST_Contains(location_union) | |
) | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment