Beispiel #1
0
def hotelRequest(hotelName, viewpoint_location):
    hotelData = hotel(hotelName)
    hotelDict = {}
    for hotel_data in range(shape(hotelData)[0]):
        hotelList = []
        hotelList.append(hotelData[hotel_data]['name'].encode('utf-8'))
        hotelList.append(hotelData[hotel_data]['location'].encode('utf-8'))
        hotelList.append(
            destina.viewpoint(
                hotelData[hotel_data]['location'].encode('utf-8'),
                viewpoint_location))
        hotelList.append(''.join(hotelData[hotel_data]['address']))
        if len(hotelData[hotel_data]['biz_ext']['rating']):
            hotel_rate = ''.join(hotelData[hotel_data]['biz_ext']['rating'])
        else:
            hotel_rate = '1'
        hotelList.append(hotel_rate)

        if len(hotelData[hotel_data]['biz_ext']['lowest_price']):
            hotel_minprice = (str(
                hotelData[hotel_data]['biz_ext']['lowest_price'])
                              ).encode('utf-8')
        else:
            hotel_minprice = '无'
        hotelList.append(hotel_minprice)
        hotelDict[hotel_data] = hotelList

    return hotelDict
Beispiel #2
0
def sel(data, viewpoint_location):
    str1 = str(var.get())
    i = int(str1)
    hotel_location = '宾馆经纬度:' + data[i]['location'].encode('utf-8')
    destination = destina.viewpoint(data[i]['location'].encode('utf-8'),
                                    viewpoint_location)
    tkMessageBox.showinfo('距离景区步行距离',
                          '距离景区步行距离:' + str(destination).encode("utf-8") + "米")
Beispiel #3
0
def hotel_distance_recom(data,viewpoint_location):
    minDistance = 10000000
    minDistanceIndex = 0
    for hotel_data in range(shape(data)[0]):
        # 景点与宾馆的距离
        hotel_view_distance = destina.viewpoint(data[hotel_data]['location'].encode('utf-8'), viewpoint_location)
        if hotel_view_distance < minDistance:
            minDistance = hotel_view_distance
            minDistanceIndex = hotel_data

    tkMessageBox.showinfo("最短距离酒店为:",[data[minDistanceIndex]['name'].encode('utf-8'),
                                      '宾馆经纬度:' + data[minDistanceIndex]['location'].encode('utf-8'),
                                      '宾馆地址:' + data[minDistanceIndex]['address'].encode('utf-8'),
                                      ])
Beispiel #4
0
def hotel_best_recom(data, viewpoint_location):
    listDistance = []
    listRate = []
    listPrice = []

    bestNum = 0
    bestNumIndex = 0
    m = shape(data)[0]

    for hotel_data in range(shape(data)[0]):
        hotel_view_distance = destina.viewpoint(
            data[hotel_data]['location'].encode('utf-8'), viewpoint_location)
        listDistance.append(float(hotel_view_distance))

        if len(data[hotel_data]['biz_ext']['rating']):
            hotelRate = float(
                (data[hotel_data]['biz_ext']['rating']).encode('utf-8'))
        else:
            hotelRate = 1.0
        listRate.append(hotelRate)

        if len(data[hotel_data]['biz_ext']['lowest_price']):
            hotelPrice = float((data[hotel_data]['biz_ext']['lowest_price']
                                ).encode('utf-8')) + 1
        else:
            hotelPrice = 30000
        listPrice.append(hotelPrice)

    maxDist = mat(listDistance).max()
    minDist = mat(listDistance).min()
    maxRate = mat(listRate).max()
    minRate = mat(listRate).min()
    maxPrice = mat(listPrice).max()
    minPrice = mat(listPrice).min()

    rangeRateData = float(maxRate - minRate)
    listRate = mat(listRate)
    normRateData = listRate - tile(minRate, (m, 1))
    normRateData = normRateData / tile(rangeRateData, (m, 1))
    normRateData = normRateData[0, :]

    rangeDistData = float(maxDist - minDist)
    listDistance = mat(listDistance)
    normDistData = listDistance - tile(minDist, (m, 1))
    normDistData = normDistData / tile(rangeDistData, (m, 1))
    normDistData = normDistData[0, :]

    rangePriceData = float(maxPrice - minPrice)
    listPrice = mat(listPrice)
    normPriceData = listPrice - tile(minPrice, (m, 1))
    normPriceData = normPriceData / tile(rangePriceData, (m, 1))
    normPriceData = normPriceData[0, :]

    for num in range(shape(data)[0]):
        best = normRateData[0, num] / (normDistData[0, num] +
                                       normPriceData[0, num] / 10)
        if best > bestNum:
            bestNum = best
            bestNumIndex = num

    tkMessageBox.showinfo("性价比酒店推荐:", [
        data[bestNumIndex]['name'].encode('utf-8'),
        '宾馆经纬度:' + data[bestNumIndex]['location'].encode('utf-8'),
        '宾馆地址:' + data[bestNumIndex]['address'].encode('utf-8'),
    ])
Beispiel #5
0
def view_hotel(viewpoint_name, viewpoint_location):
    #root.destroy()
    hotel_name = viewpoint_name.encode('utf-8') + '宾馆'
    data = hotelLocation.hotel(hotel_name)

    for hotel_data in range(shape(data)[0]):
        hotel_name = data[hotel_data]['name'].encode('utf-8')
        hotel_location = data[hotel_data]['location'].encode('utf-8')

        #景点与宾馆的距离
        hotel_view_distance = destina.viewpoint(
            data[hotel_data]['location'].encode('utf-8'), viewpoint_location)

        #hotel_tel = '宾馆电话:' + data[hotel_data]['tel'].encode('utf-8')
        hotel_address = ''.join(data[hotel_data]['address'])
        if len(data[hotel_data]['biz_ext']['rating']):
            hotel_rate = ''.join(data[hotel_data]['biz_ext']['rating'])
            hotelRate = float(
                (data[hotel_data]['biz_ext']['rating']).encode('utf-8')) + 1
        else:
            hotel_rate = '1'
            hotelRate = 1

        if len(data[hotel_data]['biz_ext']['lowest_price']):
            hotel_minprice = (str(
                data[hotel_data]['biz_ext']['lowest_price'])).encode('utf-8')
            #hotelMinPrice = (data[hotel_data]['biz_ext']['lowest_price']).encode('utf-8')
        else:
            hotel_minprice = '无'
            #hotelMinPrice = 30000

        Radiobutton(root,
                    text='最短距离推荐',
                    command=lambda: hotel_distance_recom(
                        data, viewpoint_location)).grid(row=3, column=0)
        Radiobutton(
            root,
            text='最低消费推荐',
            command=lambda: hotel_price_recom(data, viewpoint_location)).grid(
                row=4, column=0)
        Radiobutton(
            root,
            text='最佳评分推荐',
            command=lambda: hotel_rate_recom(data, viewpoint_location)).grid(
                row=5, column=0)
        Radiobutton(
            root,
            text='性价比推荐',
            command=lambda: hotel_best_recom(data, viewpoint_location)).grid(
                row=6, column=0)
        Radiobutton(root,
                    text=[
                        "宾馆名称:" + hotel_name, '宾馆经纬度:' + hotel_location,
                        hotel_address, "宾馆评分:" + hotel_rate.encode("utf-8"),
                        "宾馆最低消费:" + hotel_minprice,
                        '距离:' + str(hotel_view_distance)
                    ],
                    variable=var,
                    value=hotel_data,
                    command=lambda: selHotel(data, viewpoint_location)).grid(
                        row=hotel_data + 2, column=1)