因为刚接触Skyline不到一个星期,也怕把学习到的忘记掉,所以写一点学习到的一些皮毛的东西,赶紧记录一下,怕回头忘记
1.网上关于web端的开发非常多,也有很多牛人分享自己的经验,所以学习起来也相对更便捷
2.关于插件的开发,网上基本上没有,我也只找到一个是用C#做的,显然和Skyline的html插件形式还不一样,但是还有安装文件里有关于插件的html的源码可以学习,帮助文档也有关于如何组织插件,以及发布的资料,不过我没实验成功(尴尬而不失礼貌的微笑)
3.桌面端的开发相对容易一点,网上也有很多资料,并且帮助文档也有很多基础功能的代码可以参考
下面是我刚学习到的一些东西(做的是在上面提到的那个C#插件基础上做的一个小功能,可以根据shapefile的属性批量生成模型)
先说一下结果吧,结果也做出来了,但是之后发现人家软件本身就集成了这个功能。(那个复制对象的.....)
1.在ArcGIS里将shapefile面按属性查询导出
2.基于查询出来的面建立大小适中的渔网(渔网中有每个网格的中心点)
3.按空间位置查询,把面包含的中心点提取出来(这些点就是放模型的位置)
4.在skyline里用Ifeaturelayer,Ifeaturegroup,Ifeatures,Ifeature等一系列接口把点转化为Position,在这个位置上创建模型
但是虽然做成了,还是有缺点(还挺致命的),生成的模型没有在一个层上,,数据没有组织好,中间也走了很多弯路,但是弯路上也学到了很多东西。贴一些代码吧,比较菜....
a.关于如何图层中得到features(用的6.6的版本)
private IFeatures66 getFeatures()
{
try
{
ISGWorld66 sgworld = new SGWorld66Class();//很多东西都来自这个ISGWorld的接口
string GroupID = sgworld.ProjectTree.FindItem("tree");
{
try
{
ISGWorld66 sgworld = new SGWorld66Class();//很多东西都来自这个ISGWorld的接口
string GroupID = sgworld.ProjectTree.FindItem("tree");
if (GroupID == null)
{
MessageBox.Show("不存在");
}
else
MessageBox.Show("the id is" + GroupID);
IFeatureLayer66 featurelayer = sgworld.ProjectTree.GetLayer(GroupID);
IAttribute66 attribute = featurelayer.DataSourceInfo.Attributes.get_Attribute(1);
{
MessageBox.Show("不存在");
}
else
MessageBox.Show("the id is" + GroupID);
IFeatureLayer66 featurelayer = sgworld.ProjectTree.GetLayer(GroupID);
IAttribute66 attribute = featurelayer.DataSourceInfo.Attributes.get_Attribute(1);
IFeatureGroup66 point = featurelayer.FeatureGroups.Point;//原本featuregroups下面应该有一个item的属性可以获取到具体的某个图层,然而我并没有找到,很郁闷(帮助文档里明明写的有的),不过还好这个Point,Polygon,Polyline也能得到
IFeatures66 features = point.GetCurrentFeatures();//get the all features
MessageBox.Show(Convert.ToString(features.Count));//static the number of features;
IFeatures66 features = point.GetCurrentFeatures();//get the all features
MessageBox.Show(Convert.ToString(features.Count));//static the number of features;
return features;
}
catch (Exception ex)
{
MessageBox.Show("Unexpected error:" + ex.Message);
}
return null;
}
}
catch (Exception ex)
{
MessageBox.Show("Unexpected error:" + ex.Message);
}
return null;
}
b.上面的features通过索引就可以得到feature了//我有点繁琐,有把features放进了泛型的列表,这样其实挺慢的
List<IFeature66> featureList = new List<IFeature66>();
for (int i = 0; i < features.Count; i++)//put the every feature into list
{
IFeature66 feature = (IFeature66)features[i];//get the specific feature
featureList.Add(feature);
}
return featureList;
{
IFeature66 feature = (IFeature66)features[i];//get the specific feature
featureList.Add(feature);
}
return featureList;
c.将feature的坐标提出来(因为我的feature是point)
private IPosition66 CreatePosition(IFeature66 feature)
{
try
{
IPoint point =(IPoint)feature.Geometry;
IPosition66 position = null;
double X = point.X;
double Y = point.Y;
position = Creator.CreatePosition(X, Y, 0, AltitudeTypeCode.ATC_ON_TERRAIN, 0, 0, 0, 500);//这个ICreator的接口很厉害,啥都能生成,有点夸张了(除了坐标的位置是提取的,其他的我都是给死了)
return position;
}
catch (Exception ex)
{ MessageBox.Show(ex.Message); }
{
try
{
IPoint point =(IPoint)feature.Geometry;
IPosition66 position = null;
double X = point.X;
double Y = point.Y;
position = Creator.CreatePosition(X, Y, 0, AltitudeTypeCode.ATC_ON_TERRAIN, 0, 0, 0, 500);//这个ICreator的接口很厉害,啥都能生成,有点夸张了(除了坐标的位置是提取的,其他的我都是给死了)
return position;
}
catch (Exception ex)
{ MessageBox.Show(ex.Message); }
return null;
}
}
d.有了位置就可以建模型了
private void createModels( List<IPosition66> list)
{
string tMsg = String.Empty;
string fileName = "D:\BaiduNetdiskDownload\skyline\tools\Data-Library\3D-Objects\Helicopters\500d.xpc";//the path of my model;
double scale = 5;//set the scale for model;
string groupID ="";//as the node in the project tree;
string Description = "myfirst";
ITerrainModel66 mymodel = null;
for (int i = 0; i < list.Count; i++)
{
mymodel=Creator.CreateModel(list[i], fileName, scale, ModelTypeCode.MT_NORMAL, groupID, Description);
}
{
string tMsg = String.Empty;
string fileName = "D:\BaiduNetdiskDownload\skyline\tools\Data-Library\3D-Objects\Helicopters\500d.xpc";//the path of my model;
double scale = 5;//set the scale for model;
string groupID ="";//as the node in the project tree;
string Description = "myfirst";
ITerrainModel66 mymodel = null;
for (int i = 0; i < list.Count; i++)
{
mymodel=Creator.CreateModel(list[i], fileName, scale, ModelTypeCode.MT_NORMAL, groupID, Description);
}
}
嗯,就是这样了,虽然最后没用到,但还是学到了点东西
skyline的shape图层的数据组织,和ArcGIS还是挺像的