AshGeo.Geometry (AshGeo v0.2.0)

Base geometry type

To create a constrained geometry type, use AshGeo.Geometry accepts several options that may be useful. Options provided to use define constraints that are applied statically to a new type instance, and may be further added or overridden using :constraints on instances of that type, with the exception of :storage_type.

Example

defmodule App.Type.Point26918 do
  use AshGeo.Geometry,
    storage_type: :"geometry(Point,26918)",
    geo_types: :point
end

defmodule App.Resource.PointOfInterest do
  alias App.Type.Point26918

  attributes do
    attribute :name, :string
    attribute :location, Point26918, allow_nil?: false
  end

  actions do
    create :create do
      argument :location, Point26918 do
        allow_nil? false
        constraits: [force_srid: 26918]
      end

      change set_attribute(:location, arg(:location))
    end
  end
end

Options

  • :storage_type (atom/0) - Column type in the database
    May NOT be overridden using :constraints.

    Examples

      use AshGeo.Geometry, storage_type: :"geometry(Point,26918)"
  • :geo_types - Allowed Geo types

    Examples

      use AshGeo.Geometry, geo_types: :point
      use AshGeo.Geometry, geo_types: [:point, :point_z, :point_zm]
      use AshGeo.Geometry, geo_types: [:point, Geo.PointZ, :point_zm]

    See also

  • :force_srid (integer/0) - SRID to force on the geometry

    Examples

      use AshGeo.Geometry, force_srid: 4326
  • :check_srid (integer/0) - SRID to check on the geometry

    Examples

      use AshGeo.Geometry, check_srid: 4326