当前位置: 首页>>代码示例>>Java>>正文


Java Rectangle.getMinY方法代码示例

本文整理汇总了Java中com.spatial4j.core.shape.Rectangle.getMinY方法的典型用法代码示例。如果您正苦于以下问题:Java Rectangle.getMinY方法的具体用法?Java Rectangle.getMinY怎么用?Java Rectangle.getMinY使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.spatial4j.core.shape.Rectangle的用法示例。


在下文中一共展示了Rectangle.getMinY方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: calcDistanceFromErrPct

import com.spatial4j.core.shape.Rectangle; //导入方法依赖的package包/类
/**
 * Computes the distance given a shape and the {@code distErrPct}.  The
 * algorithm is the fraction of the distance from the center of the query
 * shape to its closest bounding box corner.
 *
 * @param shape Mandatory.
 * @param distErrPct 0 to 0.5
 * @param ctx Mandatory
 * @return A distance (in degrees).
 */
public static double calcDistanceFromErrPct(Shape shape, double distErrPct, SpatialContext ctx) {
  if (distErrPct < 0 || distErrPct > 0.5) {
    throw new IllegalArgumentException("distErrPct " + distErrPct + " must be between [0 to 0.5]");
  }
  if (distErrPct == 0 || shape instanceof Point) {
    return 0;
  }
  Rectangle bbox = shape.getBoundingBox();
  //Compute the distance from the center to a corner.  Because the distance
  // to a bottom corner vs a top corner can vary in a geospatial scenario,
  // take the closest one (greater precision).
  Point ctr = bbox.getCenter();
  double y = (ctr.getY() >= 0 ? bbox.getMaxY() : bbox.getMinY());
  double diagonalDist = ctx.getDistCalc().distance(ctr, bbox.getMaxX(), y);
  return diagonalDist * distErrPct;
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:SpatialArgs.java

示例2: getQuery

import com.spatial4j.core.shape.Rectangle; //导入方法依赖的package包/类
private Query getQuery(Function inner, Context context) {
    RefLiteralPair innerPair = new RefLiteralPair(inner);
    if (!innerPair.isValid()) {
        return null;
    }
    if (innerPair.reference().valueType().equals(DataTypes.GEO_SHAPE)) {
        // we have within('POINT(0 0)', shape_column)
        return genericFunctionFilter(inner, context);
    }
    GeoPointFieldMapper.GeoPointFieldType geoPointFieldType = getGeoPointFieldType(
            innerPair.reference().ident().columnIdent().fqn(),
            context.mapperService);

    Map<String, Object> geoJSON = (Map<String, Object>) innerPair.input().value();
    Shape shape = GeoJSONUtils.map2Shape(geoJSON);
    Geometry geometry = JtsSpatialContext.GEO.getGeometryFrom(shape);
    IndexGeoPointFieldData fieldData = context.fieldDataService.getForField(geoPointFieldType);
    if (geometry.isRectangle()) {
        Rectangle boundingBox = shape.getBoundingBox();
        return new InMemoryGeoBoundingBoxQuery(
                new GeoPoint(boundingBox.getMaxY(), boundingBox.getMinX()),
                new GeoPoint(boundingBox.getMinY(), boundingBox.getMaxX()),
                fieldData
        );
    } else {
        Coordinate[] coordinates = geometry.getCoordinates();
        GeoPoint[] points = new GeoPoint[coordinates.length];
        for (int i = 0; i < coordinates.length; i++) {
            Coordinate coordinate = coordinates[i];
            points[i] = new GeoPoint(coordinate.y, coordinate.x);
        }
        return new GeoPolygonQuery(fieldData, points);
    }
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:35,代码来源:LuceneQueryBuilder.java

示例3: QuadPrefixTree

import com.spatial4j.core.shape.Rectangle; //导入方法依赖的package包/类
public QuadPrefixTree(
    SpatialContext ctx, Rectangle bounds, int maxLevels) {
  super(ctx, maxLevels);
  this.xmin = bounds.getMinX();
  this.xmax = bounds.getMaxX();
  this.ymin = bounds.getMinY();
  this.ymax = bounds.getMaxY();

  levelW = new double[maxLevels];
  levelH = new double[maxLevels];
  levelS = new int[maxLevels];
  levelN = new int[maxLevels];

  gridW = xmax - xmin;
  gridH = ymax - ymin;
  this.xmid = xmin + gridW/2.0;
  this.ymid = ymin + gridH/2.0;
  levelW[0] = gridW/2.0;
  levelH[0] = gridH/2.0;
  levelS[0] = 2;
  levelN[0] = 4;

  for (int i = 1; i < levelW.length; i++) {
    levelW[i] = levelW[i - 1] / 2.0;
    levelH[i] = levelH[i - 1] / 2.0;
    levelS[i] = levelS[i - 1] * 2;
    levelN[i] = levelN[i - 1] * 4;
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:30,代码来源:QuadPrefixTree.java

示例4: createIndexableFields

import com.spatial4j.core.shape.Rectangle; //导入方法依赖的package包/类
public Field[] createIndexableFields(Rectangle bbox) {
  Field[] fields = new Field[5];
  fields[0] = new ComboField(field_minX, bbox.getMinX(), fieldType);
  fields[1] = new ComboField(field_maxX, bbox.getMaxX(), fieldType);
  fields[2] = new ComboField(field_minY, bbox.getMinY(), fieldType);
  fields[3] = new ComboField(field_maxY, bbox.getMaxY(), fieldType);
  fields[4] = new ComboField(field_xdl, bbox.getCrossesDateLine()?"T":"F", xdlFieldType);
  return fields;
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:BBoxStrategy.java

示例5: bufferShape

import com.spatial4j.core.shape.Rectangle; //导入方法依赖的package包/类
/** Returns a new shape that is larger than shape by at distErr.
 */
//TODO move this generic code elsewhere?  Spatial4j?
protected Shape bufferShape(Shape shape, double distErr) {
  if (distErr <= 0)
    throw new IllegalArgumentException("distErr must be > 0");
  SpatialContext ctx = grid.getSpatialContext();
  if (shape instanceof Point) {
    return ctx.makeCircle((Point)shape, distErr);
  } else if (shape instanceof Circle) {
    Circle circle = (Circle) shape;
    double newDist = circle.getRadius() + distErr;
    if (ctx.isGeo() && newDist > 180)
      newDist = 180;
    return ctx.makeCircle(circle.getCenter(), newDist);
  } else {
    Rectangle bbox = shape.getBoundingBox();
    double newMinX = bbox.getMinX() - distErr;
    double newMaxX = bbox.getMaxX() + distErr;
    double newMinY = bbox.getMinY() - distErr;
    double newMaxY = bbox.getMaxY() + distErr;
    if (ctx.isGeo()) {
      if (newMinY < -90)
        newMinY = -90;
      if (newMaxY > 90)
        newMaxY = 90;
      if (newMinY == -90 || newMaxY == 90 || bbox.getWidth() + 2*distErr > 360) {
        newMinX = -180;
        newMaxX = 180;
      } else {
        newMinX = DistanceUtils.normLonDEG(newMinX);
        newMaxX = DistanceUtils.normLonDEG(newMaxX);
      }
    } else {
      //restrict to world bounds
      newMinX = Math.max(newMinX, ctx.getWorldBounds().getMinX());
      newMaxX = Math.min(newMaxX, ctx.getWorldBounds().getMaxX());
      newMinY = Math.max(newMinY, ctx.getWorldBounds().getMinY());
      newMaxY = Math.min(newMaxY, ctx.getWorldBounds().getMaxY());
    }
    return ctx.makeRectangle(newMinX, newMaxX, newMinY, newMaxY);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:44,代码来源:WithinPrefixTreeFilter.java

示例6: checkHits

import com.spatial4j.core.shape.Rectangle; //导入方法依赖的package包/类
private void checkHits(String fieldName, boolean exact, String ptStr, double distKM, int count, int ... docIds) throws ParseException {
  if (exact && fieldName.equalsIgnoreCase("bbox")) {
    return; // bbox field only supports rectangular query
  }
  String [] tests = new String[docIds != null && docIds.length > 0 ? docIds.length + 1 : 1];
  //test for presence of required ids first
  int i = 0;
  if (docIds != null && docIds.length > 0) {
    for (int docId : docIds) {
      tests[i++] = "//result/doc/*[@name='id'][.='" + docId + "']";
    }
  }
  //check total length last; maybe response includes ids it shouldn't.  Nicer to check this last instead of first so
  // that there may be a more specific detailed id to investigate.
  tests[i++] = "*[count(//doc)=" + count + "]";

  //Test using the Lucene spatial syntax
  {
    //never actually need the score but lets test
    String score = new String[]{null, "none","distance","recipDistance"}[random().nextInt(4)];

    double distDEG = DistanceUtils.dist2Degrees(distKM, DistanceUtils.EARTH_MEAN_RADIUS_KM);
    Point point = SpatialUtils.parsePoint(ptStr, SpatialContext.GEO);
    String circleStr = "BUFFER(POINT(" + point.getX()+" "+point.getY()+")," + distDEG + ")";
    String shapeStr;
    if (exact) {
      shapeStr = circleStr;
    } else {//bbox
      //the GEO is an assumption
      SpatialContext ctx = SpatialContext.GEO;
      Rectangle bbox = ctx.readShapeFromWkt(circleStr).getBoundingBox();
      shapeStr = "ENVELOPE(" + bbox.getMinX() + ", " + bbox.getMaxX() +
          ", " + bbox.getMaxY() + ", " + bbox.getMinY() + ")";
    }

    //FYI default distErrPct=0.025 works with the tests in this file
    assertQ(req(
          "fl", "id", "q","*:*", "rows", "1000",
          "fq", "{!field f=" + fieldName + (score==null?"":" score="+score)
            + "}Intersects(" + shapeStr + ")"),
        tests);
  }
  //Test using geofilt
  {
    assertQ(req(
        "fl", "id", "q", "*:*", "rows", "1000",
        "fq", "{!" + (exact ? "geofilt" : "bbox") + " sfield=" + fieldName + " pt='" + ptStr + "' d=" + distKM + "}"),
        tests);
  }

}
 
开发者ID:europeana,项目名称:search,代码行数:52,代码来源:TestSolr4Spatial.java


注:本文中的com.spatial4j.core.shape.Rectangle.getMinY方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。