private CustomLayerInfos GetLayerInfos() { IMapServer3 mapServer = serverObjectHelper.ServerObject as IMapServer3; if (mapServer == null) { throw new Exception("Unable to access the map server."); } IMapServerInfo msInfo = mapServer.GetServerInfo(mapServer.DefaultMapName); IMapLayerInfos layerInfos = msInfo.MapLayerInfos; int c = layerInfos.Count; CustomLayerInfos customLayerInfos = new CustomLayerInfos(Constants.SOENamespaceURI); for (int i = 0; i < c; i++) { IMapLayerInfo layerInfo = layerInfos.get_Element(i); CustomLayerInfo customLayerInfo = new CustomLayerInfo(); customLayerInfo.Name = layerInfo.Name; customLayerInfo.ID = layerInfo.ID; customLayerInfo.Extent = layerInfo.Extent; customLayerInfos.Add(customLayerInfo); } return(customLayerInfos); }
public void Init(IServerObjectHelper pSOH) { this.soHelper = pSOH; this.serverLog = new ServerLogger(); this.mapServerDataAccess = (IMapServerDataAccess)this.soHelper.ServerObject; IMapServer ms = (IMapServer)this.mapServerDataAccess; IMapServerInfo mapServerInfo = ms.GetServerInfo(ms.DefaultMapName); this.layerInfos = mapServerInfo.MapLayerInfos; serverLog.LogMessage(ServerLogger.msgType.infoStandard, this.soeName + ".init()", 200, "Initialized " + this.soeName + " SOE."); }
public void Init(IServerObjectHelper pSOH) { this.soHelper = pSOH; this.serverLog = new ServerLogger(); this.mapServerDataAccess = (IMapServerDataAccess) this.soHelper.ServerObject; ms = (IMapServer3) this.mapServerDataAccess; mapServerInfo = ms.GetServerInfo(ms.DefaultMapName); this.layerInfos = mapServerInfo.MapLayerInfos; this.mapDesc = (IMapDescription3)mapServerInfo.DefaultMapDescription; serverLog.LogMessage(ServerLogger.msgType.infoStandard, this.soeName + ".init()", 200, "Initialized " + this.soeName + " SOE."); }
public void Init(IServerObjectHelper pSOH) { serverObjectHelper = pSOH; mapServerDataAccess = (IMapServerDataAccess)pSOH.ServerObject; IMapServer3 ms = (IMapServer3)pSOH.ServerObject; this.mapServerInfo = ms.GetServerInfo(ms.DefaultMapName); this.layerInfos = mapServerInfo.MapLayerInfos; if (layerId < 0) { layerId = 0; } }
/** * This method returns the layer id of the layer matching the specified name */ public int GetLayerIdByName(IMapServer mapService, string name) { IMapServerInfo msInfo = mapService.GetServerInfo(mapService.DefaultMapName); IMapLayerInfos layerInfos = msInfo.MapLayerInfos; for (int i = 0; i < layerInfos.Count; i++) { IMapLayerInfo layerInfo = layerInfos.Element[i]; if (layerInfo.Name.Equals(name, StringComparison.OrdinalIgnoreCase)) { return(layerInfo.ID); } } return(-1); }
/** * This method returns the Utility Network Layer information object. */ public IMapLayerInfo GetUNLayerInfo(IMapServer mapService) { IMapServerInfo mapServerInfo = mapService.GetServerInfo(mapService.DefaultMapName); IMapLayerInfos layerInfos = mapServerInfo.MapLayerInfos; for (int i = 0; i < layerInfos.Count; i++) { IMapLayerInfo layerInfo = layerInfos.Element[i]; if (layerInfo.Type.Equals("Utility Network Layer", StringComparison.OrdinalIgnoreCase)) { return(layerInfo); } } return(null); }
/// <summary> /// list layers in each dataframes in a TreeView /// </summary> private void listLayers(IMapServer pMapServer) { string strMapName = ""; IMapServerInfo pMSI = null; IMapLayerInfos pMLInfos = null; IMapLayerInfo pMLI = null; TreeViewItem pTVIDataFrame = null; for (int i = 0; i < pMapServer.MapCount; i++) { strMapName = pMapServer.get_MapName(i); if (!strMapName.Equals(pMapServer.DefaultMapName)) { continue; } //only for the active dataframe pMSI = pMapServer.GetServerInfo(strMapName); pMLInfos = pMSI.MapLayerInfos; pTVIDataFrame = CreateTreeViewItem(strMapName); tvwLayers.Items.Add(pTVIDataFrame); for (int j = 0; j < pMLInfos.Count; j++) { pMLI = pMLInfos.get_Element(j); AddTVItemForSubLayer(pTVIDataFrame, pMLInfos, pMLI, ref j); } pTVIDataFrame.IsExpanded = true; } if (pMapServer.MapCount > 1) { tvwLayers.Items.Add(""); TextBlock tb = new TextBlock() { Text = "<Other non-active dataframe cannot be used>", Foreground = new SolidColorBrush(Colors.DarkGray), FontStyle = FontStyles.Italic }; tvwLayers.Items.Add(tb); } }
public void Init(IServerObjectHelper pSOH) { IMapServer mapServer = pSOH.ServerObject as IMapServer; IMapServerDataAccess mapServerDataAccess = mapServer as IMapServerDataAccess; IMapServerInfo mapServerInfo = mapServer.GetServerInfo(mapServer.DefaultMapName); IMapLayerInfos layerInfos = mapServerInfo.MapLayerInfos; IMapLayerInfo ndLayerInfo = null; // Get the network dataset layer from current service for (var i = 0; i < layerInfos.Count; i++) { IMapLayerInfo layerInfo = layerInfos.Element[i]; if (layerInfo.Type.Equals("Network Dataset Layer", StringComparison.InvariantCultureIgnoreCase)) { ndLayerInfo = layerInfo; break; } } // Get the network dataset if (ndLayerInfo != null) { var dt = mapServerDataAccess.GetDataSource(mapServer.DefaultMapName, ndLayerInfo.ID); // Cast the dataset to required network dataset interface networkDataset = dt as INetworkDataset; } if (networkDataset != null) { // Open the streets feature class IDataset dataSet = networkDataset as IDataset; IFeatureWorkspace fWorkspace = dataSet.Workspace as IFeatureWorkspace; streetFC = fWorkspace.OpenFeatureClass(streetsName); // Get the Streets source ID INetworkSource streetNetworkSource = networkDataset.SourceByName[streetsName]; streetsSourceID = streetNetworkSource.ID; // Get the TraveTime attribute ID INetworkAttribute travelTimeAttribute = networkDataset.AttributeByName[costAttributeName]; travelTimeAttributeID = travelTimeAttribute.ID; } }
private void ValidateMapServiceSpatialReference() { // Currently only supporting map services published in 102100 IMapServer3 mapServer = serverObjectHelper.ServerObject as IMapServer3; if (mapServer == null) { throw new Exception("Unable to access the map server."); } IMapServerInfo mapServerInfo = mapServer.GetServerInfo(mapServer.DefaultMapName); _spatialReference = mapServerInfo.DefaultMapDescription.SpatialReference; var wkid = _spatialReference.FactoryCode; if (wkid != 102100 && wkid != 3857 && wkid != 102113) // All interchangeable, though 102100 should supercede all { throw new NotSupportedException(string.Format("WKID {0} is not currently supported. Map service must be in Web Mercator Aux. Sphere (WKID: 102100, 102113, or 3857).", wkid)); } }
public void Init(IServerObjectHelper pSOH) { serverObjectHelper = pSOH; mapServerDataAccess = (IMapServerDataAccess)pSOH.ServerObject; IMapServer3 ms = (IMapServer3)pSOH.ServerObject; this.mapServerInfo = ms.GetServerInfo(ms.DefaultMapName); this.layerInfos = mapServerInfo.MapLayerInfos; if (layerId < 0) layerId = 0; }
/// <summary> /// Retrieves a list of connection properties from the layers of a <see cref="IMapServer"/>. /// </summary> /// <param name="mapServer">A map server.</param> /// <param name="propertyNames">The names of the keys in each dictionary of the output object.</param> /// <returns> /// A list of <see cref="KeyValuePair<TKey,KValue>"/> objects. /// Each <see cref="KeyValuePair<TKey,KValue>.Key"/> corresponds to a data source name. /// Each value is a <see cref="Dictionary<TKey,TValue>"/> of connection properties. /// </returns> public static List <ConnectionProperties> GetConnectionProperties(this IMapServer mapServer /*, out List<string> propertyNames*/) { IMapLayerInfos mapLayerInfos = null; IMapLayerInfo mapLayerInfo = null; IMapServerDataAccess mapServerDA = null; IMapServerInfo mapServerInfo = null;; ////propertyNames = new List<string>(); IDataset dataset = null; IPropertySet connectionPropertySet = null; object namesObj, valuesObj; string[] names; object[] values; var output = new List <ConnectionProperties>(); try { mapServerDA = (IMapServerDataAccess)mapServer; // Get the server info for the default map. (This application will assume that there is only a single map: the default.) string mapName = mapServer.DefaultMapName; mapServerInfo = mapServer.GetServerInfo(mapName); // Loop through all of the layers in the map service... mapLayerInfos = mapServerInfo.MapLayerInfos; ConnectionProperties connectionProperties; for (int i = 0, l = mapLayerInfos.Count; i < l; i++) { mapLayerInfo = mapLayerInfos.get_Element(i); if (mapLayerInfo.IsComposite) { continue; } connectionProperties = new ConnectionProperties(mapLayerInfo.Name); try { dataset = mapServerDA.GetDataSource(mapName, i) as IDataset; } catch (NotImplementedException ex) { connectionProperties["error"] = ex.Message; output.Add(connectionProperties); continue; } if (dataset != null) { connectionPropertySet = dataset.Workspace.ConnectionProperties; connectionPropertySet.GetAllProperties(out namesObj, out valuesObj); names = namesObj as string[]; values = valuesObj as object[]; string name; for (int j = 0; j < names.Length; j++) { name = names[j]; connectionProperties[name] = values[j]; } output.Add(connectionProperties); } } } finally { foreach (var item in new object[] { mapLayerInfos, mapLayerInfo, mapServerDA, mapServerInfo, dataset, connectionPropertySet }) { if (item != null) { Marshal.ReleaseComObject(item); } } } return(output); }
private esriUnits GetMapServiceUnits(IMapServer3 mapServer) { IMapServerInfo mapServerInfo = mapServer.GetServerInfo(mapServer.DefaultMapName); return(mapServerInfo.MapUnits); }
private ISpatialReference GetSpatialReferenceFromMapService(IMapServer3 mapServer) { IMapServerInfo mapServerInfo = mapServer.GetServerInfo(mapServer.DefaultMapName); return(mapServerInfo.DefaultMapDescription.SpatialReference); }