使用什么样的DB Foursquare?

发布于 2024-10-07 02:38:21 字数 92 浏览 6 评论 0原文

使用什么样的 db foursquare?
我的意思不是:MySQL、Oracle 或其他什么,我的意思是:
他们在哪里找到场地?
来自谷歌地图?

what kind of db foursquare is using?
I don't mean: MySQL, Oracle, or whatever, I mean:
Where they get the venue?
From google maps?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

秋意浓 2024-10-14 02:38:21

据我所知,4SQ 使用 Google 地图地理定位

我不知道你使用什么技术,但我写了一个非常甜蜜的“lat/ lon”定位器,可与 Google 地图和 Bing 地图配合使用。它位于 VB.NET 中,并将纬度和经度输出为 JSON。

Imports System.Runtime.Serialization
Imports System.Web
Imports System.Net
Imports System.Runtime.Serialization.Json
Imports System.Web.Script.Serialization

Namespace Utilities.Apis
    Public NotInheritable Class Geolocation
        ''# This is the object that we are going to store the latitude and
        ''# longitude contained in the API response.
        Private coordinates As Coordinates
        Public Sub New()
            coordinates = New Coordinates
        End Sub

        Private Const googleUrl As String = "http://maps.googleapis.com/maps/api/geocode/json?address={0}&sensor=false"
        Private Const bingUrl As String = "http://dev.virtualearth.net/REST/v1/Locations?addressLine={0}&key={1}&CountryRegion={2}"
        Private Const bingKey As String = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

        Public Enum apiProvider
            Google = 1
            Bing = 2
        End Enum

        ''''# <summary>
        ''''# Gets the Latitude and Longitude of an address using either Bing or Google Geolocation
        ''''# </summary>
        ''''# <param name="Provider">ENUM apiProvider [Bing] or [Google]</param>
        ''''# <param name="Address">The address of the coordinates you'd like to locate</param>
        ''''# <param name="countryCode">Bing doesn't play nice outside the US without this. use "CA" for Canada</param>
        ''''# <returns>A JSON string using "Latitude" and "Longitude" from the Coordinates class</returns>
        Public Function GetLatLon(ByVal Provider As Integer,
                                  ByVal Address As String,
                                  Optional ByVal CountryCode As String = "CA") As String

            ''# If there happens to be some strange behavior with the placeholder,
            ''# we want to ensure that the "demo" content is not submitted to the
            ''# api.
            If Address = "6789 university drive" Then
                Return Nothing
            End If

            Address = HttpUtility.UrlEncode(Address)

            Dim url As String
            Dim responseType As Type
            If Provider = apiProvider.Bing Then
                url = String.Format(bingUrl, Address, bingKey, CountryCode)
                responseType = GetType(BingResponse)
            ElseIf Provider = apiProvider.Google Then
                url = String.Format(googleUrl, Address)
                responseType = GetType(GoogleResponse)
            Else
                ''# If for some reason, the apiResponse is NOT Google or Bing,
                ''# then we want to return Google anyways.
                url = String.Format(googleUrl, Address)
            End If

            ''# Initiate the Http Web Request to the respective provider
            Dim request = DirectCast(HttpWebRequest.Create(url), HttpWebRequest)

            ''# Deflate the compressed (gzip'd) response
            request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate")
            request.AutomaticDecompression = DecompressionMethods.GZip Or DecompressionMethods.Deflate

            ''# Serialize the response into it's respective Data Contract
            Dim serializer As New DataContractJsonSerializer(responseType)

            ''# Because the JSON Response from Google and Bing are drastically
            ''# different, we need to consume the response a little differently
            ''# for each API.  I'd like to figure out a way to shrink this a
            ''# little more, but at the same time, it's working. So I'm going to
            ''# leave it alone for now [Nov 28,2010]


            ''# Here we're handling the Bing Provider
            If Provider = apiProvider.Bing Then
                Dim res = DirectCast(serializer.ReadObject(request.GetResponse().GetResponseStream()), BingResponse)
                Dim resources As BingResponse.ResourceSet.Resource = res.resourceSets(0).resources(0)
                Dim point = resources.point
                With coordinates
                    .latitude = point.coordinates(0)
                    .longitude = point.coordinates(1)
                End With


                ''# Here we're handling the Google Provider
            ElseIf Provider = apiProvider.Google Then
                Dim res = DirectCast(serializer.ReadObject(request.GetResponse().GetResponseStream()), GoogleResponse)
                Dim resources As GoogleResponse.Result = res.results(0)
                Dim point = resources.geometry.location
                With coordinates
                    .latitude = point.lat
                    .longitude = point.lng
                End With
            End If

            ''# Serialize the coordinates and return the string
            Dim jsonSerializer = New JavaScriptSerializer
            Return jsonSerializer.Serialize(coordinates)
        End Function
    End Class

    <DataContract()>
    Public Class BingResponse
        <DataMember()>
        Public Property resourceSets() As ResourceSet()
        <DataContract()>
        Public Class ResourceSet
            <DataMember()>
            Public Property resources() As Resource()
            <DataContract([Namespace]:="http://schemas.microsoft.com/search/local/ws/rest/v1", name:="Location")>
            Public Class Resource
                <DataMember()>
                Public Property point() As m_Point
                <DataContract()>
                Public Class m_Point
                    <DataMember()>
                    Public Property coordinates() As String()
                End Class
            End Class
        End Class
    End Class

    <DataContract()>
    Public Class GoogleResponse
        <DataMember()>
        Public Property results() As Result()
        <DataContract()>
        Public Class Result
            <DataMember()>
            Public Property geometry As m_Geometry
            <DataContract()>
            Public Class m_Geometry
                <DataMember()>
                Public Property location As m_location
                <DataContract()>
                Public Class m_location
                    <DataMember()>
                    Public Property lat As String
                    <DataMember()>
                    Public Property lng As String
                End Class
            End Class
        End Class

    End Class
End Namespace

调用它是多么容易。

Geolocate.GetLatLon(Utilities.Apis.Geolocation.apiProvider.Google, "1234 Some Funky Street, Home Town, MI", "US")

所以最后,他们结合了自己的地理定位,以及“可以”由twitter或最终用户移动设备提交的信息(例如iPhone询问是否允许它发送位置信息) )。

From what I can tell, 4SQ is using Google Maps and Geolocation

I don't know what you're using for technology, but I've written a pretty sweet "lat/lon" locator that works with Google maps and Bing maps. It's in VB.NET and outputs the Latitude and Longitude as JSON.

Imports System.Runtime.Serialization
Imports System.Web
Imports System.Net
Imports System.Runtime.Serialization.Json
Imports System.Web.Script.Serialization

Namespace Utilities.Apis
    Public NotInheritable Class Geolocation
        ''# This is the object that we are going to store the latitude and
        ''# longitude contained in the API response.
        Private coordinates As Coordinates
        Public Sub New()
            coordinates = New Coordinates
        End Sub

        Private Const googleUrl As String = "http://maps.googleapis.com/maps/api/geocode/json?address={0}&sensor=false"
        Private Const bingUrl As String = "http://dev.virtualearth.net/REST/v1/Locations?addressLine={0}&key={1}&CountryRegion={2}"
        Private Const bingKey As String = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

        Public Enum apiProvider
            Google = 1
            Bing = 2
        End Enum

        ''''# <summary>
        ''''# Gets the Latitude and Longitude of an address using either Bing or Google Geolocation
        ''''# </summary>
        ''''# <param name="Provider">ENUM apiProvider [Bing] or [Google]</param>
        ''''# <param name="Address">The address of the coordinates you'd like to locate</param>
        ''''# <param name="countryCode">Bing doesn't play nice outside the US without this. use "CA" for Canada</param>
        ''''# <returns>A JSON string using "Latitude" and "Longitude" from the Coordinates class</returns>
        Public Function GetLatLon(ByVal Provider As Integer,
                                  ByVal Address As String,
                                  Optional ByVal CountryCode As String = "CA") As String

            ''# If there happens to be some strange behavior with the placeholder,
            ''# we want to ensure that the "demo" content is not submitted to the
            ''# api.
            If Address = "6789 university drive" Then
                Return Nothing
            End If

            Address = HttpUtility.UrlEncode(Address)

            Dim url As String
            Dim responseType As Type
            If Provider = apiProvider.Bing Then
                url = String.Format(bingUrl, Address, bingKey, CountryCode)
                responseType = GetType(BingResponse)
            ElseIf Provider = apiProvider.Google Then
                url = String.Format(googleUrl, Address)
                responseType = GetType(GoogleResponse)
            Else
                ''# If for some reason, the apiResponse is NOT Google or Bing,
                ''# then we want to return Google anyways.
                url = String.Format(googleUrl, Address)
            End If

            ''# Initiate the Http Web Request to the respective provider
            Dim request = DirectCast(HttpWebRequest.Create(url), HttpWebRequest)

            ''# Deflate the compressed (gzip'd) response
            request.Headers.Add(HttpRequestHeader.AcceptEncoding, "gzip,deflate")
            request.AutomaticDecompression = DecompressionMethods.GZip Or DecompressionMethods.Deflate

            ''# Serialize the response into it's respective Data Contract
            Dim serializer As New DataContractJsonSerializer(responseType)

            ''# Because the JSON Response from Google and Bing are drastically
            ''# different, we need to consume the response a little differently
            ''# for each API.  I'd like to figure out a way to shrink this a
            ''# little more, but at the same time, it's working. So I'm going to
            ''# leave it alone for now [Nov 28,2010]


            ''# Here we're handling the Bing Provider
            If Provider = apiProvider.Bing Then
                Dim res = DirectCast(serializer.ReadObject(request.GetResponse().GetResponseStream()), BingResponse)
                Dim resources As BingResponse.ResourceSet.Resource = res.resourceSets(0).resources(0)
                Dim point = resources.point
                With coordinates
                    .latitude = point.coordinates(0)
                    .longitude = point.coordinates(1)
                End With


                ''# Here we're handling the Google Provider
            ElseIf Provider = apiProvider.Google Then
                Dim res = DirectCast(serializer.ReadObject(request.GetResponse().GetResponseStream()), GoogleResponse)
                Dim resources As GoogleResponse.Result = res.results(0)
                Dim point = resources.geometry.location
                With coordinates
                    .latitude = point.lat
                    .longitude = point.lng
                End With
            End If

            ''# Serialize the coordinates and return the string
            Dim jsonSerializer = New JavaScriptSerializer
            Return jsonSerializer.Serialize(coordinates)
        End Function
    End Class

    <DataContract()>
    Public Class BingResponse
        <DataMember()>
        Public Property resourceSets() As ResourceSet()
        <DataContract()>
        Public Class ResourceSet
            <DataMember()>
            Public Property resources() As Resource()
            <DataContract([Namespace]:="http://schemas.microsoft.com/search/local/ws/rest/v1", name:="Location")>
            Public Class Resource
                <DataMember()>
                Public Property point() As m_Point
                <DataContract()>
                Public Class m_Point
                    <DataMember()>
                    Public Property coordinates() As String()
                End Class
            End Class
        End Class
    End Class

    <DataContract()>
    Public Class GoogleResponse
        <DataMember()>
        Public Property results() As Result()
        <DataContract()>
        Public Class Result
            <DataMember()>
            Public Property geometry As m_Geometry
            <DataContract()>
            Public Class m_Geometry
                <DataMember()>
                Public Property location As m_location
                <DataContract()>
                Public Class m_location
                    <DataMember()>
                    Public Property lat As String
                    <DataMember()>
                    Public Property lng As String
                End Class
            End Class
        End Class

    End Class
End Namespace

and here's how easy it is to call it.

Geolocate.GetLatLon(Utilities.Apis.Geolocation.apiProvider.Google, "1234 Some Funky Street, Home Town, MI", "US")

So in the end, they use the combination of their own Geolocating, as well as the information that "can" be submitted by twitter or by the end users mobile device (the iPhone for example asks if you want to allow it to send location information).

稀香 2024-10-14 02:38:21

他们依靠用户进入新位置。他们可能在某个时候通过进口播种了它。

They rely on users to enter new locations. They may have seeded it at some point with an import.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文