当前位置: 首页>>代码示例>>Java>>正文


Java SpatialContext.readShapeFromWkt方法代码示例

本文整理汇总了Java中com.spatial4j.core.context.SpatialContext.readShapeFromWkt方法的典型用法代码示例。如果您正苦于以下问题:Java SpatialContext.readShapeFromWkt方法的具体用法?Java SpatialContext.readShapeFromWkt怎么用?Java SpatialContext.readShapeFromWkt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.spatial4j.core.context.SpatialContext的用法示例。


在下文中一共展示了SpatialContext.readShapeFromWkt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTestData

import com.spatial4j.core.context.SpatialContext; //导入方法依赖的package包/类
/** Reads the stream, consuming a format that is a tab-separated values of 3 columns:
 * an "id", a "name" and the "shape".  Empty lines and lines starting with a '#' are skipped.
 * The stream is closed.
 */
public static Iterator<SpatialTestData> getTestData(InputStream in, SpatialContext ctx) throws IOException {
  List<SpatialTestData> results = new ArrayList<>();
  BufferedReader bufInput = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));
  try {
    String line;
    while ((line = bufInput.readLine()) != null) {
      if (line.length() == 0 || line.charAt(0) == '#')
        continue;

      SpatialTestData data = new SpatialTestData();
      String[] vals = line.split("\t");
      if (vals.length != 3)
        throw new RuntimeException("bad format; expecting 3 tab-separated values for line: "+line);
      data.id = vals[0];
      data.name = vals[1];
      try {
        data.shape = ctx.readShapeFromWkt(vals[2]);
      } catch (ParseException e) {
        throw new RuntimeException(e);
      }
      results.add(data);
    }
  } finally {
    bufInput.close();
  }
  return results.iterator();
}
 
开发者ID:europeana,项目名称:search,代码行数:32,代码来源:SpatialTestData.java

示例2: parseShape

import com.spatial4j.core.context.SpatialContext; //导入方法依赖的package包/类
protected Shape parseShape(String str, SpatialContext ctx) throws ParseException {
  //return ctx.readShape(str);//still in Spatial4j 0.4 but will be deleted
  return ctx.readShapeFromWkt(str);
}
 
开发者ID:europeana,项目名称:search,代码行数:5,代码来源:SpatialArgsParser.java


注:本文中的com.spatial4j.core.context.SpatialContext.readShapeFromWkt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。