From 426e108b3422533f885045f3b0488206b9a68a34 Mon Sep 17 00:00:00 2001 From: gemo1011 Date: Thu, 21 Jun 2018 14:33:22 +0200 Subject: [PATCH] added case when for highways in subquery --- lib/PlaceLookup.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/PlaceLookup.php b/lib/PlaceLookup.php index 44161a7e..270e2745 100644 --- a/lib/PlaceLookup.php +++ b/lib/PlaceLookup.php @@ -556,7 +556,8 @@ class PlaceLookup if ($this->bIncludePolygonAsSVG) $sSQL .= ',ST_AsSVG(geometry) as assvg'; if ($this->bIncludePolygonAsText || $this->bIncludePolygonAsPoints) $sSQL .= ',ST_AsText(geometry) as astext'; if ($fLonReverse != null && $fLatReverse != null) { - $sFrom = ' from (SELECT * , ST_ClosestPoint(geometry, ST_SetSRID(ST_Point('.$fLatReverse.','.$fLonReverse.'),4326)) AS closest_point'; + $sFrom = ' from (SELECT * , CASE WHEN (class = \'highway\') AND (ST_GeometryType(geometry) = \'ST_LineString\') THEN '; + $sFrom .=' ST_ClosestPoint(geometry, ST_SetSRID(ST_Point('.$fLatReverse.','.$fLonReverse.'),4326)) END AS closest_point'; $sFrom .= ' from placex where place_id = '.$iPlaceID.') as plx'; } else { $sFrom = ' from placex where place_id = '.$iPlaceID; -- 2.39.5