Skip to content

Commit

Permalink
Merge pull request #25 from FlorianGerhardt/master
Browse files Browse the repository at this point in the history
Add PointZ handling
  • Loading branch information
bryanjos authored Feb 11, 2019
2 parents 40d2927 + d09cf91 commit f77011f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/geo_postgis/geometry.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ if Code.ensure_loaded?(Ecto.Type) do

@types [
"Point",
"PointZ",
"LineString",
"Polygon",
"MultiPoint",
Expand Down
2 changes: 1 addition & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ defmodule GeoPostgis.Mixfile do

defp deps do
[
{:geo, "~> 3.0"},
{:geo, "~> 3.1"},
{:postgrex, "~> 0.14"},
{:ex_doc, "~> 0.19.1", only: :dev},
{:ecto_sql, "~> 3.0", optional: true, only: :test},
Expand Down
12 changes: 12 additions & 0 deletions test/geo_postgis_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,18 @@ defmodule Geo.PostGIS.Test do
assert(result.rows == [[42, "test", geo]])
end

test "insert pointz", context do
pid = context[:pid]
geo = %Geo.PointZ{coordinates: {30, -90, 70}, srid: 4326}

{:ok, _} =
Postgrex.query(pid, "CREATE TABLE point_test (id int, geom geometry(PointZ, 4326))", [])

{:ok, _} = Postgrex.query(pid, "INSERT INTO point_test VALUES ($1, $2)", [42, geo])
{:ok, result} = Postgrex.query(pid, "SELECT * FROM point_test", [])
assert(result.rows == [[42, geo]])
end

test "insert linestring", context do
pid = context[:pid]
geo = %Geo.LineString{srid: 4326, coordinates: [{30, 10}, {10, 30}, {40, 40}]}
Expand Down

0 comments on commit f77011f

Please sign in to comment.