Example #1
0
 /**
  * Returns a boolean value that shows if whether relationships between the boundaries, interiors
  * and exteriors of two geometries match the pattern specified in intersection-matrix-pattern.
  *
  * @param node1 xml element containing gml object(s)
  * @param node2 xml element containing gml object(s)
  * @param intersectionMatrix intersection matrix for two geometries
  * @return boolean value
  * @throws QueryException query exception
  */
 @Deterministic
 public Bln relate(final ANode node1, final ANode node2, final Str intersectionMatrix)
     throws QueryException {
   final Geometry geo1 = checkGeo(node1);
   final Geometry geo2 = checkGeo(node2);
   return Bln.get(geo1.relate(geo2, intersectionMatrix.toJava()));
 }
Example #2
0
  /**
   * Return a boolean value that shows weather the line is a ring or not. A line is a ring if it is
   * closed and simple.
   *
   * @param node xml element containing gml object(s)
   * @return boolean value
   * @throws QueryException query exception
   */
  @Deterministic
  public Bln isRing(final ANode node) throws QueryException {
    final Geometry geo = geo(node, Q_GML_LINEARRING, Q_GML_LINESTRING);
    if (geo == null && checkGeo(node) != null)
      throw GeoErrors.geoType(node.qname().local(), "Line");

    return Bln.get(((LineString) geo).isRing());
  }
Example #3
0
 @Override
 public Item item(final QueryContext qc, final InputInfo ii) throws QueryException {
   final Data data = checkData(qc);
   final String path = path(1, qc);
   if (data.inMemory()) return Bln.FALSE;
   final IOFile io = data.meta.binary(path);
   return Bln.get(io.exists() && !io.isDir());
 }
Example #4
0
  /**
   * Checks if the line is closed loop. That is, if the start Point is same with end Point.
   *
   * @param node xml element containing gml object(s)
   * @return boolean value
   * @throws QueryException query exception
   */
  @Deterministic
  public Bln isClosed(final ANode node) throws QueryException {
    final Geometry geo = geo(node, Q_GML_LINEARRING, Q_GML_LINESTRING, Q_GML_MULTILINESTRING);
    if (geo == null && checkGeo(node) != null)
      throw GeoErrors.geoType(node.qname().local(), "Line");

    return Bln.get(
        geo instanceof LineString
            ? ((LineString) geo).isClosed()
            : ((MultiLineString) geo).isClosed());
  }
Example #5
0
  @Override
  public Item item(final QueryContext qc, final InputInfo ii) throws QueryException {
    // compute scoring
    if (qc.scoring) {
      double s = 0;
      boolean f = false;
      for (final Expr expr : exprs) {
        final Item it = expr.ebv(qc, info);
        f |= it.bool(ii);
        s += it.score();
      }
      return Bln.get(f, Scoring.avg(s, exprs.length));
    }

    // standard evaluation
    for (final Expr expr : exprs) {
      if (expr.ebv(qc, info).bool(ii)) return Bln.TRUE;
    }
    return Bln.FALSE;
  }
Example #6
0
 @Override
 public final Item item(final QueryContext qc, final InputInfo ii) throws QueryException {
   return Bln.get(toMap(exprs[0], qc).contains(toAtomItem(exprs[1], qc), ii));
 }
Example #7
0
 /**
  * Checks if the specified item is a boolean. Returns the boolean or throws an exception.
  *
  * @param it item be checked
  * @return boolean
  * @throws QueryException query exception
  */
 protected final boolean toBoolean(final Item it) throws QueryException {
   final Type ip = checkNoEmpty(it, AtomType.BLN).type;
   if (ip == AtomType.BLN) return it.bool(info);
   if (ip.isUntyped()) return Bln.parse(it.string(info), info);
   throw castError(it, AtomType.BLN, info);
 }
Example #8
0
 /**
  * Returns a boolean value that shows if this geometry overlaps the specified geometry.
  *
  * @param node1 xml element containing gml object(s)
  * @param node2 xml element containing gml object(s)
  * @return boolean value
  * @throws QueryException query exception
  */
 @Deterministic
 public Bln overlaps(final ANode node1, final ANode node2) throws QueryException {
   final Geometry geo1 = checkGeo(node1);
   final Geometry geo2 = checkGeo(node2);
   return Bln.get(geo1.overlaps(geo2));
 }
Example #9
0
 /**
  * Returns a boolean value which shows if the specified geometry is simple or not, which has no
  * anomalous geometric points, such as self intersection or self tangency.
  *
  * @param node xml element containing gml object(s)
  * @return boolean value
  * @throws QueryException query exception
  */
 @Deterministic
 public Bln isSimple(final ANode node) throws QueryException {
   return Bln.get(checkGeo(node).isSimple());
 }
Example #10
0
 /**
  * Returns a boolean value which shows if the specified geometry is empty or not.
  *
  * @param node xml element containing gml object(s)
  * @return boolean value
  * @throws QueryException query exception
  */
 @Deterministic
 public Bln isEmpty(final ANode node) throws QueryException {
   return Bln.get(node != null && checkGeo(node) != null);
 }
Example #11
0
 /**
  * Evaluates the match function.
  *
  * @param val input value
  * @param ctx query context
  * @return function result
  * @throws QueryException query exception
  */
 private Item matches(final byte[] val, final QueryContext ctx) throws QueryException {
   final Pattern p = pattern(expr[1], expr.length == 3 ? expr[2] : null, ctx);
   return Bln.get(p.matcher(string(val)).find());
 }