2012-03-06 68 views
1

我進行了場地搜索,返回了重複的場地。除了會場編號和緯度/經度信息,重複的場地是相同的。在foursquare.com上執行相同的搜索,並且不顯示重複內容。我如何排除重複?場地搜索api返回不正確的經緯度的重複場地

這裏是API調用(負祕密): https://api.foursquare.com/v2/venues/search?ll=38.468807,-77.372589&query=starbucks

結果:

{ 
    meta: { 
     code: 200 
    } 
    notifications: [ 
    { 
     type: "notificationTray" 
     item: { 
      unreadCount: 0 
     } 
    }] 
    response: { 
     venues: [ 
     { 
      id: "4e4dc886bd41b76bef93082e" 
      name: "Starbucks Coffee" 
      contact: { 
       phone: "5407209145" 
       formattedPhone: "(540) 720-9145" 
      } 
      location: { 
       address: "1495 Stafford Market Pl" 
       lat: 38.47310969662029 
       lng: -77.38591645407749 
       distance: 1256 
       postalCode: "22556" 
       city: "Stafford" 
       state: "VA" 
       country: "United States" 
      } 
      categories: [ 
      { 
       id: "4bf58dd8d48988d1e0931735" 
       name: "Coffee Shop" 
       pluralName: "Coffee Shops" 
       shortName: "Coffee Shop" 
       icon: { 
        prefix: "https://foursquare.com/img/categories/food/coffeeshop_" 
        sizes: [ 32 44 64 88 256 ] 
        name: ".png" 
       } 
       primary: true 
      }] 
      verified: false 
      stats: { 
       checkinsCount: 13 
       usersCount: 11 
       tipCount: 0 
      } 
      specials: { 
       count: 0 
       items: [ ] 
      } 
      hereNow: { 
       count: 0 
      } 
     }, 
     { 
      id: "4b8dd66ef964a520071033e3" 
      name: "Starbucks" 
      contact: { 
       phone: "5407209145" 
       formattedPhone: "(540) 720-9145" 
      } 
      location: { 
       address: "1495 Stafford Market Place" 
       crossStreet: "Garrisonville Road" 
       lat: 38.470214117289444 
       lng: -77.41142749786377 
       distance: 3388 
       postalCode: "22554" 
       city: "Stafford" 
       state: "VA" 
       country: "United States" 
      } 
      categories: [ 
      { 
       id: "4bf58dd8d48988d1e0931735" 
       name: "Coffee Shop" 
       pluralName: "Coffee Shops" 
       shortName: "Coffee Shop" 
       icon: { 
        prefix: "https://foursquare.com/img/categories/food/coffeeshop_" 
        sizes: [ 32 44 64 88 256 ] 
        name: ".png" 
       } 
       primary: true 
      }] 
      verified: true 
      stats: { 
       checkinsCount: 1885 
       usersCount: 522 
       tipCount: 14 
      } 
      url: "http://www.starbucks.com/" 
      specials: { 
       count: 0 
       items: [ ] 
      } 
      hereNow: { 
       count: 0 
      } 
      menu: { 
       url: "https://foursquare.com/v/starbucks/4b8dd66ef964a520071033e3/menu" 
       mobileUrl: "https://foursquare.com/v/4b8dd66ef964a520071033e3/device_menu" 
      } 
     }, 
     { 
      id: "4d87c7bba98841bd5eaf3055" 
      name: "Starbucks" 
      contact: { 
       phone: "5407209145" 
       formattedPhone: "(540) 720-9145" 
       twitter: "starbucks" 
      } 
      location: { 
       address: "1495 Stafford Market Place" 
       lat: 38.50188672 
       lng: -77.37500964 
       distance: 3688 
       postalCode: "22556" 
       city: "Stafford" 
       state: "Virginia" 
       country: "United States" 
      } 
      categories: [ ] 
      verified: true 
      stats: { 
       checkinsCount: 17 
       usersCount: 11 
       tipCount: 0 
      } 
      specials: { 
       count: 0 
       items: [ ] 
      } 
      hereNow: { 
       count: 0 
      } 
     } 
    } 
} 

第二場地,ID = 4b8dd66ef964a520071033e3,是實際的。其他2個是重複的。

+0

你能提供實際的API調用(減去祕密)和結果?沒有更多細節,不可能幫助您進行調試。 – akdotcom 2012-03-06 20:52:05

回答

2

我會排除第一個結果,因爲它的鍵/值「verified:false」。 已驗證:true表示擁有者已聲明它。

我會注意到第二個結果比第三個結果更好,因爲: 1.它有一個類別 2. checkinsCount更高。在這種情況下,要高得多。 3.有一個網站鏈接(URL) 4.它的菜單鏈接 5.位置有一個跨街

基本上,如果你創建了一個算法來排序了「緊湊型場地」結果的完整性,你可以近似Foursquare.com的獨特性。我會將所有不同屬性的數量加起來,並對驗證的屬性,簽入數量和提示(告訴您用戶是否正在使用該場所)提供額外的權重。我可能會使用名稱,街道地址和可能的電話號碼作爲關鍵。郵政編碼似乎也是一個很好的使用方式,但在這種情況下,您會注意到對於應該是規範結果的結果是不正確的。

,我用來幫助回答一個很好的參考文檔是這樣的:https://developer.foursquare.com/docs/responses/venue

+0

希望我錯過了我的要求,但這聽起來像是最好的路線。謝謝。 – scott4arrows 2012-03-12 12:13:15