ArcGIS engine two development--calculate the area of Shapefile surface layer elements http://blog.csdn.net/giselite/article/details/44750349
All should learn to see AE class diagram and help, especially class diagram, in the installation directory under the diagram directory, see more natural will be handy. No more nonsense, here is a trial code I wrote
, announced, hope to help those who have the needs of children's shoes, to give them some time to save.
Using System.Runtime;
Using System.Runtime.InteropServices;
Using ESRI. Arcgis.geodatabase;
Using ESRI. Arcgis.datasourcesfile;
Using ESRI. Arcgis.geometry;
private void Form1_Click (object sender, EventArgs e)
{
Iworkspacefactory pwsf = null;
Double Darea = 0;
Try
{
Pwsf = new Shapefileworkspacefactoryclass ();
Ifeatureworkspace PWS = Pwsf.openfromfile (@ "h:\ water flooded area", 0) as Ifeatureworkspace;
Ifeatureclass PFC = Pws.openfeatureclass ("topic of water submerged area; shp");
Introduction to 6.5.1 Iproximityoperator interface
The Iproximityoperator interface is used to get the distance of two geometries, and given a point, to find the nearest spot on the other geometry from the given point. The main Iproximityoperator interface
The methods are: Querynearespoint,returndistance, Returnnearestpoint
The Returndistance method is used to return the shortest distance between two geometric objects, and the Querynearespoint method is used to query for a reference to the point where the nearest distance from the given input point is obtained on the geometric object.
The Returnnearestpoint method is used to create and return the point of the closest distance from a given input point on a geometric object.
6.5.2 Recent point Query function development
The following code fragment demonstrates how to use the Iproximityoperator interface to get the closest point to the geometry to be queried:
Returns a point from the nearest pinputpoint on the Pgeometry
</summary>
<param name= "Pinputpoint" > Given point object </param>
<param name= "Pgeometry" > Geometry to Query </param>
<returns>the Nearest Point</returns>
Private IPoint Nearestpoint (IPoint pinputpoint, Igeometry pgeometry)
{
Try
{
Iproximityoperator pproximity = (iproximityoperator) pgeometry;
IPoint pnearestpoint = Pproximity.returnnearestpoint (Pinputpoint, esrisegmentextension.esrinoextension);
return pnearestpoint;
}
catch (Exception ERR)
{
MessageBox.Show (err.message, "hint", MessageBoxButtons.OK, MessageBoxIcon.Information);
return null;
}
}
Copy Code
The following code fragment demonstrates how to use the Iproximityoperator interface to query the distance of a given two geometric objects:
<summary>
Gets the distance of two geometries
</summary>
<param name= "Pgeometrya" > Geometry a</param>
<param name= "Pgeometryb" > Geometry b</param>
<returns> Two geometry distance </returns>
Private double Gettwogeometrydistance (igeometry Pgeometrya, Igeometry pgeometryb)
{
Iproximityoperator pprooperator = Pgeometrya as Iproximityoperator;
if (pgeometrya!=null| | Pgeometryb!=null)
{
Double distance= pprooperator.returndistance (PGEOMETRYB);
return distance;
}
Else
{
return 0;
}
}
========
Spatial relationship (calculate distance between two points, calculation range) http://xitong.iteye.com/blog/1715755
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.