本文整理汇总了C#中PointClass.PutCoords方法的典型用法代码示例。如果您正苦于以下问题:C# PointClass.PutCoords方法的具体用法?C# PointClass.PutCoords怎么用?C# PointClass.PutCoords使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PointClass
的用法示例。
在下文中一共展示了PointClass.PutCoords方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: axPageLayoutControl1_OnDoubleClick
private void axPageLayoutControl1_OnDoubleClick(object sender, ESRI.ArcGIS.Controls.IPageLayoutControlEvents_OnDoubleClickEvent e)
{
if (e.button == 1)
{
//标注的修改
if (axPageLayoutControl1.CurrentTool == null) return;
if (((axPageLayoutControl1.CurrentTool) as ICommand).Name == "ControlToolsGraphicElement_SelectTool")
{
IPoint pPoint = new PointClass();
pPoint.PutCoords(e.pageX, e.pageY);
IGraphicsContainer pGraphicsContainer = axPageLayoutControl1.PageLayout as IGraphicsContainer;
IEnumElement pEnumElement = pGraphicsContainer.LocateElements(pPoint, 10);
if (pEnumElement != null)
{
IElement pElement = pEnumElement.Next();
if (pElement is ITextElement)
{
ITextElement ptextElement = pElement as ITextElement;
MapPrint.TextSetUp textSetUp = new MapPrint.TextSetUp();
textSetUp.UpdateTextElement(ptextElement);
textSetUp.Show();
}
}
}
}
}
示例2: OnClick
protected override void OnClick()
{
IActiveView activeView = ArcMap.Document.ActiveView;
IMap map = activeView as IMap;
ILayer layer = map.get_Layer(0);
IFeatureLayer featureLayer = layer as IFeatureLayer;
IFeatureClass featureClass = featureLayer.FeatureClass;
IPoint point = new PointClass();
point.PutCoords(-117.1, 34.075); //(LONG, LAT)
IWorkspace workspace = GetWorkspace();
IWorkspaceEdit workspaceEdit = workspace as IWorkspaceEdit;
workspaceEdit.StartEditing(true);
workspaceEdit.StartEditOperation();
// -------------- Perform your editing tests here ------------------
CreateFeature(featureClass, point);
//UpdateFeature(featureClass);
//DeleteFeature(featureClass);
// -----------------------------------------------------------------
workspaceEdit.StopEditOperation();
workspaceEdit.StopEditing(true);
ArcMap.Application.CurrentTool = null;
}
示例3: OnMouseDown
protected override void OnMouseDown(ESRI.ArcGIS.Desktop.AddIns.Tool.MouseEventArgs arg)
{
int intx = arg.X;
int inty = arg.Y;
IPoint pPoints = new PointClass();
pPoints.PutCoords(intx, inty);
IActiveView activeView = ArcMap.Document.ActiveView;
pPoints = activeView.ScreenDisplay.DisplayTransformation.ToMapPoint(-100, 40);//x,y为屏幕坐标
ESRI.ArcGIS.Display.IScreenDisplay screenDisplay = activeView.ScreenDisplay;
ESRI.ArcGIS.Display.IDisplayTransformation displayTransformation = screenDisplay.DisplayTransformation;
pPoints=displayTransformation.ToMapPoint(-120, 40);
IMxDocument doc = ArcMap.Document;
IMap map = doc.FocusMap;
pPoints=doc.ActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(-100, 40);
AlterForm frm = null;
if (frm == null || frm.IsDisposed)
frm = new AlterForm(intx,inty);
frm.Show();
frm.TopMost = true;
frm.Width = 400;
frm.Height = 300;
frm.Left = 500;
}
示例4: getGeoPoint
/// <summary>
/// 坐标系转换-----投影坐标系转WGS84
/// </summary>
/// <param name="x">x坐标</param>
/// <param name="y">y坐标</param>
/// <returns>转换后的IPoint</returns>
public static IPoint getGeoPoint(double x, double y)
{
IPoint pProjPoint = new PointClass();
pProjPoint.PutCoords(x, y);
ISpatialReferenceFactory pSRF = new SpatialReferenceEnvironmentClass();
pProjPoint.SpatialReference = pSRF.CreateProjectedCoordinateSystem((int)(esriSRProjCSType.esriSRProjCS_WGS1984UTM_31N));
pProjPoint.Project(pSRF.CreateGeographicCoordinateSystem((int)(esriSRGeoCSType.esriSRGeoCS_WGS1984)));
return pProjPoint; //此时为经纬度点
}
示例5: toolStripButton1_Click
private void toolStripButton1_Click(object sender, EventArgs e)
{
IEnvelope pEnvelope = new EnvelopeClass();
IPoint pPoint = new PointClass();
pPoint.PutCoords(Convert.ToDouble(txtlong.Text), Convert.ToDouble(txtlat.Text));
pEnvelope = pAxMapControl.Extent;
pEnvelope.CenterAt(pPoint);
pAxMapControl.Extent = pEnvelope.Envelope;
pAxMapControl.FlashShape(pPoint as IGeometry);
//ccc(pPoint);
//ddd(pPoint);
}
示例6: OnClick
protected override void OnClick()
{
//
// TODO: Sample code showing how to access button host
//
var referenceFactory2 = (ISpatialReferenceFactory2)new SpatialReferenceEnvironment();
ISpatialReference WGS84 = referenceFactory2.CreateSpatialReference((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);
IPointCollection pointCollection = new PolylineClass();
// ------------- Ensure that both points have negative longitude values -------------------
IPoint point = new PointClass();
point.PutCoords(-170, 10); // Equivalent to 170 degrees WEST
point.SpatialReference = WGS84;
pointCollection.AddPoint(point);
point = new PointClass();
point.PutCoords(-200, 10); // Equivalent to 160 degrees EAST
point.SpatialReference = WGS84;
pointCollection.AddPoint(point);
// -----------------------------------------------------------------------
IPolyline polyline = (IPolyline)pointCollection;
polyline.SpatialReference = WGS84;
var geometryDefEdit = (IGeometryDefEdit)new GeometryDef();
geometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolyline;
geometryDefEdit.SpatialReference_2 = WGS84;
var field = (IFieldEdit)new Field();
field.Name_2 = "Shape";
field.Type_2 = esriFieldType.esriFieldTypeGeometry;
field.GeometryDef_2 = geometryDefEdit;
var fields = (IFieldsEdit)new Fields();
fields.AddField(field);
IWorkspaceFactory workspaceFactory = new ShapefileWorkspaceFactory();
var featureWorkspace = (IFeatureWorkspace)workspaceFactory.OpenFromFile("C:\\Temp\\", 0);
IFeatureClass featureClass = featureWorkspace.CreateFeatureClass
("test3.shp", fields, null, null, esriFeatureType.esriFTSimple, "Shape", "");
var feature = featureClass.CreateFeature();
feature.Shape = polyline;
feature.Store();
ArcMap.Application.CurrentTool = null;
}
示例7: TestGetGridReferenceCorrectValues
public void TestGetGridReferenceCorrectValues(double x, double y, string sRef, string expectedRes)
{
BindRunTime();
IPoint testPoint = new PointClass();
testPoint.PutCoords(x, y);
if (sRef == "BNG")
testPoint.SpatialReference = bngSRef;
else
testPoint.SpatialReference = wgs84SRef;
BNG_Locator bng = new BNG_Locator();
IPropertySet results = bng.ReverseGeocode(testPoint, false);
object obj = results.GetProperty("BNG");
Assert.IsTrue(obj.ToString() == expectedRes);
}
示例8: CreateBalloonCalloutForFeature
/// <summary>
/// Creates a Balloon Callout with the given text and background color for the given feature.
/// </summary>
/// <param name="feature">The feature for which to create the callout.</param>
/// <param name="displayText">The text to display.</param>
/// <param name="bgColor">The background color of the callout</param>
/// <returns>Returns an element with a callout symbol.</returns>
public static IElement CreateBalloonCalloutForFeature(IFeature feature, string displayText, string bgColor)
{
ITextElement element = new TextElementClass();
if (feature != null)
{
IPoint anchor = new PointClass();
try
{
if (feature.Shape.GeometryType == esriGeometryType.esriGeometryPolyline)
((IPolyline)feature.ShapeCopy).QueryPoint(esriSegmentExtension.esriNoExtension, .5, true, anchor);
else if (feature.Shape.GeometryType == esriGeometryType.esriGeometryPoint)
anchor.PutCoords(feature.ShapeCopy.Envelope.XMax, feature.ShapeCopy.Envelope.YMax);
}
catch (Exception ex)
{
// _logger.LogException(ex, "There was an error getting the shape from the feature.");
anchor = null;
}
if (anchor != null || !anchor.IsEmpty)
{
IBalloonCallout balloon = new BalloonCalloutClass();
balloon.AnchorPoint = anchor;
balloon.LeaderTolerance = .5;
balloon.Style = esriBalloonCalloutStyle.esriBCSRoundedRectangle;
balloon.Symbol = GenerateGenericFillSymbol(bgColor, esriSimpleFillStyle.esriSFSSolid);
IFormattedTextSymbol txtSym = new TextSymbolClass();
txtSym.Background = balloon as ITextBackground;
txtSym.Size = 10;
if (string.IsNullOrEmpty(displayText))
displayText = feature.OID.ToString();
((IElement)element).Geometry = feature.ShapeCopy;//offSet;
element.Text = displayText;
element.Symbol = txtSym;
}
}
return element as IElement;
}
示例9: axMapControl1_OnMouseDown
private void axMapControl1_OnMouseDown(object sender, IMapControlEvents2_OnMouseDownEvent e)
{
double xpoint = e.mapX;
double ypoint = e.mapY;
IPoint point = new PointClass();
point.PutCoords(xpoint, ypoint);
IWorkspaceFactory wsf = new FileGDBWorkspaceFactory();
IFeatureWorkspace ws = wsf.OpenFromFile(@"\\alexn\TestGDB\Feature.gdb", 0) as IFeatureWorkspace;
IGeoDataset pointfc = ws.OpenFeatureClass(@"Points") as IGeoDataset;
point.SpatialReference = pointfc.SpatialReference;
//IGeometry point2 = point as IGeometry;
IFeatureClass pointfc2 = pointfc as IFeatureClass;
IFeature pointfc3 = pointfc2.CreateFeature();
IFeatureCursor pointFC = pointfc2.Insert(true);
IFeatureBuffer fbuffer = pointfc2.CreateFeatureBuffer();
fbuffer.Shape = point;
pointFC.InsertFeature(fbuffer);
IActiveView display = axMapControl1.ActiveView;
display.Activate(0);
display.Refresh();
}
示例10: GeoToGra
//将任意坐标系统转换为自定义Albers大地坐标(米)
public static IPoint GeoToGra(IPoint point)
{
IPoint pt = new PointClass();
pt.PutCoords(point.X, point.Y);
ISpatialReferenceFactory2 pFact = new SpatialReferenceEnvironmentClass();
//定义地理坐标,由输入的对象决定,也可以自己定义,参考: esriSRGeoCSType
IGeographicCoordinateSystem pGCS = new GeographicCoordinateSystemClass();
pGCS = pFact.CreateGeographicCoordinateSystem(point.SpatialReference.FactoryCode);
//自定义投影方式
IProjectedCoordinateSystem pProjectedCS = new ProjectedCoordinateSystemClass();
IProjectedCoordinateSystemEdit pProjectedCSEdit = pProjectedCS as IProjectedCoordinateSystemEdit;
//定义投影方式,参考: esriSRProjectionType
IProjection pProjection = new ProjectionClass();
pProjection = pFact.CreateProjection((int)esriSRProjectionType.esriSRProjection_Albers);
//定义投影单位,参考:esriSRUnitType
ILinearUnit pUnit = new LinearUnitClass();
pUnit = pFact.CreateUnit((int)esriSRUnitType.esriSRUnit_Meter) as ILinearUnit;
//定义其他参数,参考:esriSRParameterType
IParameter[] pParm = new IParameter[6];
pParm[0] = pFact.CreateParameter((int)esriSRParameterType.esriSRParameter_FalseEasting);
pParm[0].Value = 0;
pParm[1] = pFact.CreateParameter((int)esriSRParameterType.esriSRParameter_FalseNorthing);
pParm[1].Value = 0;
pParm[2] = pFact.CreateParameter((int)esriSRParameterType.esriSRParameter_CentralMeridian);
pParm[2].Value = 110;
pParm[3] = pFact.CreateParameter((int)esriSRParameterType.esriSRParameter_StandardParallel1);
pParm[3].Value = 25;
pParm[4] = pFact.CreateParameter((int)esriSRParameterType.esriSRParameter_StandardParallel2);
pParm[4].Value = 47;
pParm[5] = pFact.CreateParameter((int)esriSRParameterType.esriSRParameter_LatitudeOfOrigin);
pParm[5].Value = 0;
//设置投影相关信息
object name = "User_Defined_Albers";
object alias = "Albers";
object abbreviation = "Albers";
object remarks = "User_Defined_Albers is the projection";
object usage = "";
object gcs = pGCS;
object projectedUnit = pUnit;
object projection = pProjection;
object parameters = pParm;
pProjectedCSEdit.Define(ref name, ref alias, ref abbreviation, ref remarks, ref usage, ref gcs, ref projectedUnit, ref projection, ref parameters);
//获取自定义空间参考
ISpatialReference pSpatialRef = pProjectedCS as ISpatialReference;
IGeometry pGeometry = (IGeometry)pt;
pGeometry.SpatialReference = pGCS as ISpatialReference;
//重投影处理
pGeometry.Project(pSpatialRef);
return pt;
}
示例11: ZoomToPointAnimation
public static void ZoomToPointAnimation(AxGlobeControl axGlobeControl, double MapX, double MapY)
{
try
{
IPoint point = new PointClass();
point.PutCoords(MapX, MapY); //设置点击的点坐标
//动画缩放到
IAnimationTrack animaTrack = CreateZoomOverLocationAnimation(axGlobeControl.GlobeDisplay, MapX, MapY, 1000);
animaTrack.IsEnabled = true;
IAnimationTracks pTracks = axGlobeControl.Globe as IAnimationTracks;
//for (int i = 0; i < pTracks.TrackCount; i++)
//{
// IAnimationTrack pTrack = pTracks.Tracks.get_Element(i) as
// IAnimationTrack;
// pTrack.IsEnabled = true;//设置为true 才可以播放这条轨迹
//}
DateTime startTime = DateTime.Now;
TimeSpan timeSpan;
double elapsedTime;
double duration = 7;
bool play = true;
do
{
timeSpan = (DateTime.Now).Subtract(startTime);
elapsedTime = timeSpan.TotalSeconds;
if (elapsedTime > duration)
{
play = false;
elapsedTime = duration;
}
pTracks.ApplyTracks(axGlobeControl.Globe.GlobeDisplay.ActiveViewer, elapsedTime, duration);
axGlobeControl.Globe.GlobeDisplay.RefreshViewers();
} while (play);
#region //无动画方式
//point = CommonBaseTool.BaseGISTools.getGeoPoint(MapX, MapY); //转换坐标
//IPoint ptObserver = new PointClass();
//IPoint ptTarget = new PointClass();
////Observer点
//IClone pClone1 = point as IClone;
//ptObserver = pClone1.Clone() as IPoint;
//ptObserver.Y = ptObserver.Y - 0.08;
//ptObserver.Z = 15.45;
////Target点
//IClone pClone2 = point as IClone;
//ptTarget = pClone2.Clone() as IPoint;
//ptTarget.Z = -0.01;
//axGlobeControl.GlobeCamera.SetObserverLatLonAlt(ptObserver.Y, ptObserver.X, ptObserver.Z);
//axGlobeControl.GlobeCamera.SetTargetLatLonAlt(ptTarget.Y, ptTarget.X, ptTarget.Z);
#endregion
//刷新
axGlobeControl.GlobeDisplay.RefreshViewers();
}
catch { }
}
示例12: GetGeoHashPoly
/// <summary>
/// The get geo hash poly.
/// </summary>
/// <param name="geohash">
/// The geo hash.
/// </param>
/// <returns>
/// The <see cref="Polygon" />.
/// </returns>
private Polygon GetGeoHashPoly(string geohash)
{
var coords = Jarvis.DecodeBbox(geohash);
IPoint pt1 = new PointClass();
pt1.PutCoords(coords[1], coords[2]);
IPoint pt2 = new PointClass();
pt2.PutCoords(coords[3], coords[2]);
IPoint pt3 = new PointClass();
pt3.PutCoords(coords[3], coords[0]);
IPoint pt4 = new PointClass();
pt4.PutCoords(coords[1], coords[0]);
Polygon poly = new PolygonClass();
poly.AddPoint(pt1);
poly.AddPoint(pt2);
poly.AddPoint(pt3);
poly.AddPoint(pt4);
poly.AddPoint(pt1);
return poly;
}
示例13: CreateFeature
/// <summary>
/// ������ʵ��
/// </summary>
/// <param name="pITable">���ݱ����</param>
/// <param name="entinyNode">VCT�ռ�ʵ��ڵ�</param>
public override void CreateFeature(ITable pITable, EntityNode entinyNode)
{
try
{
IFeatureClass pFeatureCls = pITable as IFeatureClass;
this.Feature = pFeatureCls.CreateFeature();
LineNode pLineNode = entinyNode as LineNode;
if (pLineNode != null)
{
///��ʶ�븳ֵ
int dBSMIndex = -1;
dBSMIndex = this.Feature.Fields.FindField(m_strEntityIDFiled);
if (dBSMIndex != -1)
this.Feature.set_Value(dBSMIndex, pLineNode.EntityID);
///Ҫ�ش��븳ֵ
int dSYDMIndex = -1;
dSYDMIndex = this.Feature.Fields.FindField(m_strYSDMField);
if (dSYDMIndex != -1)
this.Feature.set_Value(dSYDMIndex, pLineNode.FeatureCode);
///�����ռ�����
int dLineNodeCount = pLineNode.SegmentNodes.Count;
IPointCollection pointCollection = new PolylineClass();
for (int i = 0; i < dLineNodeCount; i++)
{
//11��ʾ��������
if (Metadata.MetaDataFile.GraphConfig.GetGraphMark("LINETYPE", pLineNode.SegmentNodes[i].SegmentType.ToString()) == "BrokenLine")
{
BrokenLineNode pBLine = pLineNode.SegmentNodes[i] as BrokenLineNode;
foreach (PointInfoNode pPointInfoNode in pBLine.PointInfoNodes)
{
IPoint pPoint = new PointClass();
pPoint.PutCoords(pPointInfoNode.X, pPointInfoNode.Y);
object objType = Type.Missing;
pointCollection.AddPoint(pPoint, ref objType, ref objType);
}
}
else
{
//�������ʹ�������չ
}
}
(this.Feature as IFeature).Shape = pointCollection as IGeometry;
//feature.set_Value();
this.Feature.Store();
}
}
catch(Exception ex)
{
Logger.WriteErrorLog(ex);
}
}
示例14: createAoPoint
static IPoint createAoPoint(double x, double y)
{
IPoint retVal = new PointClass();
retVal.PutCoords(x, y);
return retVal;
}
示例15: DrawLegend
private void DrawLegend(IEnvelope Envelope)
{
// BOX DIMENSIONS AND UNIFORM SYMBOL ITEMS
double BoxX = 0.4; //Width
double BoxY = 0.3; //Height
double Text2BoxY= 0.2; //Y distance between the bottom of text and the next box
double Text2BoxX = 0.1; //X distance between a box and the text that describes it
double ColumnX = 0.5; //Space between columns
// Setup a black color object, black outline
IRgbColor BlackInsides = new ESRI.ArcGIS.Display.RgbColorClass();
BlackInsides.Blue = 0;
BlackInsides.Red = 0;
BlackInsides.Green = 0;
ILineSymbol BlackOutsides = new SimpleLineSymbolClass();
BlackOutsides.Width = 1;
BlackOutsides.Color = BlackInsides;
// Whole bunch of variables to use while going through the loop below...
#region Variables Galore!!!
IMxDocument Doc = ArcMap.Document;
IPageLayout pageLayout = Doc.ActiveView as IPageLayout;
IGraphicsContainer GraphicsContainer = pageLayout as IGraphicsContainer;
double Xcoord, Ycoord;
Xcoord = Envelope.XMin;
Ycoord = Envelope.YMax;
double IndentTerm = 0;
IPoint Point = null;
double StringLength = 0;
string LegendText = "";
string ItemName = "";
string ItemDesc = "";
IElement Ele = null;
IEnvelope TempEnv = null;
IRgbColor BoxColr = null;
ISimpleFillSymbol FillSym = new ESRI.ArcGIS.Display.SimpleFillSymbolClass();
IFillShapeElement FillEle = null;
IEnvelope FillEnv = new EnvelopeClass();
WKSEnvelope Patch = new WKSEnvelope();
IGeometry Geo = null;
string LabelText = "";
ESRI.ArcGIS.Geometry.IPoint LabelPoint = new ESRI.ArcGIS.Geometry.PointClass();
#endregion
// Get a reference to the DescriptionOfMapUnits entries
var sortedDmuEntries = GetDmuSortedByHierarchy();
// Loop through legend records
foreach (KeyValuePair<string, DescriptionOfMapUnitsAccess.DescriptionOfMapUnit> aDictionaryEntry in sortedDmuEntries)
{
// Grab the DMU entry itself
DescriptionOfMapUnitsAccess.DescriptionOfMapUnit aDescription = aDictionaryEntry.Value;
bool isHeading = (aDescription.ParagraphStyle.Contains("Heading"));
// Find out how far to indent the legend item
// Strip periods from the HierarchyKey, divide by 4, which is the length of a segment of the key
IndentTerm = aDescription.HierarchyKey.Replace(".", "").Length / 4;
// Get the coordinates of the text for the legend entry - upper left corner
// Xcoord starts at Envelope.XMin, Ycoord is Envelope.YMax: Upper left corner
Point = new PointClass();
double xAdditions = 0;
if (isHeading)
{
// Xcoord plus (indentation), Ycoord
xAdditions = 0.2 * (IndentTerm - 1);
}
else
{
//Xcoord plus (indentation) + (Box width and margin), Ycoord
xAdditions = 0.2 * (IndentTerm - 1) + BoxX + Text2BoxX;
}
Point.PutCoords(Xcoord + xAdditions, Ycoord);
// StringLength is the width remaining in the envelope in which the text has to fit IN PIXELS.
StringLength = 72 * (Envelope.Width - xAdditions);
// Fix a couple of special characters in the legend string.
// Then amalgamate item name and description
ItemName = FixLegendTextCharacters(aDescription.Name);
if (!isHeading)
{
LegendText = ItemName + " - " + FixLegendTextCharacters(aDescription.Description);
}
else
{
LegendText = ItemName;
}
// Format the legend text if it is not a heading. If it is, we're fine.
if (!isHeading)
{
LegendText = GetFormattedString(LegendText, "Arial", 8, StringLength, 8);
}
// Boldify the ItemName
LegendText = LegendText.Replace(ItemName, "<bol>" + ItemName + "</bol>");
// See if this legend item should be placed on a new column
//.........这里部分代码省略.........