Created
March 2, 2020 02:53
-
-
Save rdlabo/7e10b25589b8117188b6b1302f063556 to your computer and use it in GitHub Desktop.
This file contains 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
alter table tweet drop index geom; | |
alter table tweet modify geom geometry not null SRID 4326 ; | |
alter table tweet add spatial index(geom); | |
UPDATE tweet | |
SET | |
geom = CASE | |
WHEN | |
area_type = 1 | |
THEN | |
ST_GEOMFROMTEXT(ST_ASTEXT(ST_POINTFROMGEOHASH(ST_GEOHASH(139.7690174, 35.6803997, 8), | |
4326)), | |
4326) | |
WHEN | |
area_type = 2 | |
THEN | |
ST_GEOMFROMTEXT(ST_ASTEXT(ST_POINTFROMGEOHASH(ST_GEOHASH(135.5022535, 34.6937249, 8), | |
4326)), | |
4326) | |
ELSE ST_GEOMFROMTEXT(ST_ASTEXT(ST_POINTFROMGEOHASH(ST_GEOHASH(137.292389, 35.0182505, 8), | |
4326)), | |
4326) | |
END | |
WHERE | |
1 = 1; | |
explain SELECT | |
id | |
FROM | |
tweet | |
WHERE | |
ST_Within( | |
tweet.geom, | |
ST_GeomFromText(St_AsText(ST_Buffer(ST_GeomFromText(St_AsText(ST_GeomFromText('POINT(35.668440825448 139.74229644907)' , 4326))),0.0089831528411952)),4326) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
関数を使わないでポリゴンを指定した版