X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/a9c06d89c144fb90616e3a780029fe3d9bcfd90d..4351c76f6dec7d791e21c458a6afd46fb06cd8fe:/lib/PlaceLookup.php?ds=sidebyside diff --git a/lib/PlaceLookup.php b/lib/PlaceLookup.php index c21b1a68..eff66fd1 100644 --- a/lib/PlaceLookup.php +++ b/lib/PlaceLookup.php @@ -113,10 +113,10 @@ class PlaceLookup if ($this->bNameDetails) $sSQL .= " null as names,"; $sSQL .= " ST_X(point) as lon, ST_Y(point) as lat from (select *, ST_LineInterpolatePoint(linegeo, (housenumber-startnumber::float)/(endnumber-startnumber)::float) as point from "; $sSQL .= " (select *, "; - $sSQL .= " GREATEST(startnumber, LEAST(endnumber, CASE WHEN interpolationtype='odd' THEN floor((".$fInterpolFraction."*(endnumber-startnumber)+startnumber)/2)::int*2+1"; + $sSQL .= " CASE WHEN interpolationtype='odd' THEN floor((".$fInterpolFraction."*(endnumber-startnumber)+startnumber)/2)::int*2+1"; $sSQL .= " WHEN interpolationtype='even' THEN ((".$fInterpolFraction."*(endnumber-startnumber)+startnumber)/2)::int*2"; $sSQL .= " WHEN interpolationtype='all' THEN (".$fInterpolFraction."*(endnumber-startnumber)+startnumber)::int"; - $sSQL .= " END)) as housenumber"; + $sSQL .= " END as housenumber"; $sSQL .= " from location_property_tiger where place_id = ".$iPlaceID.") as blub1) as blub2"; } elseif ($bIsInterpolation) { $sSQL = "select place_id, partition, 'W' as osm_type, osm_id, 'place' as class, 'house' as type, null admin_level, housenumber, null as street, null as isin, postcode,"; @@ -129,10 +129,10 @@ class PlaceLookup if ($this->bNameDetails) $sSQL .= " null as names,"; $sSQL .= " ST_X(point) as lon, ST_Y(point) as lat from (select *, ST_LineInterpolatePoint(linegeo, (housenumber-startnumber::float)/(endnumber-startnumber)::float) as point from "; $sSQL .= " (select *, "; - $sSQL .= " GREATEST(startnumber, LEAST(endnumber, CASE WHEN interpolationtype='odd' THEN floor((".$fInterpolFraction."*(endnumber-startnumber)+startnumber)/2)::int*2+1"; + $sSQL .= " CASE WHEN interpolationtype='odd' THEN floor((".$fInterpolFraction."*(endnumber-startnumber)+startnumber)/2)::int*2+1"; $sSQL .= " WHEN interpolationtype='even' THEN ((".$fInterpolFraction."*(endnumber-startnumber)+startnumber)/2)::int*2"; $sSQL .= " WHEN interpolationtype='all' THEN (".$fInterpolFraction."*(endnumber-startnumber)+startnumber)::int"; - $sSQL .= " END)) as housenumber"; + $sSQL .= " END as housenumber"; $sSQL .= " from location_property_osmline where place_id = ".$iPlaceID.") as blub1) as blub2"; // testcase: interpolationtype=odd, startnumber=1000, endnumber=1006, fInterpolFraction=1 => housenumber=1007 => error in st_lineinterpolatepoint // but this will never happen, because if the searched point is that close to the endnumber, the endnumber house will be directly taken from placex (in ReverseGeocode.php line 220)