homebrew-core/Formula/libgeotiff.rb
2018-09-19 11:34:53 +02:00

72 lines
2.2 KiB
Ruby

class Libgeotiff < Formula
desc "Library and tools for dealing with GeoTIFF"
homepage "https://geotiff.osgeo.org/"
url "https://download.osgeo.org/geotiff/libgeotiff/libgeotiff-1.4.2.tar.gz"
sha256 "ad87048adb91167b07f34974a8e53e4ec356494c29f1748de95252e8f81a5e6e"
revision 2
bottle do
sha256 "820d3dff282f570595d0a0f184434e8a4673d17241bb5746e7c2a64434b66a8b" => :mojave
sha256 "5e071647442f998e8239426ee2d9dc7ff2131f02adfdd980b4a702c5316e9c78" => :high_sierra
sha256 "590457da69236c82347ee2037aada01123e835ac2169e9b8b7fe7c944319f31e" => :sierra
sha256 "590aed30a67b41c1ae71c2b4c93e976bdde6fda6d4dbff698481659ac6b6e32a" => :el_capitan
end
head do
url "https://svn.osgeo.org/metacrs/geotiff/trunk/libgeotiff"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
end
depends_on "jpeg"
depends_on "libtiff"
depends_on "proj"
def install
system "./autogen.sh" if build.head?
system "./configure", "--disable-dependency-tracking",
"--prefix=#{prefix}",
"--with-jpeg"
system "make" # Separate steps or install fails
system "make", "install"
end
test do
(testpath/"test.c").write <<~EOS
#include "geotiffio.h"
#include "xtiffio.h"
#include <stdlib.h>
#include <string.h>
int main(int argc, char* argv[])
{
TIFF *tif = XTIFFOpen(argv[1], "w");
GTIF *gtif = GTIFNew(tif);
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, (uint32) 10);
GTIFKeySet(gtif, GeogInvFlatteningGeoKey, TYPE_DOUBLE, 1, (double)123.456);
int i;
char buffer[20L];
memset(buffer,0,(size_t)20L);
for (i=0;i<20L;i++){
TIFFWriteScanline(tif, buffer, i, 0);
}
GTIFWriteKeys(gtif);
GTIFFree(gtif);
XTIFFClose(tif);
return 0;
}
EOS
system ENV.cc, "test.c", "-I#{include}", "-L#{lib}", "-lgeotiff",
"-L#{Formula["libtiff"].opt_lib}", "-ltiff", "-o", "test"
system "./test", "test.tif"
output = shell_output("#{bin}/listgeo test.tif")
assert_match /GeogInvFlatteningGeoKey.*123.456/, output
end
end