本文整理汇总了C#中Envelope.ExpandToInclude方法的典型用法代码示例。如果您正苦于以下问题:C# Envelope.ExpandToInclude方法的具体用法?C# Envelope.ExpandToInclude怎么用?C# Envelope.ExpandToInclude使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Envelope
的用法示例。
在下文中一共展示了Envelope.ExpandToInclude方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Reproject
public Envelope Reproject(Envelope envelope, ISpatialReference @from, ISpatialReference to)
{
var transformation = GetMathTransform(@from, to);
var res = new Envelope(transformation.Transform(new Coordinate(envelope.MinX, envelope.MinY)));
res.ExpandToInclude(transformation.Transform(new Coordinate(envelope.MinX, envelope.MaxY)));
res.ExpandToInclude(transformation.Transform(new Coordinate(envelope.MaxX, envelope.MaxY)));
res.ExpandToInclude(transformation.Transform(new Coordinate(envelope.MaxX, envelope.MinY)));
return res;
}
示例2: GetData
public JsonResult GetData(float w, float n, float e, float s, int z)
{
string format = String.Format("~/App_Data/berlin/{0}", "osmbuildings.shp");
string path = this.HttpContext.Server.MapPath(format);
if (!System.IO.File.Exists(path))
throw new FileNotFoundException("file not found", path);
Point start = this.GeoToPixel(n, w, z);
var meta = new { n, w, s, e, x = start.X, y = start.Y, z };
Envelope bbox = new Envelope();
bbox.ExpandToInclude(new Coordinate(n, w));
bbox.ExpandToInclude(new Coordinate(s, e));
FeatureDataSet ds = new FeatureDataSet();
using (ShapeFile provider = new ShapeFile(path))
{
provider.DoTrueIntersectionQuery = true;
provider.Open();
provider.ExecuteIntersectionQuery(bbox, ds);
provider.Close();
}
int zz = MaxZoom - z;
List<object> data = new List<object>();
FeatureDataTable table = ds.Tables[0];
foreach (FeatureDataRow row in table)
{
int c = (short)(row["height"]);
if (c == 0)
c = 5; // default value for "null" (zero) heights
int h = c * ScaleZ >> zz;
if (h <= 1)
h = 1;
IGeometry geometry = row.Geometry;
Coordinate[] coords = geometry.Coordinates;
int total = coords.Length;
double[] values = new double[total * 2];
int i = 0;
foreach (Coordinate curr in coords)
{
Point p = this.GeoToPixel(curr.X, curr.Y, z);
values[i++] = p.X - start.X;
values[i++] = p.Y - start.Y;
}
data.Add(new object[] { h, values });
}
return this.Json(new { meta, data }, JsonRequestBehavior.AllowGet);
}
示例3: TransformBox
/// <summary>
/// Transforms a <see cref="Envelope"/>.
/// </summary>
/// <param name="box">BoundingBox to transform</param>
/// <param name="transform">Math Transform</param>
/// <returns>Transformed object</returns>
public static Envelope TransformBox(Envelope box, IMathTransform transform)
{
if (box == null)
return null;
var corners = new Coordinate[4];
#if PCL
var ll = new Coordinate(box.MinX, box.MinY);
var ur = new Coordinate(box.MaxX, box.MaxY);
var llTrans = transform.Transform(ll);
var urTrans = transform.Transform(ur);
corners[0] = new Coordinate(llTrans.X, llTrans.Y); //lower left
corners[2] = new Coordinate(llTrans.X, urTrans.Y); //upper left
corners[1] = new Coordinate(urTrans.X, urTrans.Y); //upper right
corners[3] = new Coordinate(urTrans.X, llTrans.Y); //lower right
#else
var ll = box.Min().ToDoubleArray();
var ur = box.Max().ToDoubleArray();
var llTrans = transform.Transform(ll);
var urTrans = transform.Transform(ur);
corners[0] = new Coordinate(llTrans[0], llTrans[1]); //lower left
corners[2] = new Coordinate(llTrans[0], urTrans[1]); //upper left
corners[1] = new Coordinate(urTrans[0], urTrans[1]); //upper right
corners[3] = new Coordinate(urTrans[0], llTrans[1]); //lower right
#endif
var result = new Envelope(corners[0]);
for (var i = 1; i < 4; i++)
result.ExpandToInclude(corners[i]);
return result;
}
示例4: GetBoundingBoxInLatLngWithMargin
private Envelope GetBoundingBoxInLatLngWithMargin(int tileX, int tileY, int zoom)
{
Point px1 = new Point((tileX * 256), (tileY * 256));
Point px2 = new Point(((tileX + 1) * 256), ((tileY + 1) * 256));
PointF ll1 = TileSystemHelper.PixelXYToLatLong(px1, zoom);
PointF ll2 = TileSystemHelper.PixelXYToLatLong(px2, zoom);
double[] prj1 = this.projection.MathTransform.Transform(new double[] { ll1.X, ll1.Y });
double[] prj2 = this.projection.MathTransform.Transform(new double[] { ll2.X, ll2.Y });
Envelope bbox = new Envelope();
bbox.ExpandToInclude(prj1[0], prj1[1]);
bbox.ExpandToInclude(prj2[0], prj2[1]);
return bbox;
}
示例5: ComputeVertexEnvelope
private static Envelope ComputeVertexEnvelope(IEnumerable<Vertex> vertices)
{
Envelope env = new Envelope();
foreach (Vertex v in vertices)
env.ExpandToInclude(v.Coordinate);
return env;
}
示例6: GetSelectionExtent
private void GetSelectionExtent()
{
AppState appState = AppState.FromJson(Request.Form["state"]);
Envelope extent = new Envelope();
if (appState.TargetIds.Count > 0)
{
extent.ExpandToInclude(appState.SelectionManager.GetExtent(FeatureType.Target));
}
if (appState.SelectionIds.Count > 0)
{
extent.ExpandToInclude(appState.SelectionManager.GetExtent(FeatureType.Selection));
}
ReturnJson<double[]>("extent", extent.IsNull ? null : extent.ToArray());
}
示例7: Envelope
/// <summary>
/// Computes the <see cref="Envelope"/> of a collection of <see cref="Coordinate"/>s.
/// </summary>
/// <param name="coords">a List of Coordinates</param>
/// <returns>the envelope of the set of coordinates</returns>
public static Envelope Envelope(ICollection<Coordinate> coords)
{
Envelope env = new Envelope();
foreach (var coord in coords)
{
env.ExpandToInclude(coord);
}
return env;
}
示例8: OnComplete
protected override void OnComplete()
{
//var rect = DragRectangle.ToRectanglePolygon();
var bottom = DragRectangle.Top - DragRectangle.Height;
var points = new[]{
new WinPoint(DragRectangle.Left, bottom),
new WinPoint (DragRectangle.Left, DragRectangle.Top),
new WinPoint(DragRectangle.Right, DragRectangle.Top),
new WinPoint (DragRectangle.Right, bottom)};
Viewport.ClientToWorld().Transform(points);
var box = new Envelope();
box.ExpandToInclude(ToCoordinate(points[0]));
box.ExpandToInclude(ToCoordinate(points[1]));
box.ExpandToInclude(ToCoordinate(points[2]));
box.ExpandToInclude(ToCoordinate(points[3]));
Select(box);
}
示例9: TestEverything
public void TestEverything()
{
Envelope e1 = new Envelope();
Assert.IsTrue(e1.IsNull);
Assert.AreEqual(0, e1.Width, 1E-3);
Assert.AreEqual(0, e1.Height, 1E-3);
e1.ExpandToInclude(100, 101);
e1.ExpandToInclude(200, 202);
e1.ExpandToInclude(150, 151);
Assert.AreEqual(200, e1.MaxX, 1E-3);
Assert.AreEqual(202, e1.MaxY, 1E-3);
Assert.AreEqual(100, e1.MinX, 1E-3);
Assert.AreEqual(101, e1.MinY, 1E-3);
Assert.IsTrue(e1.Contains(120, 120));
Assert.IsTrue(e1.Contains(120, 101));
Assert.IsTrue(!e1.Contains(120, 100));
Assert.AreEqual(101, e1.Height, 1E-3);
Assert.AreEqual(100, e1.Width, 1E-3);
Assert.IsTrue(!e1.IsNull);
Envelope e2 = new Envelope(499, 500, 500, 501);
Assert.IsTrue(!e1.Contains(e2));
Assert.IsTrue(!e1.Intersects(e2));
e1.ExpandToInclude(e2);
Assert.IsTrue(e1.Contains(e2));
Assert.IsTrue(e1.Intersects(e2));
Assert.AreEqual(500, e1.MaxX, 1E-3);
Assert.AreEqual(501, e1.MaxY, 1E-3);
Assert.AreEqual(100, e1.MinX, 1E-3);
Assert.AreEqual(101, e1.MinY, 1E-3);
Envelope e3 = new Envelope(300, 700, 300, 700);
Assert.IsTrue(!e1.Contains(e3));
Assert.IsTrue(e1.Intersects(e3));
Envelope e4 = new Envelope(300, 301, 300, 301);
Assert.IsTrue(e1.Contains(e4));
Assert.IsTrue(e1.Intersects(e4));
}
示例10: Measure
public double Measure(IGeometry g1, IGeometry g2)
{
double distance = DiscreteHausdorffDistance.Distance(g1, g2, DensifyFraction);
Envelope env = new Envelope(g1.EnvelopeInternal);
env.ExpandToInclude(g2.EnvelopeInternal);
double envSize = DiagonalSize(env);
// normalize so that more similarity produces a measure closer to 1
double measure = 1 - distance/envSize;
//System.out.println("Hausdorff distance = " + distance + ", measure = " + measure);
return measure;
}
示例11: TransformBox
/// <summary>
/// Transforms a <see cref="Envelope" /> object.
/// </summary>
/// <param name="box"></param>
/// <param name="transform"></param>
/// <returns></returns>
public static Envelope TransformBox(Envelope box, IMathTransform transform)
{
if (box == null) return null;
var corners = new double[4][];
corners[0] = transform.Transform(ToArray(box.MinX, box.MinY)); //LL
corners[1] = transform.Transform(ToArray(box.MaxX, box.MaxY)); //UR
corners[2] = transform.Transform(ToArray(box.MinX, box.MaxY)); //UL
corners[3] = transform.Transform(ToArray(box.MaxX, box.MinY)); //LR
var result = new Envelope();
foreach (var p in corners)
result.ExpandToInclude(p[0], p[1]);
return result;
}
示例12: TransformBox
/// <summary>
/// Transforms a <see cref="Envelope"/>.
/// </summary>
/// <param name="box">BoundingBox to transform</param>
/// <param name="transform">Math Transform</param>
/// <returns>Transformed object</returns>
public static Envelope TransformBox(Envelope box, IMathTransform transform)
{
if (box == null)
return null;
var corners = new [] {
transform.Transform(new Coordinate(box.MinX, box.MinY)),
transform.Transform(new Coordinate(box.MinX, box.MaxY)),
transform.Transform(new Coordinate(box.MaxX, box.MinY)),
transform.Transform(new Coordinate(box.MaxX, box.MaxY)) };
var result = new Envelope(corners[0]);
for (var i = 1; i < 4; i++)
result.ExpandToInclude(corners[i]);
return result;
}
示例13: Create
private void Create()
{
if (_subdiv != null) return;
Envelope siteEnv = DelaunayTriangulationBuilder.Envelope(_siteCoords);
_diagramEnv = siteEnv;
// add a buffer around the final envelope
double expandBy = Math.Max(_diagramEnv.Width, _diagramEnv.Height);
_diagramEnv.ExpandBy(expandBy);
if (_clipEnv != null)
_diagramEnv.ExpandToInclude(_clipEnv);
var vertices = DelaunayTriangulationBuilder.ToVertices(_siteCoords);
_subdiv = new QuadEdgeSubdivision(siteEnv, _tolerance);
IncrementalDelaunayTriangulator triangulator = new IncrementalDelaunayTriangulator(_subdiv);
triangulator.InsertSites(vertices);
}
示例14: GetExtent
public static Envelope GetExtent(int[] groupIds)
{
Envelope extent = new Envelope();
string idsString = String.Join(",", groupIds.Select(o => o.ToString()).ToArray());
string sql = String.Format("select Shape from {0}Markup where GroupID in ({1}) and Deleted = 0", AppSettings.ConfigurationTablePrefix, idsString);
using (OleDbConnection connection = AppContext.GetDatabaseConnection())
{
using (OleDbCommand command = new OleDbCommand(sql, connection))
{
WKTReader wktReader = new WKTReader();
using (OleDbDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
IGeometry geometry = wktReader.Read(reader.GetString(0));
extent.ExpandToInclude(geometry.EnvelopeInternal);
}
}
}
if (!extent.IsNull)
{
if (extent.Width == 0 && extent.Height == 0)
{
extent = new Envelope(new Coordinate(extent.MinX - 50, extent.MinY - 50), new Coordinate(extent.MaxX + 50, extent.MaxY + 50));
}
extent.ScaleBy(1.2);
}
}
return extent;
}
示例15: QuadTree
/// <summary>
/// Creates a node and either splits the objects recursively into sub-nodes, or stores them at the node depending on the heuristics.
/// Tree is built top->down
/// </summary>
/// <param name="objList">Geometries to index</param>
/// <param name="depth">Current depth of tree</param>
/// <param name="heurdata">Heuristics data</param>
public QuadTree(List<BoxObjects> objList, uint depth, Heuristic heurdata)
{
_depth = depth;
_box = new Envelope(objList[0].Box);
for (var i = 1; i < objList.Count; i++)
_box.ExpandToInclude(objList[i].Box);
// test our build heuristic - if passes, make children
if (depth < heurdata.maxdepth && objList.Count > heurdata.mintricnt &&
(objList.Count > heurdata.tartricnt || ErrorMetric(_box) > heurdata.minerror))
{
var objBuckets = new List<BoxObjects>[2]; // buckets of geometries
objBuckets[0] = new List<BoxObjects>();
objBuckets[1] = new List<BoxObjects>();
var longaxis = _box.LongestAxis(); // longest axis
var geoavg = 0d; // geometric average - midpoint of ALL the objects
// go through all bbox and calculate the average of the midpoints
var frac = 1.0d/objList.Count;
for (var i = 0; i < objList.Count; i++)
geoavg += objList[i].Box.Centre[longaxis]*frac;
// bucket bbox based on their midpoint's side of the geo average in the longest axis
for (var i = 0; i < objList.Count; i++)
objBuckets[geoavg > objList[i].Box.Centre[longaxis] ? 1 : 0].Add(objList[i]);
//If objects couldn't be splitted, just store them at the leaf
//TODO: Try splitting on another axis
if (objBuckets[0].Count == 0 || objBuckets[1].Count == 0)
{
_child0 = null;
_child1 = null;
// copy object list
_objList = objList;
}
else
{
//We don't need the list anymore;
objList.Clear();
// create new children using the buckets
_child0 = new QuadTree(objBuckets[0], depth + 1, heurdata);
_child1 = new QuadTree(objBuckets[1], depth + 1, heurdata);
}
}
else
{
// otherwise the build heuristic failed, this is
// set the first child to null (identifies a leaf)
_child0 = null;
_child1 = null;
// copy object list
_objList = objList;
}
}