code: public static Map<String, Geometry> queryToGeomMap( ADb db, String sql, Map<String, Geometry> optionalType )
              throws Exception {
          Map<String, Geometry> map = optionalType;
          if (map == null) {
              map = new HashMap<>();
          }
          IGeometryParser gp = db.getType().getGeometryParser();
          Map<String, Geometry> _map = map;
          return db.execOnConnection(connection -> {
              try (IHMStatement stmt = connection.createStatement(); IHMResultSet rs = stmt.executeQuery(sql)) {
                  while( rs.next() ) {
                      String key = rs.getObject(1).toString();
                      Geometry geometry = gp.fromResultSet(rs, 2);
                      _map.put(key, geometry);
                  }
                  return _map;
              }
          });
      }
docs: Quick method to convert a query to a map with geometry values.
  
  @param db the db to use.
  @param sql the query to run. It has to have at least 2 parameters, of which the second has to be a geometry field. The first will be used as key, the second as value.
  @param optionalType can be null. Optional parameter in case one needs a {@link TreeMap} or something the like.
  @return the map of values from the query.
  @throws Exception