diff --git a/lib/geo_postgis/extension.ex b/lib/geo_postgis/extension.ex index 8a5826d..bc9c2d5 100644 --- a/lib/geo_postgis/extension.ex +++ b/lib/geo_postgis/extension.ex @@ -44,6 +44,7 @@ defmodule Geo.PostGIS.Extension do Geo.GeometryCollection, Geo.LineString, Geo.LineStringZ, + Geo.LineStringZM, Geo.MultiLineString, Geo.MultiLineStringZ, Geo.MultiPoint, diff --git a/lib/geo_postgis/geometry.ex b/lib/geo_postgis/geometry.ex index a35197c..a762b98 100644 --- a/lib/geo_postgis/geometry.ex +++ b/lib/geo_postgis/geometry.ex @@ -11,6 +11,7 @@ if Code.ensure_loaded?(Ecto.Type) do PointZM, LineString, LineStringZ, + LineStringZM, Polygon, PolygonZ, MultiPoint, @@ -29,6 +30,7 @@ if Code.ensure_loaded?(Ecto.Type) do "PointZM", "LineString", "LineStringZ", + "LineStringZM", "Polygon", "PolygonZ", "MultiPoint", @@ -46,6 +48,7 @@ if Code.ensure_loaded?(Ecto.Type) do PointZM, LineString, LineStringZ, + LineStringZM, Polygon, PolygonZ, MultiPoint, diff --git a/test/geo_postgis_test.exs b/test/geo_postgis_test.exs index 70faa76..93628fb 100644 --- a/test/geo_postgis_test.exs +++ b/test/geo_postgis_test.exs @@ -7,7 +7,7 @@ defmodule Geo.PostGIS.Test do {:ok, _result} = Postgrex.query( pid, - "DROP TABLE IF EXISTS text_test, point_test, linestring_test, polygon_test, multipoint_test, multilinestring_test, multipolygon_test, geometrycollection_test", + "DROP TABLE IF EXISTS text_test, point_test, linestring_test, linestringz_test, linestringzm_test, polygon_test, multipoint_test, multilinestring_test, multipolygon_test, geometrycollection_test", [] ) @@ -76,6 +76,42 @@ defmodule Geo.PostGIS.Test do assert(result.rows == [[42, geo]]) end + test "insert LineStringZ", context do + pid = context[:pid] + geo = %Geo.LineStringZ{srid: 4326, coordinates: [{30, 10, 20}, {10, 30, 2}, {40, 40, 50}]} + + {:ok, _} = + Postgrex.query( + pid, + "CREATE TABLE linestringz_test (id int, geom geometry(LineStringZ, 4326))", + [] + ) + + {:ok, _} = Postgrex.query(pid, "INSERT INTO linestringz_test VALUES ($1, $2)", [42, geo]) + {:ok, result} = Postgrex.query(pid, "SELECT * FROM linestringz_test", []) + assert result.rows == [[42, geo]] + end + + test "insert LineStringZM", context do + pid = context[:pid] + + geo = %Geo.LineStringZM{ + srid: 4326, + coordinates: [{30, 10, 20, 40}, {10, 30, 2, -10}, {40, 40, 50, 100}] + } + + {:ok, _} = + Postgrex.query( + pid, + "CREATE TABLE linestringzm_test (id int, geom geometry(LineStringZM, 4326))", + [] + ) + + {:ok, _} = Postgrex.query(pid, "INSERT INTO linestringzm_test VALUES ($1, $2)", [42, geo]) + {:ok, result} = Postgrex.query(pid, "SELECT * FROM linestringzm_test", []) + assert result.rows == [[42, geo]] + end + test "insert polygon", context do pid = context[:pid]