开发者

MySQL Spatial Extensions: Getting records that fall with in a certain area

I am wanting to use the MySQL spartial extension for a project. What it is a javascript viewer will send the edges of the viewable area so the most weaterly, easterly and north and sothern points as the appropriate cordiates(latitude and logitude). I have come accors examples using doing distance caclulation and distance from. However I am only wanting to pluck out the records that would be points with in the viewable area for the user. With the mysql spartial extension say if开发者_开发问答 I have:

name: varchar location: point long: double lat: double

(The long and lat is for ploting the point)

Given the small example table, how would i pull out points with in a viewable area

The folowing link shows how it is done in postgresql. However need it for mysql.


Most likely you want to compute the spatial index yourself. A spatial index is just a space-filling-curve reducing your 2D problem to a 1D problem and thus make it easier to understand. Instead of picking the spatial index most likely you can pick a nested-string-key from the sfc or quadtree. The nested-key is read from the left to the right and the query for similar keys or lat/lng pairs is hence just a string comparision with every operator possible. I have done a sfc implementation in php at phpclasses.org ( hilbert-curve ). Most likely you want to download it! Or most likely you want to search google for Nick's blog spatial index hilbert curve and quadtree.


You want to use the 'geometry' mysql extension. If your location is of type 'geometry' you could do such a query

SELECT *, AsWKT(location) as geomWKT
FROM myTable
WHERE Intersects(location,GeomFromText('POINT(1.9845 49.8543)'))

Some examples about the format here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜