Package com.spatial4j.core.shape.impl

Examples of com.spatial4j.core.shape.impl.Range


  }

  protected Rectangle computeBoundingBox(Collection<? extends Shape> shapes, SpatialContext ctx) {
    if (shapes.isEmpty())
      return ctx.makeRectangle(Double.NaN, Double.NaN, Double.NaN, Double.NaN);
    Range xRange = null;
    double minY = Double.POSITIVE_INFINITY;
    double maxY = Double.NEGATIVE_INFINITY;
    for (Shape geom : shapes) {
      Rectangle r = geom.getBoundingBox();

      Range xRange2 = Range.xRange(r, ctx);
      if (xRange == null) {
        xRange = xRange2;
      } else {
        xRange = xRange.expandTo(xRange2);
      }
View Full Code Here


    if (geoms.isEmpty())
      return new RectangleImpl(Double.NaN, Double.NaN, Double.NaN, Double.NaN, ctx);
    final Envelope env = geoms.getEnvelopeInternal();//for minY & maxY (simple)
    if (env.getWidth() > 180 && geoms.getNumGeometries() > 1)  {
      // This is ShapeCollection's bbox algorithm
      Range xRange = null;
      for (int i = 0; i < geoms.getNumGeometries(); i++ ) {
        Envelope envI = geoms.getGeometryN(i).getEnvelopeInternal();
        Range xRange2 = new Range.LongitudeRange(envI.getMinX(), envI.getMaxX());
        if (xRange == null) {
          xRange = xRange2;
        } else {
          xRange = xRange.expandTo(xRange2);
        }
View Full Code Here

  protected Rectangle randomRectangle(Point nearP) {
    Rectangle bounds = ctx.getWorldBounds();
    if (nearP == null)
      nearP = randomPointIn(bounds);

    Range xRange = randomRange(rarely() ? 0 : nearP.getX(), Range.xRange(bounds, ctx));
    Range yRange = randomRange(rarely() ? 0 : nearP.getY(), Range.yRange(bounds, ctx));

    return makeNormRect(
        divisible(xRange.getMin()),
        divisible(xRange.getMax()),
        divisible(yRange.getMin()),
        divisible(yRange.getMax()) );
  }
View Full Code Here

  }

  private Range randomRange(double near, Range bounds) {
    double mid = near + randomGaussian() * bounds.getWidth() / 6;
    double width = Math.abs(randomGaussian()) * bounds.getWidth() / 6;//1/3rd
    return new Range(mid - width / 2, mid + width / 2);
  }
View Full Code Here

TOP

Related Classes of com.spatial4j.core.shape.impl.Range

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.