5 ms·
> Can I measure the distance between two given points? Make sure you have the earthdistance module enabled: CREATE EXTENSION IF NOT EXISTS earthdistance CASCADE
by jsiepkes 7y ago
> Can I measure the distance between two given points? Make sure you have the earthdistance module enabled: CREATE EXTENSION IF NOT EXISTS earthdistance CASCADE (cascade pulls in requirements, which are just the cube module). Then use the eponymous earth_distance function; note that it doesn’t take coordinates directly, but its own type, which you convert to with ll_to_earth(lat, long).
Maybe I'm missing the point but I don't really see how that is easier then using "CREATE EXTENSION postgis;" and "ST_Distance" ?
- derefr 7y ago`CREATE EXTENSION postgis` implies that you have PostGIS installed. PostGIS is about five times the size of Postgres itself, and has about twenty requirements, some of which have their own heavy trees of recursive requirements, some of which are near-impossible to build in certain environments (e.g. macOS Homebrew) without weird finessing. The (alpine!) Docker image of a PostGIS-enabled Postgres is 713MB. That's a lot of extra binary if you just need to record some points! And the real problem with all that isn't the size/deps themselves, but rather the fact that the size/deps will probably lead to you wanting to use a binary distribution (or pre-made Docker image) of PostGIS rather than treating PostGIS as any other Postgres extension installed against a regular running Postgres cluster. Which then means that you'll need to find/settle for the set of extensions that are packaged for that binary distribution, rather than just using the standard set of extensions that come with a standard Postgres distribution (e.g. the PGDG Postgres apt repo, which contains many individually-packaged extensions.)
- Doctor_Fegg 7y agoPostgres.app comes with PostGIS plus GDAL etc. There’s no good reason to use Homebrew Postgres over Postgres.app.
- leblancfg 7y agoUnless you're referring to something else, the official [Alpine PostGIS docker image is 151MB](https://hub.docker.com/layers/postgis/postgis/9.5-2.5-alpine/images/sha256-d02f60373f803dd58b0e6460be7c54f482c8088664808ba7ea168da0e6167be9?context=explore https://hub.docker.com/layers/postgis/postgis/9.5-2.5-alpine...), and you can find minimal images around 35MB. These images contain geometry engine binaries like GEOS, which you will likely need if you want to perform operations other than `distance` at decent speeds.
- ris 7y agoI think the bigger issue is whether your production database platform supports PostGIS. If you don't have C extension privileges over your production database, you're going to have to start convincing some admins to do you a favour. (These days, it's actually quite a common request though and it's generally one of the first extensions most e.g. cloud offerings support)