Skip to content

Instantly share code, notes, and snippets.

@bjackson
Last active November 3, 2021 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bjackson/9e4f2caacfae137e46a6b237aecface2 to your computer and use it in GitHub Desktop.
Save bjackson/9e4f2caacfae137e46a6b237aecface2 to your computer and use it in GitHub Desktop.
GeoDjango libs for 2.2
class Gdal < Formula
desc "Geospatial Data Abstraction Library"
homepage "https://www.gdal.org/"
url "https://download.osgeo.org/gdal/2.3.2/gdal-2.3.2.tar.xz"
sha256 "3f6d78fe8807d1d6afb7bed27394f19467840a82bc36d65e66316fa0aa9d32a4"
revision 1
# bottle do
# rebuild 2
# sha256 "1ebee988a01554396a8088744237faa72061fa1b9e0d4c62dcef5106b746eb0b" => :mojave
# sha256 "fcd1ba09e3309176f3a408a83ba0e77dbd5d97930bf7db2c1bbd1efda0d0acfa" => :high_sierra
# sha256 "822726f02695989901e1008c8b9ffb725478c2799835db1d75b0f6dc74a65719" => :sierra
# end
head do
url "https://github.com/OSGeo/gdal.git"
depends_on "doxygen" => :build
end
depends_on "cfitsio"
depends_on "epsilon"
depends_on "expat"
depends_on "freexl"
depends_on "geos"
depends_on "giflib"
depends_on "hdf5"
depends_on "jasper"
depends_on "jpeg"
depends_on "json-c"
depends_on "libdap"
depends_on "libgeotiff"
depends_on "libpng"
depends_on "libpq"
depends_on "libspatialite"
depends_on "libtiff"
depends_on "libxml2"
depends_on "netcdf"
depends_on "numpy"
depends_on "pcre"
depends_on "podofo"
depends_on "poppler"
depends_on "proj"
depends_on "python"
# depends_on "python@2"
depends_on "sqlite" # To ensure compatibility with SpatiaLite
depends_on "unixodbc" # macOS version is not complete enough
depends_on "webp"
depends_on "xerces-c"
depends_on "xz" # get liblzma compression algorithm library from XZutils
depends_on "zstd"
def install
args = [
# Base configuration
"--prefix=#{prefix}",
"--mandir=#{man}",
"--disable-debug",
"--with-libtool",
"--with-local=#{prefix}",
"--with-opencl",
"--with-threads",
# GDAL native backends
# "--with-bsb",
"--with-grib",
"--with-pam",
"--with-pcidsk=internal",
"--with-pcraster=internal",
# Homebrew backends
"--with-curl=/usr/bin/curl-config",
"--with-expat=#{Formula["expat"].prefix}",
"--with-freexl=#{Formula["freexl"].opt_prefix}",
"--with-geos=#{Formula["geos"].opt_prefix}/bin/geos-config",
"--with-geotiff=#{Formula["libgeotiff"].opt_prefix}",
"--with-gif=#{Formula["giflib"].opt_prefix}",
"--with-jpeg=#{Formula["jpeg"].opt_prefix}",
"--with-libjson-c=#{Formula["json-c"].opt_prefix}",
"--with-libtiff=#{Formula["libtiff"].opt_prefix}",
"--with-pg=#{Formula["libpq"].opt_prefix}/bin/pg_config",
"--with-png=#{Formula["libpng"].opt_prefix}",
"--with-spatialite=#{Formula["libspatialite"].opt_prefix}",
"--with-sqlite3=#{Formula["sqlite"].opt_prefix}",
"--with-proj5-api=#{Formula["proj"].opt_prefix}",
"--with-zstd=#{Formula["zstd"].opt_prefix}",
"--with-liblzma=yes",
"--with-cfitsio=/opt/homebrew/opt/cfitsio",
"--with-hdf5=/opt/homebrew/opt/hdf5",
"--with-netcdf=/opt/homebrew/opt/netcdf",
# "--with-jasper=/opt/homebrew/opt/jasper",
"--with-xerces=/opt/homebrew/opt/xerces-c",
"--with-odbc=/opt/homebrew/opt/unixodbc",
# "--with-dods-root=/opt/homebrew/opt",
"--with-epsilon=/opt/homebrew/opt/epsilon",
"--with-webp=/opt/homebrew/opt/webp",
"--with-podofo=/opt/homebrew/opt/podofo",
# Explicitly disable some features
"--with-armadillo=no",
"--with-qhull=no",
"--without-grass",
"--without-jpeg12",
"--without-libgrass",
"--without-mysql",
"--without-perl",
"--without-php",
"--without-python",
"--without-ruby",
"--with-dods-root=no",
"--without-bsb",
"--without-jasper",
# Unsupported backends are either proprietary or have no compatible version
# in Homebrew. Podofo is disabled because Poppler provides the same
# functionality and then some.
"--without-gta",
"--without-ogdi",
"--without-fme",
"--without-hdf4",
"--without-openjpeg",
"--without-fgdb",
"--without-ecw",
"--without-kakadu",
"--without-mrsid",
"--without-jp2mrsid",
"--without-mrsid_lidar",
"--without-msg",
"--without-oci",
"--without-ingres",
"--without-dwgdirect",
"--without-idb",
"--without-sde",
"--without-podofo",
"--without-rasdaman",
"--without-sosi",
]
# Work around "error: no member named 'signbit' in the global namespace"
if DevelopmentTools.clang_build_version >= 900
ENV.delete "SDKROOT"
ENV.delete "HOMEBREW_SDKROOT"
end
system "./configure", *args
system "make"
system "make", "install"
if build.stable? # GDAL 2.3 handles Python differently
cd "swig/python" do
system "python3", *Language::Python.setup_install_args(prefix)
# system "python2", *Language::Python.setup_install_args(prefix)
end
bin.install Dir["swig/python/scripts/*.py"]
end
system "make", "man" if build.head?
# Force man installation dir: https://trac.osgeo.org/gdal/ticket/5092
system "make", "install-man", "INST_MAN=#{man}"
# Clean up any stray doxygen files
Dir.glob("#{bin}/*.dox") { |p| rm p }
end
test do
# basic tests to see if third-party dylibs are loading OK
system "#{bin}/gdalinfo", "--formats"
system "#{bin}/ogrinfo", "--formats"
if build.stable? # GDAL 2.3 handles Python differently
system "python3", "-c", "import gdal"
# system "python2", "-c", "import gdal"
end
end
end
class Geos < Formula
desc "Geometry Engine"
homepage "https://trac.osgeo.org/geos"
url "https://download.osgeo.org/geos/geos-3.7.3.tar.bz2"
sha256 "02035ae4e0ad711fa5a5556d7712530029edacac364b5b9c3ade0ded865fca7e"
# bottle do
# cellar :any
# sha256 "ff40b1f3533d27f19ddc89ef3836f41f816b67bc492b52b592c49fab66f5f701" => :catalina
# sha256 "ef713f51fa1a2bfada35f3cb002ee36dc4289b59487dc79e46a4ad9ce1236bc5" => :mojave
# sha256 "309f427d5560709649390de757980e37dbedc7851f2f0e02d54fbcd2e2678080" => :high_sierra
# end
depends_on "swig" => :build
depends_on "python"
def install
# https://trac.osgeo.org/geos/ticket/771
inreplace "configure" do |s|
s.gsub! /PYTHON_CPPFLAGS=.*/, %Q(PYTHON_CPPFLAGS="#{`python3-config --includes`.strip}")
s.gsub! /PYTHON_LDFLAGS=.*/, 'PYTHON_LDFLAGS="-Wl,-undefined,dynamic_lookup"'
end
system "./configure", "--disable-dependency-tracking",
"--prefix=#{prefix}",
"--enable-python",
"PYTHON=#{Formula["python"].opt_bin}/python3"
system "make", "install"
end
test do
system "#{bin}/geos-config", "--libs"
end
end
class Proj < Formula
desc "Cartographic Projections Library"
homepage "https://proj4.org/"
url "https://download.osgeo.org/proj/proj-5.2.0.tar.gz"
sha256 "ef919499ffbc62a4aae2659a55e2b25ff09cccbbe230656ba71c6224056c7e60"
# bottle do
# sha256 "bead47d7970ed3a59ef4c9567e86cf834fcaf01a1a8b63efeb372b62e2f39b83" => :mojave
# sha256 "80caa7d9b6ffc5cee9c397b8821b834a16b37c05cd0acd0262f825fa95eb8e08" => :high_sierra
# sha256 "1906c694029b8a01fbd912733b3c9ba295f4b8ba9d32d0d3f8f2b549b179d04a" => :sierra
# sha256 "9cbf5a3dfb98c5b5ee82a3e4b8d9d0f927a4d45e514d99a71ca78eb123d5cafe" => :el_capitan
# end
head do
url "https://github.com/OSGeo/proj.4.git"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
end
option "with-vdatum", "Install vertical datum files (~380 MB)"
conflicts_with "blast", :because => "both install a `libproj.a` library"
# The datum grid files are required to support datum shifting
resource "datumgrid" do
url "https://download.osgeo.org/proj/proj-datumgrid-1.8.zip"
sha256 "b9838ae7e5f27ee732fb0bfed618f85b36e8bb56d7afb287d506338e9f33861e"
end
# Vertical datum files
resource "usa_geoid2012b" do
url "https://download.osgeo.org/proj/vdatum/usa_geoid2012b.zip"
sha256 "7a2bddfff18c303853b692830515b86eb46a3e6f81f14d4f193f0e28b1d57aca"
end
resource "usa_geoid2012" do
url "https://download.osgeo.org/proj/vdatum/usa_geoid2012.zip"
sha256 "afe49dc2c405d19a467ec756483944a3c9148e8c1460cb7e82dc8d4a64c4c472"
end
resource "usa_geoid2009" do
url "https://download.osgeo.org/proj/vdatum/usa_geoid2009.zip"
sha256 "1a232fb7fe34d2dad2d48872025597ac7696882755ded1493118a573f60008b1"
end
resource "usa_geoid2003" do
url "https://download.osgeo.org/proj/vdatum/usa_geoid2003.zip"
sha256 "1d15950f46e96e422ebc9202c24aadec221774587b7a4cd963c63f8837421351"
end
resource "usa_geoid1999" do
url "https://download.osgeo.org/proj/vdatum/usa_geoid1999.zip"
sha256 "665cd4dfc991f2517752f9db84d632b56bba31a1ed6a5f0dc397e4b0b3311f36"
end
resource "vertconc" do
url "https://download.osgeo.org/proj/vdatum/vertcon/vertconc.gtx"
sha256 "ecf7bce7bf9e56f6f79a2356d8d6b20b9cb49743701f81db802d979b5a01fcff"
end
resource "vertcone" do
url "https://download.osgeo.org/proj/vdatum/vertcon/vertcone.gtx"
sha256 "f6da1c615c2682ecb7adcfdf22b1d37aba2771c2ea00abe8907acea07413903b"
end
resource "vertconw" do
url "https://download.osgeo.org/proj/vdatum/vertcon/vertconw.gtx"
sha256 "de648c0f6e8b5ebfc4b2d82f056c7b993ca3c37373a7f6b7844fe9bd4871821b"
end
resource "egm08_25" do
url "https://download.osgeo.org/proj/vdatum/egm08_25/egm08_25.gtx"
sha256 "c18f20d1fe88616e3497a3eff993227371e1d9acc76f96253e8d84b475bbe6bf"
end
skip_clean :la
def install
resources.each do |r|
if r.name == "datumgrid"
(buildpath/"nad").install r
elsif build.with? "vdatum"
pkgshare.install r
end
end
system "./autogen.sh" if build.head?
system "./configure", "--disable-dependency-tracking",
"--prefix=#{prefix}"
system "make", "install"
end
test do
(testpath/"test").write <<~EOS
45d15n 71d07w Boston, United States
40d40n 73d58w New York, United States
48d51n 2d20e Paris, France
51d30n 7'w London, England
EOS
match = <<~EOS
-4887590.49\t7317961.48 Boston, United States
-5542524.55\t6982689.05 New York, United States
171224.94\t5415352.81 Paris, France
-8101.66\t5707500.23 London, England
EOS
assert_equal match,
`#{bin}/proj +proj=poly +ellps=clrk66 -r #{testpath}/test`
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment