Package com.spatial4j.core.shape

Examples of com.spatial4j.core.shape.Shape


      String name = getName(family, column.getName());
      if (!_strategy.getFieldName().equals(name)) {
        throw new RuntimeException("Strategy name and column name do not match.");
      }
      List<Field> fields = new ArrayList<Field>();
      Shape shape = getShape(column);
      checkShape(shape);
      for (Field f : _strategy.createIndexableFields(shape)) {
        fields.add(f);
      }
      fields.add(new StoredField(name, column.getValue()));
View Full Code Here


      String name = getName(family, column.getName(), subName);
      if (!_strategy.getFieldName().equals(name)) {
        throw new RuntimeException("Strategy name and column name do not match.");
      }
      List<Field> fields = new ArrayList<Field>();
      Shape shape = getShape(column);
      checkShape(shape);
      for (Field f : _strategy.createIndexableFields(shape)) {
        fields.add(f);
      }
      return fields;
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 = shapeReadWriter.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

          return (String) value;
        } else
          throw new IllegalArgumentException("Relation is not supported for string value: " + relation);
      } else if (value instanceof Geoshape) {
        Preconditions.checkArgument(relation == Geo.INTERSECT, "Relation is not supported for geo value: " + relation);
        Shape shape = ((Geoshape) value).convert2Spatial4j();
        return "Intersects(" + shape.toString() + ")";
      } else {
        throw new IllegalArgumentException("Unsupported type: " + value);
      }
    } else if (condition instanceof KeyNot) {
      return "-(" + getQueryString(family, ((KeyNot<String>) condition).getChild()) + ")";
View Full Code Here

    if (value instanceof Number) {
      return value.toString();
    } else if (value instanceof String) {
      return (String) value;
    } else if (value instanceof Geoshape) {
      Shape shape = ((Geoshape) value).convert2Spatial4j();
      return shape.toString();
    }
    throw new IllegalArgumentException("Unsupported type: " + value);
  }
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

    Map<String, Shape> indexedShapes = new LinkedHashMap<String, Shape>();
    Map<String, Rectangle> indexedGriddedShapes = new LinkedHashMap<String, Rectangle>();
    final int numIndexedShapes = randomIntBetween(1, 6);
    for (int i = 1; i <= numIndexedShapes; i++) {
      String id = "" + i;
      Shape indexShape = randomRectangle();
      Rectangle gridShape = gridSnapp(indexShape);
      indexedShapes.put(id, indexShape);
      indexedGriddedShapes.put(id, gridShape);
      adoc(id, indexShape);
    }

    commit();

    final int numQueryShapes = atLeast(10);
    for (int i = 0; i < numQueryShapes; i++) {
      int scanLevel = randomInt(grid.getMaxLevels());
      ((RecursivePrefixTreeStrategy) strategy).setPrefixGridScanLevel(scanLevel);
      Rectangle queryShape = randomRectangle();
      Rectangle queryGridShape = gridSnapp(queryShape);

      //Generate truth via brute force
      final SpatialOperation operation = SpatialOperation.Intersects;
      Set<String> expectedIds = new TreeSet<String>();
      Set<String> optionalIds = new TreeSet<String>();
      for (String id : indexedShapes.keySet()) {
        Shape indexShape = indexedShapes.get(id);
        Rectangle indexGridShape = indexedGriddedShapes.get(id);
        if (operation.evaluate(indexShape, queryShape))
          expectedIds.add(id);
        else if (operation.evaluate(indexGridShape, queryGridShape))
          optionalIds.add(id);
View Full Code Here

      prevN = n;
      n = n.getSubCells().iterator().next();//TODO random which one?
     
      assertEquals(prevN.getLevel()+1,n.getLevel());
      Rectangle prevNShape = (Rectangle) prevN.getShape();
      Shape s = n.getShape();
      Rectangle sbox = s.getBoundingBox();
      assertTrue(prevNShape.getWidth() > sbox.getWidth());
      assertTrue(prevNShape.getHeight() > sbox.getHeight());
    }
  }
View Full Code Here

    trie = new QuadPrefixTree(ctx, 12);
    TermQueryPrefixTreeStrategy strategy = new TermQueryPrefixTreeStrategy(trie, "geo");
    Document doc = new Document();
    doc.add(new TextField("id", "1", Store.YES));

    Shape area = ctx.makeRectangle(-122.82, -122.78, 48.54, 48.56);

    Field[] fields = strategy.createIndexableFields(area, 0.025);
    for (Field field : fields) {
      doc.add(field);
    }
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.