GeoGson tooling
[gpl/argeo-suite.git] / org.argeo.app.geo / src / org / argeo / app / geo / JTS.java
diff --git a/org.argeo.app.geo/src/org/argeo/app/geo/JTS.java b/org.argeo.app.geo/src/org/argeo/app/geo/JTS.java
new file mode 100644 (file)
index 0000000..2623712
--- /dev/null
@@ -0,0 +1,27 @@
+package org.argeo.app.geo;
+
+import org.argeo.api.cms.CmsLog;
+import org.locationtech.jts.geom.GeometryFactory;
+
+/**
+ * Factories initialisation and workarounds for the JTS library. The idea is to
+ * code defensively around factory initialisation, API changes, and issues
+ * related to running in an OSGi environment. Rather see {@link GeoUtils} for
+ * functional static utilities.
+ */
+public class JTS {
+       private final static CmsLog log = CmsLog.getLog(JTS.class);
+
+       public final static GeometryFactory GEOMETRY_FACTORY;
+
+       static {
+               try {
+                       // GEOMETRY_FACTORY = JTSFactoryFinder.getGeometryFactory();
+                       GEOMETRY_FACTORY = new GeometryFactory();
+               } catch (RuntimeException e) {
+                       log.error("Basic JTS initialisation failed, geographical utilities are probably not available", e);
+                       throw e;
+               }
+       }
+
+}