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 interfaces used by some common GIS functions, including spatial topology operations, Spatial Relational operations, and spatial proximity operations. 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 must be used, using these interfaces can greatly improve developers' development 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 generate new combined objects by performing spatial topology operations on existing geometric objects. Classes that implement this interface include point, multipoint, polyline, polygon, and multipatch, which are all high-level geometric objects. In addition, geometrybag also implements this interface. Low-Level geometric objects such as segments (line, circular Arc, elliptic arc, bezercurve), paths, or rings. 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 two parts: left and right, the right part is relative to the direction of the curve. Point and multi-point cannot be cut. polyline and polygon can run the cut method only when they are intersection with the cut curve, for example:

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, remove all overlapping points from a pointcollection object. For segmentcollection, remove all overlapping lines, and the intersection lines will become non-intersecting lines (that is, generate a vertex at the intersection ); all overlapping rings of polygon 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 irelationaloperator interface introduction there are some associations between geometric objects, such as include, equal, internal, intersection, and superposition. These associations can be obtained through the irelationaloperator interface. relational operations are performed between two geometric objects, the irelationaloperator method returns a Boolean value to indicate whether the two geometric objects have such a relationship. All the classes that support itopologicaloperator geometric objects also implement the irelationaloperator interface, including the envelope object, which means that the envelope of the two geometric objects can also 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 obtain the point closest to the given point on the other. The main methods of the iproximityoperator interface are: 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.