示例#1
0
        public static RecordSet QueryFeatures(LayerDescription activelayerdesc, QueryFilter qf, bool useTrueCurves)
        {
            QueryResultOptions queryResultOptions = new QueryResultOptions();

            queryResultOptions.Format = esriQueryResultFormat.esriQueryResultRecordSetAsObject;
            GeometryResultOptions geometryResultOptions = new GeometryResultOptions();

            geometryResultOptions.MaximumDeviation       = 0.0;
            geometryResultOptions.MaximumSegmentLength   = -1.0;
            geometryResultOptions.MaximumAllowableOffset = 0.0;
            if (useTrueCurves)
            {
                geometryResultOptions.DensifyGeometries = false;
            }
            else
            {
                geometryResultOptions.DensifyGeometries    = true;
                geometryResultOptions.GeneralizeGeometries = true;
            }
            activelayerdesc.LayerResultOptions = new LayerResultOptions
            {
                FormatValuesInResults     = true,
                GeometryResultOptions     = geometryResultOptions,
                IncludeGeometry           = true,
                ReturnFieldNamesInResults = true
            };
            QueryResult queryResult = MapServiceFidTests._mapservice.QueryFeatureData2(MapServiceFidTests.name, activelayerdesc, qf, queryResultOptions);

            return((RecordSet)queryResult.Object);
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the FeatureLayer class.
        /// </summary>
        /// <param name="featureLayerUri">The URL of the feature layer.</param>
        /// <param name="layerDescription">The reference to the layer description object.</param>
        /// <param name="requestSender">The reference to the request sender object.</param>
        /// <exception cref="System.ArgumentNullException"><paramref name="featureLayerUri"/>,
        /// <paramref name="layerDescription"/> or <paramref name="requestSender"/> argument is
        /// a null reference.</exception>
        public FeatureLayer(
            Uri featureLayerUri,
            LayerDescription layerDescription,
            IFeatureServiceRequestSender requestSender)
        {
            if (featureLayerUri == null)
            {
                throw new ArgumentNullException("featureLayerUri");
            }

            if (layerDescription == null)
            {
                throw new ArgumentNullException("layerDescription");
            }

            if (requestSender == null)
            {
                throw new ArgumentNullException("requestSender");
            }

            var serializer = new JsonSerializer(VrpRequestBuilder.JsonTypes, true);

            _mapper           = new FeatureRecordMapper <TFeatureRecord>(layerDescription, serializer);
            _requestSender    = requestSender;
            _uri              = featureLayerUri;
            _layerDescription = layerDescription;
        }
示例#3
0
        public static void QueryFeaturesTest()
        {
            MapServiceFidTests.Initialize();
            LayerDescription layerDescription = null;

            LayerDescription[] layerDescriptions = MapServiceFidTests._mapinfo.DefaultMapDescription.LayerDescriptions;
            for (int i = 0; i < layerDescriptions.Length; i++)
            {
                LayerDescription layerDescription2 = layerDescriptions[i];
                if (layerDescription2.LayerID == 13)
                {
                    layerDescription = layerDescription2;
                    break;
                }
            }
            string        geomFieldName = MapServiceFidTests.GetGeomFieldName(MapServiceFidTests._mapinfo, layerDescription.LayerID);
            SpatialFilter spatialfilter = MapServiceFidTests.BuildSpatialFilter((EnvelopeN)MapServiceFidTests._mapinfo.Extent, geomFieldName, MapServiceFidTests._mapinfo.DefaultMapDescription.SpatialReference);

            MapServiceFidTests.completeSpRef = MapServiceFidTests._mapinfo.DefaultMapDescription.SpatialReference;
            int num = 4326;

            MapServiceFidTests.wkidSpRef = MapServiceFidTests.SpRefFromWKID(ref num);
            string wKT = MapServiceFidTests.completeSpRef.WKT;

            MapServiceFidTests.wktSpRef = MapServiceFidTests.SpRefFromWKT(ref wKT);
            string text = "PROJCS[\"WGS_1984_Web_Mercator_Auxiliary_Sphere\",GEOGCS[\"GCS_WGS_1984\",DATUM[\"D_WGS_1984\",SPHEROID[\"WGS_1984\",6378137.0,298.257223563]],PRIMEM[\"Greenwich\",0.0],UNIT[\"Degree\",0.0174532925199433]],PROJECTION[\"Mercator_Auxiliary_Sphere\"],PARAMETER[\"False_Easting\",0.0],PARAMETER[\"False_Northing\",0.0],PARAMETER[\"Central_Meridian\",0.0],PARAMETER[\"Standard_Parallel_1\",0.0],PARAMETER[\"Auxiliary_Sphere_Type\",0.0],UNIT[\"Meter\",1.0],AUTHORITY[\"EPSG\",3857]]";

            MapServiceFidTests.alternateSpRef = MapServiceFidTests.SpRefFromWKT(ref text);
            MapServiceFidTests.TestAlt(layerDescription, spatialfilter);
        }
        /// <summary>
        /// Initializes a new instance of the FeatureRecordMapper class with the specified layer
        /// description.
        /// </summary>
        /// <param name="description">The reference to the layer description for feature
        /// layer containing feature records to be converted.</param>
        /// <param name="serializer">The reference to the serializer object to be used for
        /// serializing complex data types.</param>
        /// <exception cref="System.ArgumentNullException"><paramref name="description"/> or
        /// <paramref name="serializer"/> is a null reference.</exception>
        public FeatureRecordMapper(LayerDescription description, ISerializer serializer)
        {
            if (description == null)
            {
                throw new ArgumentNullException("description");
            }

            if (serializer == null)
            {
                throw new ArgumentNullException("serializer");
            }

            _layerDescription = description;
            _serializer       = serializer;

            _properties = TypeDescriptor.GetProperties(typeof(TFeatureRecord))
                          .Cast <PropertyDescriptor>()
                          .ToDictionary(property => property.Name);

            _locationProperty = _properties.Values
                                .Where(property => _IsGeometryType(property.PropertyType))
                                .FirstOrDefault();

            var objectIDPropertyName = _GetPropertyName(o => o.ObjectID);

            _properties.TryGetValue(objectIDPropertyName, out _objectIDProperty);
        }
示例#5
0
        public static void TheTest(LayerDescription activelayerdesc, SpatialFilter spatialfilter, SpatialReference sp1, SpatialReference sp2)
        {
            string oIDFieldName = MapServiceFidTests.GetOIDFieldName(MapServiceFidTests._mapinfo, activelayerdesc.LayerID);

            spatialfilter.OutputSpatialReference = sp1;
            EnvelopeN envelopeN = spatialfilter.FilterGeometry as EnvelopeN;

            envelopeN.SpatialReference   = sp2;
            spatialfilter.FilterGeometry = envelopeN;
            FIDSet      fIDSet      = MapServiceFidTests.BuildFIDSet(MapServiceFidTests.name, activelayerdesc, spatialfilter);
            QueryFilter queryFilter = MapServiceFidTests.BuildQueryFromFIDSet(fIDSet, sp1);

            queryFilter.OutputSpatialReference = sp1;
            RecordSet        recordSet        = MapServiceFidTests.QueryFeatures(activelayerdesc, queryFilter, false);
            RecordSet        rs               = MapServiceFidTests.QueryFeatures(activelayerdesc, queryFilter, true);
            int              num              = MapServiceFidTests.FindGeometryFieldIndex(recordSet);
            SpatialReference spatialReference = recordSet.Fields.FieldArray[num].GeometryDef.SpatialReference;

            recordSet = MapServiceFidTests.ProjectRecordSet(MapServiceFidTests._mapinfo.FullExtent, recordSet, num, spatialReference, sp2);
            rs        = MapServiceFidTests.ProjectRecordSet(MapServiceFidTests._mapinfo.FullExtent, rs, num, spatialReference, sp2);
            FIDSet fIDSet2 = MapServiceFidTests.BuildDeltaFIDSet(fIDSet, recordSet, oIDFieldName);

            while (fIDSet2.FIDArray.Length > 0)
            {
                queryFilter = MapServiceFidTests.BuildQueryFromFIDSet(fIDSet2, sp1);
                queryFilter.OutputSpatialReference = sp1;
                recordSet = MapServiceFidTests.QueryFeatures(activelayerdesc, queryFilter, false);
                rs        = MapServiceFidTests.QueryFeatures(activelayerdesc, queryFilter, true);
                fIDSet2   = MapServiceFidTests.BuildDeltaFIDSet(fIDSet2, recordSet, oIDFieldName);
            }
        }
        static void Main()
        {
            LayerDescription desciption = new LayerDescription()
            {
                Bias = 0.0, LayerFactory = new SimpleLayerFactory(), Name = "Single", NeuronNumber = 5
            };
            Network neuralNetwork = new Network(5, new List <LayerDescription> {
                desciption
            });
            IEnumerable <IEnumerable <double> > inputData = new List <IEnumerable <double> >
            {
                new List <double> {
                    0, 1, 2, 3, 4
                },
                new List <double> {
                    0, 1, 2, 3, 4
                },
                new List <double> {
                    0, 1, 2, 3, 4
                },
                new List <double> {
                    0, 1, 2, 3, 4
                },
                new List <double> {
                    0, 1, 2, 3, 4
                }
            };
            IEnumerable <double> result = neuralNetwork.Compute(inputData);

            Console.WriteLine(string.Join(" , ", result));
            Console.ReadKey();
        }
示例#7
0
 public LayerDescription(LayerDescription layer)
 {
     this.imagepath      = layer.imagepath;
     this.imageDepthPath = layer.imageDepthPath;
     this.imageLumPath   = layer.imageLumPath;
     this.isFloatImage   = layer.isFloatImage;
     this.paramidx       = layer.paramidx;
     this.paramvalid     = layer.paramvalid;
 }
示例#8
0
        private MapImage GetMapImage(esriImageReturnType returnType)
        {
            MapDescription mapDescription = ((AgsDataFrame)DataFrame).MapServerInfo.NewMapDescription(Extent);

            mapDescription.SetAllLayersNotVisible();

            for (int i = 0; i < _layerList.Count; ++i)
            {
                AgsLayer layer = _layerList[i];
                string   query = _queryList[i];

                MapLayerInfo mapLayerInfo = layer.MapLayerInfo;

                while (mapLayerInfo != null)
                {
                    LayerDescription layerDescription = mapDescription.LayerDescriptions.First(ld => ld.LayerID == mapLayerInfo.LayerID);
                    layerDescription.Visible = true;

                    if (!String.IsNullOrEmpty(query))
                    {
                        layerDescription.DefinitionExpression = query;
                    }

                    mapLayerInfo = mapLayerInfo.Parent;
                    query        = null;
                }
            }

            ImageDescription imageDescription = new ImageDescription();

            imageDescription.ImageDisplay = new ImageDisplay(Convert.ToInt32(Width * Resolution), Convert.ToInt32(Height * Resolution), DataFrame.Dpi * Resolution);
            imageDescription.ImageType    = new ImageType(returnType);

            switch (ImageType)
            {
            case CommonImageType.Png:
                imageDescription.ImageType.ImageFormat = esriImageFormat.esriImagePNG32;

                if (TransparentBackground)
                {
                    mapDescription.TransparentColor = mapDescription.BackgroundSymbol.Color;
                }
                break;

            default:
                imageDescription.ImageType.ImageFormat = esriImageFormat.esriImageJPG;
                break;
            }

            return(_service.MapServer.ExportMapImage(mapDescription, imageDescription));
        }
示例#9
0
        private static FIDSet BuildFIDSet(string name, LayerDescription activelayerdesc, SpatialFilter spatialfilter)
        {
            FIDSet result;

            try
            {
                result = MapServiceFidTests._mapservice.QueryFeatureIDs2(name, activelayerdesc, spatialfilter);
            }
            catch
            {
                result = null;
            }
            return(result);
        }
        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();
        }
示例#11
0
    public static bool IsHidden(Type layerType)
    {
        LayerDescription layerData = (LayerDescription)Attribute.GetCustomAttribute(layerType, typeof(LayerDescription));

        return(layerData.Hide);
    }
示例#12
0
    public static string GetLayerTypeName(Type layerType)
    {
        LayerDescription layerData = (LayerDescription)Attribute.GetCustomAttribute(layerType, typeof(LayerDescription));

        return(layerData.LayerName);
    }
示例#13
0
 public static void TestSix(LayerDescription activelayerdesc, SpatialFilter spatialfilter)
 {
     MapServiceFidTests.TheTest(activelayerdesc, spatialfilter, MapServiceFidTests.wktSpRef, MapServiceFidTests.wkidSpRef);
 }
示例#14
0
 public static void TestOne(LayerDescription activelayerdesc, SpatialFilter spatialfilter)
 {
     MapServiceFidTests.TheTest(activelayerdesc, spatialfilter, MapServiceFidTests.completeSpRef, MapServiceFidTests.completeSpRef);
 }
示例#15
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);
            }
        }
示例#16
0
        CallState _initializationCallState;  // call state for the InitializeAsync method


        /// <summary>
        /// Creates a new Layer from the specified LayerDescription.
        /// </summary>
        public Layer(LayerDescription layerDesc)
        {
            LayerDescription = layerDesc;
            ConnectionStatus = LayerConnectionStatus.NotConnected;
        }
示例#17
0
        public bool MapRequest(gView.Framework.Carto.IDisplay display)
        {
            if (_dataset == null ||
                _dataset._mapServer == null ||
                _dataset._mapDescription == null || Themes == null)
            {
                return(false);
            }

            List <IWebServiceTheme> themes = Themes;

            #region Check for visible Layers
            bool visFound = false;
            foreach (IWebServiceTheme theme in themes)
            {
                if (!theme.Visible)
                {
                    continue;
                }
                if (theme.MinimumScale > 1 && theme.MinimumScale > display.mapScale)
                {
                    continue;
                }
                if (theme.MaximumScale > 1 && theme.MaximumScale < display.mapScale)
                {
                    continue;
                }

                visFound = true;
                break;
            }
            if (!visFound)
            {
                if (_image != null)
                {
                    _image.Dispose();
                    _image = null;
                }
                return(true);
            }
            #endregion

            ISpatialReference sRef = (display.SpatialReference != null) ?
                                     display.SpatialReference.Clone() as ISpatialReference :
                                     null;

            int iWidth  = display.iWidth;
            int iHeight = display.iHeight;

            if (BeforeMapRequest != null)
            {
                BeforeMapRequest(this, display, ref sRef, ref iWidth, ref iHeight);
            }

            try
            {
                #region Extent
                _dataset._mapDescription.MapArea.Extent =
                    ArcServerHelper.EnvelopeN(display.Envelope);
                if (display.DisplayTransformation.UseTransformation)
                {
                    _dataset._mapDescription.Rotation = display.DisplayTransformation.DisplayRotation;
                }
                #endregion

                #region Back/Transparent Color
                RgbColor         backColor  = ArcServerHelper.RgbColor(display.BackgroundColor);
                SimpleFillSymbol fillSymbol = new SimpleFillSymbol();
                fillSymbol.Color   = backColor;
                fillSymbol.Outline = null;
                _dataset._mapDescription.BackgroundSymbol = fillSymbol;
                _dataset._mapDescription.TransparentColor = backColor;
                #endregion

                #region Layer Visibility
                LayerDescription[] layerDescriptions = _dataset._mapDescription.LayerDescriptions;
                foreach (LayerDescription layerDescr in layerDescriptions)
                {
                    IWebServiceTheme theme = GetThemeByLayerId(layerDescr.LayerID.ToString());
                    if (theme == null)
                    {
                        continue;
                    }
                    layerDescr.Visible = theme.Visible;
                    if (layerDescr.Visible)
                    {
                        foreach (int parentLayerId in _dataset.ParentLayerIds(layerDescr.LayerID))
                        {
                            LayerDescription parent = _dataset.LayerDescriptionById(parentLayerId);
                            if (parent != null)
                            {
                                parent.Visible = true;
                            }
                        }
                    }
                }
                #endregion

                #region ImageDescription
                ImageType imgType = new ImageType();
                imgType.ImageFormat     = esriImageFormat.esriImagePNG24;
                imgType.ImageReturnType = esriImageReturnType.esriImageReturnURL;

                ImageDisplay imgDisp = new ImageDisplay();
                imgDisp.ImageWidth       = iWidth;
                imgDisp.ImageHeight      = iHeight;
                imgDisp.ImageDPI         = display.dpi;
                imgDisp.TransparentColor = backColor;

                ImageDescription imgDescr = new ImageDescription();
                imgDescr.ImageDisplay = imgDisp;
                imgDescr.ImageType    = imgType;
                #endregion

                MapImage mapImg = _dataset._mapServer.ExportMapImage(_dataset._mapDescription, imgDescr);
                if (mapImg != null && !String.IsNullOrEmpty(mapImg.ImageURL))
                {
                    System.Drawing.Bitmap bm = WebFunctions.DownloadImage(mapImg.ImageURL, _dataset._proxy, System.Net.CredentialCache.DefaultNetworkCredentials);
                    if (bm != null)
                    {
                        _image                  = new GeorefBitmap(bm);
                        _image.Envelope         = new gView.Framework.Geometry.Envelope(new gView.Framework.Geometry.Envelope(display.Envelope));
                        _image.SpatialReference = display.SpatialReference;

                        if (AfterMapRequest != null)
                        {
                            AfterMapRequest(this, display, _image);
                        }
                    }
                }
                else
                {
                    if (_image != null)
                    {
                        _image.Dispose();
                        _image = null;
                    }
                }
                return(_image != null);
            }
            catch (Exception ex)
            {
                //ArcIMSClass.ErrorLog(context, "MapRequest", server, service, ex);
                return(false);
            }
        }