Thoughts on updating `ash_geo` to follow current ash extension patterns?

I'm considering using ash_geo, but noticed it doesn't use the same patterns extensions like ash_money for installing postgres extensions and types. I know it's not owned by the ash-project org, but wanted to see what people thing about giving it an overhaul to have a nicer installation experience and follow current extension patterns.
14 Replies
Chaz Watkins
Chaz WatkinsOP•4mo ago
If people think it would be helpful to update it as suggested, I can do it as I don't really want to pull it in with it's current implementation. Mind you I completely understand it was made prior to Ash 3.0. So, not throwing shade on it at all. 🙂 The main thing I'd like to address is the runtime.exs config for adding types to postgrex which feels weird. I'll look into it
kernel
kernel•4mo ago
I use ashgeo in a handful of projects, but only to give me the ash types, everything else I just fallback to using fragments
Chaz Watkins
Chaz WatkinsOP•4mo ago
That’s what I’m considering as well.
kernel
kernel•4mo ago
the macros do work, but I prefer fragments for the most part 🙂
Chaz Watkins
Chaz WatkinsOP•4mo ago
@kernel did you have to do the Postgrex types module in the runtime.exs config per the docs? I noticed when my migrations generated, it was just :geometry type and not more specific to the actual type like point shown in the geo_postgis docs. For example
defmodule Repo.Migrations.AdvancedInit do
use Ecto.Migration

def change do
create table(:test) do
add :name, :string
end
# Add a field `lng_lat_point` with type `geometry(Point,4326)`.
# This can store a "standard GPS" (epsg4326) coordinate pair {longitude,latitude}.
execute("SELECT AddGeometryColumn ('test','lng_lat_point',4326,'POINT',2);", "")

# Once a GIS data table exceeds a few thousand rows, you will want to build an index to speed up spatial searches of the data
# Syntax - CREATE INDEX [indexname] ON [tablename] USING GIST ( [geometryfield] );
execute("CREATE INDEX test_geom_idx ON test USING GIST (lng_lat_point);", "")
end
end
defmodule Repo.Migrations.AdvancedInit do
use Ecto.Migration

def change do
create table(:test) do
add :name, :string
end
# Add a field `lng_lat_point` with type `geometry(Point,4326)`.
# This can store a "standard GPS" (epsg4326) coordinate pair {longitude,latitude}.
execute("SELECT AddGeometryColumn ('test','lng_lat_point',4326,'POINT',2);", "")

# Once a GIS data table exceeds a few thousand rows, you will want to build an index to speed up spatial searches of the data
# Syntax - CREATE INDEX [indexname] ON [tablename] USING GIST ( [geometryfield] );
execute("CREATE INDEX test_geom_idx ON test USING GIST (lng_lat_point);", "")
end
end
ok, looks like the best thing to do is to create new type and specify the storage type
kernel
kernel•4mo ago
yeah I think you still need to do the Postgrex things in general like I had to tweak Postgrex types for the Duration type to work etc I just do it in repo.ex
kernel
kernel•4mo ago
ala
No description
kernel
kernel•4mo ago
I don't think any other Ash types use types that aren't already supported by Postgrex, that's why you generally don't need to do it I remember needing to do it to add range support to postgrex like 10+ years ago, but it seems like they've added range support sometime between now and then 🤣
Chaz Watkins
Chaz WatkinsOP•4mo ago
Cool. Thanks. I’ve been struggling through it since this packages set up is significantly more work than others. Appreciate the help
kernel
kernel•4mo ago
whichever way you go about it, you will still need to add types to postgrex iirc 🙂 https://github.com/elixir-ecto/postgrex as theres no geo stuff in postgrex ash_money doesn't need it for example as it uses a composite type, which postgrex represents as a tuple
Chaz Watkins
Chaz WatkinsOP•4mo ago
Finally got it working. Definitely needs an overhaul to the latest Ash Type patterns. But, at least it works now. 🙂
kernel
kernel•4mo ago
note that geography types don't work OOB and you'd generally use it when you want to do distance measurements in meters etc (on a global scale)
Carl
Carl•2mo ago
Oh I ran into setting this up now and see what you mean 🙄
Chaz Watkins
Chaz WatkinsOP•5w ago
Could be worthwhile for someone to do an igniter installer even if we don’t upgrade it to the latest type patterns.

Did you find this page helpful?