- // look for place nodes with the given country code
- $sSQL = 'SELECT place_id FROM';
- $sSQL .= ' (SELECT place_id, rank_search,';
- $sSQL .= ' ST_distance('.$sPointSQL.', geometry) as distance';
- $sSQL .= ' FROM placex';
- $sSQL .= ' WHERE osm_type = \'N\'';
- $sSQL .= ' AND country_code = \''.$sCountryCode.'\'';
- $sSQL .= ' AND rank_search > 4';
- $sSQL .= ' AND rank_search <= ' .min(25, $iMaxRank);
- $sSQL .= ' AND type != \'postcode\'';
- $sSQL .= ' AND name IS NOT NULL ';
- $sSQL .= ' and indexed_status = 0 and linked_place_id is null';
- $sSQL .= ' AND ST_DWithin('.$sPointSQL.', geometry, 5.0)) p ';
- $sSQL .= 'WHERE distance <= reverse_place_diameter(rank_search)';
- $sSQL .= ' ORDER BY rank_search DESC, distance ASC';
- $sSQL .= ' LIMIT 1';
-
- if (CONST_Debug) var_dump($sSQL);
- $aPlacNode = chksql(
- $this->oDB->getRow($sSQL),
- 'Could not determine place node.'
- );
- if ($aPlacNode) {
- return $aPlacNode;
+ $aPlace = $this->oDB->getRow($sSQL, null, 'Could not determine place node.');
+ Debug::printVar('Country node', $aPlace);
+
+ if ($aPlace) {
+ return new Result($aPlace['place_id']);
+ }