sfackler / rust-postgres

Native PostgreSQL driver for the Rust programming language
Apache License 2.0
3.43k stars 436 forks source link

How to get geo point (`GEOMETRY(Point, 4326)`) ? #1174

Closed nurmohammed840 closed 2 weeks ago

nurmohammed840 commented 2 weeks ago

My schema look like this:

CREATE TABLE IF NOT EXISTS "Post" (
    post_location GEOMETRY(Point, 4326) NOT NULL, -- Geographic coordinate system
    ...
);
let _:  geo_types::Point<f64> = row.try_get("post_location")?;
    Error {
        kind: FromSql(1),
        cause: Some(
            WrongType {
                postgres: Other(
                    Other {
                        name: "geometry",
                        oid: 17566,
                        kind: Simple,
                        schema: "public",
                    },
                ),
                rust: "geo_types::geometry::point::Point",
            },
        ),
    }

How do i get this value?

nurmohammed840 commented 2 weeks ago

I guess you need to convert GEOMETRY into Point in SELECT expr