Query the Feature Source for Intersections

Land Desktop Map 3D Samples

 
Query the Feature Source for Intersections
 
 
 

This method takes ten arguments:

  1. an MgFeatureService object
  2. an MgResourceIdentifier object (identifies the feature source)
  3. a qualified class name (used to identify the desired features)
  4. a geometry property name (used to extract the geometry properties from the selected features)
  5. an MgFeatureQueryOptions object (this has an operational effect on feature selection when a limit on the number of intersections to be found has been set)
  6. a limit (either 0 indicating find all intersections or a positive integer indicating when to stop looking for intersections)
  7. a list of visited points (this is initially empty; the function adds points to it)
  8. an identity property value (initially 1; the function increments it)
  9. an MgBatchPropertyCollection object (the function adds MgPropertyCollection objects to it)
  10. a tolerance

It does the following:

  1. Uses the MgFeatureService , MgResourceIdentifier, and MgFeatureQueryOptions arguments and the qualifed feature class name to get an MgFeatureReader object containing the features from the feature source.
  2. Loops through the features in the MgFeatureReader object using the default geometry property name to extract the geometry property and using the MgAgfReaderWriter object to create an MgLineString object from the geometry property, filtering out any geometry that is not an MgLineString. Tests the start and end points of the MgLineString ojbect and adds them to the end points list if they are unique. The test is described in the topic Point Exists.
  3. Loops through the list of end points, using the tolerance value to create a bounding box around each one and then doing an EnvelopeIntersects operation on the end point bounding box and each of the feature geometries in the layer to get an intersection count. The foregoing involves the use of the MgCoordinateCollection, MgGeometryFactory, MgPolygon, MgFeatureQueryOptions, MgFeatureReader, MgFeatureService, and MgResourceIdentifier classes. If the EnvelopeIntersects operation yields more than two intersections, the end point, the intersection count, and an identity number are turned into properties and added to an MgPropertyCollection object, and the latter is added to the MgBatchPropertyCollection object that represents all of the qualifying intersection points.
  4. Determine that there is no limit on the number of intersections to be found and continue processing or that there is a limit, the limit has been reached and stop processing the list of end points.
  5. Return the number of features processed. The MgBatchPropertyCollection object contains all of the intersection features.