Ejemplo n.º 1
0
        public Task <FindResult> DoFind(string serviceId, Geometry geometry, string fields, string value)
        {
            LayerObject lo = null;

            foreach (var t in ConfigUtil.DynamicLayer)
            {
                if (serviceId != t.Id)
                {
                    continue;
                }
                lo = t;
            }
            if (lo == null)
            {
                return(null);
            }
            var findTask = new FindTask(lo.Uri);

            if (lo.Token != null)
            {
                findTask.Token = lo.Token;
            }

            //初始化FindParameters参数
            FindParameters findParameters = new FindParameters();

            string[] Layers = lo.Layers.Split('、');
            if (Layers != null && Layers.Length > 0)
            {
                foreach (var item in Layers)
                {
                    var layerId = lo.GetLayerId(item);
                    if (layerId != null)
                    {
                        findParameters.LayerIDs.Add(Convert.ToInt16(layerId)); //查找的图层
                    }
                }
            }
            findParameters.SearchFields.Add(fields); //查找的字段范围
            findParameters.ReturnGeometry = true;
            findParameters.Contains       = false;
            findParameters.SearchText     = value; //查找的“属性值”

            //异步执行
            return(findTask.ExecuteAsync(findParameters));
        }
Ejemplo n.º 2
0
        public Task <IdentifyResult> DoIdentify(string serviceId, string layers, MapPoint pt)
        {
            LayerObject lo = null;

            foreach (var t in ConfigUtil.DynamicLayer)
            {
                if (serviceId != t.Id)
                {
                    continue;
                }
                lo = t;
            }
            if (lo == null)
            {
                return(null);
            }

            //创建查询IdentifyTask
            IdentifyTask task = new IdentifyTask(lo.Uri);


            if (lo.Token != null)
            {
                task.Token = lo.Token;
            }

            //设置查询参数
            var queryPara = new IdentifyParameters(pt, Map.MapView.Extent, 7
                                                   , (int)Map.MapView.ActualHeight, (int)Map.MapView.ActualWidth)
            {
                LayerOption = LayerOption.Visible
            };

            var layerArr = layers.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            var ids = (from layer in layerArr select lo.GetLayerId(layer) into layerId where layerId != null select(int) layerId).ToList();

            queryPara.LayerIDs = ids;

            queryPara.SpatialReference = Map.MapView.SpatialReference;
            return(task.ExecuteAsync(queryPara));
        }
Ejemplo n.º 3
0
        public Task <QueryResult> DoQuery(string serviceId, string layer, Geometry geometry, string where)
        {
            LayerObject lo = null;

            foreach (var t in ConfigUtil.DynamicLayer)
            {
                if (serviceId != t.Id)
                {
                    continue;
                }
                lo = t;
            }
            if (lo == null)
            {
                return(null);
            }
            var layerId = lo.GetLayerId(layer);
            var task    = layerId != null ? new QueryTask(new Uri(lo.Uri + "/" + layerId)) : new QueryTask(lo.Uri);

            if (lo.Token != null)
            {
                task.Token = lo.Token;
            }
            var query = new Query("1=1");

            if (geometry != null)
            {
                query.Geometry = geometry;
            }
            if (where.Trim() != "")
            {
                query.Where = where;
            }
            query.ReturnGeometry = true;
            return(task.ExecuteAsync(query));
        }