使用pgx从Postgres扫描PostGIS Point时,接口{}是字符串,而不是[] uint8

问题描述

我有一个带有buildings表的数据库,该表包含类型为coordinate的{​​{1}}列。为了阅读坐标,我编写了以下代码

GEOMETRY(POINT,4326)

然后,我收到以下错误

    rows,err := db.pool.Query(context.Background(),`select "uuid","coordinate" from "building"`)
    defer rows.Close()

    for rows.Next() {
        var uuid pgtype.UUID
        var coordinate postgis.Point
        err := rows.Scan(&uuid,&coordinate)
        if err != nil {
            return err
        }
        log.Println("~~~",coordinate.X,coordinate.Y)
    }

先谢谢您。任何建议都会有所帮助。

解决方法

01234567
acbbaacc  k = 2

0 a  heap: (0 a)

1 c  heap: (1 c) <- (0 a)

2 b  heap: (2 b) <- (1 c) <- (0 a)

3 b  kth instance,remove (2 b)
     heap: (1 c) <- (0 a)
     leftmost instance of b is to the
     right of the heap root.
     check root + 1 = 2,which points
     to a new valid substring,add the
     substring to the queue
     queue: (2,3)
     result: 1 + 0 = 1
     
4 a  kth instance,remove (0 a)
     heap: (1 c)
     queue: (2,3)
     result: 1
     leftmost instance of a is left
     of the heap root so continue
     
5 a  (k+1)th instance,move left border
     of the window to index 1
     heap: (1 c)
     queue: (2,3)
     result: 1
     
     (5 a) is now the kth instance of
     a and its leftmost instance is to
     the right of the heap root.
     check root + 1 = 2,which points
     to a valid substring in the queue,add new substring to queue
     heap: (1 c)
     queue: (2,3) -> (4,5)
     result: 1 + 1 + 1 = 3
     
6 c  kth instance,remove (1 c)
     heap: empty
     add new substring to queue
     queue: (1) -> (2,5) -> (6)
     (for simplicity,the queue here
     is not labeled; labels may be needed
     for the split intervals)
     result: 3 + 1 + 0 = 4
     
7 c  (k+1)th instance,move left border
     of the window to index 2,update queue
     heap: empty
     queue: (2,5)
     result: 4
     
     (7 c) is now the kth instance of c
     heap: empty
     add new substring to queue
     queue: (2,5) -> (6,7)
     result: 4 + 1 + 2 = 7