ArcGIS Engine basic development tutorial (6) -- Learning Space Analysis

Source: Internet
Author: User
Tags polyline ipoint

Reprinted from: http://bbs.esrichina-bj.cn/ESRI/thread-48168-1-1.html

Spatial analysis is one of the main functions of GIS. This chapter will introduce the space topology operations, spatial relationship operations, and spatial proximity operations that are commonly used in GIS development.
Port. For example, to develop a buffer analysis function, obtain the shortest distance between two geometric elements, and determine the topological relationship between the two geometric elements, these interfaces need to be used. Using these interfaces can greatly improve developers' open
Sending efficiency.
1.1 Goals
1. Familiar with the use of the ITopologicalOperator interface (for space topology operations)
2. Familiar with the use of the IRelationalOperator interface (for Spatial Join Operations)
3. Familiar with IProximityOperator interface (for space distance calculation)
1.2 preparations
1. IDE: Visual maxcompute 2005/2008
2. ArcGIS Engine Developer kit 9.3

1.1 ITopologicalOperator interface 1.1.1
Introduction to ITopologicalOperator interface the ITopologicalOperator interface is used to create a new knot by performing spatial topology operations on existing geometric objects.
Object. Classes that implement this interface include Point, Multipoint, Polyline, Polygon, and MultiPatch, which are high-level geometric objects.
GeometryBag also implements this interface. Low-level building geometric objects such as Segments (Line, Circular Arc, Elliptic
If you want to use this interface, you need to wrap it into an advanced geometric object.

The ITopologicalOperator interface is widely used in GIS development. This interface is usually used in GIS system for buffer analysis, geometric cropping, differential geometric operations, and geometric image merging operations. The following table describes the main methods of the ITopologicalOperator interface:

 

Method Name Description
Boundary Border of a geometric object
Buffer Perform a buffer space topology operation on a geometric object
Clip Crop a space topology for a geometric object
ConstructUnion Efficiently Merge multiple enumerated geometric objects and a single geometric object into a single geometric object, which is very efficient for the combination of a large number of geometric objects
ConvexHull Constructing convex edges of geometric objects
Cut Cutting geometric objects
Difference The part of a ry minus the intersection of the other ry.
Intersect Intersection of two geometric objects in the same dimension
Simplify Make the topology of the geometric object consistent
SymmetricDifference Symmetric Difference: subtract the intersection of two geometries from the union of the two geometries.
Union Merges two geometric objects in the same dimension into a single geometric object.

1. Boundary attributes

The Boundary of a Polygon geometric object is a Polyline geometric object.

[Boundary is the Point geometric object that makes up Polyline.

The Boundary of the Point geometric object is an empty object, as shown in:

Download
(20.15 KB)

2. Buffer method:

The Buffer method can generate a Buffer for an advanced geometric object. Both Polygon, Polyline, and Point are area-specific geometric objects, as shown in:

Download
(11.73 KB)

3. Clip method

The Clip method can crop a geometric object with an Envelope object. For details, refer to the section where the geometric object is surrounded by an Envelope object:

Download
(16.11 KB)

4. ConvexHull Method

The ConvexHull method can generate the smallest border convex polygon of A ry (no concave surface contains the smallest polygon of the ry)

Download
(11.54 KB)

5. Cut Method

The Cut method does not support GeometryBags ry objects. It can specify a cutting curve and a ry,
After the cutting operation, the ry is divided into the left and right parts. The right two parts are relative to the direction of the curve. Point and multi-point cannot be cut, and Polyline and Polygon must be intersection with the cut curve.
To run the Cut method, such:

Download
(10.03 KB)

6. Difference Method

The Difference method is used to generate the Difference set of two geometric objects. :

Download
(10.61 KB)

7. both the Union method and ConstructUnion method are used to merge geometric objects. The difference is that the former merges two geometric objects in the same dimension into a single geometric object, the latter is efficient combination of multiple enumerated geometric objects and a single geometric object into a single geometric object, which is very efficient for the combination of a large number of geometric objects.

Download
(5.69 KB)

8. Intersect method

The Intersect method is used to return the intersection of two geometric objects in the same dimension, that is, the overlapping part of the two geometric objects. As shown in:

Download
(8.04 KB)

9. SymetricDifference Method

The SymetricDifference method is used to generate symmetric differences between two geometries, that is, the Union part of the two ry minus the intersection part of the two ry, as shown in:

Download
(12.38 KB)

10. IsSimple attribute and Simplify method

The IsSimple attribute is used to check whether the ry object is a simplified ry object. The Simplify method is used to Simplify the ry object so that the ry object topology is correct. As shown in:

Download
(50.01 KB)

 

Image001.png
(20.15 KB)

Downloads: 4

Image003.png
(11.73 KB)

Downloads: 3

Image005.png
(16.11 KB)

Downloads: 3

Image007.png
(11.54 KB)

Downloads: 1

Image009.png
(10.03 KB)

Downloads: 3

Image011.png
(10.61 KB)

Downloads: 3

Image013.png
(5.69 KB)

Downloads: 6

Image015.png
(8.04 KB)

Downloads: 4

6.3.2 simplified geometric object feature development

 
During the development of geometric object space analysis, the operated geometric object must be a simplified geometric object. The following code snippet demonstrates how to make a geometric object topology consistent, for example, in
Remove all overlapping points from the PointCollection object. For segmentCollection, remove all overlapping lines.
Generate a vertex at the intersection). For Polygon, all intersecting rings will be removed, and unclosed rings will be closed.

 

  1. /// <Summary>
  2. /// Simplified the geometric object
  3. /// </Summary>
  4. /// <Param name = "pGeometry"> geometric object </param>
  5. Private void SimplifyGeometry (IGeometry pGeometry)
  6. {
  7. Try
  8. {
  9. ITopologicalOperator pTopOperator = pGeometry as ITopologicalOperator;
  10. If (pTopOperator! = Null)
  11. {
  12. If (! (PTopOperator. IsKnownSimple ))
  13. {
  14. If (! (PTopOperator. IsSimple ))
  15. {
  16. PTopOperator. Simplify ();
  17. }
  18. }
  19. }
  20. }
  21. Catch (Exception Err)
  22. {
  23. MessageBox. Show (Err. Message, "prompt", MessageBoxButtons. OK, MessageBoxIcon. Information );
  24. }
  25. }

Copy code

6.4 IRelationalOperator Interface

6.4.1
The IRelationalOperator interface describes some associations between geometric objects, such as inclusion, equality, inner, intersection, and superposition. The links can be obtained through
The IRelationalOperator interface is obtained. relational operations are performed between two geometric objects. One method of IRelationalOperator is returned.
Boolean value to indicate whether the two geometric objects have such a relationship. All ry objects that support ITopologicaloperator are also implemented
IRelationalOperator interface, including the Envelope object, which means that the Envelope of the two geometric objects can be checked for the association relationship.

 

Method Name Description
Contains Check whether two geometric figures 1 contain ry 2
Crosses Used to detect the intersection of two Geometries
Equal Used to check whether two geometries are equal
Touches Used to check whether two geometries are connected
Disjoint Used to check whether two geometries do not Intersection
Overlaps Used to check whether two geometries overlap
Relation Used to check whether a definition of relationship exists
Within Check whether two geometric figures 1 are included in ry 2

6.4.2 ry object inclusion Function Development the following code snippet demonstrates how to determine whether ry A contains ry B:

 

  1. /// <Summary>
  2. /// Check whether ry A contains ry B
  3. /// </Summary>
  4. /// <Param name = "pGeometryA"> ry A </param>
  5. /// <Param name = "pGeometryB"> ry B </param>
  6. /// <Returns> True is included, False is not included </returns>
  7. Private bool CheckGeometryContain (IGeometry pGeometryA, IGeometry pGeometryB)
  8. {
  9. IRelationalOperator pRelOperator = pGeometryA as IRelationalOperator;
  10. If (pRelOperator. Contains (pGeometryB ))
  11. {
  12. Return true;
  13. }
  14. Else
  15. {
  16. Return false;
  17. }
  18. }

Copy code

6.5 IProximityOperator Interface

6.5.1 IProximityOperator Interface

The IProximityOperator interface is used to obtain the distance between two geometries and
Point to find the Point closest to the given Point on another ry. Main method of IProximityOperator Interface
Yes: QueryNearesPoint, ReturnDistance, ReturnNearestPoint

The ReturnDistance method is used to return the shortest distance between two geometric objects. The QueryNearesPoint method is used to query the reference of the point closest to the given input point on the geometric object, the ReturnNearestPoint method is used to create and return the point closest to the given input point on the geometric object.

6.5.2 development of the latest point query function

The following code snippet demonstrates how to use the IProximityOperator interface to obtain the closest point of the fixed point and the ry to be queried:

 

  1. /// Return a point closest to pInputPoint on pGeometry

  2. /// </Summary>
  3. /// <Param name = "pInputPoint"> specified vertex object </param>
  4. /// <Param name = "pGeometry"> ry </param>
  5. /// <Returns> the nearest Point </returns>
  6. Private IPoint NearestPoint (IPoint pInputPoint, IGeometry pGeometry)
  7. {
  8. Try
  9. {
  10. IProximityOperator pProximity = (IProximityOperator) pGeometry;
  11. IPoint pNearestPoint = pProximity. ReturnNearestPoint (pInputPoint, esriSegmentExtension. esriNoExtension );
  12. Return pNearestPoint;
  13. }
  14. Catch (Exception Err)
  15. {
  16. MessageBox. Show (Err. Message, "prompt", MessageBoxButtons. OK, MessageBoxIcon. Information );
  17. Return null;
  18. }
  19. }

Copy code

The following code snippet demonstrates how to use the IProximityOperator interface to query the distance between two given geometric objects:

 

  1. /// <Summary>

  2. /// Obtain the distance between two Geometries
  3. /// </Summary>
  4. /// <Param name = "pGeometryA"> ry A </param>
  5. /// <Param name = "pGeometryB"> ry B </param>
  6. /// <Returns> distance between two geometries </returns>
  7. Private double GetTwoGeometryDistance (IGeometry pGeometryA, IGeometry pGeometryB)
  8. {
  9. IProximityOperator pProOperator = pGeometryA as IProximityOperator;
  10. If (pGeometryA! = Null | pGeometryB! = Null)
  11. {
  12. Double distance = pProOperator. ReturnDistance (pGeometryB );
  13. Return distance;
  14. }
  15. Else
  16. {
  17. Return 0;
  18. }
  19. }

Copy code

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.