以下为引用的内容: public IPolyline TestGeometryEnvironment() { CHINAZ ISpatialReferenceFactory spatialReferenceFactory =new SpatialReferenceEnvironmentClass(); //Create a projected coordinate system and define its domain, resolution, and x,y tolerance. ISpatialReferenceResolution spatialReferenceResolution = spatialReferenceFactory.CreateProjectedCoordinateSystem((int)esriSRProjCSType.esriSRProjCS_NAD1983UTM_11N) as ISpatialReferenceResolution; CHINAZ spatialReferenceResolution.ConstructFromHorizon(); ISpatialReferenceTolerance spatialReferenceTolerance = spatialReferenceResolution as ISpatialReferenceTolerance; spatialReferenceTolerance.SetDefaultXYTolerance(); ISpatialReference spatialReference = spatialReferenceResolution as ISpatialReference;
CHINAZ
//Create an array of WKSPoint structures starting in the middle of the x,y domain of the //projected coordinate system. double xMin; double xMax;
CHINAZ
double yMin; double yMax; spatialReference.GetDomain(out xMin, out xMax, out yMin, out yMax); double xFactor = (xMin + xMax) *0.5; CHINAZ double yFactor = (yMin + yMax) *0.5; WKSPoint[] wksPoints =new WKSPoint[10]; for (int i =0; i < wksPoints.Length; i++) CHINAZ { CHINAZ wksPoints[i].X = xFactor + i; wksPoints[i].Y = yFactor + i; } IPointCollection4 pointCollection =new PolylineClass();
//Set the properties of the spatial filter here. IGeometry geometryBag =new GeometryBagClass(); //Define the spatial reference of the bag before adding geometries to it.
CHINAZ
geometryBag.SpatialReference = geoDataset.SpatialReference; //Use a nonrecycling cursor so each returned geometry is a separate object. IFeatureCursor featureCursor = featureClass.Search(queryFilter, false);
CHINAZ
IGeometryCollection geometryCollection = geometryBag as IGeometryCollection; IFeature currentFeature = featureCursor.NextFeature(); while (currentFeature !=null) CHINAZ { CHINAZ //Add a reference to this feature's geometry into the bag. //You don't specify the before or after geometry (missing), //so the currentFeature.Shape IGeometry is added to the end of the geometryCollection. object missing = Type.Missing; CHINAZ geometryCollection.AddGeometry(currentFeature.Shape, ref missing, ref missing); currentFeature = featureCursor.NextFeature(); } // Create the polygon that will be the union of the features returned from the search cursor. CHINAZ // The spatial reference of this feature does not need to be set ahead of time. The // ConstructUnion method defines the constructed polygon's spatial reference to be the same as // the input geometry bag. ITopologicalOperator unionedPolygon =new PolygonClass();
CHINAZ
unionedPolygon.ConstructUnion(geometryBag as IEnumGeometry); return unionedPolygon as IPolygon; }
以下为引用的内容: public IPolyline ConstructMultiPartPolyline(IPolyline inputPolyline) {
CHINAZ
IGeometry outGeometry =new PolylineClass(); //Always associate new, top-level geometries with an appropriate spatial reference. outGeometry.SpatialReference = inputPolyline.SpatialReference;
CHINAZ
IGeometryCollection geometryCollection = outGeometry as IGeometryCollection; ISegmentCollection segmentCollection = inputPolyline as ISegmentCollection; //Iterate over existing polyline segments using a segment enumerator. CHINAZ IEnumSegment segments = segmentCollection.EnumSegments; ISegment currentSegment; int partIndex =0;; int segmentIndex =0;;
ILine normal =new LineClass(); //Geometry methods with _Query_ in their name expect to modify existing geometries. //In this case, the QueryNormal method modifies an existing line //segment (normal) to be the normal vector to
CHINAZ
//currentSegment at the specified location along currentSegment. currentSegment.QueryNormal(esriSegmentExtension.esriNoExtension, 0.5, true, currentSegment.Length /3, normal); //Since each normal vector is not connected to others, create a new path for each one. CHINAZ ISegmentCollection newPath =new PathClass(); object missing = Type.Missing; newPath.AddSegment(normal as ISegment, ref missing, ref missing); CHINAZ //The spatial reference associated with geometryCollection will be assigned to all incoming paths and segments. geometryCollection.AddGeometry(newPath as IGeometry, ref missing, ref missing); segments.Next(out currentSegment,ref partIndex, ref segmentIndex); CHINAZ } //The geometryCollection now contains the new, multipart polyline. return geometryCollection as IPolyline; }