mysql - Spatial query using my SQL -


i writing 2 varchar formatted columns named 'lattitude' , 'longitude' point formatted column named 'coordinate' using statement below.

"update table_name set coordinate = pointfromtext(concat('point(',table_name.longitude,' ',table_name.lattitude,')'))" 

i attempting spatial query on coordinate column using following statement.

select id , coordinate table_name mbrcontains(geomfromtext('polygon(-126.728566 49.226434, -123.652395 23.586457,-56.679738 23.908252,-53.076223 55.243002)'), coordinate) 

according tool polygon in query covers entire u.s. know there points in table fall in u.s. still not getting results (note i'm getting null result not error). ideas i'm doing wrong?

update. below updated attempt @ executing query per suggestion below.

set @g1 = geomfromtext('polygon((23.586457 -123.652395,23.908252 -56.679738,55.243002 -53.076223,55.243002 -53.076223,23.586457 -123.652395))');  select id , coordinate table_name mbrcontains(@g1, coordinate) 

select id , coordinate table_name mbrcontains(geomfromtext('polygon((-126.728566 49.226434, -123.652395 23.586457,-56.679738 23.908252,-53.076223 55.243002, -126.728566 49.226434))'), coordinate) 

this should work. problem polygon coordinates should in double parenthesis. has interior rings (polygons). plus david noticed need close polygon.

ps: noticed use longitude x , latitude y when should other way around. x horizontal , y vertical.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -