本文整理汇总了C#中Spatial4n.Core.Context.SpatialContext.ReadShapeFromWkt方法的典型用法代码示例。如果您正苦于以下问题:C# SpatialContext.ReadShapeFromWkt方法的具体用法?C# SpatialContext.ReadShapeFromWkt怎么用?C# SpatialContext.ReadShapeFromWkt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spatial4n.Core.Context.SpatialContext
的用法示例。
在下文中一共展示了SpatialContext.ReadShapeFromWkt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetTestData
/** 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 IEnumerator<SpatialTestData> GetTestData(Stream @in, SpatialContext ctx)
{
List<SpatialTestData> results = new List<SpatialTestData>();
TextReader bufInput = new StreamReader(@in, Encoding.UTF8);
try
{
String line;
while ((line = bufInput.ReadLine()) != null)
{
if (line.Length == 0 || line[0] == '#')
continue;
SpatialTestData data = new SpatialTestData();
String[] vals = line.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
if (vals.Length != 3)
throw new ArgumentException("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 ApplicationException(e.Message, e);
}
results.Add(data);
}
}
finally
{
bufInput.Dispose();
}
return results.GetEnumerator();
}
示例2: ParseShape
protected virtual IShape ParseShape(string str, SpatialContext ctx)
{
//return ctx.readShape(str);//still in Spatial4n 0.4 but will be deleted
return ctx.ReadShapeFromWkt(str);
}