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

GeoJSON default SRID not set #129

Closed
gworkman opened this issue Apr 28, 2020 · 1 comment · Fixed by #219
Closed

GeoJSON default SRID not set #129

gworkman opened this issue Apr 28, 2020 · 1 comment · Fixed by #219

Comments

@gworkman
Copy link

gworkman commented Apr 28, 2020

It seems that the SRID of a geometry parsed from geojson is not set to the default of 4326, as defined by the spec. I've run into this issue because I am parsing a geojson object and performing a query with it using the great geo_postgis lib. However, when the database's column SRID is 4326, I get an error that it cannot compare the two geometries because the SRIDs are different (the parsed geojson geometry has an SRID of 0).

As a temporary solution, I changed the SRID of the column to 0 in the database, which is clearly not ideal.

I'm more than happy to write up a merge request for this issue, if this should be the desired behavior. Just point me in the right direction!

EDIT: add versions

➜ elixir --version
Erlang/OTP 22 [erts-10.7.1] [source] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1] [hipe] [dtrace]

Elixir 1.10.2 (compiled with Erlang/OTP 22)
  defp deps do
    [
      {:ecto_sql, "~> 3.1"},
      {:postgrex, ">= 0.0.0"},
      {:jason, "~> 1.0"},
      ...
      {:geo_postgis, "~>3.3.0"}
    ]
  end
@bitboxer
Copy link

I solved this by setting the srid manually after decoding:

Map.put(Geo.JSON.decode!(item, :srid, 4326)

s3cur3 added a commit that referenced this issue Aug 31, 2024
The GeoJSON spec [indicates](https://tools.ietf.org/html/rfc7946#section-4) that all GeoJSON should be assumed to use the WGS 84 datum by default. We should be permissive and allow overriding that datum (as we did previously), but I think the correct behavior here is to make the datum explicit in our decoded `Geo.Geometry.t()` values.

This is a breaking change, but one which I expect to have quite little impact on users. (See the CHANGELOG.md for more.)

Resolves #129
s3cur3 added a commit that referenced this issue Sep 17, 2024
The GeoJSON spec [indicates](https://tools.ietf.org/html/rfc7946#section-4) that all GeoJSON should be assumed to use the WGS 84 datum by default. We should be permissive and allow overriding that datum (as we did previously), but I think the correct behavior here is to make the datum explicit in our decoded `Geo.Geometry.t()` values.

This is a breaking change, but one which I expect to have quite little impact on users. (See the CHANGELOG.md for more.)

Resolves #129
@s3cur3 s3cur3 closed this as completed in 44ee1de Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging a pull request may close this issue.

2 participants