我试图得到形状文件中的点。我尝试过Spatial函数,它显示了一个名为的错误
3033 - Binary geometry function st_contains given two geometries of different srids: 4326 and 0, which should have been identical.
我的疑问是
SELECT lightning.lightning_id,lightning.latitude,lightning.longitude,
lightning.flash_type, DATE_FORMAT(lightning.lightning_time, '%D %b %Y %T %p') as lightning_time FROM lightning, districts_s
WHERE ST_CONTAINS(districts_s.SHAPE, Point(lightning.longitude, lightning.latitude)) AND lightning.height > 50
为了纠正错误,我从here和这个link得到了一个解决方案,但没有结果。因为这也显示了一个错误
ST_Transform不存在
我使用的是PHP 5.6。任何解决方案都非常有用。
您可以尝试使用PHP代码。
$point = array(22.765863,75.887488);
$vs = array();
$polygonPoints = '[{"lat":22.765863133410004,"lng":75.88748805487819},{"lat":22.76631821037386,"lng":75.89153282607265},{"lat":22.76462650356429,"lng":75.89126460517116},{"lat":22.764082382883878,"lng":75.89017026389308},{"lat":22.76430992452311,"lng":75.88933341468044},{"lat":22.763815268301787,"lng":75.88875405753322},{"lat":22.764705648209898,"lng":75.8886253115005},{"lat":22.764438534847113,"lng":75.88744513953395},{"lat":22.765229980328275,"lng":75.88824980223842}]';
$boundries = json_decode($polygonPoints);
foreach ($boundries as $key => $val)
{
$polygon[$key] = array($val->lat,$val->lng);
}
// Check Point Inside Polygone
$check = pointInPolygon($point, $polygon);
if($check == true)
{
echo "This point inside in polygone";
}
function pointInPolygon($point, $vs)
{
$x = $point[0];
$y = $point[1];
$inside = false;
for ($i = 0, $j = count($vs) - 1; $i < count($vs); $j = $i++) {
$xi = $vs[$i][0];
$yi = $vs[$i][1];
$xj = $vs[$j][0];
$yj = $vs[$j][1];
$intersect = (($yi > $y) != ($yj > $y))
&& ($x < ($xj - $xi) * ($y - $yi) / ($yj - $yi) + $xi);
if ($intersect) $inside = !$inside;
}
return $inside;;
}