-
-
Notifications
You must be signed in to change notification settings - Fork 195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Feature] Nearest point on polygon from a point #51
Comments
With Reference to this requirement I want to find nearest point on polygon(An Area on map) from a particular point (Lat, Long). |
@sumit2201 did you ever happen to find this elsewhere? |
I could not find any PHP solution for this, and my requirement was GIS centric, so I used postGIS queries to find nearest point. I used ST_ClosestPoint of postGIS/postgresql. |
@sumit2201 Lets keep it open since its a sweet feature, last question, did St_CLosestPoint give you the actual point that was found on the Line? and not only the distance? |
Hi, is such an implemention available in source code in any language and with a permissive license? If that's the case, I'd be happy to translate it to PHP and integrate it into phpgeo. |
@mjaschen I think you're pretty darn close already. You have your PerpendicularDistance utility which I use in combination with polygon foreach ($this->polygon->getSegments() as $line) {
if ($line->getLength($haversine) !== 0.0) {
$polyline = new Polyline();
$polyline->addPoint($line->getPoint1());
$polyline->addPoint($line->getPoint2());
$distances[] = [
'value' => $perp->getPerpendicularDistance($this->point, $line),
'geometry' => json_decode($formatter->format($polyline), true),
];
}
}
usort($distances, function($a, $b) {
return $a['value'] - $b['value'];
});
return reset($distance) All that I think is missing from this @mjaschen is getting that Utility to tell us WHERE on the line did you find was the closest? |
No description provided.
The text was updated successfully, but these errors were encountered: