Exemple #1
0
 public ArcIMSReprojectDownload(ArcIMSServerUri serverUri, int index, GeographicBoundingBox sourceBounds, ArcIMSFeatureCoordSys sourceCoordSys, String serviceName)
     : base(serverUri, index)
 {
     this.sourceBounds   = sourceBounds;
     this.sourceCoordSys = sourceCoordSys;
     this.serviceName    = serviceName;
 }
Exemple #2
0
        internal ArcIMSQuadLayerBuilder(ArcIMSServerUri oServerUri, String strServiceName, String szLayerTitle, String szLayerID, GeographicBoundingBox oEnvelope, ArcIMSFeatureCoordSys oProjection, WorldWindow oWorldWindow, IBuilder oParent, double dMinScale, double dMaxScale, CultureInfo oInfo)
            : base(szLayerTitle, oWorldWindow, oParent)
        {
            m_oServerUri           = oServerUri;
            m_oCultureInfo         = oInfo;
            m_oUnprojectedEnvelope = oEnvelope;
            m_oProjection          = oProjection;
            m_szLayerID            = szLayerID;
            m_szServiceName        = strServiceName;
            m_dMinScale            = dMinScale;
            if (m_dMinScale < DefaultMinScale)
            {
                m_dMinScale = DefaultMinScale;
            }
            m_dMaxScale = dMaxScale;
            if (m_dMaxScale > DefaultMaxScale)
            {
                m_dMaxScale = DefaultMaxScale;
            }
            if (m_dMaxScale < m_dMinScale)
            {
                // --- Weird scale values, ignore them and hope for the best ---
                m_dMaxScale = DefaultMaxScale;
                m_dMinScale = DefaultMinScale;
            }

            CalculateLevels();
        }
 public ArcIMSReprojectDownload(ArcIMSServerUri serverUri, int index, GeographicBoundingBox sourceBounds, ArcIMSFeatureCoordSys sourceCoordSys, String serviceName)
     : base(serverUri, index)
 {
     this.sourceBounds = sourceBounds;
     this.sourceCoordSys = sourceCoordSys;
     this.serviceName = serviceName;
 }
        internal ArcIMSQuadLayerBuilder(ArcIMSServerUri oServerUri, String strServiceName, String szLayerTitle, String szLayerID, GeographicBoundingBox oEnvelope, ArcIMSFeatureCoordSys oProjection, WorldWindow oWorldWindow, IBuilder oParent, double dMinScale, double dMaxScale, CultureInfo oInfo)
            : base(szLayerTitle, oWorldWindow, oParent)
        {
            m_oServerUri = oServerUri;
            m_oCultureInfo = oInfo;
            m_oUnprojectedEnvelope = oEnvelope;
            m_oProjection = oProjection;
            m_szLayerID = szLayerID;
            m_szServiceName = strServiceName;
            m_dMinScale = dMinScale;
            if (m_dMinScale < DefaultMinScale)
                m_dMinScale = DefaultMinScale;
            m_dMaxScale = dMaxScale;
            if (m_dMaxScale > DefaultMaxScale)
                m_dMaxScale = DefaultMaxScale;
            if (m_dMaxScale < m_dMinScale)
            {
                // --- Weird scale values, ignore them and hope for the best ---
                m_dMaxScale = DefaultMaxScale;
                m_dMinScale = DefaultMinScale;
            }

            CalculateLevels();
        }
Exemple #5
0
        protected override ModelNode[] Load()
        {
            NumberStyles parseStyle =
                NumberStyles.AllowDecimalPoint |
                NumberStyles.AllowLeadingSign |
                NumberStyles.AllowLeadingWhite |
                NumberStyles.AllowTrailingWhite;

            String strServiceFilename = CapabilitiesFilename;

            ArcIMSServiceDownload oServiceDownload = new ArcIMSServiceDownload((Parent as ServerModelNode).Uri as ArcIMSServerUri, m_strServiceName, 0);
            oServiceDownload.DownloadFile(strServiceFilename);

            // --- Parse the XML document downloaded ---

            XmlDocument oServiceXML = new XmlDocument();
            try
            {
                oServiceXML.Load(strServiceFilename);
            }
            catch (XmlException)
            {
                throw new InvalidDataException("Server's response is not valid XML");
            }

            XmlElement oFeatureCoordSys = oServiceXML.SelectSingleNode("/ARCXML/RESPONSE/SERVICEINFO/PROPERTIES/FEATURECOORDSYS") as XmlElement;
            if (oFeatureCoordSys != null)
            {
                m_oCoordinateSystem = new ArcIMSFeatureCoordSys(m_oCultureInfo, oFeatureCoordSys);
            }
            else
            {
                m_oCoordinateSystem = new ArcIMSFeatureCoordSys(m_oCultureInfo);
            }

            GeographicBoundingBox oServiceBounds = null;

            XmlElement oServiceEnvelope = oServiceXML.SelectSingleNode("/ARCXML/RESPONSE/SERVICEINFO/PROPERTIES/ENVELOPE") as XmlElement;
            if (oServiceEnvelope != null)
            {
                GeographicBoundingBox oRealServiceBounds = new GeographicBoundingBox();
                bool blValid = true;
                blValid &= Double.TryParse(oServiceEnvelope.GetAttribute("minx"), parseStyle, m_oCultureInfo, out oRealServiceBounds.West);
                blValid &= Double.TryParse(oServiceEnvelope.GetAttribute("miny"), parseStyle, m_oCultureInfo, out oRealServiceBounds.South);
                blValid &= Double.TryParse(oServiceEnvelope.GetAttribute("maxx"), parseStyle, m_oCultureInfo, out oRealServiceBounds.East);
                blValid &= Double.TryParse(oServiceEnvelope.GetAttribute("maxy"), parseStyle, m_oCultureInfo, out oRealServiceBounds.North);

                if (blValid)
                    oServiceBounds = oRealServiceBounds;
            }

            List<ModelNode> result = new List<ModelNode>();

            XmlNodeList oNodeList = oServiceXML.SelectNodes("/ARCXML/RESPONSE/SERVICEINFO/LAYERINFO");
            foreach (XmlElement nLayerElement in oNodeList)
            {
                String szID = nLayerElement.GetAttribute("id");
                String szTitle = nLayerElement.GetAttribute("name");
                if (String.IsNullOrEmpty(szTitle)) szTitle = "LayerID " + szID;

                String szMinScale = nLayerElement.GetAttribute("minscale");
                double dMinScale = ArcIMSQuadLayerBuilder.DefaultMinScale;
                if (!String.IsNullOrEmpty(szMinScale))
                {
                    Double.TryParse(szMinScale, NumberStyles.Any, CultureInfo.InvariantCulture, out dMinScale);
                }

                String szMaxScale = nLayerElement.GetAttribute("maxscale");
                double dMaxScale = ArcIMSQuadLayerBuilder.DefaultMaxScale;
                if (!String.IsNullOrEmpty(szMaxScale))
                {
                    Double.TryParse(szMaxScale, NumberStyles.Any, CultureInfo.InvariantCulture, out dMaxScale);
                }

                if (dMaxScale < dMinScale || dMinScale > 1.0)
                {
                    // --- If the server sends back weird values, ignore them ---
                    dMaxScale = ArcIMSQuadLayerBuilder.DefaultMaxScale;
                    dMinScale = ArcIMSQuadLayerBuilder.DefaultMinScale;
                }

                GeographicBoundingBox oLayerBounds = (oServiceBounds != null ? oServiceBounds.Clone() as GeographicBoundingBox : null);

                XmlElement oLayerEnvelope = null;
                if (nLayerElement.GetAttribute("type").Equals("image"))
                    oLayerEnvelope = nLayerElement.SelectSingleNode("ENVELOPE") as XmlElement;
                if (nLayerElement.GetAttribute("type").Equals("featureclass"))
                    oLayerEnvelope = nLayerElement.SelectSingleNode("FCLASS/ENVELOPE") as XmlElement;
                if (oLayerEnvelope != null)
                {
                    GeographicBoundingBox oRealLayerBounds = new GeographicBoundingBox();
                    bool blValid = true;
                    blValid &= Double.TryParse(oLayerEnvelope.GetAttribute("minx"), parseStyle, m_oCultureInfo, out oRealLayerBounds.West);
                    blValid &= Double.TryParse(oLayerEnvelope.GetAttribute("miny"), parseStyle, m_oCultureInfo, out oRealLayerBounds.South);
                    blValid &= Double.TryParse(oLayerEnvelope.GetAttribute("maxx"), parseStyle, m_oCultureInfo, out oRealLayerBounds.East);
                    blValid &= Double.TryParse(oLayerEnvelope.GetAttribute("maxy"), parseStyle, m_oCultureInfo, out oRealLayerBounds.North);
                    if (blValid)
                        oLayerBounds = oRealLayerBounds;
                }

                result.Add(new ArcIMSLayerModelNode(m_oModel, szTitle, szID, oLayerBounds, dMinScale, dMaxScale, m_oCultureInfo));
            }

            result.Sort();

            return result.ToArray();
        }