云
发布于

如何找到从 MySQL 返回的匹配坐标,坐标是二进制形式的?

因为latitude 值不正确而无法正常工作的代码是

  
conn = pymysql.connect(
    host=endpoint,
    user=username,
    password=password,
    port=port,
    database=database
)

cursor = conn.cursor()

query = """
SELECT uuid, ERASEnabled, useractivity
FROM algoData
WHERE gender = %s
AND dob BETWEEN %s AND %s
AND ST_Distance_Sphere(location, ST_PointFromText(%s)) / 1609.34 <= %s
LIMIT %s;
"""

limit = 5000

parameters = (
    lookingFor,
    min_date_string,
    max_date_string,
    formattedCoordinatesForSQLUse,
    maxDistance,
    limit,
)

用于检索所有二进制位置点的代码是

  
conn = pymysql.connect(
        host=endpoint,
        user=username,
        password=password,
        port=port,
        database=database
    )

    cursor = conn.cursor()


    read_command = """
        SELECT *
        FROM algoData
    """

    cursor.execute(read_command)
    results = cursor.fetchall()
    
    uuids = [result[0] for result in results]
    locationPoints = [result[3] for result in results]
    locationPoints = [str(point) for point in locationPoints]

列描述为 ('location', 'point', 'NO', 'MUL', None, '')

浏览 (38)
点赞
收藏
1条评论
Klustron小助手
通过从 DB 中单独获取 X 和 Y 坐标来解决这个问题,而不是以二进制形式获取整个位置 对于 MySQL 中,类似于 查询 = “”” SELECT ST_X(location), ST_Y(location) 从 your_table; &#34;&#34;&#34; 其中 location 是您的点数据类型列
点赞
评论