Package com.spatial4j.core.shape

Examples of com.spatial4j.core.shape.Shape


      return null;
    //shape types must start with a letter
    if (!Character.isLetter(state.rawString.charAt(state.offset)))
      return null;
    String shapeType = state.nextWord();
    Shape result = null;
    try {
      result = parseShapeByType(state, shapeType);
    } catch (ParseException e) {
      throw e;
    } catch (Exception e) {//most likely InvalidShapeException
View Full Code Here


   * </pre>
   * Whereas 'number' is the distance to buffer the shape by.
   */
  protected Shape parseBufferShape(State state) throws ParseException {
    state.nextExpect('(');
    Shape shape = shape(state);
    state.nextExpect(',');
    double distance = normDist(state.nextDouble());
    state.nextExpect(')');
    return shape.getBuffered(distance, ctx);
  }
View Full Code Here

  /** Reads a shape from the current position, starting with the name of the shape. It
   * calls {@link #parseShapeByType(com.spatial4j.core.io.WktShapeParser.State, String)}
   * and throws an exception if the shape wasn't supported. */
  protected Shape shape(State state) throws ParseException {
    String type = state.nextWord();
    Shape shape = parseShapeByType(state, type);
    if (shape == null)
      throw new ParseException("Shape of type "+type+" is unknown", state.offset);
    return shape;
  }
View Full Code Here

   */
  public Filter geoSearch(String value) {
    GeopositionComparator comp = (GeopositionComparator) prop.getComparator();
    double dist = comp.getMaxDistance();
    double degrees = DistanceUtils.dist2Degrees(dist, DistanceUtils.EARTH_MEAN_RADIUS_KM * 1000.0);
    Shape circle = spatialctx.makeCircle(parsePoint(value), degrees);
    SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, circle);
    return strategy.makeFilter(args);
  }
View Full Code Here

    final FunctionValues shapeValues = shapeValueSource.getValues(context, readerContext);

    return new DoubleDocValues(this) {
      @Override
      public double doubleVal(int doc) {
        Shape shape = (Shape) shapeValues.objectVal(doc);
        if (shape == null || shape.isEmpty())
          return nullValue;
        Point pt = shape.getCenter();
        return distCalc.distance(queryPoint, pt) * multiplier;
      }

      @Override
      public Explanation explain(int doc) {
View Full Code Here

    final FunctionValues shapeValues = shapeValuesource.getValues(context, readerContext);

    return new BoolDocValues(this) {
      @Override
      public boolean boolVal(int doc) {
        Shape indexedShape = (Shape) shapeValues.objectVal(doc);
        if (indexedShape == null)
          return false;
        return op.evaluate(indexedShape, queryShape);
      }
View Full Code Here

  public Filter makeFilter(SpatialArgs args) {
    final SpatialOperation op = args.getOperation();
    if (op == SpatialOperation.IsDisjointTo)
      return new DisjointSpatialFilter(this, args, getFieldName());

    Shape shape = args.getShape();
    int detailLevel = grid.getLevelForDistance(args.resolveDistErr(ctx, distErrPct));

    if (pointsOnly || op == SpatialOperation.Intersects) {
      return new IntersectsPrefixTreeFilter(
          shape, getFieldName(), grid, detailLevel, prefixGridScanLevel, !pointsOnly);
View Full Code Here

  public Filter makeFilter(SpatialArgs args) {
    final SpatialOperation op = args.getOperation();
    if (op != SpatialOperation.Intersects)
      throw new UnsupportedSpatialOperation(op);

    Shape shape = args.getShape();
    int detailLevel = grid.getLevelForDistance(args.resolveDistErr(ctx, distErrPct));
    List<Cell> cells = grid.getCells(shape, detailLevel,
        false,//no parents
        true);//simplify
    BytesRef[] terms = new BytesRef[cells.size()];
View Full Code Here

      SmallDocSet leafDocs = getLeafDocs(cell, acceptContains);

      // Get the AND of all child results (into combinedSubResults)
      SmallDocSet combinedSubResults = null;
      //   Optimization: use null subCellsFilter when we know cell is within the query shape.
      Shape subCellsFilter = queryShape;
      if (cell.getLevel() != 0 && ((cell.getShapeRel() == null || cell.getShapeRel() == SpatialRelation.WITHIN))) {
        subCellsFilter = null;
        assert cell.getShape().relate(queryShape) == SpatialRelation.WITHIN;
      }
      Collection <Cell> subCells = cell.getSubCells(subCellsFilter);
View Full Code Here

    String body = v.substring(idx + 1, edx).trim();
    if (body.length() < 1) {
      throw new ParseException("missing body : " + v, idx + 1);
    }

    Shape shape = parseShape(body, ctx);
    SpatialArgs args = newSpatialArgs(op, shape);

    if (v.length() > (edx + 1)) {
      body = v.substring(edx + 1).trim();
      if (body.length() > 0) {
View Full Code Here

TOP

Related Classes of com.spatial4j.core.shape.Shape

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.