本文整理汇总了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();
}
示例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);
}