本文整理汇总了C#中Spatial4n.Core.Context.SpatialContext.ReadShape方法的典型用法代码示例。如果您正苦于以下问题:C# SpatialContext.ReadShape方法的具体用法?C# SpatialContext.ReadShape怎么用?C# SpatialContext.ReadShape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Spatial4n.Core.Context.SpatialContext
的用法示例。
在下文中一共展示了SpatialContext.ReadShape方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Parse
/// <summary>
/// Parses a string such as "Intersects(-10,20,-8,22) distErrPct=0.025".
/// </summary>
/// <param name="v"></param>
/// <param name="ctx"></param>
/// <returns></returns>
public SpatialArgs Parse(String v, SpatialContext ctx)
{
int idx = v.IndexOf('(');
int edx = v.LastIndexOf(')');
if (idx < 0 || idx > edx)
{
throw new ArgumentException("missing parens: " + v);
}
SpatialOperation op = SpatialOperation.Get(v.Substring(0, idx).Trim());
//Substring in .NET is (startPosn, length), But in Java it's (startPosn, endPosn)
//see http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/String.html#substring(int, int)
String body = v.Substring(idx + 1, edx - (idx + 1)).Trim();
if (body.Length < 1)
{
throw new ArgumentException("missing body : " + v);
}
var shape = ctx.ReadShape(body);
var args = new SpatialArgs(op, shape);
if (v.Length > (edx + 1))
{
body = v.Substring(edx + 1).Trim();
if (body.Length > 0)
{
Dictionary<String, String> aa = ParseMap(body);
args.DistErrPct = ReadDouble(aa["distErrPct"]); aa.Remove(DIST_ERR_PCT);
args.DistErr = ReadDouble(aa["distErr"]); aa.Remove(DIST_ERR);
if (aa.Count != 0)
{
throw new ArgumentException("unused parameters: " + aa);
}
}
}
args.Validate();
return args;
}
示例2: Parse
public SpatialArgs Parse(String v, SpatialContext ctx)
{
int idx = v.IndexOf('(');
int edx = v.LastIndexOf(')');
if (idx < 0 || idx > edx)
{
throw new InvalidSpatialArgument("missing parens: " + v);
}
SpatialOperation op = SpatialOperation.Get(v.Substring(0, idx).Trim());
//Substring in .NET is (startPosn, length), But in Java it's (startPosn, endPosn)
//see http://docs.oracle.com/javase/1.4.2/docs/api/java/lang/String.html#substring(int, int)
String body = v.Substring(idx + 1, edx - (idx + 1)).Trim();
if (body.Length < 1)
{
throw new InvalidSpatialArgument("missing body : " + v);
}
var shape = ctx.ReadShape(body);
var args = new SpatialArgs(op, shape);
if (v.Length > (edx + 1))
{
body = v.Substring(edx + 1).Trim();
if (body.Length > 0)
{
Dictionary<String, String> aa = ParseMap(body);
args.Min = ReadDouble(aa["min"]);
args.Max = ReadDouble(aa["max"]);
args.SetDistPrecision(ReadDouble(aa["distPrec"]));
if (aa.Count > 3)
{
throw new InvalidSpatialArgument("unused parameters: " + aa);
}
}
}
return args;
}
示例3: InitWorldBounds
protected void InitWorldBounds()
{
String worldBoundsStr;
if (!Args.TryGetValue("worldBounds", out worldBoundsStr) || worldBoundsStr == null)
return;
//kinda ugly we do this just to read a rectangle. TODO refactor
var simpleCtx = new SpatialContext(Units, Calculator, null);
WorldBounds = (Rectangle)simpleCtx.ReadShape(worldBoundsStr);
}