static void Main(string[] args)
        {
            SampleServer6.USA_MapServer mapservice = new SampleServer6.USA_MapServer();
            String defaultMapName = mapservice.GetDefaultMapName();

            Console.WriteLine("Map name: " + defaultMapName + "\n");

            MapServerInfo  mapinfo = mapservice.GetServerInfo(defaultMapName);
            MapDescription mapdesc = mapinfo.DefaultMapDescription;
            ImageType      imgtype = new ImageType();

            imgtype.ImageFormat     = esriImageFormat.esriImagePNG;
            imgtype.ImageReturnType = esriImageReturnType.esriImageReturnURL;
            ImageDisplay imgdisp = new ImageDisplay();

            imgdisp.ImageHeight = 500; //pixels
            imgdisp.ImageWidth  = 500; //pixels
            imgdisp.ImageDPI    = 96;
            ImageDescription imgdesc = new ImageDescription();

            imgdesc.ImageDisplay = imgdisp;
            imgdesc.ImageType    = imgtype;
            MapImage mapimg = mapservice.ExportMapImage(mapdesc, imgdesc);

            Console.WriteLine("Output URL:" + mapimg.ImageURL);
            Console.ReadLine();
        }
示例#2
0
        public static string GetGeomFieldName(MapServerInfo mapinfo, int layerID)
        {
            MapLayerInfo[] mapLayerInfos = mapinfo.MapLayerInfos;
            string         empty         = string.Empty;

            MapLayerInfo[] array = mapLayerInfos;
            for (int i = 0; i < array.Length; i++)
            {
                MapLayerInfo mapLayerInfo = array[i];
                if (layerID == mapLayerInfo.LayerID)
                {
                    Field[] fieldArray = mapLayerInfo.Fields.FieldArray;
                    Field[] array2     = fieldArray;
                    for (int j = 0; j < array2.Length; j++)
                    {
                        Field field = array2[j];
                        if (field.Type == esriFieldType.esriFieldTypeGeometry)
                        {
                            empty = field.Name;
                            break;
                        }
                    }
                }
            }
            return(empty);
        }
示例#3
0
 public static void Initialize()
 {
     MapServiceFidTests._mapservice     = new MapServerProxy();
     MapServiceFidTests._mapservice.Url = "http://mashup/ArcGIS/services/MapServices/Austin/MapServer";
     MapServiceFidTests.name            = MapServiceFidTests._mapservice.GetDefaultMapName();
     MapServiceFidTests._mapinfo        = MapServiceFidTests._mapservice.GetServerInfo(MapServiceFidTests.name);
 }
示例#4
0
 public TiledRaster(Document doc)
 {
     this.ParentDoc       = doc;
     this.RasterIds       = new List <ObjectId>();
     this._mapservice     = new MapServerProxy();
     this._mapservice.Url = "http://mashup/ArcGIS/services/MapServices/CorvallisCompact/MapServer";
     this._mapinfo        = this._mapservice.GetServerInfo(this._mapservice.GetDefaultMapName());
     this.SampleGetTileInfo();
 }
示例#5
0
 public static string GetOIDFieldName(MapServerInfo mapinfo, int layerID)
 {
     MapLayerInfo[] mapLayerInfos = mapinfo.MapLayerInfos;
     MapLayerInfo[] array         = mapLayerInfos;
     for (int i = 0; i < array.Length; i++)
     {
         MapLayerInfo mapLayerInfo = array[i];
         if (layerID == mapLayerInfo.LayerID)
         {
             return(mapLayerInfo.IDField);
         }
     }
     return(string.Empty);
 }
        public AgsDataFrame(AgsMapService service, MapServerInfo mapServerInfo, bool isDefault)
        {
            _mapServerInfo = mapServerInfo;

            Service   = service;
            Name      = mapServerInfo.Name;
            IsDefault = isDefault;

            ImageType imageType = new ImageType(esriImageFormat.esriImagePNG, esriImageReturnType.esriImageReturnMimeData);

            MapServerLegendInfo[] legendInfos = service.MapServer.GetLegendInfo(mapServerInfo.Name, null, null, imageType, null, null);

            foreach (MapLayerInfo mapLayerInfo in mapServerInfo.MapLayerInfos)
            {
                MapServerLegendInfo mapServerLegendInfo = legendInfos.FirstOrDefault(li => li.LayerID == mapLayerInfo.LayerID);
                LayerDescription    layerDescription    = mapServerInfo.DefaultMapDescription.LayerDescriptions.First(ld => ld.LayerID == mapLayerInfo.LayerID);

                Layers.Add(new AgsLayer(this, mapLayerInfo, mapServerLegendInfo, layerDescription.Visible));
            }

            CreateLayerHierarchy();
        }
        public override void OnRead(RiftClient From)
        {
            Log.Success("SelectRequest", "Enter on World : " + From.GetIp + ",GUID=" + GUID);

            if (From.Acct == null || From.Rm == null)
            {
                Log.Error("LobbyCharacterSelectRequest", "Acct or Rm == null");
                return;
            }

            Character Char = From.Rm.GetObject <CharactersMgr>().GetCharacter(GUID);

            if (Char == null || Char.AccountId != From.Acct.Id)
            {
                Log.Error("SelectRequest", "Invalid CharacterId = " + GUID);
                From.Disconnect();
                return;
            }


            MapServerInfo Info = From.Rm.GetObject <WorldMgr>().GetMapInfo();

            if (Info == null)
            {
                Log.Error("SelectRequest", "No map loaded ! Run MapServer");
                return;
            }

            Log.Success("SelectRequest", "Entering on Map : " + Info.MapAdress);

            Info.GetObject <MapMgr>().RegisterConnecting(From.Acct.Username, Char.CharacterId);

            LobbyCharacterSelectResponse Rp = new LobbyCharacterSelectResponse();

            Rp.Ips.Add(Info.MapAdress);
            From.SendSerialized(Rp);
        }
示例#8
0
        public void RegisterMaps(MapServerInfo MapInfo, RpcClientInfo RpcInfo)
        {
            MapServerInfo Info = GetMapInfo(MapInfo.MapAdress);

            if (Info == null)
                MapsInfo.Add(MapInfo);
            else
                Info.RpcInfo = RpcInfo;

            MapInfo.RpcInfo = RpcInfo;
            Log.Success("MapMgr", "Map online : " + MapInfo.MapAdress);
        }
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////
        /// <summary>
        /// Initializes routine (support reinit).
        /// </summary>
        /// <param name="mapLayer">Layer for creating images.</param>
        public void Init(MapLayer mapLayer)
        {
            Debug.Assert(null != mapLayer);
            Debug.Assert(!_serviceInWorkedState); // only once

            AgsServer server = ((AgsMapLayer)mapLayer).Server;
            ServiceHelper.ValidateServerState(server);

            _mapService = new MapServiceClient(mapLayer.Url, server.OpenConnection());

            _mapInfo = _mapService.GetServerInfo(_mapService.GetDefaultMapName());
            _mapDescription = _mapInfo.DefaultMapDescription;

            var imgType = new ImageType();
            imgType.ImageFormat = esriImageFormat.esriImagePNG;
            imgType.ImageReturnType = esriImageReturnType.esriImageReturnMimeData;

            _imgDescription = new ImageDescription();
            _imgDescription.ImageType = imgType;

            _serviceInWorkedState = true;
        }
示例#10
0
        public bool Open(gView.MapServer.IServiceRequestContext context)
        {
            if (_class == null)
            {
                _class = new AGSClass(this);
            }

            #region Parameters
            string server  = ConfigTextStream.ExtractValue(ConnectionString, "server");
            string service = ConfigTextStream.ExtractValue(ConnectionString, "service");
            string user    = ConfigTextStream.ExtractValue(ConnectionString, "user");
            string pwd     = ConfigTextStream.ExtractValue(ConnectionString, "pwd");

            if ((user == "#" || user == "$") &&
                context != null && context.ServiceRequest != null && context.ServiceRequest.Identity != null)
            {
                string roles = String.Empty;
                if (user == "#" && context.ServiceRequest.Identity.UserRoles != null)
                {
                    foreach (string role in context.ServiceRequest.Identity.UserRoles)
                    {
                        if (String.IsNullOrEmpty(role))
                        {
                            continue;
                        }
                        roles += "|" + role;
                    }
                }
                user = context.ServiceRequest.Identity.UserName + roles;
                pwd  = context.ServiceRequest.Identity.HashedPassword;
            }
            #endregion

            try
            {
                _proxy = ProxySettings.Proxy(server);

                _themes.Clear();
                _parentIds.Clear();

                _mapServer       = new gView.Interoperability.AGS.Proxy.MapServer(service);
                _mapServer.Proxy = gView.Framework.Web.ProxySettings.Proxy(service);
                MapServerInfo msi = _mapServer.GetServerInfo(_mapServer.GetDefaultMapName());
                _mapDescription = msi.DefaultMapDescription;

                MapLayerInfo[] mapLayerInfos = msi.MapLayerInfos;
                foreach (MapLayerInfo layerInfo in mapLayerInfos)
                {
                    if (layerInfo.Extent is EnvelopeN)
                    {
                        EnvelopeN env = (EnvelopeN)layerInfo.Extent;
                        if (_envelope == null)
                        {
                            _envelope = new gView.Framework.Geometry.Envelope(env.XMin, env.YMin, env.XMax, env.YMax);
                        }
                        else
                        {
                            _envelope.Union(new gView.Framework.Geometry.Envelope(env.XMin, env.YMin, env.XMax, env.YMax));
                        }
                    }

                    CalcParentLayerIds(mapLayerInfos, layerInfo.LayerID);
                    IClass           themeClass = null;
                    IWebServiceTheme theme      = null;
                    LayerDescription ld         = LayerDescriptionById(layerInfo.LayerID);
                    if (ld == null)
                    {
                        continue;
                    }

                    if (layerInfo.LayerType == "Feature Layer")
                    {
                        #region Geometry Type (Point, Line, Polygon)
                        geometryType geomType = geometryType.Unknown;
                        if (layerInfo.Fields != null)
                        {
                            foreach (Proxy.Field fieldInfo in layerInfo.Fields.FieldArray)
                            {
                                if (fieldInfo.Type == esriFieldType.esriFieldTypeGeometry &&
                                    fieldInfo.GeometryDef != null)
                                {
                                    switch (fieldInfo.GeometryDef.GeometryType)
                                    {
                                    case esriGeometryType.esriGeometryMultipoint:
                                    case esriGeometryType.esriGeometryPoint:
                                        geomType = geometryType.Point;
                                        break;

                                    case esriGeometryType.esriGeometryPolyline:
                                        geomType = geometryType.Polyline;
                                        break;

                                    case esriGeometryType.esriGeometryPolygon:
                                        geomType = geometryType.Polygon;
                                        break;

                                    case esriGeometryType.esriGeometryMultiPatch:
                                        break;
                                    }
                                }
                            }
                        }
                        #endregion

                        themeClass = new AGSThemeFeatureClass(this, layerInfo, geomType);
                        theme      = LayerFactory.Create(themeClass, _class as IWebServiceClass) as IWebServiceTheme;
                        if (theme == null)
                        {
                            continue;
                        }
                    }
                    else if (layerInfo.LayerType == "Raster Layer" ||
                             layerInfo.LayerType == "Raster Catalog Layer")
                    {
                        themeClass = new AGSThemeRasterClass(this, layerInfo);
                        theme      = LayerFactory.Create(themeClass, _class as IWebServiceClass) as IWebServiceTheme;
                        if (theme == null)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        MapLayerInfo parentLayer = MapLayerInfoById(mapLayerInfos, layerInfo.ParentLayerID);
                        if (parentLayer != null && parentLayer.LayerType == "Annotation Layer")
                        {
                            themeClass = new AGSThemeFeatureClass(this, layerInfo, geometryType.Polygon);
                            theme      = LayerFactory.Create(themeClass, _class as IWebServiceClass) as IWebServiceTheme;
                            if (theme == null)
                            {
                                continue;
                            }
                        }
                    }
                    if (theme != null)
                    {
                        theme.MinimumScale = layerInfo.MaxScale;
                        theme.MaximumScale = layerInfo.MinScale;
                        theme.Visible      = ld.Visible;
                        _themes.Add(theme);
                    }
                }

                _state = DatasetState.opened;
                return(true);
            }
            catch (Exception ex)
            {
                _state  = DatasetState.unknown;
                _errMsg = ex.Message;
                return(false);
            }
        }