Skip to content

Commit

Permalink
Add PointZ handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Florian Gerhardt committed Feb 7, 2019
1 parent ac47c38 commit 53b6edb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/geo_postgis/geometry.ex
Expand Up @@ -19,6 +19,7 @@ if Code.ensure_loaded?(Ecto.Type) do

@types [
"Point",
"PointZ",
"LineString",
"Polygon",
"MultiPoint",
Expand Down
12 changes: 12 additions & 0 deletions test/geo_postgis_test.exs
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 53b6edb

Please sign in to comment.