Package com.spatial4j.core.shape

Examples of com.spatial4j.core.shape.Shape


   * See <a href="https://issues.apache.org/jira/browse/LUCENE-4770>LUCENE-4770</a>.
   */
  @Test
  public void testBadPrefixTreePrune() throws Exception {
 
    Shape area = ctx.readShape("POLYGON((-122.83 48.57, -122.77 48.56, -122.79 48.53, -122.83 48.57))");
   
    SpatialPrefixTree trie = new QuadPrefixTree(ctx, 12);
    TermQueryPrefixTreeStrategy strategy = new TermQueryPrefixTreeStrategy(trie, "geo");
    Document doc = new Document();
    doc.add(new TextField("id", "1", Store.YES));
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

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

    Shape shape = ctx.readShape(body);
    SpatialArgs args = new SpatialArgs(op, shape);

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

        collectDocs(results);
      }

      @Override
      protected void visitScanned(Cell cell) throws IOException {
        Shape cShape;
        //if this cell represents a point, use the cell center vs the box
        // TODO this behavior is debatable; might want to be configurable
        // (points never have isLeaf())
        if (cell.getLevel() == grid.getMaxLevels() && !cell.isLeaf())
          cShape = cell.getCenter();
View Full Code Here

    while (sampleData.hasNext()) {
      SampleData data = sampleData.next();
      Document document = new Document();
      document.add(new StringField("id", data.id, Field.Store.YES));
      document.add(new StringField("name", data.name, Field.Store.YES));
      Shape shape = ctx.readShape(data.shape);
      shape = convertShapeFromGetDocuments(shape);
      if (shape != null) {
        for (Field f : strategy.createIndexableFields(shape)) {
          document.add(f);
        }
View Full Code Here

      }
    }
  }

  protected void adoc(String id, String shapeStr) throws IOException {
    Shape shape = shapeStr==null ? null : ctx.readShape(shapeStr);
    addDocument(newDoc(id, shape));
  }
View Full Code Here

    commit();
    deleteDoc("999");
    commit();

    double dist = ctx.getDistCalc().distance(p100, p101);
    Shape queryShape = ctx.makeCircle(2.01, 0.99, dist);
    checkValueSource(strategy.makeRecipDistanceValueSource(queryShape),
        new float[]{1.00f, 0.10f, 0f}, 0.09f);
  }
View Full Code Here

    while (sampleData.hasNext()) {
      SpatialTestData data = sampleData.next();
      Document document = new Document();
      document.add(new StringField("id", data.id, Field.Store.YES));
      document.add(new StringField("name", data.name, Field.Store.YES));
      Shape shape = data.shape;
      shape = convertShapeFromGetDocuments(shape);
      if (shape != null) {
        for (Field f : strategy.createIndexableFields(shape)) {
          document.add(f);
        }
        if (storeShape)//just for diagnostics
          document.add(new StoredField(strategy.getFieldName(), shape.toString()));
      }

      documents.add(document);
    }
    return documents;
View Full Code Here

  protected Query makeQuery(SpatialTestQuery q) {
    return strategy.makeQuery(q.args);
  }

  protected void adoc(String id, String shapeStr) throws IOException, ParseException {
    Shape shape = shapeStr==null ? null : ctx.readShapeFromWkt(shapeStr);
    addDocument(newDoc(id, shape));
  }
View Full Code Here

    assertTrue(34*distMult < DIST);
    checkHits(q(qPt, 34 * KM2DEG, distErrPct), 0, null);
  }

  private SpatialArgs q(Point pt, double distDEG, double distErrPct) {
    Shape shape = ctx.makeCircle(pt, distDEG);
    SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects,shape);
    args.setDistErrPct(distErrPct);
    return args;
  }
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.