Пример #1
0
 /**
  * Parses a module.
  *
  * @param io input reference
  * @return query parser
  * @throws QueryException query exception
  */
 final QueryParser parseQuery(final IO io) throws QueryException {
   try (final QueryContext qctx = new QueryContext(qc)) {
     final String input = string(io.read());
     // parse query
     final QueryParser qp = new QueryParser(input, io.path(), qctx, null);
     module = QueryProcessor.isLibrary(input) ? qp.parseLibrary(true) : qp.parseMain();
     return qp;
   } catch (final IOException | QueryException ex) {
     throw IOERR_X.get(info, ex);
   }
 }
Пример #2
0
  /**
   * Writes an geometry and returns a string representation of the geometry.
   *
   * @param geometry geometry
   * @return DBNode database node
   * @throws QueryException exception
   */
  private DBNode gmlWriter(final Geometry geometry) throws QueryException {
    final String geo;
    try {
      // write geometry and add namespace declaration
      geo =
          new GMLWriter()
              .write(geometry)
              .replaceAll("^<gml:(.*?)>", "<gml:$1 xmlns:gml='" + string(URI) + "'>");
    } catch (final Exception ex) {
      throw GeoErrors.gmlWriterErr(ex);
    }

    try {
      final IO io = new IOContent(geo);
      return new DBNode(MemBuilder.build(new XMLParser(io, queryContext.context.options)));
    } catch (final IOException ex) {
      throw IOERR_X.get(null, ex);
    }
  }