Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Geometry type seems to be silently cast to geography #102

Open
kanes115 opened this issue Feb 9, 2021 · 1 comment
Open

Geometry type seems to be silently cast to geography #102

kanes115 opened this issue Feb 9, 2021 · 1 comment

Comments

@kanes115
Copy link

kanes115 commented Feb 9, 2021

Hey, I have the following definitions:

# Model
  schema "places" do
    field :name, :binary
    field :location, Geo.PostGIS.Geometry
  end

  def changeset(struct \\ %__MODULE__{}, attrs) do
    struct
    |> cast(attrs, @fields)
    |> validate_required(@fields)
  end

My migration:

    create table("places") do
      add :name, :binary
      add :location, :geometry
    end

And I try to use it as follows:

    google_maps_srid = 3857
    location = %Geo.Point{coordinates: {50.091211805442974, 19.89650102357312}, srid: google_maps_srid}
    %{name: "name", location: location}
    |> Place.changeset()
    |> Repo.insert()

I get the following error:

(Postgrex.Error) ERROR 22023 (invalid_parameter_value) Only lon/lat coordinate systems are supported in geography.

And insert log:

21:54:17.882 [debug] QUERY ERROR db=38.5ms queue=4.3ms
     INSERT INTO "places" ("location","name") VALUES ($1,$2) RETURNING "id" [%Geo.Point{coordinates: {50.091211805442974, 19.89650102357312}, properties: %{}, srid: 3857}, "Some name"]

It looks like somewhere along the way the geometry type is treated as geography but I fail at understanding where. Any help would be appreciated.

@adampash
Copy link

adampash commented Feb 7, 2023

I'm running into the same bug. @kanes115 did you have any luck figuring this out?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants