Esempio n. 1
0
        async public Task <bool> Open()
        {
            await RefreshClasses();

            _state = DatasetState.opened;
            return(true);
        }
Esempio n. 2
0
        public bool Open()
        {
            /*
             *          _file=new SHPFile(_connectionString);
             *
             *          _minX=_file.Header.Xmin;
             *          _minY=_file.Header.Ymin;
             *          _maxX=_file.Header.Xmax;
             *          _maxY=_file.Header.Ymax;
             *
             *          // Tree bauen fehlt noch...
             *          double [] minBounds=new double[4];
             *          double [] maxBounds=new double[4];
             *          minBounds[0]=_minX;
             *          minBounds[1]=_minY;
             *          maxBounds[0]=_maxX;
             *          maxBounds[1]=_maxY;
             *
             *          //QuadTree _tree=null; //new QuadTree((int)_file.Entities);
             *          //_tree.SHPCreateTree(2,10,new Envelope(_minX,_minY,_maxX,_maxY));
             *
             *          if(!_file.IDX_Exists && _file.IDX_Filename!="")
             *          {
             *                  DualTree tree=new DualTree(500);
             *
             *  CreateSpatialIndexTree creator = new CreateSpatialIndexTree(_file, tree, (IEnvelope)(new Envelope(_minX, _minY, _maxX, _maxY)));
             *
             *  if (_useGUI)
             *  {
             *      Thread thread = new Thread(new ThreadStart(creator.Create));
             *      gView.Framework.UI.Dialogs.FormProgress frmProgress = new gView.Framework.UI.Dialogs.FormProgress(tree, thread);
             *      frmProgress.Text = "Create Spatial Index...";
             *
             *      frmProgress.ShowDialog();
             *  }
             *  else
             *  {
             *      creator.Create();
             *  }
             *          }
             *
             *          gView.Framework.FDB.IIndexTree iTree=null;
             *          if(_file.IDX_Exists)
             *          {
             *  iTree = new IDXIndexTree(_file.IDX_Filename);
             *                  //iTree=new gView.Framework.FDB.FDBDualTree(_file.IDX_Filename,_file.Title);
             *          }
             *
             *          ShapeDatasetElement layer=new ShapeDatasetElement(_file,this,iTree);
             *
             *          _layers=new List<IDatasetElement>();
             *          _layers.Add(layer);
             */

            _state = DatasetState.opened;
            return(true);
        }
Esempio n. 3
0
        public bool Open()
        {
            _class           = new ParentRasterClass(this);
            _dsElement       = new DatasetElement(_class);
            _dsElement.Title = "Cache";

            _state = DatasetState.opened;
            return(true);
        }
Esempio n. 4
0
        public Task <bool> Open()
        {
            _class           = new ParentRasterClass(this);
            _dsElement       = new DatasetElement(_class);
            _dsElement.Title = "Cache";

            _state = DatasetState.opened;
            return(Task.FromResult(true));
        }
Esempio n. 5
0
        public bool Open()
        {
            if (_fdb == null) return false;

            _dsID = _fdb.DatasetID(_dsname);
            if (_dsID < 0) return false;

            _sRef = this.SpatialReference;
            _state = DatasetState.opened;
            _sIndexDef = _fdb.SpatialIndexDef(_dsID);

            return true;
        }
Esempio n. 6
0
        public Task <bool> SetConnectionString(string value)
        {
            if (value == String.Empty)
            {
                _etcon = null;
            }
            else
            {
                _etcon = new EventTableConnection();
                _etcon.FromXmlString(value);
                _state = DatasetState.unknown;
            }

            return(Task.FromResult(true));
        }
Esempio n. 7
0
        public bool Open()
        {
            if (_connStr == "")
            {
                return(false);
            }

            //if (_sConnection != null)
            //{
            //    _sConnection.Dispose();
            //}
            //_sConnection = new SmartSdeConnection(_connStr);

            _state = DatasetState.opened;
            return(true);
        }
Esempio n. 8
0
        public bool Open()
        {
            if (_connString == null || _connString == "" ||
                _dsname == null || _dsname == "" || _fdb == null)
            {
                return(false);
            }

            _dsID = _fdb.DatasetID(_dsname);
            if (_dsID == -1)
            {
                return(false);
            }

            _sRef      = _fdb.SpatialReference(_dsname);
            _sIndexDef = _fdb.SpatialIndexDef(_dsID);

            _state = DatasetState.opened;
            return(true);
        }
Esempio n. 9
0
        public bool Open()
        {
            try
            {
                OSGeo.OGR.Ogr.RegisterAll();

                _dataSource = OSGeo.OGR.Ogr.Open(_connectionString, 0);
                if (_dataSource != null)
                {
                    _state = DatasetState.opened;
                    return(true);
                }
                return(false);
            }
            catch (Exception ex)
            {
                _lastErrMsg = ex.Message;
                return(false);
            }
        }
Esempio n. 10
0
        async public Task <bool> Open(gView.MapServer.IServiceRequestContext context)
        {
            string url = String.Empty;

            try
            {
                _isOpened = true;
                bool ret = true;

                if (_wfsDataset != null)
                {
                    ret = _wfsDataset.Open();
                }
                if (_class != null)
                {
                    string param = "REQUEST=GetCapabilities&VERSION=1.1.1&SERVICE=WMS";

                    url = Append2Url(_connection, param);
                    string response = WebFunctions.HttpSendRequest(url, "GET", null,
                                                                   ConfigTextStream.ExtractValue(_connectionString, "usr"),
                                                                   ConfigTextStream.ExtractValue(_connectionString, "pwd"));

                    response = RemoveDOCTYPE(response);

                    _class.Init(response, _wfsDataset);
                }

                _state = (ret) ? DatasetState.opened : DatasetState.unknown;

                return(ret);
            }
            catch (Exception ex)
            {
                await WMSClass.ErrorLogAsync(context, "GetCapabilities", url, ex);

                _class      = null;
                _wfsDataset = null;

                return(false);
            }
        }
Esempio n. 11
0
        async public Task <bool> Open()
        {
            if (_fdb == null)
            {
                return(false);
            }

            _dsID = await _fdb.DatasetID(_dsname);

            if (_dsID < 0)
            {
                return(false);
            }

            _sRef = await this.GetSpatialReference();

            _state     = DatasetState.opened;
            _sIndexDef = await _fdb.SpatialIndexDef(_dsID);

            return(true);
        }
Esempio n. 12
0
        public Task <bool> Open()
        {
            try
            {
                switch (OSGeo.Initializer.InstalledVersion)
                {
                case OSGeo.GdalVersion.V1:
                    using (var dataSourceV1 = OSGeo_v1.OGR.Ogr.Open(_connectionString, 0))
                    {
                        if (dataSourceV1 != null)
                        {
                            _state = DatasetState.opened;
                            return(Task.FromResult(true));
                        }
                    }

                    break;

                case OSGeo.GdalVersion.V3:
                    using (var dataSourceV3 = OSGeo_v3.OGR.Ogr.Open(_connectionString, 0))
                    {
                        if (dataSourceV3 != null)
                        {
                            _state = DatasetState.opened;
                            return(Task.FromResult(true));
                        }
                    }

                    break;
                }


                return(Task.FromResult(false));
            }
            catch (Exception ex)
            {
                _lastErrMsg = ex.Message;
                return(Task.FromResult(false));
            }
        }
Esempio n. 13
0
        async public Task <bool> Open()
        {
            if (_fdb == null)
            {
                return(false);
            }

            _dsID = await _fdb.DatasetID(_dsname);

            if (_dsID < 0)
            {
                _errMsg = _fdb.LastErrorMessage ?? _fdb.lastException?.Message;
                return(false);
            }

            _sRef = await this.GetSpatialReference();

            _state     = DatasetState.opened;
            _sIndexDef = await _fdb.SpatialIndexDef(_dsID);

            return(true);
        }
Esempio n. 14
0
        public bool Open()
        {
            try
            {
                _state = DatasetState.unknown;
                _elements.Clear();

                FileInfo fi_gml = new FileInfo(_connectionString);
                if (!fi_gml.Exists)
                {
                    return(false);
                }
                FileInfo fi_xsd = new FileInfo(fi_gml.FullName.Substring(0, fi_gml.FullName.Length - fi_gml.Extension.Length) + ".xsd");
                if (!fi_xsd.Exists)
                {
                    return(false);
                }

                _gml_file = fi_gml.FullName;
                _xsd_file = fi_xsd.FullName;

                XmlDocument schema = new XmlDocument();
                schema.Load(System.IO.File.ReadAllText(fi_xsd.FullName));
                XmlSchemaReader schemaReader    = new XmlSchemaReader(schema);
                string          targetNamespace = schemaReader.TargetNamespaceURI;
                if (targetNamespace == String.Empty)
                {
                    return(false);
                }

                PlugInManager compMan = new PlugInManager();
                foreach (string elementName in schemaReader.ElementNames)
                {
                    string       shapeFieldName;
                    geometryType geomType;
                    Fields       fields = schemaReader.ElementFields(elementName, out shapeFieldName, out geomType);
                    FeatureClass fc     = new FeatureClass(this, elementName, fields);
                    fc.ShapeFieldName = shapeFieldName;
                    fc.GeometryType   = geomType;
                    IFeatureLayer layer = LayerFactory.Create(fc) as IFeatureLayer;
                    if (layer == null)
                    {
                        continue;
                    }

                    //layer.FeatureRenderer = compMan.getComponent(KnownObjects.Carto_UniversalGeometryRenderer) as IFeatureRenderer;

                    _elements.Add(layer);
                }

                _doc = new XmlDocument();

                using (XmlTextReader xmlTextReader = new XmlTextReader(fi_gml.FullName))
                {
                    xmlTextReader.ReadToDescendant("boundedBy", "http://www.opengis.net/gml");
                    string boundedBy = xmlTextReader.ReadOuterXml();
                    _doc.LoadXml(boundedBy);
                }

                _ns = new XmlNamespaceManager(_doc.NameTable);
                _ns.AddNamespace("GML", "http://www.opengis.net/gml");
                _ns.AddNamespace("WFS", "http://www.opengis.net/wfs");
                _ns.AddNamespace("OGC", "http://www.opengis.net/ogc");
                _ns.AddNamespace("myns", targetNamespace);
                XmlNode boundedByNode = _doc.ChildNodes[0];

                if (boundedByNode != null)
                {
                    XmlNode geomNode = boundedByNode.SelectSingleNode("GML:*", _ns);
                    if (geomNode != null)
                    {
                        _envelope = GeometryTranslator.GML2Geometry(geomNode.OuterXml, _gmlVersion) as IEnvelope;
                        if (geomNode.Attributes["srsName"] != null)
                        {
                            _sRef = gView.Framework.Geometry.SpatialReference.FromID(geomNode.Attributes["srsName"].Value);
                        }
                    }
                }

                _state = DatasetState.opened;
                return(true);
            }
            catch (Exception ex)
            {
                _errMsg = ex.Message;
                return(false);
            }
        }
Esempio n. 15
0
        public bool Open()
        {
            try
            {
                _opened = true;
                _themes.Clear();

                MapServerConnection server = new MapServerConnection(ConfigTextStream.ExtractValue(_connection, "server"));
                string axl = "<ARCXML version=\"1.1\"><REQUEST><GET_SERVICE_INFO fields=\"true\" envelope=\"true\" renderer=\"false\" extensions=\"false\" gv_meta=\"true\" /></REQUEST></ARCXML>";
                axl = server.Send(_name, axl, "BB294D9C-A184-4129-9555-398AA70284BC",
                                  ConfigTextStream.ExtractValue(_connection, "user"),
                                  ConfigTextStream.ExtractValue(_connection, "pwd"));

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(axl);

                if (_class == null)
                {
                    _class = new MapServerClass(this);
                }

                double  dpi    = 96.0;
                XmlNode screen = doc.SelectSingleNode("//ENVIRONMENT/SCREEN");
                if (screen != null)
                {
                    if (screen.Attributes["dpi"] != null)
                    {
                        dpi = Convert.ToDouble(screen.Attributes["dpi"].Value.Replace(".", ","));
                    }
                }
                double dpm = (dpi / 0.0254);

                XmlNode spatialReference = doc.SelectSingleNode("//PROPERTIES/SPATIALREFERENCE");
                if (spatialReference != null)
                {
                    if (spatialReference.Attributes["param"] != null)
                    {
                        SpatialReference sRef = new SpatialReference();
                        gView.Framework.Geometry.SpatialReference.FromProj4(sRef, spatialReference.Attributes["param"].Value);

                        if (spatialReference.Attributes["name"] != null)
                        {
                            sRef.Name = spatialReference.Attributes["name"].Value;
                        }

                        _class.SpatialReference = sRef;
                    }
                }
                else
                {
                    XmlNode FeatureCoordSysNode = doc.SelectSingleNode("ARCXML/RESPONSE/SERVICEINFO/PROPERTIES/FEATURECOORDSYS");
                    if (FeatureCoordSysNode != null)
                    {
                        if (FeatureCoordSysNode.Attributes["id"] != null)
                        {
                            _class.SpatialReference = gView.Framework.Geometry.SpatialReference.FromID("epsg:" + FeatureCoordSysNode.Attributes["id"].Value);
                        }
                        else if (FeatureCoordSysNode.Attributes["string"] != null)
                        {
                            _class.SpatialReference = gView.Framework.Geometry.SpatialReference.FromWKT(FeatureCoordSysNode.Attributes["string"].Value);
                        }

                        // TODO: Geogr. Datum aus "datumtransformid" und "datumtransformstring"
                        //if (_sRef != null && FeatureCoordSysNode.Attributes["datumtransformstring"] != null)
                        //{

                        //}
                    }
                }

                foreach (XmlNode envelopeNode in doc.SelectNodes("//ENVELOPE"))
                {
                    if (_envelope == null)
                    {
                        _envelope = (new Envelope(envelopeNode)).MakeValid();
                    }
                    else
                    {
                        _envelope.Union((new Envelope(envelopeNode)).MakeValid());
                    }
                }
                foreach (XmlNode layerNode in doc.SelectNodes("//LAYERINFO[@id]"))
                {
                    bool visible = true;

                    ISpatialReference sRef = _class.SpatialReference;

                    /*
                     * spatialReference = doc.SelectSingleNode("//PROPERTIES/SPATIALREFERENCE");
                     * if (spatialReference != null)
                     * {
                     *  if (spatialReference.Attributes["param"] != null)
                     *  {
                     *      sRef = new SpatialReference();
                     *      gView.Framework.Geometry.SpatialReference.FromProj4(sRef, spatialReference.Attributes["param"].Value);
                     *
                     *      if (spatialReference.Attributes["name"] != null)
                     *          ((SpatialReference)sRef).Name = spatialReference.Attributes["name"].Value;
                     *  }
                     * }
                     * else
                     * {
                     *  XmlNode FeatureCoordSysNode = doc.SelectSingleNode("ARCXML/RESPONSE/SERVICEINFO/PROPERTIES/FEATURECOORDSYS");
                     *  if (FeatureCoordSysNode != null)
                     *  {
                     *      if (FeatureCoordSysNode.Attributes["id"] != null)
                     *      {
                     *          sRef = gView.Framework.Geometry.SpatialReference.FromID("epsg:" + FeatureCoordSysNode.Attributes["id"].Value);
                     *      }
                     *      else if (FeatureCoordSysNode.Attributes["string"] != null)
                     *      {
                     *          sRef = gView.Framework.Geometry.SpatialReference.FromWKT(FeatureCoordSysNode.Attributes["string"].Value);
                     *      }
                     *
                     *      // TODO: Geogr. Datum aus "datumtransformid" und "datumtransformstring"
                     *      //if (_sRef != null && FeatureCoordSysNode.Attributes["datumtransformstring"] != null)
                     *      //{
                     *
                     *      //}
                     *  }
                     * }
                     */

                    if (layerNode.Attributes["visible"] != null)
                    {
                        bool.TryParse(layerNode.Attributes["visible"].Value, out visible);
                    }

                    IClass           themeClass = null;
                    IWebServiceTheme theme      = null;
                    if (layerNode.Attributes["type"] != null && layerNode.Attributes["type"].Value == "featureclass")
                    {
                        themeClass = new MapThemeFeatureClass(this, layerNode.Attributes["id"].Value);
                        ((MapThemeFeatureClass)themeClass).Name             = layerNode.Attributes["name"] != null ? layerNode.Attributes["name"].Value : layerNode.Attributes["id"].Value;
                        ((MapThemeFeatureClass)themeClass).fieldsFromAXL    = layerNode.InnerXml;
                        ((MapThemeFeatureClass)themeClass).SpatialReference = sRef;

                        XmlNode FCLASS = layerNode.SelectSingleNode("FCLASS[@type]");
                        if (FCLASS != null)
                        {
                            ((MapThemeFeatureClass)themeClass).fClassTypeString = FCLASS.Attributes["type"].Value;
                        }
                        theme = LayerFactory.Create(themeClass, _class) as IWebServiceTheme;
                        if (theme == null)
                        {
                            continue;
                        }
                        theme.Visible = visible;
                    }
                    else if (layerNode.Attributes["type"] != null && layerNode.Attributes["type"].Value == "image")
                    {
                        if (layerNode.SelectSingleNode("gv_meta/class/implements[@type='gView.Framework.Data.IPointIdentify']") != null)
                        {
                            themeClass = new MapThemeQueryableRasterClass(this, layerNode.Attributes["id"].Value);
                            ((MapThemeQueryableRasterClass)themeClass).Name = layerNode.Attributes["name"] != null ? layerNode.Attributes["name"].Value : layerNode.Attributes["id"].Value;
                        }
                        else
                        {
                            themeClass = new MapThemeRasterClass(this, layerNode.Attributes["id"].Value);
                            ((MapThemeRasterClass)themeClass).Name = layerNode.Attributes["name"] != null ? layerNode.Attributes["name"].Value : layerNode.Attributes["id"].Value;
                        }
                        theme = new WebServiceTheme(
                            themeClass,
                            themeClass.Name,
                            layerNode.Attributes["id"].Value,
                            visible,
                            _class);
                    }
                    else
                    {
                        continue;
                    }

                    try
                    {
                        if (layerNode.Attributes["minscale"] != null)
                        {
                            theme.MinimumScale = Convert.ToDouble(layerNode.Attributes["minscale"].Value.Replace(".", ",")) * dpm;
                        }
                        if (layerNode.Attributes["maxscale"] != null)
                        {
                            theme.MaximumScale = Convert.ToDouble(layerNode.Attributes["maxscale"].Value.Replace(".", ",")) * dpm;
                        }
                    }
                    catch { }
                    _themes.Add(theme);
                }
                _state = DatasetState.opened;
                return(true);
            }
            catch (Exception ex)
            {
                _state = DatasetState.unknown;
                _class = null;
                return(false);
            }
        }
Esempio n. 16
0
 public bool Open()
 {
     RefreshClasses();
     _state = DatasetState.opened;
     return(true);
 }
Esempio n. 17
0
 virtual public Task <bool> Open()
 {
     _state = DatasetState.opened;
     return(Task.FromResult(true));
 }
Esempio n. 18
0
 public bool Open()
 {
     _state = DatasetState.opened;
     return(true);
 }
Esempio n. 19
0
 public void Dispose()
 {
     _state = DatasetState.unknown;
 }
Esempio n. 20
0
        async public Task <bool> Open(IServiceRequestContext context)
        {
            if (_class == null)
            {
                _class = new ArcIMSClass(this);
            }

            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;
            //}

            dotNETConnector connector = new dotNETConnector();

            if (!String.IsNullOrEmpty(user) || !String.IsNullOrEmpty(pwd))
            {
                connector.setAuthentification(user, pwd);
            }

            try
            {
                _themes.Clear();

                string axl = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ARCXML version=\"1.1\"><REQUEST><GET_SERVICE_INFO fields=\"true\" envelope=\"true\" renderer=\"true\" extensions=\"true\" /></REQUEST></ARCXML>";
                //string axl = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ARCXML version=\"1.1\"><REQUEST><GET_SERVICE_INFO dpi=\"96\" toc=\"true\" /></REQUEST></ARCXML>";

                await ArcIMSClass.LogAsync(context, "GetServiceInfo Response", server, service, axl);

                axl = connector.SendRequest(axl, server, service);
                await ArcIMSClass.LogAsync(context, "GetServiceInfo Response", server, service, axl);

                XmlDocument doc = new XmlDocument();
                doc.LoadXml(axl);

                double  dpi    = 96.0;
                XmlNode screen = doc.SelectSingleNode("//ENVIRONMENT/SCREEN");
                if (screen != null)
                {
                    if (screen.Attributes["dpi"] != null)
                    {
                        dpi = Convert.ToDouble(screen.Attributes["dpi"].Value.Replace(".", ","));
                    }
                }
                double dpm = (dpi / 0.0254);

                XmlNode FeatureCoordSysNode = doc.SelectSingleNode("ARCXML/RESPONSE/SERVICEINFO/PROPERTIES/FEATURECOORDSYS");
                _sRef = ArcXMLGeometry.AXL2SpatialReference(FeatureCoordSysNode);

                foreach (XmlNode envelopeNode in doc.SelectNodes("//ENVELOPE"))
                {
                    if (_envelope == null)
                    {
                        _envelope = new Envelope(envelopeNode);
                    }
                    else
                    {
                        _envelope.Union(new Envelope(envelopeNode));
                    }
                }
                foreach (XmlNode layerNode in doc.SelectNodes("//LAYERINFO[@id]"))
                {
                    bool visible = true;

                    if (layerNode.Attributes["visible"] != null)
                    {
                        bool.TryParse(layerNode.Attributes["visible"].Value, out visible);
                    }

                    XmlNode tocNode = layerNode.SelectSingleNode("TOC");
                    if (tocNode != null)
                    {
                        ReadTocNode(tocNode);
                    }
                    IClass           themeClass = null;
                    IWebServiceTheme theme;
                    if (layerNode.Attributes["type"] != null && layerNode.Attributes["type"].Value == "featureclass")
                    {
                        themeClass = await ArcIMSThemeFeatureClass.CreateAsync(this, layerNode.Attributes["id"].Value);

                        ((ArcIMSThemeFeatureClass)themeClass).Name             = layerNode.Attributes["name"] != null ? layerNode.Attributes["name"].Value : layerNode.Attributes["id"].Value;
                        ((ArcIMSThemeFeatureClass)themeClass).fieldsFromAXL    = layerNode.InnerXml;
                        ((ArcIMSThemeFeatureClass)themeClass).SpatialReference = _sRef;

                        XmlNode FCLASS = layerNode.SelectSingleNode("FCLASS[@type]");
                        if (FCLASS != null)
                        {
                            ((ArcIMSThemeFeatureClass)themeClass).fClassTypeString = FCLASS.Attributes["type"].Value;
                        }
                        foreach (XmlNode child in layerNode.ChildNodes)
                        {
                            switch (child.Name)
                            {
                            case "SIMPLERENDERER":
                            case "SIMPLELABELRENDERER":
                            case "VALUEMAPRENDERER":
                            case "SCALEDEPENDENTRENDERER":
                            case "VALUEMAPLABELRENDERER":
                            case "GROUPRENDERER":
                                ((ArcIMSThemeFeatureClass)themeClass).OriginalRendererNode = child;
                                break;
                            }
                        }
                        theme = LayerFactory.Create(themeClass, _class as IWebServiceClass) as IWebServiceTheme;
                        if (theme == null)
                        {
                            continue;
                        }
                        theme.Visible = visible;
                    }
                    else if (layerNode.Attributes["type"] != null && layerNode.Attributes["type"].Value == "image")
                    {
                        //themeClass = new ArcIMSThemeRasterClass(this,
                        //    layerNode.Attributes["name"] != null ? layerNode.Attributes["name"].Value : layerNode.Attributes["id"].Value);
                        themeClass = new ArcIMSThemeRasterClass(this, layerNode.Attributes["id"].Value);
                        ((ArcIMSThemeRasterClass)themeClass).Name = layerNode.Attributes["name"] != null ? layerNode.Attributes["name"].Value : layerNode.Attributes["id"].Value;

                        theme = new WebServiceTheme(
                            themeClass,
                            themeClass.Name,
                            layerNode.Attributes["id"].Value,
                            visible,
                            _class as IWebServiceClass);
                    }
                    else
                    {
                        continue;
                    }

                    try
                    {
                        if (layerNode.Attributes["minscale"] != null)
                        {
                            theme.MinimumScale = Convert.ToDouble(layerNode.Attributes["minscale"].Value.Replace(".", ",")) * dpm;
                        }
                        if (layerNode.Attributes["maxscale"] != null)
                        {
                            theme.MaximumScale = Convert.ToDouble(layerNode.Attributes["maxscale"].Value.Replace(".", ",")) * dpm;
                        }
                    }
                    catch { }
                    _themes.Add(theme);
                }
                _state = DatasetState.opened;

                ((ArcIMSClass)_class).SpatialReference = await this.GetSpatialReference();

                return(true);
            }
            catch (Exception ex)
            {
                _state  = DatasetState.unknown;
                _errMsg = ex.Message;
                await ArcIMSClass.ErrorLog(context, "Open Dataset", server, service, ex);

                return(false);
            }
        }
Esempio n. 21
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);
            }
        }