[postgis-users] about postgis gecode and fuzzy search

Min Wang ser.basis at gmail.com
Mon Mar 5 14:21:47 PST 2012


HI steve

       In google map:

  if I input:
11 genside st, glenside,pa

it suggest:

11 W Glenside Ave, Glenside, Montgomery, PA 19038


in my postgis install, I got this:

  SELECT g.rating, ST_X(g.geomout) As lon, ST_Y(g.geomout) As lat,
(addy).address As stno, (addy).streetname As street,
(addy).streettypeabbrev As styp, (addy).location As city, 
(addy).stateabbrev As st,(addy).zip
FROM geocode('11 genside st, glenside,pa') As g;
  rating |        lon        |       lat        | stno |  street  | styp 
|     city     | st |  zip
--------+-------------------+------------------+------+----------+------+--------------+----+-------
      50 | -79.9444026616404 | 40.5023271849759 |   11 | Ganster  | St   
| Etna         | PA | 15223
      53 | -75.8618299032068 | 40.3252632536899 |   11 | Ganster  | St   
| St. Lawrence | PA | 19606
      70 | -76.4294405434179 |   40.06776635101 |      | Gemstone | Dr   
| Lancaster    | PA | 17601
      70 | -76.8821996748582 | 39.7607632310703 |      | Gemstone | Ln   
| Manheim      | PA | 17329
      70 | -76.7548609358801 | 40.0150088699944 |      | Gemstone | Ln   
| New Salem    | PA | 17404
      71 | -76.7548609358801 | 40.0150088699944 |      | Gemstone | Ln   
| Shiloh       | PA | 17404
      72 | -76.7548186259445 | 40.0148316859951 |      | Gemstone | Ln   
| Weigelstown  | PA | 17404
      75 | -79.5774090801793 | 40.3146561945201 |      | Gemstone | Ave  
| Jeannette    | PA | 15644
      76 | -79.5774090801793 | 40.3146561945201 |      | Gemstone | Ave  
| Murrysville  | PA | 15644
      76 | -79.5776410781123 |  40.314686466754 |      | Gemstone | Ave  
| Smithton     | PA | 15644
(10 rows)



Is there way to achieve something like google using fuzzy search?


thanks.


min




On 03/05/2012 04:42 PM, Stephen Woodbridge wrote:
> Hi Min,
>
> If you are doing a fuzzy search, then you request does not make sense. 
> The whole purpose of a fuzzy search to to find some like what you are 
> looking for. What you are asking for is different. You want and exact 
> search with a fallback to to city centroid or zip centroid if the 
> exact match fails.
>
> You could achieve this by filtering you query below like:
>
> select * from (
> SELECT g.rating, ST_X(g.geomout) As lon, ST_Y(g.geomout) As lat,
> (addy).address As stno, (addy).streetname As street,
> (addy).streettypeabbrev As styp, (addy).location As city, 
> (addy).stateabbrev As st,(addy).zip
> FROM geocode('38 blair mill rod, glenside,pa') As g
> ) as h where h.city ilike "glenside";
>
> Then if this fails to return a result, you could lookup the city 
> centroid for "glenside, pa" in another table you would need to load.
>
> -Steve
>
> On 3/5/2012 4:38 PM, Min Wang wrote:
>> HI
>> I am new to postgis geocoding.
>>
>> I have installed postgis 2.0 with fuzzy search, and imported the tiger
>> data for usa.
>>
>> Now for geocoding non-exist or some not accurate addresses
>>
>> e.g: 38 blair mill rod, glenside, pa
>>
>> its output:
>>
>> SELECT g.rating, ST_X(g.geomout) As lon, ST_Y(g.geomout) As lat,
>> (addy).address As stno, (addy).streetname As street,
>> (addy).streettypeabbrev As styp, (addy).location As city,
>> (addy).stateabbrev As st,(addy).zip
>> FROM geocode('38 blair mill rod, glenside,pa') As g;
>> rating | lon | lat | stno | street | styp | city | st | zip
>> --------+-------------------+------------------+------+--------+------+------------------+----+------- 
>>
>>
>> 20 | -80.1461480769354 | 39.8912098295989 | 38 | Blair | Ct | Waynesburg
>> | PA | 15370
>> 20 | -76.9528968230038 | 41.1701753366091 | 38 | Blair | Dr | Montgomery
>> | PA | 17752
>> 20 | -80.1461480769354 | 39.8912098295989 | 38 | Blair | Ct | West
>> Waynesburg | PA | 15370
>> 20 | -80.1461480769354 | 39.8912098295989 | 38 | Blair | Ct |
>> Morrisville | PA | 15370
>> 20 | -77.2937928401596 | 40.2205725968637 | 38 | Blair | Ct | Plainfield
>> | PA | 17015
>> 21 | -78.7498163920357 | 40.467390956601 | 38 | Blair | Rd | Ebensburg |
>> PA | 15931
>> 22 | -80.0234909653877 | 41.4774803539524 | 38 | Blair | Ln | French
>> Creek | PA | 16311
>> 24 | -78.9484013917784 | 41.0336884088542 | | Blair | Dr | Reynoldsville
>> | PA | 15851
>> 25 | -80.236503518171 | 40.5702521235743 | 38 | Blair | Aly | South
>> Heights | PA | 15081
>> 27 | -75.1757087347985 | 41.0177238645261 | 38 | Blair | Ct | East
>> Stroudsburg | PA | 18301
>>
>>
>> none of them is in glenside, PA
>>
>> what I would like the result is: return some addresses or center in
>> glenside, PA instead of other cities address?
>>
>> Is it possible? Is there anyway to specify the weight of the search?
>>
>> like city: glenside has some weight during the geocode search?
>>
>> the state : PA has more weight?
>>
>>
>>
>>
>>
>> thanks
>>
>>
>> min
>> _______________________________________________
>> postgis-users mailing list
>> postgis-users at postgis.refractions.net
>> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users




More information about the postgis-users mailing list