示例#1
0
 @Override
 public void registerClasses(@Nonnull Kryo kryo) {
   kryo.register(Object[].class);
   kryo.register(scala.Tuple2[].class);
   kryo.register(String.class);
   kryo.register(SpatialFilter.class);
   kryo.register(PointImpl.class);
   kryo.register(Shape.class);
   kryo.register(SpatialRelation.class);
   kryo.register(SpatialContext.class);
   kryo.register(SpatialContext.GEO.getClass());
   doRegistration(kryo, "scala.collection.mutable.WrappedArray$ofRef");
 }
  /**
   * Spatial4J shapes have no knowledge of directed edges. For this reason, a bounding box that
   * wraps the dateline can have a min longitude that is mathematically > than the Rectangles'
   * minX value. This is an issue for geometric collections (e.g., MultiPolygon and ShapeCollection)
   * Until geometry logic can be cleaned up in Spatial4J, ES provides the following expansion
   * algorithm for GeometryCollections
   */
  private Rectangle expandBBox(Rectangle bbox, Rectangle expand) {
    if (bbox.equals(expand) || bbox.equals(SpatialContext.GEO.getWorldBounds())) {
      return bbox;
    }

    double minX = bbox.getMinX();
    double eMinX = expand.getMinX();
    double maxX = bbox.getMaxX();
    double eMaxX = expand.getMaxX();
    double minY = bbox.getMinY();
    double eMinY = expand.getMinY();
    double maxY = bbox.getMaxY();
    double eMaxY = expand.getMaxY();

    bbox.reset(
        Math.min(Math.min(minX, maxX), Math.min(eMinX, eMaxX)),
        Math.max(Math.max(minX, maxX), Math.max(eMinX, eMaxX)),
        Math.min(Math.min(minY, maxY), Math.min(eMinY, eMaxY)),
        Math.max(Math.max(minY, maxY), Math.max(eMinY, eMaxY)));

    return bbox;
  }
示例#3
0
 @Test
 public void testParseVsInvalidExceptions() throws Exception {
   testParseVsInvalidExceptions(SpatialContext.GEO.getWktShapeParser());
   testParseVsInvalidExceptions(JtsSpatialContext.GEO.getWktShapeParser());
 }