本文整理汇总了C#中FeatureLayer.GetTable方法的典型用法代码示例。如果您正苦于以下问题:C# FeatureLayer.GetTable方法的具体用法?C# FeatureLayer.GetTable怎么用?C# FeatureLayer.GetTable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FeatureLayer
的用法示例。
在下文中一共展示了FeatureLayer.GetTable方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: constructSamplePolylines
/// <summary>
/// Create sample polyline feature using the geometries from the point feature layer.
/// </summary>
/// <param name="polylineLayer">Polyline geometry feature layer used to add the new features.</param>
/// <param name="pointLayer">The geometries from the point layer are used as vertices for the new line features.</param>
/// <returns></returns>
private Task<bool> constructSamplePolylines(FeatureLayer polylineLayer, FeatureLayer pointLayer)
{
// execute the fine grained API calls on the CIM main thread
return QueuedTask.Run(() =>
{
// get the underlying feature class for each layer
var polylineFeatureClass = polylineLayer.GetTable() as FeatureClass;
var pointFeatureClass = pointLayer.GetTable() as FeatureClass;
// retrieve the feature class schema information for the feature classes
var polylineDefinition = polylineFeatureClass.GetDefinition() as FeatureClassDefinition;
var pointDefinition = pointFeatureClass.GetDefinition() as FeatureClassDefinition;
// construct a cursor for all point features, since we want all feature there is no
// QueryFilter required
var pointCursor = pointFeatureClass.Search(null, false);
// initialize a counter variable
int pointCounter = 0;
// initialize a list to hold 5 coordinates that are used as vertices for the polyline
var lineCoordinates = new List<Coordinate>(5);
// set up the edit operation for the feature creation
var createOperation = new EditOperation();
createOperation.Name = "Create polylines";
createOperation.SelectNewFeatures = false;
// loop through the point features
while (pointCursor.MoveNext())
{
pointCounter++;
var pointFeature = pointCursor.Current as Feature;
// add the feature point geometry as a coordinate into the vertex list of the line
// - ensure that the projection of the point geometry is converted to match the spatial reference of the line
lineCoordinates.Add(((MapPoint)GeometryEngine.Project(pointFeature.GetShape(), polylineDefinition.GetSpatialReference())).Coordinate);
// for every 5 geometries, construct a new polyline and queue a feature create
if (pointCounter % 5 == 0)
{
// construct a new polyline by using the 5 point coordinate in the current list
var newPolyline = PolylineBuilder.CreatePolyline(lineCoordinates, polylineDefinition.GetSpatialReference());
// queue the create operation as part of the edit operation
createOperation.Create(polylineLayer, newPolyline);
// reset the list of coordinates
lineCoordinates = new List<Coordinate>(5);
}
}
// execute the edit (create) operation
return createOperation.ExecuteAsync();
});
}
示例2: constructSamplePoints
/// <summary>
/// Create random sample points in the extent of the spatial reference
/// </summary>
/// <param name="pointFeatureLayer">Point geometry feature layer used to the generate the points.</param>
/// <returns>Task{bool}</returns>
private Task<bool> constructSamplePoints(FeatureLayer pointFeatureLayer)
{
// create a random number generator
var randomGenerator = new Random();
// the database and geometry interactions are considered fine-grained and must be executed on
// the main CIM thread
return QueuedTask.Run(() =>
{
// start an edit operation to create new (random) point features
var createOperation = new EditOperation();
createOperation.Name = "Generate points";
createOperation.SelectNewFeatures = false;
// get the feature class associated with the layer
var featureClass = pointFeatureLayer.GetTable() as FeatureClass;
// define an area of interest. Random points are generated in the allowed
// confines of the allow extent range
var areaOfInterest = MapView.Active.Extent;
MapPoint newMapPoint = null;
// retrieve the class definition of the point feature class
var classDefinition = featureClass.GetDefinition() as FeatureClassDefinition;
// store the spatial reference as its own variable
var spatialReference = classDefinition.GetSpatialReference();
// create 20 new point geometries and queue them for creation
for (int i = 0; i < 20; i++)
{
// generate either 2D or 3D geometries
if (classDefinition.HasZ())
newMapPoint = MapPointBuilder.CreateMapPoint(randomGenerator.NextCoordinate(areaOfInterest, true), spatialReference);
else
newMapPoint = MapPointBuilder.CreateMapPoint(randomGenerator.NextCoordinate(areaOfInterest, false), spatialReference);
// queue feature creation
createOperation.Create(pointFeatureLayer, newMapPoint);
}
// execute the edit (feature creation) operation
return createOperation.ExecuteAsync();
});
}
示例3: constructSampleMultiPoints
/// <summary>
/// Create a single multi-point feature that is comprised of 20 points.
/// </summary>
/// <param name="multiPointLayer">Multi-point geometry feature layer used to add the multi-point feature.</param>
/// <returns></returns>
private Task constructSampleMultiPoints(FeatureLayer multiPointLayer)
{
// create a random number generator
var randomGenerator = new Random();
// the database and geometry interactions are considered fine-grained and need to be executed on
// a separate thread
return QueuedTask.Run(() =>
{
// get the feature class associated with the layer
var featureClass = multiPointLayer.GetTable() as FeatureClass;
var featureClassDefinition = featureClass.GetDefinition() as FeatureClassDefinition;
// store the spatial reference as its own variable
var spatialReference = featureClassDefinition.GetSpatialReference();
// define an area of interest. Random points are generated in the allowed
// confines of the allow extent range
var areaOfInterest = MapView.Active.Extent;
// start an edit operation to create new (random) multi-point feature
var createOperation = new EditOperation();
createOperation.Name = "Generate multipoints";
// retrieve the class definition of the point feature class
var classDefinition = featureClass.GetDefinition() as FeatureClassDefinition;
// create a list to hold the 20 coordinates of the multi-point feature
IList<Coordinate> coordinateList = new List<Coordinate>(20);
for (int i = 0; i < 20; i++)
{
// generate either 2D or 3D geometries
if (classDefinition.HasZ())
coordinateList.Add(randomGenerator.NextCoordinate(areaOfInterest, true));
else
coordinateList.Add(randomGenerator.NextCoordinate(areaOfInterest, false));
}
var newPoints = MultipointBuilder.CreateMultipoint(coordinateList, classDefinition.GetSpatialReference());
// create and execute the feature creation operation
createOperation.Create(multiPointLayer, newPoints);
return createOperation.ExecuteAsync();
});
}
示例4: constructSamplePolygon
/// <summary>
/// Create sample polygon feature using the point geometries from the multi-point feature using the
/// ConvexHull method provided by the GeometryEngine.
/// </summary>
/// <param name="polygonLayer">Polygon geometry feature layer used to add the new feature.</param>
/// <param name="lineLayer">The polyline feature layer containing the features used to construct the polygon.</param>
/// <returns></returns>
private Task<bool> constructSamplePolygon(FeatureLayer polygonLayer, FeatureLayer lineLayer)
{
// execute the fine grained API calls on the CIM main thread
return QueuedTask.Run(() =>
{
// get the underlying feature class for each layer
var polygonFeatureClass = polygonLayer.GetTable() as FeatureClass;
var polygonDefinition = polygonFeatureClass.GetDefinition() as FeatureClassDefinition;
var lineFeatureClass = lineLayer.GetTable() as FeatureClass;
// construct a cursor to retrieve the line features
var lineCursor = lineFeatureClass.Search(null, false);
// set up the edit operation for the feature creation
var createOperation = new EditOperation()
{
Name = "Create polygons",
SelectNewFeatures = false
};
PolylineBuilder polylineBuilder = new PolylineBuilder(polygonDefinition.GetSpatialReference());
while (lineCursor.MoveNext())
{
// retrieve the first feature
var lineFeature = lineCursor.Current as Feature;
// add the coordinate collection of the current geometry into our overall list of collections
var polylineGeometry = lineFeature.GetShape() as Polyline;
polylineBuilder.AddParts(polylineGeometry.Parts);
}
// use the ConvexHull method from the GeometryEngine to construct the polygon geometry
var newPolygon = GeometryEngine.ConvexHull(polylineBuilder.ToGeometry()) as Polygon;
// queue the polygon creation
createOperation.Create(polygonLayer, newPolygon);
// execute the edit (polygon create) operation
return createOperation.ExecuteAsync();
});
}
示例5: GetGeometry
public static ArcGIS.Core.Geometry.Geometry GetGeometry(int featureClassID, int OID, out bool isLine, FeatureLayer lineFeatureLayer, FeatureLayer pointFeatureLayer)
{
isLine = true;
IFeatureClass fc = null;
if(_fcIDToFeatureClass.ContainsKey(featureClassID) == false)
{
IFeatureWorkspaceManage2 fwsm2 = (IFeatureWorkspaceManage2)_fws;
string className = fwsm2.GetObjectClassNameByID(featureClassID);
_fcIDToFeatureClass.Add(featureClassID,_fws.OpenFeatureClass(className) );
}
fc = _fcIDToFeatureClass[featureClassID];
var shape = fc.GetFeature(OID).Shape;
if (shape.GeometryType == ESRI.ArcGIS.Geometry.esriGeometryType.esriGeometryPoint)
{
IPoint pnt = (IPoint)shape;
//var coord = new Coordinate(xCoord, yCoord);
//newMapPoint = MapPointBuilder.CreateMapPoint(coord, spatialReference);
isLine = false;
}
else
{
isLine = true;
}
bool isLineForLambda = isLine;
QueuedTask.Run(() =>
{
EnvelopeBuilder envBuilder = new EnvelopeBuilder();
envBuilder.XMin = 0;
envBuilder.XMax = 0;
envBuilder.YMin = 0;
envBuilder.YMax = 0;
var env = envBuilder.ToGeometry().Extent;
var pntFeatureClass = pointFeatureLayer.GetTable() as ArcGIS.Core.Data.FeatureClass;
var pntClassDefinition = pntFeatureClass.GetDefinition() as FeatureClassDefinition;
var spatialReference = pntClassDefinition.GetSpatialReference();
var createOperation = new EditOperation();
createOperation.Name = "Highlight Design Features";
createOperation.SelectNewFeatures = false;
if (isLineForLambda == false) //point
{
IPoint pnt = (IPoint)shape;
var coord = new Coordinate(pnt.X,pnt.Y);
var newMapPoint = MapPointBuilder.CreateMapPoint(coord, spatialReference);
// queue feature creation
createOperation.Create(pointFeatureLayer, newMapPoint);
Common.UnionEnvelopes(envBuilder, newMapPoint);
}
else
{
IPointCollection pc = (IPointCollection)shape;
var lineCoordinates = new List<Coordinate>(pc.PointCount);
for (int i = 0; i < pc.PointCount; i++)
{
var vertex = new Coordinate(pc.get_Point(i).X, pc.get_Point(i).Y);
lineCoordinates.Add(vertex);
var newPolyline = PolylineBuilder.CreatePolyline(lineCoordinates, spatialReference);
createOperation.Create(lineFeatureLayer, newPolyline);
Common.UnionEnvelopes(envBuilder, newPolyline);
}
}
});
return null;
}
示例6: GetFeatureLayersAndSpatReference
private static SpatialReference GetFeatureLayersAndSpatReference(FeatureLayer pointFeatureLayer)
{
var pntFeatureClass = pointFeatureLayer.GetTable() as ArcGIS.Core.Data.FeatureClass;
var pntClassDefinition = pntFeatureClass.GetDefinition() as FeatureClassDefinition;
var spatialReference = pntClassDefinition.GetSpatialReference();
return spatialReference;
}