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.11.0.tar.bz2"
|
|
sha256 "79ab8cabf4aa8604d161557b52e3e4d84575acdc0d08cb09ab3f7aaefa4d858a"
|
|
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: "25dce9a65e623bc866fc0fdf21be70d2939f33d8f23abc275932e5f3804470c7"
|
|
sha256 cellar: :any, arm64_big_sur: "4adfc940062c8e534c9596ba2e932fe634e750d2ee53207db14a2949d8af3a4d"
|
|
sha256 cellar: :any, monterey: "f8f1bd048260aa996c233a61f102f80c4eb045e9922a5c7896974f177fb24956"
|
|
sha256 cellar: :any, big_sur: "6b4b5202a09fc1bb7d5a2ed971b15ea3af0f242da4c801d21e654a62b26bb469"
|
|
sha256 cellar: :any, catalina: "cade2a003b9ca0de0c84874967653a4d8cc4fd7e20f19771a8d9badb36122102"
|
|
sha256 cellar: :any_skip_relocation, x86_64_linux: "ff1f6210032d16af3456e9f3734028013688d6134d8920e30a5b16e7363bc842"
|
|
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
|