Skip to content

Error when inserting PostGISPoint as byte array #8

@antonsergeyev

Description

@antonsergeyev

I have a table with geometry(point,4326) column. When trying to insert a record using a PostGISPoint type, postgres gives the following error:

ERROR: parse error - invalid geometry at character ...
HINT: "\x" <-- parse error at position 2 within geometry
STATEMENT: INSERT INTO "devices" ("geolocation") VALUES ('\x535249443d343332363b504f494e542833372e3431333332333530202d3132322e303831323637303029')

After some search, I discovered that if I don't convert a point value to byte array, it works fine (postgis.go, line 21):

// this
return fmt.Sprintf("SRID=4326;POINT(%.8f %.8f)", p.Lon, p.Lat), nil
// instead of this
return []byte(fmt.Sprintf("SRID=4326;POINT(%.8f %.8f)", p.Lon, p.Lat)), nil

Maybe I don't understand completely how postgis works. So can you please clarify why conversion to byte array is needed and how do I make it work without modifying your library?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions