MySQL implementation of ray-casting Algorithm?

后端 未结 7 2069
小蘑菇
小蘑菇 2021-02-01 08:56

We need to figure out a quick and fairly accurate method for point-in-polygon for lat/long values and polygons over google maps. After some research - came across some posts abo

7条回答
  •  终归单人心
    2021-02-01 09:16

    In reply to zarun function for finding lat/long within polygon.

    I had a property table having lat/long information. So I had to get the records whose lat/long lies within polygon lats/longs (which I got from Google API). At first I was dumb how to use the Zarun function. So here is the solution query for it.

    • Table: properties
    • Fields: id, latitude, longitude, beds etc...
    • Query:
    SELECT id
    FROM properties
    WHERE myWithin(
        PointFromText(concat( "POINT(", latitude, " ", longitude, ")")),
        PolyFromText('POLYGON((37.628134 -77.458334,37.629867 -77.449021,37.62324 -77.445416,37.622424 -77.457819,37.628134 -77.458334))' )
    ) = 1 limit 0,50;
    

    Hope it will save time for dumbs like me ;)

提交回复
热议问题