本文用于记录一些使用频率较高但归类繁杂,非系统性的一些代码。
主要方便自己使用和查阅,随时更新。
- using Geodatabase gdb = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(gdbPath)));
- FeatureDataset featureDataset = gdb.OpenDataset
(featureDatasetName); - FeatureClass featureClass = gdb.OpenDataset
(featureClassName); - Table table = gdb.OpenDataset
(tableName);
2、从GDB数据库中获取【FeatureDatasetDefinition\FeatureClassDefinition\TableDefinition】
- // 扩展用法:GetDefinitions<>
- FeatureDatasetDefinition featureDatasetDefinition = gdb.GetDefinition
(featureDatasetName); - FeatureClassDefinition featureClassDefinition = gdb.GetDefinition
(featureClassName); - TableDefinition tableDefinition = gdb.GetDefinition
(tableName);
3、从【FeatureLayer\FeatureClass】中获取【Feature\Row】
- using (RowCursor rowCursor = featureLayer.Search())
- {
- while (rowCursor.MoveNext())
- {
- using Feature feature2 = rowCursor.Current as Feature;
- using Row row = rowCursor.Current;
- }
- }
4、Feature转换为Geometry
Geometry geometry1 = feature.GetShape();
5、Geometry转换为Polygon
Polygon polygon1 = geometry as Polygon;
6、设置Feature的几何形状
feature.SetShape(geometry);
7、获取线、面要素的折点、首末点
- ReadOnlyPointCollection mapPoints = polygon.Points;
- ReadOnlyPointCollection mapPoints2 = polyline.Points;
- MapPoint startPoint = mapPoints.First();
- MapPoint endPoint = mapPoints.Last();
8、switch用法示例
- string featureclass_type = esriGeometryType switch
- {
- esriGeometryType.esriGeometryPoint => "Point",
- esriGeometryType.esriGeometryPolyline => "Polyline",
- esriGeometryType.esriGeometryPolygon => "Polygon",
- _ => "",
- };
9、获取活动地图视图中选择框选定的要素【SelectiontSet】
SelectionSet selectedSet = MapView.Active.Map.GetSelection();
10、在MapTool中获取选择的要素【SelectiontSet】
SelectionSet selectedSet2 = MapView.Active.GetFeatures(geometry);
11、从【SelectionSet】中获取【Geometry】
- var selectionList = selectedSet.ToDictionary();
- Inspector inspector = new Inspector();
- foreach (var selection in selectionList)
- {
- MapMember mapMember = selection.Key;
- List<long> oids = selection.Value;
- foreach (var oid in oids)
- {
- inspector.Load(mapMember, oid);
- Polygon polygon2 = inspector.Shape as Polygon;
- }
- }
12、Geometry的属性
- double polygonArea = polygon.Area; // 面积
- Envelope polygonExtent = polygon.Extent; // 范围
- GeometryType geometryType = geometry.GeometryType; // 要素类型
- SpatialReference spatialReference = geometry.SpatialReference; // 坐标系
- int pointCount = polyline.PointCount; // 折点数
-
相关阅读:
启动hadoop并测试问题合集
SpringBoot学习笔记(4)——B站动力节点
kubernetes 之 Pod 控制器 Deployment
C# - 委托、事件、Action、Func
vue中$attrs,$props,$listener
【Android development】系列_01创建安卓应用程序
SmartNews 基于 Flink 的 Iceberg 实时数据湖实践
深入理解mvcc机制(详解)
动态规划总结篇!
Linux执行jps命令的时候报错:-bash: jps: command not found
-
原文地址:https://blog.csdn.net/xcc34452366/article/details/133753165