Geo Fencing - point inside/outside polygon

后端 未结 16 1741
我在风中等你
我在风中等你 2020-11-28 02:15

I would like to determine a polygon and implement an algorithm which would check if a point is inside or outside the polygon.

Does anyone know if there is any exampl

16条回答
  •  离开以前
    2020-11-28 02:59

    You can try this simple class https://github.com/xopbatgh/sb-polygon-pointer

    It is easy to deal with it

    1. You just insert polygon coordinates into array
    2. Ask library is desired point with lat/lng inside the polygon
    $polygonBox = [
        [55.761515, 37.600375],
        [55.759428, 37.651156],
        [55.737112, 37.649566],
        [55.737649, 37.597301],
    ];
    
    $sbPolygonEngine = new sbPolygonEngine($polygonBox);
    
    $isCrosses = $sbPolygonEngine->isCrossesWith(55.746768, 37.625605);
    
    // $isCrosses is boolean
    
    

    (answer was returned from deleted by myself because initially it was formatted wrong)

提交回复
热议问题