Skyline Web 二次开发- 获取Shp对象的内部存储属性值
在web中可以获取到shp对象的内部存储属性值,同时通过对象转换可以提取到面积等属性
JavaScript
var flyPath = "";
var shpLayerID = "";
var shpLayer = ""; //shpLayer
var shpFeatureGroup = ""; //shpFeatureGroup
var shpFeatures = ""; //shpFeatures
var shpFeature = ""; //shpFeature
var shpFeatureAttribute = ""; //shpFeatureAttribute
var shpshpFeatureGeometry = ""; //从Feature转换到Geometry
shpLayerID = SGWorld66.ProjectTree.FindItem("房屋");
shpLayer = SGWorld66.ProjectTree.GetLayer(shpLayerID);
shpLayer.DataSourceInfo.Attributes.ImportAll = true;
shpLayer.Streaming = false;
shpLayer.Load();
shpFeatureGroup = shpLayer.FeatureGroups(0);
shpFeatures = shpFeatureGroup.Features;
// 以下两个方法都可以获取到shp内部数据的数量,但调用方式不同
//shpLayer.FeatureGroups(0).Features;
//shpLayer.FeatureGroups(0).GetCurrentFeatures();
//alert(shpLayer.FeatureGroups(0).GetCurrentFeatures().Count + "/" + shpLayer.FeatureGroups(0).Features.Count);
for (var i = 0; i < shpFeatures.Count; i++) {
shpFeature = shpFeatures.Item(i);
shpshpFeatureGeometry = shpFeature.Geometry;
$("#info").append("Area:" + shpshpFeatureGeometry.Area + "<br/>");
$("#info").append("X:" + shpshpFeatureGeometry.Centroid.X + "<br/>");
$("#info").append("Y:" + shpshpFeatureGeometry.Centroid.Y + "<br/>");
for (var j = 0; j < shpFeature.FeatureAttributes.Count; j++) {
shpFeatureAttribute = shpFeature.FeatureAttributes.Item(j);
$("#info").append("Name:" + shpFeatureAttribute.Name + "<br/>");
$("#info").append("Value:" + shpFeatureAttribute.Value + "<br/>");
}
}