本文整理汇总了C#中PointClass.PutCoordsFromMGRS方法的典型用法代码示例。如果您正苦于以下问题:C# PointClass.PutCoordsFromMGRS方法的具体用法?C# PointClass.PutCoordsFromMGRS怎么用?C# PointClass.PutCoordsFromMGRS使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointClass
的用法示例。
在下文中一共展示了PointClass.PutCoordsFromMGRS方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMGRSPolygon
private IPolygon GetMGRSPolygon(IPoint point)
{
CoordinateMGRS mgrs;
IPointCollection pc = new RingClass();
// bottom left
CoordinateMGRS.TryParse(InputCoordinate, out mgrs);
// don't create a polygon for 1m resolution
if (mgrs.Easting.ToString().Length > 4 && mgrs.Northing.ToString().Length > 4)
return null;
var tempPoint = new PointClass() as IConversionNotation;
(tempPoint as IPoint).SpatialReference = GetSR();
var anotherMGRSstring = mgrs.ToString("", new CoordinateMGRSFormatter());
tempPoint.PutCoordsFromMGRS(anotherMGRSstring, esriMGRSModeEnum.esriMGRSMode_Automatic);
pc.AddPoint(tempPoint as IPoint);
// top left
var tempMGRS = new CoordinateMGRS(mgrs.GZD, mgrs.GS, mgrs.Easting, mgrs.Northing);
var tempEasting = mgrs.Easting.ToString().PadRight(5,'0');
tempMGRS.Easting = Convert.ToInt32(tempEasting);
var tempNorthing = mgrs.Northing.ToString().PadRight(5,'9');
tempMGRS.Northing = Convert.ToInt32(tempNorthing.Replace('0','9'));
tempPoint = new PointClass() as IConversionNotation;
(tempPoint as IPoint).SpatialReference = GetSR();
anotherMGRSstring = tempMGRS.ToString("ZSX00000Y00000", new CoordinateMGRSFormatter());
tempPoint.PutCoordsFromMGRS(anotherMGRSstring, esriMGRSModeEnum.esriMGRSMode_Automatic);
pc.AddPoint(tempPoint as IPoint);
// top right
tempEasting = mgrs.Easting.ToString().PadRight(5,'9');
tempMGRS.Easting = Convert.ToInt32(tempEasting.Replace('0', '9'));
tempNorthing = mgrs.Northing.ToString().PadRight(5,'9');
tempMGRS.Northing = Convert.ToInt32(tempNorthing.Replace('0', '9'));
tempPoint = new PointClass() as IConversionNotation;
(tempPoint as IPoint).SpatialReference = GetSR();
tempPoint.PutCoordsFromMGRS(tempMGRS.ToString("ZSX00000Y00000", new CoordinateMGRSFormatter()), esriMGRSModeEnum.esriMGRSMode_Automatic);
pc.AddPoint(tempPoint as IPoint);
// bottom right
tempEasting = mgrs.Easting.ToString().PadRight(5,'9');
tempMGRS.Easting = Convert.ToInt32(tempEasting.Replace('0', '9'));
tempNorthing = mgrs.Northing.ToString().PadRight(5,'0');
tempMGRS.Northing = Convert.ToInt32(tempNorthing);
tempPoint = new PointClass() as IConversionNotation;
(tempPoint as IPoint).SpatialReference = GetSR();
tempPoint.PutCoordsFromMGRS(tempMGRS.ToString("ZSX00000Y00000", new CoordinateMGRSFormatter()), esriMGRSModeEnum.esriMGRSMode_Automatic);
pc.AddPoint(tempPoint as IPoint);
// create polygon
var poly = new PolygonClass();
poly.SpatialReference = GetSR();
poly.AddPointCollection(pc);
poly.Close();
return poly;
}