- $sSQL .= " union ";
- $sSQL .= "select 'T' as osm_type,place_id as osm_id,'place' as class,'house' as type,null as admin_level,30 as rank_search,30 as rank_address,min(place_id) as place_id, min(parent_place_id) as parent_place_id,'us' as country_code,";
- $sSQL .= "get_address_by_language(place_id, $sLanguagePrefArraySQL) as langaddress,";
- $sSQL .= "null as placename,";
- $sSQL .= "null as ref,";
- if ($this->bIncludeExtraTags) $sSQL .= "null as extra,";
- if ($this->bIncludeNameDetails) $sSQL .= "null as names,";
- $sSQL .= "avg(ST_X(centroid)) as lon,avg(ST_Y(centroid)) as lat, ";
- $sSQL .= $sImportanceSQL."-1.15 as importance, ";
- $sSQL .= "(select max(p.importance*(p.rank_address+2)) from place_addressline s, placex p where s.place_id = min(location_property_tiger.parent_place_id) and p.place_id = s.address_place_id and s.isaddress and p.importance is not null) as addressimportance, ";
- $sSQL .= "null as extra_place ";
- $sSQL .= "from location_property_tiger where place_id in ($sPlaceIDs) ";
- $sSQL .= "and 30 between $this->iMinAddressRank and $this->iMaxAddressRank ";
- $sSQL .= "group by place_id";
- if (!$this->bDeDupe) $sSQL .= ",place_id ";
+ //query also location_property_tiger_line and location_property_aux
+ //Tiger search only if it was searched for a housenumber (searchedHousenumber >=0) and if it was found (housenumberFound = true)
+ //only Tiger housenumbers need to be interpolated, because they are saved as lines with start- and endnumber, the common osm housenumbers are usually saved as points
+ if($this->searchedHousenumber>=0 && $this->housenumberFound){
+ $sSQL .= "union ";
+ $sSQL .= "select 'T' as osm_type, place_id as osm_id,'place' as class,'house' as type,null as admin_level,30 as rank_search,30 as rank_address,min(place_id) as place_id, min(parent_place_id) as parent_place_id,'us' as country_code";
+ $sSQL .= ", get_address_by_language(place_id, $sLanguagePrefArraySQL) as langaddress ";
+ $sSQL .= ", null as placename";
+ $sSQL .= ", null as ref";
+ if ($this->bIncludeExtraTags) $sSQL .= ", null as extra";
+ if ($this->bIncludeNameDetails) $sSQL .= ", null as names";
+ $sSQL .= ", avg(st_x(point)) as lon, avg(st_y(point)) as lat";
+ $sSQL .= $sImportanceSQL.", -1.15 as importance ";
+ $sSQL .= ", 1.0 as addressimportance "; //not sure how the addressimportance is/should be calculated for Tiger data
+ $sSQL .= ", null as extra_place ";
+ $sSQL .= " from (select place_id";
+ //interpolate the Tiger housenumbers here
+ $sSQL .= ",ST_LineInterpolatePoint(linegeo, ($this->searchedHousenumber::float-startnumber::float)/(endnumber-startnumber)::float) as point, parent_place_id ";
+ $sSQL .= "from location_property_tiger_line where place_id in ($sPlaceIDs) ";
+ $sSQL .= "and 30 between $this->iMinAddressRank and $this->iMaxAddressRank) as blub"; //postgres wants an alias here
+ $sSQL .= " group by place_id"; //why group by place_id, isnt place_id unique?
+ if (!$this->bDeDupe) $sSQL .= ",place_id ";
+ }