65 lines
2.8 KiB
Ruby
65 lines
2.8 KiB
Ruby
class Geos < Formula
|
|
desc "Geometry Engine"
|
|
homepage "https://trac.osgeo.org/geos"
|
|
url "https://download.osgeo.org/geos/geos-3.10.2.tar.bz2"
|
|
sha256 "50bbc599ac386b4c2b3962dcc411f0040a61f204aaef4eba7225ecdd0cf45715"
|
|
license "LGPL-2.1-or-later"
|
|
|
|
livecheck do
|
|
url "https://download.osgeo.org/geos/"
|
|
regex(/href=.*?geos[._-]v?(\d+(?:\.\d+)+)\.t/i)
|
|
end
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_monterey: "428a34a85cedb1ae8e3f36db4d926fb1c5d4897549d11aec14541eeed417d048"
|
|
sha256 cellar: :any, arm64_big_sur: "99d4cefa2243a67dba6ee118fc2255edcf524e039179df567e09de4181031032"
|
|
sha256 cellar: :any, monterey: "1a31f70c0017373e0f8676cfd69ddc3d7bcc3879010e60b0912a6103a4eeebbf"
|
|
sha256 cellar: :any, big_sur: "d5c404e8bed308173d7a6bbc86ea14610b8ac8dd417af97e420964e4649119ce"
|
|
sha256 cellar: :any, catalina: "3e5f0c6bd82f9083f4c91745275b34bf440bef7c90f67cfd1de36cbfda53a487"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "8c24de077aa44a6387c42d9bfedf00082f7244c308ddb9be138e2af54c404bf6"
|
|
end
|
|
|
|
depends_on "cmake" => :build
|
|
|
|
def install
|
|
system "cmake", "-S", ".", "-B", "build", *std_cmake_args, "-DCMAKE_INSTALL_RPATH=#{rpath}"
|
|
system "cmake", "--build", "build"
|
|
system "cmake", "--install", "build"
|
|
system "cmake", "-S", ".", "-B", "static", *std_cmake_args, "-DBUILD_SHARED_LIBS=OFF"
|
|
system "cmake", "--build", "static"
|
|
lib.install Dir["static/lib/*.a"]
|
|
end
|
|
|
|
test do
|
|
(testpath/"test.c").write <<~EOS
|
|
#include <stdio.h>
|
|
#include <stdarg.h>
|
|
#include <geos_c.h>
|
|
static void geos_message_handler(const char* fmt, ...) {
|
|
va_list ap;
|
|
va_start(ap, fmt);
|
|
vprintf (fmt, ap);
|
|
va_end(ap);
|
|
}
|
|
int main() {
|
|
initGEOS(geos_message_handler, geos_message_handler);
|
|
const char* wkt_a = "POLYGON((0 0, 10 0, 10 10, 0 10, 0 0))";
|
|
const char* wkt_b = "POLYGON((5 5, 15 5, 15 15, 5 15, 5 5))";
|
|
GEOSWKTReader* reader = GEOSWKTReader_create();
|
|
GEOSGeometry* geom_a = GEOSWKTReader_read(reader, wkt_a);
|
|
GEOSGeometry* geom_b = GEOSWKTReader_read(reader, wkt_b);
|
|
GEOSGeometry* inter = GEOSIntersection(geom_a, geom_b);
|
|
GEOSWKTWriter* writer = GEOSWKTWriter_create();
|
|
GEOSWKTWriter_setTrim(writer, 1);
|
|
char* wkt_inter = GEOSWKTWriter_write(writer, inter);
|
|
printf("Intersection(A, B): %s\\n", wkt_inter);
|
|
return 0;
|
|
}
|
|
EOS
|
|
cflags = shell_output("#{bin}/geos-config --cflags").split
|
|
libs = shell_output("#{bin}/geos-config --clibs").split
|
|
system ENV.cc, *cflags, "test.c", *libs
|
|
assert_match "POLYGON ((10 10, 10 5, 5 5, 5 10, 10 10))", shell_output("./a.out")
|
|
end
|
|
end
|