- $iPlaceID = $aPlace['place_id'];
- $iParentPlaceID = $aPlace['parent_place_id'];
- $bIsInUnitedStates = ($aPlace['country_code'] == 'us');
- }
-
- // If a house was found make sure there isn't an interpolation line
- // that is closer
- if ($bDoInterpolation && !$bPlaceIsLine && $aPlace && $aPlace['rank_search'] == 30) {
- // get the distance of the house to the search point
- $sSQL = 'SELECT ST_distance('.$sPointSQL.', house.geometry)';
- $sSQL .= ' FROM placex as house WHERE house.place_id='.$iPlaceID;
-
- $fDistancePlacex = chksql(
- $this->oDB->getOne($sSQL),
- "Could not determine distance between searched point and placex house."
- );
-
- // look for an interpolation that is closer
- $aPlaceLine = $this->lookupInterpolation($sPointSQL, $fDistancePlacex);
-
- if ($aPlaceLine && (float) $aPlaceLine['distance'] < (float) $fDistancePlacex) {
- // interpolation is closer to point than placex house
- $bPlaceIsLine = true;
- $aPlace = $aPlaceLine;
- $iPlaceID = $aPlaceLine['place_id'];
- $iParentPlaceID = $aPlaceLine['parent_place_id']; // the street
- $fFraction = $aPlaceLine['fraction'];
+ if ($aPlace) {
+ $oResult = new Result($aPlace['place_id']);
+ $iParentPlaceID = $aPlace['parent_place_id'];
+ if ($bDoInterpolation) {
+ if ($aPlace['rank_search'] == 26 || $aPlace['rank_search'] == 27) {
+ $bIsTigerStreet = ($aPlace['country_code'] == 'us');
+ } elseif ($aPlace['rank_search'] == 30) {
+ // If a house was found, make sure there isn't an
+ // interpolation line that is closer.
+ $aHouse = $this->lookupInterpolation(
+ $sPointSQL,
+ $aPlace['distance']
+ );
+ if ($aHouse && $aPlace['distance'] < $aHouse['distance']) {
+ $oResult = new Result(
+ $aHouse['place_id'],
+ Result::TABLE_OSMLINE
+ );
+ $oResult->iHouseNumber = closestHouseNumber($aHouse);
+
+ $aPlace = $aHouse;
+ $iParentPlaceID = $aHouse['parent_place_id'];
+ }
+ }
+ }