private bool calcPolygon() { if (!InitReader()) { return(false); } TFWFile tfw = this.GeoCoord as TFWFile; if (tfw == null) { return(false); } int iWidth = _geoCoord.iWidth; int iHeight = _geoCoord.iHeight; _polygon = new Polygon(); Ring ring = new Ring(); gView.Framework.Geometry.Point p1 = new gView.Framework.Geometry.Point( tfw.X - tfw.dx_X / 2.0 - tfw.dy_X / 2.0, tfw.Y - tfw.dx_Y / 2.0 - tfw.dy_Y / 2.0); ring.AddPoint(p1); ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + tfw.dx_X * iWidth, p1.Y + tfw.dx_Y * iWidth)); ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + tfw.dx_X * iWidth + tfw.dy_X * iHeight, p1.Y + tfw.dx_Y * iWidth + tfw.dy_Y * iHeight)); ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + tfw.dy_X * iHeight, p1.Y + tfw.dy_Y * iHeight)); _polygon.AddRing(ring); return(true); }
private void AddPoint(double x, double y) { if (_polygon == null) { _polygon = new Polygon(); Ring path = new Ring(); _polygon.AddRing(path); } _polygon[0].AddPoint(new Point(x, y)); }
public void Load(IPersistStream stream) { if (_polygon == null || stream == null) { return; } PersistablePointCollection p; while ((p = stream.Load("Ring", null, new PersistablePointCollection(new Ring())) as PersistablePointCollection) != null) { _polygon.AddRing(p.PointCollection as IRing); } }
public void AddPoint(IPoint point) { if (point == null) { return; } if (_geometry is IPoint && _actPartNr == 0) { ((IPoint)_geometry).X = point.X; ((IPoint)_geometry).Y = point.Y; ((IPoint)_geometry).Z = point.Z; } else if (_geometry is IMultiPoint) { IMultiPoint mPoint = (IMultiPoint)_geometry; mPoint.AddPoint(point); } else if (_geometry is IPolyline) { IPolyline pLine = (IPolyline)_geometry; if (_actPartNr >= pLine.PathCount) { gView.Framework.Geometry.Path path = new gView.Framework.Geometry.Path(); path.AddPoint(point); pLine.AddPath(path); _actPartNr = pLine.PathCount - 1; } else { pLine[_actPartNr].AddPoint(point); } } else if (_geometry is IPolygon) { IPolygon poly = (IPolygon)_geometry; if (_actPartNr >= poly.RingCount) { Ring ring = new Ring(); ring.AddPoint(point); poly.AddRing(ring); _actPartNr = poly.RingCount - 1; } else { poly[_actPartNr].AddPoint(point); } } }
private void calcPolygon() { _polygon = new Polygon(); Ring ring = new Ring(); gView.Framework.Geometry.Point p1 = new gView.Framework.Geometry.Point( _tfw.X - _tfw.dx_X / 2.0 - _tfw.dy_X / 2.0, _tfw.Y - _tfw.dx_Y / 2.0 - _tfw.dy_Y / 2.0); ring.AddPoint(p1); ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + _tfw.dx_X * _iWidth, p1.Y + _tfw.dx_Y * _iWidth)); ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + _tfw.dx_X * _iWidth + _tfw.dy_X * _iHeight, p1.Y + _tfw.dx_Y * _iWidth + _tfw.dy_Y * _iHeight)); ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + _tfw.dy_X * _iHeight, p1.Y + _tfw.dy_Y * _iHeight)); _polygon.AddRing(ring); }
private void calcPolygon(IEnvelope env) { if (env == null) { return; } _polygon = new Polygon(); Ring ring = new Ring(); ring.AddPoint(new Point(env.minx, env.miny)); ring.AddPoint(new Point(env.maxx, env.miny)); ring.AddPoint(new Point(env.maxx, env.maxy)); ring.AddPoint(new Point(env.minx, env.maxy)); _polygon.AddRing(ring); }
private void SetBounds(GraphicsEngine.Abstraction.IBitmap bitmap) { if (bitmap != null) { _iWidth = bitmap.Width; _iHeight = bitmap.Height; } _polygon = new Polygon(); Ring ring = new Ring(); gView.Framework.Geometry.Point p1 = new gView.Framework.Geometry.Point( _tfw.X - _tfw.dx_X / 2.0 - _tfw.dy_X / 2.0, _tfw.Y - _tfw.dx_Y / 2.0 - _tfw.dy_Y / 2.0); ring.AddPoint(p1); ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + _tfw.dx_X * _iWidth, p1.Y + _tfw.dx_Y * _iWidth)); ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + _tfw.dx_X * _iWidth + _tfw.dy_X * _iHeight, p1.Y + _tfw.dx_Y * _iWidth + _tfw.dy_Y * _iHeight)); ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + _tfw.dy_X * _iHeight, p1.Y + _tfw.dy_Y * _iHeight)); _polygon.AddRing(ring); }
private void setBounds(Image image) { if (image != null) { _iWidth = image.Width; _iHeight = image.Height; } _polygon = new Polygon(); Ring ring = new Ring(); gView.Framework.Geometry.Point p1 = new gView.Framework.Geometry.Point( _tfw.X - _tfw.dx_X / 2.0 - _tfw.dy_X / 2.0, _tfw.Y - _tfw.dx_Y / 2.0 - _tfw.dy_Y / 2.0); ring.AddPoint(p1); ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + _tfw.dx_X * _iWidth, p1.Y + _tfw.dx_Y * _iWidth)); ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + _tfw.dx_X * _iWidth + _tfw.dy_X * _iHeight, p1.Y + _tfw.dx_Y * _iWidth + _tfw.dy_Y * _iHeight)); ring.AddPoint(new gView.Framework.Geometry.Point(p1.X + _tfw.dy_X * _iHeight, p1.Y + _tfw.dy_Y * _iHeight)); _polygon.AddRing(ring); }
public static IGeometry GML2Geometry(string gml, GmlVersion gmlVersion) { try { gml = gml.Replace("<gml:", "<").Replace("</gml:", "</"); XmlDocument doc = new XmlDocument(); doc.LoadXml(gml); XmlNode geomNode = doc.ChildNodes[0]; ISpatialReference sRef = null; if ((int)gmlVersion > 2 && geomNode.Attributes["srsName"] != null) { sRef = SpatialReference.FromID(geomNode.Attributes["srsName"].Value); } switch (geomNode.Name) { case "Point": return(GML2Point(geomNode, sRef)); case "pointProperty": return(GML2Point(geomNode.SelectSingleNode("Point"), sRef)); case "Box": case "Envelope": return(GML2Envelope(geomNode, sRef)); case "LineString": IPath path = GML2Path(geomNode, sRef); if (path == null) { return(null); } Polyline polyline = new Polyline(); polyline.AddPath(path); return(polyline); case "MultiLineString": return(GML2Polyline(geomNode, sRef)); case "curveProperty": return(GML2Polyline(geomNode, sRef)); case "Polygon": return(GML2Polygon(geomNode, sRef)); case "MultiPolygon": AggregateGeometry aGeom1 = new AggregateGeometry(); foreach (XmlNode polygonNode in geomNode.SelectNodes("polygonMember/Polygon")) { IPolygon polygon = GML2Polygon(polygonNode, sRef); if (polygon != null) { aGeom1.AddGeometry(polygon); } } if (aGeom1.GeometryCount == 0) { return(null); } IPolygon mpolygon1 = (IPolygon)aGeom1[0]; for (int i = 1; i < aGeom1.GeometryCount; i++) { IPolygon p = (IPolygon)aGeom1[i]; for (int r = 0; r < p.RingCount; r++) { mpolygon1.AddRing(p[r]); } } return(mpolygon1); case "surfaceProperty": AggregateGeometry aGeom2 = new AggregateGeometry(); foreach (XmlNode polygonNode in geomNode.SelectNodes("Surface/patches/PolygonPatch")) { IPolygon polygon = GML2Polygon(polygonNode, sRef); if (polygon != null) { aGeom2.AddGeometry(polygon); } } if (aGeom2.GeometryCount == 0) { return(null); } IPolygon mpolygon2 = (IPolygon)aGeom2[0]; for (int i = 1; i < aGeom2.GeometryCount; i++) { IPolygon p = (IPolygon)aGeom2[i]; for (int r = 0; r < p.RingCount; r++) { mpolygon2.AddRing(p[r]); } } return(mpolygon2); default: return(null); } } catch (Exception ex) { string err = ex.Message; return(null); } }