fix detection when JTS / spatial4j are not available

This commit is contained in:
Shay Banon 2012-09-28 22:29:08 +02:00
parent 7d6c567e6f
commit 5bf566660b
1 changed files with 3 additions and 4 deletions

View File

@ -19,8 +19,7 @@
package org.elasticsearch.common.geo; package org.elasticsearch.common.geo;
import com.spatial4j.core.shape.impl.PointImpl; import org.elasticsearch.common.Classes;
import com.vividsolutions.jts.geom.GeometryFactory;
/** /**
*/ */
@ -32,7 +31,7 @@ public class ShapesAvailability {
static { static {
boolean xSPATIAL4J_AVAILABLE; boolean xSPATIAL4J_AVAILABLE;
try { try {
new PointImpl(0, 0, GeoShapeConstants.SPATIAL_CONTEXT); Classes.getDefaultClassLoader().loadClass("com.spatial4j.core.shape.impl.PointImpl");
xSPATIAL4J_AVAILABLE = true; xSPATIAL4J_AVAILABLE = true;
} catch (Throwable t) { } catch (Throwable t) {
xSPATIAL4J_AVAILABLE = false; xSPATIAL4J_AVAILABLE = false;
@ -41,7 +40,7 @@ public class ShapesAvailability {
boolean xJTS_AVAILABLE; boolean xJTS_AVAILABLE;
try { try {
new GeometryFactory(); Classes.getDefaultClassLoader().loadClass("com.vividsolutions.jts.geom.GeometryFactory");
xJTS_AVAILABLE = true; xJTS_AVAILABLE = true;
} catch (Throwable t) { } catch (Throwable t) {
xJTS_AVAILABLE = false; xJTS_AVAILABLE = false;