动态创建地图文档MXD并发布地图服务
1、动态创建MXD
private bool CreateMxd(string MxdPath, string MxdName)
{
IMapDocument pMapDocument = CreateObject("esriCarto.MapDocument") as IMapDocument;
if (MxdPath.Substring(MxdPath.Length - 1) != @"\")
MxdPath += @"\";
pMapDocument.New(MxdPath + MxdName + ".mxd");
AddLayerToMxd(pMapDocument, MxdName);
if (pMapDocument == null)
return false;
if (pMapDocument.get_IsReadOnly(MxdPath + MxdName + ".mxd") == true)
{
return false;
}
pMapDocument.Save(true, false);
return true;
}
2、动态创建地图服务
private bool CreateServices(string MapPath, string ServerName)
{
//IGISServerConnection pGISServerConnection;
//pGISServerConnection = new GISServerConnectionClass();
//pGISServerConnection.Connect(HostName);
ESRI.ArcGIS.ADF.Identity identity = new ESRI.ArcGIS.ADF.Identity(MapServerUserName, MapserverPass, "");
ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection agsConnection = new ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection(HostName, identity);
agsConnection.Connect();
IServerObjectAdmin pServerObjectAdmin;
pServerObjectAdmin = agsConnection.ServerObjectAdmin;
IServerObjectConfiguration2 configuration = (IServerObjectConfiguration2)pServerObjectAdmin.CreateConfiguration();
configuration.Name = ServerName;//发布Service的名称,必填
configuration.TypeName = "MapServer";//发布服务的类型,如:MapServer,GeocodeServer
IPropertySet props = configuration.Properties;
props.SetProperty("FilePath", MapPath);//设置MXD的路径
#region 一下的property并非必须,只要一个filepath就可以发布
props.SetProperty("OutputDir", "c:\\arcgisserver\\arcgisoutput");//图片的输出目录
props.SetProperty("VirtualOutPutDir", "http://" + HostName + "/arcgisoutput");//图片输出的虚拟路径
props.SetProperty("SupportedImageReturnTypes", "URL");//支持的图片类型
props.SetProperty("MaxImageHeight", "2048");//图片的最大高度
props.SetProperty("MaxRecordCount", "500");//返回记录的最大条数
props.SetProperty("MaxBufferCount", "100");//缓冲区分析的最大数目
props.SetProperty("MaxImageWidth", "2048");//图片的最大宽度
props.SetProperty("IsCached", "false");//是否切片
props.SetProperty("CacheOnDemand", "false");//是否主动切片
props.SetProperty("IgnoreCache", "false");//是否忽略切片
props.SetProperty("ClientCachingAllowed", "true");//是否允许客户端缓冲
props.SetProperty("CacheDir", "c:\\arcgisserver\\arcgiscache\\NewService");//切片的输出路径
props.SetProperty("SOMCacheDir", "c:\\arcgisserver\\arcgiscache");//som的切片输出路径 //configuration.Description = "NewService";//Service的描述
configuration.IsolationLevel = esriServerIsolationLevel.esriServerIsolationHigh;//或者esriServerIsolationLow,esriServerIsolationAny
configuration.IsPooled = true;//是否池化
configuration.MaxInstances = 2;//最多的实例数
configuration.MinInstances = 1;//最少的实例数 ////设置刷新
IPropertySet recycleProp = configuration.RecycleProperties;
recycleProp.SetProperty("StartTime", "00:00");//刷新开始时间
recycleProp.SetProperty("Interval", "3600");//刷新间隔 ////设置是否开启REST服务
IPropertySet infoProp = configuration.Info;
infoProp.SetProperty("WebEnabled", "true");//是否提供REST服务
infoProp.SetProperty("WebCapabilities", "Map,Query,Data");//提供何种服务 //configuration.StartupType = esriStartupType.esriSTAutomatic;//或者esriSTManual
//configuration.UsageTimeout = 120;//客户端占用一个服务的最长时间
//configuration.WaitTimeout = 120;//客户端申请一个服务的最长等待时间
#endregion //添加服务到Server
pServerObjectAdmin.AddConfiguration(configuration); //启动服务
pServerObjectAdmin.StartConfiguration(ServerName, "MapServer");
return true; }
3. 动态创建影像服务
private bool CreateServices(string ImagePath, string ServerName)
{
ESRI.ArcGIS.ADF.Identity identity = new ESRI.ArcGIS.ADF.Identity(MapServerUserName, MapserverPass, "");
ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection agsConnection = new ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection(HostName, identity);
agsConnection.Connect();
IServerObjectAdmin pServerObjectAdmin;
pServerObjectAdmin = agsConnection.ServerObjectAdmin;
IServerObjectConfiguration2 configuration = (IServerObjectConfiguration2)pServerObjectAdmin.CreateConfiguration();
configuration.Name = ServerName;//发布Service的名称,必填
configuration.TypeName = "ImageServer";//发布服务的类型,如:MapServer,GeocodeServer
IPropertySet propertySet = configuration.Properties;
propertySet.SetProperty("Path", ImagePath);//设置Image的路径
propertySet.SetProperty("Start", "00:00");
propertySet.SetProperty("Interval", "24");
propertySet.SetProperty("SupportedImageReturnTypes", "URL");
propertySet.SetProperty("OutputDir", "c:\\arcgisserver\\arcgisoutput");//图片的输出目录
propertySet.SetProperty("VirtualOutPutDir", "http://" + HostName + "/arcgisoutput");//图片输出的虚拟路径
//propertySet.SetProperty("MaxImageHeight", 4100);//4100
// propertySet.SetProperty("MaxImageWidth", 15000);//15000
//propertySet.SetProperty("AllowedCompressions", "None,JPEG,LZ77");//"None,JPEG,LZ77"
//propertySet.SetProperty("DefaultResamplingMethod", 0);//0
//propertySet.SetProperty("DefaultCompressionQuality", 75);//75
//propertySet.SetProperty("MaxRecordCount", 500);//500
//propertySet.SetProperty("MaxMosaicImageCount", 1);//20
//propertySet.SetProperty("MaxDownloadImageCount", 20);//20
//propertySet.SetProperty("AllowedFields","Name,MinPS,MaxPS,LowPS,HighPS,CenterX,CenterY");//"Name,MinPS,MaxPS,LowPS,HighPS,CenterX,CenterY"
//propertySet.SetProperty("AllowedMosaicMethods","Center,NorthWest,LockRaster,ByAttribute,Nadir,Viewpoint,Seamline");//"Center,NorthWest,LockRaster,ByAttribute,Nadir,Viewpoint,Seamline"
//propertySet.SetProperty("AllowedItemMetadata", "Full");//"Full"
//ImageServiceInfo pImageSerivce = new ImageServiceInfo();
configuration.StartupType = esriStartupType.esriSTAutomatic;
configuration.MinInstances = 1;
configuration.MaxInstances = 2;
configuration.IsPooled = true;
configuration.Info.SetProperty("WebEnabled", "true");
configuration.Info.SetProperty("WebCapabilities", "Image,Catalog,Metadata,Download,Pixels");
pServerObjectAdmin.AddConfiguration(configuration);
//启动服务
pServerObjectAdmin.StartConfiguration(ServerName, "ImageServer");
return true;
}
3、相关方法
private IServerContext CreateServerContext(string ServerName, string UserName, string PassWord)
{
ESRI.ArcGIS.ADF.Identity identity = new ESRI.ArcGIS.ADF.Identity(UserName, PassWord, "");
ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection agsConnection = new ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection(ServerName, identity);
agsConnection.Connect();
if (agsConnection.IsConnected)
{
try
{
IServerObjectManager som = agsConnection.ServerObjectManager;
IServerContext pServerContext = som.CreateServerContext("Geometry", "GeometryServer");
return pServerContext;
}
catch (Exception e)
{
return null;
}
}
return null;
} #region ServerContext CreateObject函数
private object CreateObject(string ObjectCLSID)
{
IServerContext pServerContext = CreateServerContext(HostName,MapServerUserName,MapserverPass);
if (pServerContext == null) return null;
try
{
return pServerContext.CreateObject(ObjectCLSID);
}
catch
{
return null;
}
finally
{
pServerContext.ReleaseContext();
}
}
动态创建地图文档MXD并发布地图服务的更多相关文章
- ArcGIS地图文档MXD效率慢的一点建议(二)
经常有用户询问,我的MXD图层比较多,而且配置好了相关的符号,但是我的服务器更换了一下,而且两个服务器的要素类名称都是一样的,我想配置一下新的数据源,而且我的这个MXD已经连接不到原来的数据源了,打开 ...
- ArcGIS发布地图服务
一般做完矢量图绘制工作后,生成的.mxd文件只能在ArcMap中查看,为了方便用户进行浏览,我们需要发布地图服务. 目前为止最常用的就是在ArcGIS中发布地图服务. 今天也算是在做“发布地图服务”的 ...
- 手把手教你怎么用ArcgisOnline发布地图服务
Arcgis推出了Arcgis Online,但是大家都不知道这是个什么东西,怎么用这个东西,今天这篇文章手把手的教你如何使用Arcgisonline发布地图服务. 一.ArcgisOnline简介 ...
- GeoServer自动发布地图服务
1 NetCDF气象文件自动发布案例 GeoServer是一个地理服务器,提供了管理页面进行服务发布,样式,切片,图层预览等一系列操作,但是手动进行页面配置有时并不满足业务需求,所以GeoServer ...
- JavaWeb和WebGIS学习笔记(六)——使用ArcGIS for Server发布地图服务
系列链接: Java web与web gis学习笔记(一)--Tomcat环境搭建 Java web与web gis学习笔记(二)--百度地图API调用 JavaWeb和WebGIS学习笔记(三)-- ...
- 利用 PortableBasemapServer 发布地图服务
前段时间需要给自己的C/S系统加一个地图,但是没有数据,于是就想到了使用网上的切片地图,但是C/S系统又不能联网,于是就想本地发布切片服务来使用. 本来想用ArcGIS Server来发布从网上下载的 ...
- geoserver 通过代码实现发布地图服务
GeoServer:代码实现批量发布地图服务 利用GeoServer发布WCS服务,那么如果我有很多数据需要进行发布,这样利用GeoServer提供的UI界面进行操作显然很不显示.那能不能利用GeoS ...
- ArcGIS Server 10.1安装、配置、发布地图服务
先跟大家分享一个esri的学习资料,http://pan.baidu.com/s/1nBzxB,<ArcGIS10.1 for Server 入门教程>.教程讲述的很清楚,下面说说我这次发 ...
- arcgis server10.2发布地图服务报错
发布地图服务时,读取了本机电脑中的切片方案.发布服务,报打包成功,但发布失败错误. 解决办法:给arcgis账户,赋予读写权限即可.重复发布服务,成功发布.
随机推荐
- 剪花布条[HDU2087]
剪花布条 Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submi ...
- BZOJ1707 : [Usaco2007 Nov]tanning分配防晒霜
S向每头奶牛连边,容量1 每个防晒霜向T连边,容量cover 每头奶牛向SPF在自己范围内的防晒霜连边,容量inf 用线段树优化建图跑最大流即可. #include<cstdio> con ...
- BZOJ3680 : 吊打XXX
本题就是找一个受力平衡的点 我们一开始假设这个点是(0,0) 然后求出它受到的力,将合力正交分解后朝着合力的方向走若干步,并不断缩小步长,一步步逼近答案 #include<cstdio> ...
- BZOJ4010: [HNOI2015]菜肴制作
Description 知名美食家小 A被邀请至ATM 大酒店,为其品评菜肴. ATM 酒店为小 A 准备了 N 道菜肴,酒店按照为菜肴预估的质量从高到低给予 1到N的顺序编号,预估质量最高的菜肴编号 ...
- 关于实现banner轮换的问题,如何修改
最近遇到了这样的问题,本来banner都是gif格式的,但是现在要求上传图片格式为jpg时,运用JS实现动画效果,原来的也能用. aspx: <div id="bh" run ...
- JAVA中使用FTPClient实现文件上传下载
在JAVA程序中,经常需要和FTP打交道,比如向FTP服务器上传文件.下载文件,本文简单介绍如何利用jakarta commons中的FTPClient(在commons-net包中)实现上传下载文件 ...
- MatLab GUI Use Command for Debug 界面调试的一些方法
在MatLab的GUI界面编程,我们在调试的时候需要打印出一些变量,那么介绍下我用到的两种调试方法: 第一种,使用弹出对话框来打印变量,要注意的是打印的东西必须是string类型的,所以其他类型的变量 ...
- Swift Internal Parameter and External Parameter 外部参数和内部参数
今天跟大神又学习了些关于IOS开发Swift语言的外部参数和内部参数 func doSomething(num1: Int, num2: Int) -> Int { return num1 + ...
- spark-shell --conf
spark-shell --conf -h Usage: ./bin/spark-shell [options] Options: --master MASTER_URL spark://host:p ...
- html5文章 -- 应用HTML5 开发手机APP
因为HTML5暂时无法短期内在PC普及,主要方向在使用高端浏览器的高端移动设备,所以可以用作开发Android系统的App.但只有Android2.2以上.iOS3.2以上均支持HTML5,两大平台有 ...