宗地结构

获取活动记录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
string errorMessage = await QueuedTask.Run(() =>
{
try
{
var myParcelFabricLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<ParcelLayer>().FirstOrDefault();
//if there is no fabric in the map then bail
if (myParcelFabricLayer == null)
return "There is no fabric in the map.";
var theActiveRecord = myParcelFabricLayer.GetActiveRecord();
if (theActiveRecord == null)
return "There is no Active Record. Please set the active record and try again.";
}
catch (Exception ex)
{
return ex.Message;
}
return "";
});
if (!string.IsNullOrEmpty(errorMessage))
MessageBox.Show(errorMessage, "Get Active Record.");

设置活动记录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
string errorMessage = await QueuedTask.Run(async () =>
{
try
{
string sExistingRecord = "MyRecordName";
var myParcelFabricLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<ParcelLayer>().FirstOrDefault();
//if there is no fabric in the map then bail
if (myParcelFabricLayer == null)
return "There is no fabric in the map.";

bool bSuccess = await myParcelFabricLayer.SetActiveRecordAsync(sExistingRecord);
if (!bSuccess)
return "No record called " + sExistingRecord + " was found.";
}
catch (Exception ex)
{
return ex.Message;
}
return "";
});
if (!string.IsNullOrEmpty(errorMessage))
MessageBox.Show(errorMessage, "Set Active Record.");

创建新记录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
string errorMessage = await QueuedTask.Run(async () =>
{
Dictionary<string, object> RecordAttributes = new Dictionary<string, object>();
string sNewRecord = "MyRecordName";
try
{
var myParcelFabricLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<ParcelLayer>().FirstOrDefault();
//if there is no fabric in the map then bail
if (myParcelFabricLayer == null)
return "There is no fabric in the map.";
var recordsLayer = await myParcelFabricLayer.GetRecordsLayerAsync();
var editOper = new EditOperation()
{
Name = "Create Parcel Fabric Record",
ProgressMessage = "Create Parcel Fabric Record...",
ShowModalMessageAfterFailure = true,
SelectNewFeatures = false,
SelectModifiedFeatures = false
};
RecordAttributes.Add("Name", sNewRecord);
var editRowToken = editOper.Create(recordsLayer.FirstOrDefault(), RecordAttributes);
if (!editOper.Execute())
return editOper.ErrorMessage;

var defOID = -1;
var lOid = editRowToken.ObjectID.HasValue ? editRowToken.ObjectID.Value : defOID;
await myParcelFabricLayer.SetActiveRecordAsync(lOid);
}
catch (Exception ex)
{
return ex.Message;
}
return "";
});
if (!string.IsNullOrEmpty(errorMessage))
MessageBox.Show(errorMessage, "Create New Record.");

将标准线要素复制到宗地类型

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
string errorMessage = await QueuedTask.Run( async () =>
{
// check for selected layer
if (MapView.Active.GetSelectedLayers().Count == 0)
return "Please select a target parcel polygon layer in the table of contents.";
//get the feature layer that's selected in the table of contents
var destPolygonL = MapView.Active.GetSelectedLayers().OfType<FeatureLayer>().FirstOrDefault();
try
{
var myParcelFabricLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<ParcelLayer>().FirstOrDefault();
//if there is no fabric in the map then bail
if (myParcelFabricLayer == null)
return "There is no fabric in the map.";
var pRec = myParcelFabricLayer.GetActiveRecord();
if (pRec == null)
return "There is no Active Record. Please set the active record and try again.";
string ParcelTypeName = "";
IEnumerable<string> parcelTypeNames = await myParcelFabricLayer.GetParcelTypeNamesAsync();
foreach (string parcelTypeNm in parcelTypeNames)
{
var polygonLyrParcelTypeEnum = await myParcelFabricLayer.GetParcelPolygonLayerByTypeNameAsync(parcelTypeNm);
foreach (FeatureLayer lyr in polygonLyrParcelTypeEnum)
if (lyr == destPolygonL)
{
ParcelTypeName = parcelTypeNm;
break;
}
}
if (String.IsNullOrEmpty(ParcelTypeName))
return "Please select a target parcel polygon layer in the table of contents.";
var srcFeatLyr = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>().FirstOrDefault(l => l.Name.Contains("MySourceLines") && l.IsVisible);
if (srcFeatLyr == null)
return "Looking for a layer named 'MySourceLines' in the table of contents.";
//now get the line layer for this parcel type
var destLineLyrEnum = await myParcelFabricLayer.GetParcelLineLayerByTypeNameAsync(ParcelTypeName);
if (destLineLyrEnum.Count() == 0) //make sure there is one in the map
return ParcelTypeName + " not found.";
var destLineL = destLineLyrEnum.FirstOrDefault();
if (destLineL == null || destPolygonL == null)
return "";
var editOper = new EditOperation()
{
Name = "Copy Line Features To Parcel Type",
ProgressMessage = "Copy Line Features To Parcel Type...",
ShowModalMessageAfterFailure = true,
SelectNewFeatures = true,
SelectModifiedFeatures = false
};
var ids = new List<long>((srcFeatLyr as FeatureLayer).GetSelection().GetObjectIDs());
if (ids.Count == 0)
return "No selected lines were found. Please select line features and try again.";
editOper.CopyLineFeaturesToParcelType(srcFeatLyr, ids, destLineL, destPolygonL);
if (!editOper.Execute())
return editOper.ErrorMessage;
}
catch (Exception ex)
{
return ex.Message;
}
return "";
});
if (!string.IsNullOrEmpty(errorMessage))
MessageBox.Show(errorMessage, "Copy Line Features To Parcel Type.");

将宗地行复制到宗地类型

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
string errorMessage = await QueuedTask.Run( async () =>
{
// check for selected layer
if (MapView.Active.GetSelectedLayers().Count == 0)
return "Please select a source parcel polygon feature layer in the table of contents.";
try
{
var myParcelFabricLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<ParcelLayer>().FirstOrDefault();
if (myParcelFabricLayer == null)
return "No parcel layer found in the map.";

//get the feature layer that's selected in the table of contents
var srcParcelFeatLyr = MapView.Active.GetSelectedLayers().OfType<FeatureLayer>().FirstOrDefault();
string sTargetParcelType = "Tax";
var destLineLEnum = await myParcelFabricLayer.GetParcelLineLayerByTypeNameAsync(sTargetParcelType);
if (destLineLEnum.Count() == 0)
return "";
var destLineL = destLineLEnum.FirstOrDefault();
var destPolygonLEnum = await myParcelFabricLayer.GetParcelPolygonLayerByTypeNameAsync(sTargetParcelType);
if (destPolygonLEnum.Count() == 0)
return "";
var destPolygonL = destPolygonLEnum.FirstOrDefault();
if (destLineL == null || destPolygonL == null)
return "";
var theActiveRecord = myParcelFabricLayer.GetActiveRecord();
if (theActiveRecord == null)
return "There is no Active Record. Please set the active record and try again.";
var editOper = new EditOperation()
{
Name = "Copy Lines To Parcel Type",
ProgressMessage = "Copy Lines To Parcel Type ...",
ShowModalMessageAfterFailure = true,
SelectNewFeatures = true,
SelectModifiedFeatures = false
};
var ids = new List<long>(srcParcelFeatLyr.GetSelection().GetObjectIDs());
if (ids.Count == 0)
return "No selected parcels found. Please select parcels and try again.";
//add the standard feature line layers source, and their feature ids to a new Dictionary
var sourceParcelFeatures = new Dictionary<MapMember, List<long>>();
sourceParcelFeatures.Add(srcParcelFeatLyr, ids);
editOper.CopyParcelLinesToParcelType(myParcelFabricLayer, SelectionSet.FromDictionary(sourceParcelFeatures), destLineL, destPolygonL, true, false, true);
if (!editOper.Execute())
return editOper.ErrorMessage;
}
catch (Exception ex)
{
return ex.Message;
}
return "";
});
if (!string.IsNullOrEmpty(errorMessage))
MessageBox.Show(errorMessage, "Copy Parcel Lines To Parcel Type.");

将要素分配给活动记录

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
string errorMessage = await QueuedTask.Run( () =>
{
//check for selected layer
if (MapView.Active.GetSelectedLayers().Count == 0)
return "Please select a source feature layer in the table of contents.";
//first get the feature layer that's selected in the table of contents
var srcFeatLyr = MapView.Active.GetSelectedLayers().OfType<FeatureLayer>().FirstOrDefault();
var myParcelFabricLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<ParcelLayer>().FirstOrDefault();
if (myParcelFabricLayer == null)
return "No parcel layer found in the map.";
try
{
var theActiveRecord = myParcelFabricLayer.GetActiveRecord();
if (theActiveRecord == null)
return "There is no Active Record. Please set the active record and try again.";
var editOper = new EditOperation()
{
Name = "Assign Features to Record",
ProgressMessage = "Assign Features to Record...",
ShowModalMessageAfterFailure = true,
SelectNewFeatures = true,
SelectModifiedFeatures = false
};
//add parcel type layers and their feature ids to a new Dictionary
var ids = new List<long>(srcFeatLyr.GetSelection().GetObjectIDs());
var sourceFeatures = new Dictionary<MapMember, List<long>>();
sourceFeatures.Add(srcFeatLyr, ids);
editOper.AssignFeaturesToRecord(myParcelFabricLayer,
SelectionSet.FromDictionary(sourceFeatures), theActiveRecord);
if (!editOper.Execute())
return editOper.ErrorMessage;
}
catch (Exception ex)
{
return ex.Message;
}
return "";
});
if (!string.IsNullOrEmpty(errorMessage))
MessageBox.Show(errorMessage, "Assign Features To Record.");

创建宗地种子

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
try
{
var theActiveRecord = myParcelFabricLayer.GetActiveRecord();
if (theActiveRecord == null)
return "There is no Active Record. Please set the active record and try again.";

var guid = theActiveRecord.Guid;
var editOper = new EditOperation()
{
Name = "Create Parcel Seeds",
ProgressMessage = "Create Parcel Seeds...",
ShowModalMessageAfterFailure = true,
SelectNewFeatures = true,
SelectModifiedFeatures = false
};
editOper.CreateParcelSeedsByRecord(myParcelFabricLayer, guid, MapView.Active.Extent);
if (!editOper.Execute())
return editOper.ErrorMessage;
}
catch (Exception ex)
{
return ex.Message;
}
return "";

构建宗地

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
try
{
var myParcelFabricLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<ParcelLayer>().FirstOrDefault();
if (myParcelFabricLayer == null)
return "Parcel layer not found in map.";

var theActiveRecord = myParcelFabricLayer.GetActiveRecord();
var guid = theActiveRecord.Guid;
var editOper = new EditOperation()
{
Name = "Build Parcels",
ProgressMessage = "Build Parcels...",
ShowModalMessageAfterFailure = true,
SelectNewFeatures = true,
SelectModifiedFeatures = true
};
editOper.BuildParcelsByRecord(myParcelFabricLayer, guid);
if (!editOper.Execute())
return editOper.ErrorMessage;
}
catch (Exception ex)
{
return ex.Message;
}
return "";

重复的包裹

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
var myParcelFabricLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<ParcelLayer>().FirstOrDefault();
if (myParcelFabricLayer == null)
return "Parecl layer not found in the map.";
//get the source polygon layer from the parcel fabric layer type, in this case a layer called Lot
var srcFeatLyrEnum = await myParcelFabricLayer.GetParcelPolygonLayerByTypeNameAsync("Lot");
if (srcFeatLyrEnum.Count() == 0)
return "";
var sourcePolygonL = srcFeatLyrEnum.FirstOrDefault();
//get the target polygon layer from the parcel fabric layer type, in this case a layer called Tax
var targetFeatLyrEnum = await myParcelFabricLayer.GetParcelPolygonLayerByTypeNameAsync("Tax");
if (targetFeatLyrEnum.Count() == 0)
return "";
var targetFeatLyr = targetFeatLyrEnum.FirstOrDefault();
var ids = new List<long>(sourcePolygonL.GetSelection().GetObjectIDs());
if (ids.Count == 0)
return "No selected parcels found. Please select parcels and try again.";
//add polygon layers and the feature ids to be duplicated to a new Dictionary
var sourceFeatures = new Dictionary<MapMember, List<long>>();
sourceFeatures.Add(sourcePolygonL, ids);
try
{
var theActiveRecord = myParcelFabricLayer.GetActiveRecord();
if (theActiveRecord == null)
return "There is no Active Record. Please set the active record and try again.";
var editOper = new EditOperation()
{
Name = "Duplicate Parcels",
ProgressMessage = "Duplicate Parcels...",
ShowModalMessageAfterFailure = true,
SelectNewFeatures = true,
SelectModifiedFeatures = false
};
editOper.DuplicateParcels(myParcelFabricLayer,
SelectionSet.FromDictionary(sourceFeatures), theActiveRecord, targetFeatLyr);
if (!editOper.Execute())
return editOper.ErrorMessage;
}
catch (Exception ex)
{
return ex.Message;
}

设置历史宗地

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
string errorMessage = await QueuedTask.Run(async () =>
{
var myParcelFabricLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<ParcelLayer>().FirstOrDefault();
if (myParcelFabricLayer == null)
return "Please add a parcel fabric to the map";
try
{
FeatureLayer destPolygonL = null;
//find the first layer that is a parcel type, is non-historic, and has a selection
bool bFound = false;
var ParcelTypesEnum = await myParcelFabricLayer.GetParcelTypeNamesAsync();
foreach (FeatureLayer mapFeatLyr in MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>())
{
foreach (string ParcelType in ParcelTypesEnum)
{
var layerEnum = await myParcelFabricLayer.GetParcelPolygonLayerByTypeNameAsync(ParcelType);
foreach (FeatureLayer flyr in layerEnum)
{
if (flyr == mapFeatLyr)
{
bFound = mapFeatLyr.SelectionCount > 0;
destPolygonL = mapFeatLyr;
break;
}
}
if (bFound) break;
}
if (bFound) break;
}
if (!bFound)
return "Please select parcels to set as historic.";

var theActiveRecord = myParcelFabricLayer.GetActiveRecord();
if (theActiveRecord == null)
return "There is no Active Record. Please set the active record and try again.";

var ids = new List<long>(destPolygonL.GetSelection().GetObjectIDs());
//can do multi layer selection but using single per code above
var sourceFeatures = new Dictionary<MapMember, List<long>>();
sourceFeatures.Add(destPolygonL, ids);
var editOper = new EditOperation()
{
Name = "Set Parcels Historic",
ProgressMessage = "Set Parcels Historic...",
ShowModalMessageAfterFailure = true,
SelectNewFeatures = true,
SelectModifiedFeatures = false
};
editOper.SetParcelHistoryRetired(myParcelFabricLayer,
SelectionSet.FromDictionary(sourceFeatures), theActiveRecord);
if (!editOper.Execute())
return editOper.ErrorMessage;
}
catch (Exception ex)
{
return ex.Message;
}
return "";
});
if (!string.IsNullOrEmpty(errorMessage))
MessageBox.Show(errorMessage, "Set Parcels Historic.");

将包裹收缩为种子

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
string errorMessage = await QueuedTask.Run(async () =>
{
var myParcelFabricLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<ParcelLayer>().FirstOrDefault();
if (myParcelFabricLayer == null)
return "Please add a parcel fabric to the map";
try
{
FeatureLayer parcelPolygonLyr = null;
//find the first layer that is a polygon parcel type, is non-historic, and has a selection
bool bFound = false;
var ParcelTypesEnum = await myParcelFabricLayer.GetParcelTypeNamesAsync();
foreach (FeatureLayer mapFeatLyr in MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>())
{
foreach (string ParcelType in ParcelTypesEnum)
{
var layerEnum = await myParcelFabricLayer.GetParcelPolygonLayerByTypeNameAsync(ParcelType);
foreach (FeatureLayer flyr in layerEnum)
{
if (flyr == mapFeatLyr)
{
bFound = mapFeatLyr.SelectionCount > 0;
parcelPolygonLyr = mapFeatLyr;
break;
}
}
if (bFound) break;
}
if (bFound) break;
}
if (!bFound)
return "Please select parcels to shrink to seeds.";
var editOper = new EditOperation()
{
Name = "Shrink Parcels To Seeds",
ProgressMessage = "Shrink Parcels To Seeds...",
ShowModalMessageAfterFailure = true,
SelectNewFeatures = true,
SelectModifiedFeatures = false
};
var ids = new List<long>(parcelPolygonLyr.GetSelection().GetObjectIDs());
var sourceParcelFeatures = new Dictionary<MapMember, List<long>>();
sourceParcelFeatures.Add(parcelPolygonLyr, ids);
editOper.ShrinkParcelsToSeeds(myParcelFabricLayer,SelectionSet.FromDictionary(sourceParcelFeatures));
if (!editOper.Execute())
return editOper.ErrorMessage;
}
catch (Exception ex)
{
return ex.Message;
}
return "";
});
if (!string.IsNullOrEmpty(errorMessage))
MessageBox.Show(errorMessage, "Shrink Parcels To Seeds.");

更改宗地类型

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
//add polygon layers and the feature ids to change the type on to a new Dictionary
var ids = new List<long>(sourcePolygonL.GetSelection().GetObjectIDs());
var sourceFeatures = new Dictionary<MapMember, List<long>>();
sourceFeatures.Add(sourcePolygonL, ids);
try
{
var editOper = new EditOperation()
{
Name = "Change Parcel Type",
ProgressMessage = "Change Parcel Type...",
ShowModalMessageAfterFailure = true,
SelectNewFeatures = true,
SelectModifiedFeatures = false
};
editOper.ChangeParcelType(myParcelFabricLayer, SelectionSet.FromDictionary(sourceFeatures), targetFeatLyr);
if (!editOper.Execute())
return editOper.ErrorMessage;
}
catch (Exception ex)
{
return ex.Message;
}
return "";

获取宗地要素

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
string sReportResult = "Polygon Information --" + Environment.NewLine;
string sParcelTypeName = "tax";
string errorMessage = await QueuedTask.Run(async () =>
{
var myParcelFabricLayer =
MapView.Active.Map.GetLayersAsFlattenedList().OfType<ParcelLayer>().FirstOrDefault();
//if there is no fabric in the map then bail
if (myParcelFabricLayer == null)
return "There is no fabric layer in the map.";

//first get the parcel type feature layer
var featSrcLyr = myParcelFabricLayer.GetParcelPolygonLayerByTypeNameAsync(sParcelTypeName).Result.FirstOrDefault();

if (featSrcLyr.SelectionCount == 0)
return "There is no selection on the " + sParcelTypeName + " layer.";

sReportResult += " Parcel Type: " + sParcelTypeName + Environment.NewLine;
sReportResult += " Poygons: " + featSrcLyr.SelectionCount + Environment.NewLine + Environment.NewLine;

try
{
// ------- get the selected parcels ---------
var ids = new List<long>((featSrcLyr as FeatureLayer).GetSelection().GetObjectIDs());
var sourceParcels = new Dictionary<MapMember, List<long>>();
sourceParcels.Add(featSrcLyr, ids);
//---------------------------------------------
ParcelFeatures parcFeatures =
await myParcelFabricLayer.GetParcelFeaturesAsync(SelectionSet.FromDictionary(sourceParcels));
//since we know that we want to report on Tax lines only, and for this functionality
// we can use any of the Tax line layer instances (if there happens to be more than one)
// we can get the first instance as follows
FeatureLayer myLineFeatureLyr =
myParcelFabricLayer.GetParcelLineLayerByTypeNameAsync(sParcelTypeName).Result.FirstOrDefault();
if (myLineFeatureLyr == null)
return sParcelTypeName + " line layer not found";

FeatureLayer myPointFeatureLyr =
myParcelFabricLayer.GetPointsLayerAsync().Result.FirstOrDefault();
if (myPointFeatureLyr == null)
return "fabric point layer not found";

var LineInfo = parcFeatures.Lines; //then get the line information from the parcel features object
//... and then do some work for each of the lines
int iRadiusAttributeCnt = 0;
int iDistanceAttributeCnt = 0;
sReportResult += "Line Information --";
foreach (KeyValuePair<string, List<long>> kvp in LineInfo)
{
if (kvp.Key.ToLower() != sParcelTypeName)
continue; // ignore any other lines from different parcel types

foreach (long oid in kvp.Value)
{
var insp = myLineFeatureLyr.Inspect(oid);
var dRadius = insp["RADIUS"];
var dDistance = insp["DISTANCE"];

if (dRadius != DBNull.Value)
iRadiusAttributeCnt++;
if (dDistance != DBNull.Value)
iDistanceAttributeCnt++;
//Polyline poly = (Polyline)insp["SHAPE"];
}
sReportResult += Environment.NewLine + " Distance attributes: " + iDistanceAttributeCnt.ToString();
sReportResult += Environment.NewLine + " Radius attributes: " + iRadiusAttributeCnt.ToString();
}

var PointInfo = parcFeatures.Points; //get the point information from the parcel features object
//... and then do some work for each of the points
sReportResult += Environment.NewLine + Environment.NewLine + "Point Information --";
int iFixedPointCnt = 0;
int iNonFixedPointCnt = 0;
foreach (long oid in PointInfo)
{
var insp = myPointFeatureLyr.Inspect(oid);
var isFixed = insp["ISFIXED"];
if (isFixed == DBNull.Value || (int)isFixed == 0)
iNonFixedPointCnt++;
else
iFixedPointCnt++;
// var pt = insp["SHAPE"];

}
sReportResult += Environment.NewLine + " Fixed Points: " + iFixedPointCnt.ToString();
sReportResult += Environment.NewLine + " Non-Fixed Points: " + iNonFixedPointCnt.ToString();
}
catch (Exception ex)
{
return ex.Message;
}
return "";
});
if (!string.IsNullOrEmpty(errorMessage))
MessageBox.Show(errorMessage, "Get Parcel Features");
else
MessageBox.Show(sReportResult, "Get Parcel Features");

从宗地图层获取宗地结构数据集控制器

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
string errorMessage = await QueuedTask.Run(() =>
{
try
{
var myParcelFabricLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<ParcelLayer>().FirstOrDefault();
//if there is no fabric in the map then bail
if (myParcelFabricLayer == null)
return "There is no fabric in the map.";
var myParcelFabricDataset = myParcelFabricLayer.GetParcelFabric();
}
catch (Exception ex)
{
return ex.Message;
}
return "";
});
if (!string.IsNullOrEmpty(errorMessage))
MessageBox.Show(errorMessage, "Get Parcel Fabric Dataset from layer.");

获取宗地结构数据集的宗地拓扑

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
string errorMessage = await QueuedTask.Run(() =>
{
try
{
var myParcelFabricLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<ParcelLayer>().FirstOrDefault();
//if there is no fabric in the map then bail
if (myParcelFabricLayer == null)
return "There is no fabric in the map.";
var myParcelFabricDataset = myParcelFabricLayer.GetParcelFabric();
var myTopology = myParcelFabricDataset.GetParcelTopology();
}
catch (Exception ex)
{
return ex.Message;
}
return "";
});
if (!string.IsNullOrEmpty(errorMessage))
MessageBox.Show(errorMessage, "Get Parcel Fabric Topology.");

从宗地结构数据集中获取点、连接和记录要素类

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
string errorMessage = await QueuedTask.Run(() =>
{
try
{
var myParcelFabricLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<ParcelLayer>().FirstOrDefault();
//if there is no fabric in the map then bail
if (myParcelFabricLayer == null)
return "There is no fabric in the map.";
var myParcelFabricDataset = myParcelFabricLayer.GetParcelFabric();
FeatureClass myPointsFC = myParcelFabricDataset.GetSystemTable(SystemTableType.Points) as FeatureClass;
FeatureClass myCoonectionsFC = myParcelFabricDataset.GetSystemTable(SystemTableType.Connections) as FeatureClass;
FeatureClass myRecordsFC = myParcelFabricDataset.GetSystemTable(SystemTableType.Records) as FeatureClass;
}
catch (Exception ex)
{
return ex.Message;
}
return "";
});
if (!string.IsNullOrEmpty(errorMessage))
MessageBox.Show(errorMessage, "Get point, connection, and record feature classes.");

从宗地结构数据集获取宗地类型要素类

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
string errorMessage = await QueuedTask.Run(() =>
{
try
{
var myParcelFabricLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType<ParcelLayer>().FirstOrDefault();
//if there is no fabric in the map then bail
if (myParcelFabricLayer == null)
return "There is no fabric in the map.";
string myParcelTypeName = "Tax";
var myParcelFabricDataset = myParcelFabricLayer.GetParcelFabric();
var typeInfo = myParcelFabricDataset.GetParcelTypeInfo();
FeatureClass lineFCType = null;
FeatureClass polyFCType = null;
foreach (var info in typeInfo)
{
if (info.Name.ToLower() == myParcelTypeName.ToLower())
{
lineFCType = info.LineFeatureTable as FeatureClass;
polyFCType = info.PolygonFeatureTable as FeatureClass;
break;
}
}
}
catch (Exception ex)
{
return ex.Message;
}
return "";
});
if (!string.IsNullOrEmpty(errorMessage))
MessageBox.Show(errorMessage, "Get Parcel Type feature classes.");

从要素图层获取宗地类型名称

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
private async Task<string> GetParcelTypeNameFromFeatureLayer(ParcelLayer myParcelFabricLayer, FeatureLayer featLayer, GeometryType geomType)
{
if (featLayer == null) //nothing to do, return empty string
return String.Empty;
IEnumerable<string> parcelTypeNames = await myParcelFabricLayer.GetParcelTypeNamesAsync();
foreach (string parcelTypeName in parcelTypeNames)
{
if (geomType == GeometryType.Polygon)
{
var polygonLyrParcelTypeEnum = await myParcelFabricLayer.GetParcelPolygonLayerByTypeNameAsync(parcelTypeName);
foreach (FeatureLayer lyr in polygonLyrParcelTypeEnum)
if (lyr == featLayer)
return parcelTypeName;

polygonLyrParcelTypeEnum = await myParcelFabricLayer.GetHistoricParcelPolygonLayerByTypeNameAsync(parcelTypeName);
foreach (FeatureLayer lyr in polygonLyrParcelTypeEnum)
if (lyr == featLayer)
return parcelTypeName;
}
if (geomType == GeometryType.Polyline)
{
var lineLyrParcelTypeEnum = await myParcelFabricLayer.GetParcelLineLayerByTypeNameAsync(parcelTypeName);
foreach (FeatureLayer lyr in lineLyrParcelTypeEnum)
if (lyr == featLayer)
return parcelTypeName;

lineLyrParcelTypeEnum = await myParcelFabricLayer.GetHistoricParcelLineLayerByTypeNameAsync(parcelTypeName);
foreach (FeatureLayer lyr in lineLyrParcelTypeEnum)
if (lyr == featLayer)
return parcelTypeName;
}
}
return String.Empty;
}

从表中获取宗地结构

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public static ParcelFabric GetParcelFabricFromTable(Table table)
{
ParcelFabric myParcelFabricDataset = null;
if (table.IsControllerDatasetSupported())
{
// Tables can belong to multiple controller datasets, but at most one of them will be a parcel fabric

IReadOnlyList<Dataset> controllerDatasets = table.GetControllerDatasets();
foreach (Dataset controllerDataset in controllerDatasets)
{
if (controllerDataset is ParcelFabric)
{
myParcelFabricDataset = controllerDataset as ParcelFabric;
}
else
{
controllerDataset.Dispose();
}
}
}
return myParcelFabricDataset;
}

}