Пример #1
0
        public static Imageset CreateGeneric(ImageSetType dataSetType, BandPass bandPass)
        {
            Imageset temp = new Imageset();

            temp.generic         = true;
            temp.name            = "Generic";
            temp.sparse          = false;
            temp.dataSetType     = dataSetType;
            temp.bandPass        = bandPass;
            temp.quadTreeTileMap = "";
            temp.url             = "";
            temp.levels          = 0;
            temp.baseTileDegrees = 0;
            temp.imageSetID      = 0;
            temp.extension       = "";
            temp.projection      = ProjectionType.Equirectangular;
            temp.bottomsUp       = false;
            temp.baseLevel       = 0;
            temp.mercator        = (temp.projection == ProjectionType.Mercator);
            temp.centerX         = 0;
            temp.centerY         = 0;
            temp.rotation        = 0;
            //todo add scale
            temp.thumbnailUrl = "";

            temp.matrix = Matrix3d.Identity;
            temp.matrix.Multiply(Matrix3d.RotationX((((temp.Rotation)) / 180f * Math.PI)));
            temp.matrix.Multiply(Matrix3d.RotationZ(((temp.CenterY) / 180f * Math.PI)));
            temp.matrix.Multiply(Matrix3d.RotationY((((360 - temp.CenterX) + 180) / 180f * Math.PI)));

            return(temp);
        }
 public void SetInitialParameters(string name, string url, ImageSetType dataSetType, BandPass bandPass, ProjectionType projection, int imageSetID, int baseLevel, int levels, double baseTileDegrees, string extension, bool bottomsUp, string quadTreeMap, double centerX, double centerY, double rotation, bool sparse, string thumbnailUrl, bool defaultSet, bool elevationModel, int wf, double offsetX, double offsetY, string credits, string creditsUrl, string demUrlIn, string alturl, double meanRadius, string referenceFrame)
 {
     this.ReferenceFrame  = referenceFrame;
     this.MeanRadius      = meanRadius;
     this.altUrl          = alturl;
     this.demUrl          = demUrlIn;
     this.creditsText     = credits;
     this.creditsUrl      = creditsUrl;
     this.offsetY         = offsetY;
     this.offsetX         = offsetX;
     this.widthFactor     = wf;
     this.elevationModel  = elevationModel;
     this.defaultSet      = defaultSet;
     this.name            = name;
     this.sparse          = sparse;
     this.dataSetType     = dataSetType;
     this.bandPass        = bandPass;
     this.quadTreeTileMap = quadTreeMap;
     this.url             = url;
     this.levels          = levels;
     this.baseTileDegrees = baseTileDegrees;
     this.imageSetID      = imageSetID;
     this.extension       = extension;
     this.projection      = projection;
     this.bottomsUp       = bottomsUp;
     this.baseLevel       = baseLevel;
     this.mercator        = (projection == ProjectionType.Mercator);
     this.centerX         = centerX;
     this.centerY         = centerY;
     this.rotation        = rotation;
     this.thumbnailUrl    = thumbnailUrl;
     this.ComputeMatrix();
 }
Пример #3
0
        public ImageSetHelper(ImageSetType dataSetType, BandPass bandPass)
        {
            generic          = true;
            this.name        = "Generic";
            this.sparse      = false;
            this.dataSetType = dataSetType;

            this.bandPass        = bandPass;
            this.quadTreeTileMap = "";
            this.url             = "";
            this.levels          = 0;
            this.baseTileDegrees = 0;
            this.imageSetID      = 0;
            this.extension       = "";
            this.projection      = ProjectionType.Equirectangular;
            this.bottomsUp       = false;
            this.baseLevel       = 0;
            this.mercator        = (projection == ProjectionType.Mercator);
            this.centerX         = 0;
            this.centerY         = 0;
            this.rotation        = 0;
            //todo add scale
            this.thumbnailUrl = "";

            matrix = Matrix3d.Identity;
            matrix.Multiply(Matrix3d.RotationX((((Rotation)) / 180f * Math.PI)));
            matrix.Multiply(Matrix3d.RotationZ(((CenterY) / 180f * Math.PI)));
            matrix.Multiply(Matrix3d.RotationY((((360 - CenterX) + 180) / 180f * Math.PI)));

            Earth3d.AddImageSetToTable(this.GetHash(), this);
        }
Пример #4
0
        public ImageSetHelper(ImageSetType dataSetType, BandPass bandPass)
        {
            generic = true;
            name = "Generic";
            sparse = false;
            this.dataSetType = dataSetType;

            this.bandPass = bandPass;
            quadTreeTileMap = "";
            url = "";
            levels = 0;
            baseTileDegrees = 0;
            imageSetID = 0;
            extension = "";
            projection = ProjectionType.Equirectangular;
            bottomsUp = false;
            baseLevel = 0;
            mercator = (projection == ProjectionType.Mercator);
            centerX = 0;
            centerY = 0;
            rotation = 0;
            //todo add scale
            thumbnailUrl = "";

            matrix = Matrix3d.Identity;
            matrix.Multiply(Matrix3d.RotationX((((Rotation)) / 180f * Math.PI)));
            matrix.Multiply(Matrix3d.RotationZ(((CenterY) / 180f * Math.PI)));
            matrix.Multiply(Matrix3d.RotationY((((360 - CenterX) + 180) / 180f * Math.PI)));

            Earth3d.AddImageSetToTable(GetHash(), this);
        }
Пример #5
0
        public static Imageset Create(string name, string url, ImageSetType dataSetType, BandPass bandPass, ProjectionType projection, int imageSetID, int baseLevel, int levels, int tileSize, double baseTileDegrees, string extension, bool bottomsUp, string quadTreeMap, double centerX, double centerY, double rotation, bool sparse, string thumbnailUrl, bool defaultSet, bool elevationModel, int wf, double offsetX, double offsetY, string credits, string creditsUrl, string demUrlIn, string alturl, double meanRadius, string referenceFrame)
        {
            Imageset temp = new Imageset();

            temp.ReferenceFrame  = referenceFrame;
            temp.MeanRadius      = meanRadius;
            temp.altUrl          = alturl;
            temp.demUrl          = demUrlIn;
            temp.creditsText     = credits;
            temp.creditsUrl      = creditsUrl;
            temp.offsetY         = offsetY;
            temp.offsetX         = offsetX;
            temp.widthFactor     = wf;
            temp.elevationModel  = elevationModel;
            temp.defaultSet      = defaultSet;
            temp.name            = name;
            temp.sparse          = sparse;
            temp.dataSetType     = dataSetType;
            temp.bandPass        = bandPass;
            temp.quadTreeTileMap = quadTreeMap;
            temp.url             = url;
            temp.levels          = levels;
            temp.baseTileDegrees = baseTileDegrees;
            temp.imageSetID      = imageSetID;
            temp.extension       = extension;
            temp.projection      = projection;
            temp.bottomsUp       = bottomsUp;
            temp.baseLevel       = baseLevel;
            temp.mercator        = (projection == ProjectionType.Mercator);
            temp.centerX         = centerX;
            temp.centerY         = centerY;
            temp.rotation        = rotation;
            temp.thumbnailUrl    = thumbnailUrl;
            temp.ComputeMatrix();

            return(temp);
        }
Пример #6
0
        public static Imageset FromXMLNode(XmlNode node)
        {
            try
            {
                ImageSetType type = ImageSetType.Sky;

                ProjectionType projection = ProjectionType.Tangent;

                if (node.Attributes.GetNamedItem("DataSetType") != null)
                {
                    type = (ImageSetType)Enums.Parse("ImageSetType", node.Attributes.GetNamedItem("DataSetType").Value);
                }

                BandPass bandPass = BandPass.Visible;

                bandPass = (BandPass)Enums.Parse("BandPass", node.Attributes.GetNamedItem("BandPass").Value);

                int wf = 1;
                if (node.Attributes.GetNamedItem("WidthFactor") != null)
                {
                    wf = int.Parse(node.Attributes.GetNamedItem("WidthFactor").Value);
                }

                if (node.Attributes.GetNamedItem("Generic") == null || !bool.Parse(node.Attributes.GetNamedItem("Generic").Value.ToString()))
                {
                    projection = (ProjectionType)Enums.Parse("ProjectionType", node.Attributes.GetNamedItem("Projection").Value);

                    string fileType = node.Attributes.GetNamedItem("FileType").Value.ToString();
                    if (!fileType.StartsWith("."))
                    {
                        fileType = "." + fileType;
                    }


                    string thumbnailUrl = "";

                    XmlNode thumbUrl = Util.SelectSingleNode(node, "ThumbnailUrl");
                    if (thumbUrl != null)
                    {
                        if (string.IsNullOrEmpty(thumbUrl.InnerText))
                        {
                            ChromeNode cn = (ChromeNode)(object)thumbUrl;
                            thumbnailUrl = cn.TextContent;
                        }
                        else
                        {
                            thumbnailUrl = thumbUrl.InnerText;
                        }
                    }

                    bool stockSet       = false;
                    bool elevationModel = false;

                    if (node.Attributes.GetNamedItem("StockSet") != null)
                    {
                        stockSet = bool.Parse(node.Attributes.GetNamedItem("StockSet").Value.ToString());
                    }

                    if (node.Attributes.GetNamedItem("ElevationModel") != null)
                    {
                        elevationModel = bool.Parse(node.Attributes.GetNamedItem("ElevationModel").Value.ToString());
                    }

                    string demUrl = "";
                    if (node.Attributes.GetNamedItem("DemUrl") != null)
                    {
                        demUrl = node.Attributes.GetNamedItem("DemUrl").Value.ToString();
                    }

                    string alturl = "";

                    if (node.Attributes.GetNamedItem("AltUrl") != null)
                    {
                        alturl = node.Attributes.GetNamedItem("AltUrl").Value.ToString();
                    }


                    double offsetX = 0;

                    if (node.Attributes.GetNamedItem("OffsetX") != null)
                    {
                        offsetX = double.Parse(node.Attributes.GetNamedItem("OffsetX").Value.ToString());
                    }

                    double offsetY = 0;

                    if (node.Attributes.GetNamedItem("OffsetY") != null)
                    {
                        offsetY = double.Parse(node.Attributes.GetNamedItem("OffsetY").Value.ToString());
                    }

                    string creditText = "";

                    XmlNode credits = Util.SelectSingleNode(node, "Credits");

                    if (credits != null)
                    {
                        creditText = Util.GetInnerText(credits);
                    }

                    string creditsUrl = "";

                    credits = Util.SelectSingleNode(node, "CreditsUrl");

                    if (credits != null)
                    {
                        creditsUrl = Util.GetInnerText(credits);
                    }

                    double meanRadius = 0;

                    if (node.Attributes.GetNamedItem("MeanRadius") != null)
                    {
                        meanRadius = double.Parse(node.Attributes.GetNamedItem("MeanRadius").Value.ToString());
                    }

                    string referenceFrame = null;
                    if (node.Attributes.GetNamedItem("ReferenceFrame") != null)
                    {
                        referenceFrame = node.Attributes.GetNamedItem("ReferenceFrame").Value;
                    }

                    string name = "";
                    if (node.Attributes.GetNamedItem("Name") != null)
                    {
                        name = node.Attributes.GetNamedItem("Name").Value.ToString();
                    }

                    string url = "";
                    if (node.Attributes.GetNamedItem("Url") != null)
                    {
                        url = node.Attributes.GetNamedItem("Url").Value.ToString();
                    }

                    int baseTileLevel = 0;
                    if (node.Attributes.GetNamedItem("BaseTileLevel") != null)
                    {
                        baseTileLevel = int.Parse(node.Attributes.GetNamedItem("BaseTileLevel").Value.ToString());
                    }

                    int tileLevels = 0;
                    if (node.Attributes.GetNamedItem("TileLevels") != null)
                    {
                        tileLevels = int.Parse(node.Attributes.GetNamedItem("TileLevels").Value.ToString());
                    }

                    double baseDegreesPerTile = 0;

                    if (node.Attributes.GetNamedItem("BaseDegreesPerTile") != null)
                    {
                        baseDegreesPerTile = double.Parse(node.Attributes.GetNamedItem("BaseDegreesPerTile").Value.ToString());
                    }


                    bool bottomsUp = false;


                    if (node.Attributes.GetNamedItem("BottomsUp") != null)
                    {
                        bottomsUp = bool.Parse(node.Attributes.GetNamedItem("BottomsUp").Value.ToString());
                    }

                    string quadTreeMap = "";
                    if (node.Attributes.GetNamedItem("QuadTreeMap") != null)
                    {
                        quadTreeMap = node.Attributes.GetNamedItem("QuadTreeMap").Value.ToString();
                    }

                    double centerX = 0;

                    if (node.Attributes.GetNamedItem("CenterX") != null)
                    {
                        centerX = double.Parse(node.Attributes.GetNamedItem("CenterX").Value.ToString());
                    }

                    double centerY = 0;

                    if (node.Attributes.GetNamedItem("CenterY") != null)
                    {
                        centerY = double.Parse(node.Attributes.GetNamedItem("CenterY").Value.ToString());
                    }

                    double rotation = 0;

                    if (node.Attributes.GetNamedItem("Rotation") != null)
                    {
                        rotation = double.Parse(node.Attributes.GetNamedItem("Rotation").Value.ToString());
                    }

                    bool sparse = false;

                    if (node.Attributes.GetNamedItem("Sparse") != null)
                    {
                        sparse = bool.Parse(node.Attributes.GetNamedItem("Sparse").Value.ToString());
                    }

                    return(Imageset.Create(name, url,
                                           type, bandPass, projection, Math.Abs(Util.GetHashCode(url)),
                                           baseTileLevel, tileLevels,
                                           256, baseDegreesPerTile, fileType,
                                           bottomsUp, quadTreeMap,
                                           centerX, centerY,
                                           rotation, sparse,
                                           thumbnailUrl, stockSet, elevationModel, wf, offsetX, offsetY, creditText, creditsUrl, demUrl, alturl, meanRadius, referenceFrame));
                }
                else
                {
                    return(Imageset.CreateGeneric(type, bandPass));
                }
            }
            catch
            {
                return(null);
            }
        }
        public static Imageset Create(string name, string url, ImageSetType dataSetType, BandPass bandPass, ProjectionType projection, int imageSetID, int baseLevel, int levels, int tileSize, double baseTileDegrees, string extension, bool bottomsUp, string quadTreeMap, double centerX, double centerY, double rotation, bool sparse, string thumbnailUrl, bool defaultSet, bool elevationModel, int wf, double offsetX, double offsetY, string credits, string creditsUrl, string demUrlIn, string alturl, double meanRadius, string referenceFrame)
        {
            Imageset temp = new Imageset();

            temp.SetInitialParameters(name, url, dataSetType, bandPass, projection, imageSetID, baseLevel, levels, baseTileDegrees, extension, bottomsUp, quadTreeMap, centerX, centerY, rotation, sparse, thumbnailUrl, defaultSet, elevationModel, wf, offsetX, offsetY, credits, creditsUrl, demUrlIn, alturl, meanRadius, referenceFrame);

            return(temp);
        }
Пример #8
0
        public static ImageSetHelper CreateGeneric(ImageSetType dataSetType, BandPass bandPass)
        {
            ImageSetHelper temp = new ImageSetHelper();
            temp.generic = true;
            temp.name = "Generic";
            temp.sparse = false;
            temp.dataSetType = dataSetType;
            temp.bandPass = bandPass;
            temp.quadTreeTileMap = "";
            temp.url = "";
            temp.levels = 0;
            temp.baseTileDegrees = 0;
            temp.imageSetID = 0;
            temp.extension = "";
            temp.projection = ProjectionType.Equirectangular;
            temp.bottomsUp = false;
            temp.baseLevel = 0;
            temp.mercator = (temp.projection == ProjectionType.Mercator);
            temp.centerX = 0;
            temp.centerY = 0;
            temp.rotation = 0;
            //todo add scale
            temp.thumbnailUrl = "";

            temp.matrix = Matrix3d.Identity;
            temp.matrix.Multiply(Matrix3d.RotationX((((temp.Rotation)) / 180f * Math.PI)));
            temp.matrix.Multiply(Matrix3d.RotationZ(((temp.CenterY) / 180f * Math.PI)));
            temp.matrix.Multiply(Matrix3d.RotationY((((360 - temp.CenterX) + 180) / 180f * Math.PI)));

            return temp;
        }
Пример #9
0
        public static ImageSetHelper Create(string name, string url, ImageSetType dataSetType, BandPass bandPass, ProjectionType projection, int imageSetID, int baseLevel, int levels, int tileSize, double baseTileDegrees, string extension, bool bottomsUp, string quadTreeMap, double centerX, double centerY, double rotation, bool sparse, string thumbnailUrl, bool defaultSet, bool elevationModel, int wf, double offsetX, double offsetY, string credits, string creditsUrl, string demUrlIn, string alturl, double meanRadius, string referenceFrame)
        {
            ImageSetHelper temp = new ImageSetHelper();

            temp.ReferenceFrame = referenceFrame;
            temp.MeanRadius = meanRadius;
            temp.altUrl = alturl;
            temp.demUrl = demUrlIn;
            temp.creditsText = credits;
            temp.creditsUrl = creditsUrl;
            temp.offsetY = offsetY;
            temp.offsetX = offsetX;
            temp.widthFactor = wf;
            temp.elevationModel = elevationModel;
            temp.defaultSet = defaultSet;
            temp.name = name;
            temp.sparse = sparse;
            temp.dataSetType = dataSetType;
            temp.bandPass = bandPass;
            temp.quadTreeTileMap = quadTreeMap;
            temp.url = url;
            temp.levels = levels;
            temp.baseTileDegrees = baseTileDegrees;
            temp.imageSetID = imageSetID;
            temp.extension = extension;
            temp.projection = projection;
            temp.bottomsUp = bottomsUp;
            temp.baseLevel = baseLevel;
            temp.mercator = (projection == ProjectionType.Mercator);
            temp.centerX = centerX;
            temp.centerY = centerY;
            temp.rotation = rotation;
            temp.thumbnailUrl = thumbnailUrl;
            temp.ComputeMatrix();

            return temp;
        }
Пример #10
0
        public ImageSetHelper(string name, string url, ImageSetType dataSetType, BandPass bandPass, ProjectionType projection, int imageSetID, int baseLevel, int levels, int tileSize, double baseTileDegrees, string extension, bool bottomsUp, string quadTreeMap, double centerX, double centerY, double rotation, bool sparse, string thumbnailUrl, bool defaultSet, bool elevationModel, int wf, double offsetX, double offsetY, string credits, string creditsUrl, string demUrlIn, string alturl, double meanRadius, string referenceFrame)
        {
            ReferenceFrame = referenceFrame;
            MeanRadius = meanRadius;
            altUrl = alturl;
            demUrl = demUrlIn;
            creditsText = credits;
            this.creditsUrl = creditsUrl;
            this.offsetY = offsetY;
            this.offsetX = offsetX;
            widthFactor = wf;
            this.elevationModel = elevationModel;
            this.defaultSet = defaultSet;
            this.name = name;
            this.sparse = sparse;
            this.dataSetType = dataSetType;

            this.bandPass = bandPass;
            quadTreeTileMap = quadTreeMap;
            this.url = url;
            this.levels = levels;
            this.baseTileDegrees = baseTileDegrees;
            this.imageSetID = imageSetID;
            this.extension = extension;
            this.projection = projection;
            this.bottomsUp = bottomsUp;
            this.baseLevel = baseLevel;
            mercator = (projection == ProjectionType.Mercator);
            this.centerX = centerX;
            this.centerY = centerY;
            this.rotation = rotation;
            this.thumbnailUrl = thumbnailUrl;

            ComputeMatrix();
            //if (Earth3d.multiMonClient)
            {
                Earth3d.AddImageSetToTable(GetHash(), this);
            }
        }
Пример #11
0
        public static ImageSetHelper FromXMLNode(XmlNode node)
        {
            try
            {
                var type = ImageSetType.Sky;

                var projection = ProjectionType.Tangent;
                if (node.Attributes["DataSetType"] != null)
                {
                    type = (ImageSetType)Enum.Parse(typeof(ImageSetType), node.Attributes["DataSetType"].Value, true);
                }

                var bandPass = BandPass.Visible;

                if (node.Attributes["BandPass"] != null)
                {
                    bandPass = (BandPass) Enum.Parse(typeof(BandPass),node.Attributes["BandPass"].Value);
                }
                var wf = 1;
                if (node.Attributes["WidthFactor"] != null)
                {
                    wf = Convert.ToInt32(node.Attributes["WidthFactor"].Value);
                }

                if (node.Attributes["Generic"] == null || !Convert.ToBoolean(node.Attributes["Generic"].Value))
                {

                    switch (node.Attributes["Projection"].Value.ToLower())
                    {
                        case "tan":
                        case "tangent":
                            projection = ProjectionType.Tangent;
                            break;
                        case "mercator":
                            projection = ProjectionType.Mercator;
                            break;
                        case "equirectangular":
                            projection = ProjectionType.Equirectangular;
                            break;
                        case "toast":
                            projection = ProjectionType.Toast;
                            break;
                        case "spherical":
                            projection = ProjectionType.Spherical;
                            break;
                        case "plotted":
                            projection = ProjectionType.Plotted;
                            break;
                        case "skyimage":
                            projection = ProjectionType.SkyImage;
                            break;
                    }

                    var fileType = node.Attributes["FileType"].Value;
                    if (!fileType.StartsWith("."))
                    {
                        fileType = "." + fileType;
                    }

                    string thumbnailUrl;

                    XmlNode thumbUrl = node["ThumbnailUrl"];
                    thumbnailUrl = thumbUrl.InnerText;

                    var stockSet = false;
                    var elevationModel = false;

                    if (node.Attributes["StockSet"] != null)
                    {
                        stockSet = Convert.ToBoolean(node.Attributes["StockSet"].Value);
                    }

                    if (node.Attributes["ElevationModel"] != null)
                    {
                        elevationModel = Convert.ToBoolean(node.Attributes["ElevationModel"].Value);
                    }

                    var demUrl = "";
                    if (node.Attributes["DemUrl"] != null)
                    {
                        demUrl = node.Attributes["DemUrl"].Value;
                    }

                    var alturl = "";

                    if (node.Attributes["AltUrl"] != null)
                    {
                        alturl = node.Attributes["AltUrl"].Value;
                    }

                    double offsetX = 0;

                    if (node.Attributes["OffsetX"] != null)
                    {
                        offsetX = Convert.ToDouble(node.Attributes["OffsetX"].Value);
                    }

                    double offsetY = 0;

                    if (node.Attributes["OffsetY"] != null)
                    {
                        offsetY = Convert.ToDouble(node.Attributes["OffsetY"].Value);
                    }

                    var creditText = "";

                    XmlNode credits = node["Credits"];

                    if (credits != null)
                    {
                        creditText = credits.InnerText;
                    }

                    var creditsUrl = "";

                    credits = node["CreditsUrl"];

                    if (credits != null)
                    {
                        creditsUrl = credits.InnerText;
                    }

                    double meanRadius = 0;

                    if (node.Attributes["MeanRadius"] != null)
                    {
                        meanRadius = Convert.ToDouble(node.Attributes["MeanRadius"].Value);
                    }
                    string referenceFrame = null;
                    if (node.Attributes["ReferenceFrame"] != null)
                    {
                        referenceFrame = node.Attributes["ReferenceFrame"].Value;
                    }

                    return new ImageSetHelper(node.Attributes["Name"].Value, node.Attributes["Url"].Value, type, bandPass, projection, Math.Abs(node.Attributes["Url"].Value.GetHashCode32()), Convert.ToInt32(node.Attributes["BaseTileLevel"].Value), Convert.ToInt32(node.Attributes["TileLevels"].Value), 256, Convert.ToDouble(node.Attributes["BaseDegreesPerTile"].Value), fileType, Convert.ToBoolean(node.Attributes["BottomsUp"].Value), node.Attributes["QuadTreeMap"].Value, Convert.ToDouble(node.Attributes["CenterX"].Value), Convert.ToDouble(node.Attributes["CenterY"].Value), Convert.ToDouble(node.Attributes["Rotation"].Value), Convert.ToBoolean(node.Attributes["Sparse"].Value), thumbnailUrl, stockSet, elevationModel, wf, offsetX, offsetY, creditText, creditsUrl, demUrl, alturl, meanRadius, referenceFrame);
                }
                return new ImageSetHelper(type, bandPass);
            }
            catch
            {
                return null;
            }
        }
Пример #12
0
        public Imageset GetDefaultImageset(ImageSetType imageSetType, BandPass bandPass)
        {
            foreach (Imageset imageset in ImageSets)
            {
                if (imageset.DefaultSet && imageset.BandPass == bandPass && imageset.DataSetType == imageSetType)
                {
                    return imageset;
                }

            }
            foreach (Imageset imageset in ImageSets)
            {
                if (imageset.BandPass == bandPass && imageset.DataSetType == imageSetType)
                {
                    return imageset;
                }

            }
            foreach (Imageset imageset in ImageSets)
            {
                if (imageset.DataSetType == imageSetType)
                {
                    return imageset;
                }

            }
            return ImageSets[0];
        }
Пример #13
0
        public static Imageset FromXMLNode(XmlNode node)
        {
            try
            {
                ImageSetType type = ImageSetType.Sky;

                ProjectionType projection = ProjectionType.Tangent;

                if (node.Attributes.GetNamedItem("DataSetType") != null)
                {
                    switch (node.Attributes.GetNamedItem("DataSetType").Value.ToLowerCase())
                    {
                        case "earth":
                            type = ImageSetType.Earth;
                            break;
                        case "planet":
                            type = ImageSetType.Planet;
                            break;
                        case "sky":
                            type = ImageSetType.Sky;
                            break;
                        case "panorama":
                            type = ImageSetType.Panorama;
                            break;
                        case "solarsystem":
                            type = ImageSetType.SolarSystem;
                            break;
                    }
                }

                BandPass bandPass = BandPass.Visible;

                switch (node.Attributes.GetNamedItem("BandPass").Value)
                {
                    case "Gamma":
                        bandPass = BandPass.Gamma;
                        break;
                    case "XRay":
                        bandPass = BandPass.XRay;
                        break;
                    case "Ultraviolet":
                        bandPass = BandPass.Ultraviolet;
                        break;
                    case "Visible":
                        bandPass = BandPass.Visible;
                        break;
                    case "HydrogenAlpha":
                        bandPass = BandPass.HydrogenAlpha;
                        break;
                    case "IR":
                        bandPass = BandPass.IR;
                        break;
                    case "Microwave":
                        bandPass = BandPass.Microwave;
                        break;
                    case "Radio":
                        bandPass = BandPass.Radio;
                        break;
                    case "VisibleNight":
                        bandPass = BandPass.VisibleNight;
                        break;
                    default:
                        break;
                }

                int wf = 1;
                if (node.Attributes.GetNamedItem("WidthFactor") != null)
                {
                    wf = int.Parse(node.Attributes.GetNamedItem("WidthFactor").Value);
                }

                if (node.Attributes.GetNamedItem("Generic") == null || !bool.Parse(node.Attributes.GetNamedItem("Generic").Value.ToString()))
                {

                    switch (node.Attributes.GetNamedItem("Projection").Value.ToString().ToLowerCase())
                    {
                        case "tan":
                        case "tangent":
                            projection = ProjectionType.Tangent;
                            break;
                        case "mercator":
                            projection = ProjectionType.Mercator;
                            break;
                        case "equirectangular":
                            projection = ProjectionType.Equirectangular;
                            break;
                        case "toast":
                            projection = ProjectionType.Toast;
                            break;
                        case "spherical":
                            projection = ProjectionType.Spherical;
                            break;
                        case "plotted":
                            projection = ProjectionType.Plotted;
                            break;
                        case "skyimage":
                            projection = ProjectionType.SkyImage;
                            break;
                    }

                    string fileType = node.Attributes.GetNamedItem("FileType").Value.ToString();
                    if (!fileType.StartsWith("."))
                    {
                        fileType = "." + fileType;
                    }

                    string thumbnailUrl = "";

                    XmlNode thumbUrl = Util.SelectSingleNode(node, "ThumbnailUrl");
                    if (thumbUrl != null)
                    {
                        if (string.IsNullOrEmpty(thumbUrl.InnerText))
                        {
                            ChromeNode cn = (ChromeNode)(object)thumbUrl;
                            thumbnailUrl = cn.TextContent;
                        }
                        else
                        {
                            thumbnailUrl = thumbUrl.InnerText;
                        }
                    }

                    bool stockSet = false;
                    bool elevationModel = false;

                    if (node.Attributes.GetNamedItem("StockSet") != null)
                    {
                        stockSet = bool.Parse(node.Attributes.GetNamedItem("StockSet").Value.ToString());
                    }

                    if (node.Attributes.GetNamedItem("ElevationModel") != null)
                    {
                        elevationModel = bool.Parse(node.Attributes.GetNamedItem("ElevationModel").Value.ToString());
                    }

                    string demUrl = "";
                    if (node.Attributes.GetNamedItem("DemUrl") != null)
                    {
                        demUrl = node.Attributes.GetNamedItem("DemUrl").Value.ToString();
                    }

                    string alturl = "";

                    if (node.Attributes.GetNamedItem("AltUrl") != null)
                    {
                        alturl = node.Attributes.GetNamedItem("AltUrl").Value.ToString();
                    }

                    double offsetX = 0;

                    if (node.Attributes.GetNamedItem("OffsetX") != null)
                    {
                        offsetX = double.Parse(node.Attributes.GetNamedItem("OffsetX").Value.ToString());
                    }

                    double offsetY = 0;

                    if (node.Attributes.GetNamedItem("OffsetY") != null)
                    {
                        offsetY = double.Parse(node.Attributes.GetNamedItem("OffsetY").Value.ToString());
                    }

                    string creditText = "";

                    XmlNode credits = Util.SelectSingleNode(node, "Credits");

                    if (credits != null)
                    {
                        creditText = Util.GetInnerText(credits);
                    }

                    string creditsUrl = "";

                    credits = Util.SelectSingleNode(node, "CreditsUrl");

                    if (credits != null)
                    {
                        creditsUrl = Util.GetInnerText(credits);
                    }

                    double meanRadius = 0;

                    if (node.Attributes.GetNamedItem("MeanRadius") != null)
                    {
                        meanRadius = double.Parse(node.Attributes.GetNamedItem("MeanRadius").Value.ToString());
                    }

                    string referenceFrame = null;
                    if (node.Attributes.GetNamedItem("ReferenceFrame") != null)
                    {
                        referenceFrame = node.Attributes.GetNamedItem("ReferenceFrame").Value;
                    }

                    string name = "";
                    if (node.Attributes.GetNamedItem("Name") != null)
                    {
                        name = node.Attributes.GetNamedItem("Name").Value.ToString();
                    }

                    string url = "";
                    if (node.Attributes.GetNamedItem("Url") != null)
                    {
                        url = node.Attributes.GetNamedItem("Url").Value.ToString();
                    }

                    int baseTileLevel = 0;
                    if (node.Attributes.GetNamedItem("BaseTileLevel") != null)
                    {
                        baseTileLevel = int.Parse(node.Attributes.GetNamedItem("BaseTileLevel").Value.ToString());
                    }

                    int tileLevels = 0;
                    if (node.Attributes.GetNamedItem("TileLevels") != null)
                    {
                        tileLevels = int.Parse(node.Attributes.GetNamedItem("TileLevels").Value.ToString());
                    }

                    double baseDegreesPerTile = 0;

                    if (node.Attributes.GetNamedItem("BaseDegreesPerTile") != null)
                    {
                        baseDegreesPerTile = double.Parse(node.Attributes.GetNamedItem("BaseDegreesPerTile").Value.ToString());
                    }

                    bool bottomsUp = false;

                    if (node.Attributes.GetNamedItem("BottomsUp") != null)
                    {
                        bottomsUp = bool.Parse(node.Attributes.GetNamedItem("BottomsUp").Value.ToString());
                    }

                    string quadTreeMap = "";
                    if (node.Attributes.GetNamedItem("QuadTreeMap") != null)
                    {
                        quadTreeMap = node.Attributes.GetNamedItem("QuadTreeMap").Value.ToString();
                    }

                    double centerX = 0;

                    if (node.Attributes.GetNamedItem("CenterX") != null)
                    {
                        centerX = double.Parse(node.Attributes.GetNamedItem("CenterX").Value.ToString());
                    }

                    double centerY = 0;

                    if (node.Attributes.GetNamedItem("CenterY") != null)
                    {
                        centerY = double.Parse(node.Attributes.GetNamedItem("CenterY").Value.ToString());
                    }

                    double rotation = 0;

                    if (node.Attributes.GetNamedItem("Rotation") != null)
                    {
                        rotation = double.Parse(node.Attributes.GetNamedItem("Rotation").Value.ToString());
                    }

                    bool sparse = false;

                    if (node.Attributes.GetNamedItem("Sparse") != null)
                    {
                        sparse = bool.Parse(node.Attributes.GetNamedItem("Sparse").Value.ToString());
                    }

                    return Imageset.Create(name, url,
                        type, bandPass, projection, Math.Abs(Util.GetHashCode(url)),
                        baseTileLevel, tileLevels,
                        256, baseDegreesPerTile, fileType,
                        bottomsUp, quadTreeMap,
                        centerX, centerY,
                        rotation, sparse,
                        thumbnailUrl, stockSet, elevationModel, wf, offsetX, offsetY, creditText, creditsUrl, demUrl, alturl, meanRadius, referenceFrame);
                }
                else
                {
                    return Imageset.CreateGeneric(type, bandPass);
                }

            }
            catch
            {
                return null;
            }
        }
Пример #14
0
        public static Imageset FromXMLNode(XmlNode node)
        {
            try
            {
                ImageSetType type = ImageSetType.Sky;



                ProjectionType projection = ProjectionType.Tangent;

                if (node.Attributes.GetNamedItem("DataSetType") != null)
                {
                    switch (node.Attributes.GetNamedItem("DataSetType").Value.ToLowerCase())
                    {
                    case "earth":
                        type = ImageSetType.Earth;
                        break;

                    case "planet":
                        type = ImageSetType.Planet;
                        break;

                    case "sky":
                        type = ImageSetType.Sky;
                        break;

                    case "panorama":
                        type = ImageSetType.Panorama;
                        break;

                    case "solarsystem":
                        type = ImageSetType.SolarSystem;
                        break;
                    }
                }

                BandPass bandPass = BandPass.Visible;



                switch (node.Attributes.GetNamedItem("BandPass").Value)
                {
                case "Gamma":
                    bandPass = BandPass.Gamma;
                    break;

                case "XRay":
                    bandPass = BandPass.XRay;
                    break;

                case "Ultraviolet":
                    bandPass = BandPass.Ultraviolet;
                    break;

                case "Visible":
                    bandPass = BandPass.Visible;
                    break;

                case "HydrogenAlpha":
                    bandPass = BandPass.HydrogenAlpha;
                    break;

                case "IR":
                    bandPass = BandPass.IR;
                    break;

                case "Microwave":
                    bandPass = BandPass.Microwave;
                    break;

                case "Radio":
                    bandPass = BandPass.Radio;
                    break;

                case "VisibleNight":
                    bandPass = BandPass.VisibleNight;
                    break;

                default:
                    break;
                }


                int wf = 1;
                if (node.Attributes.GetNamedItem("WidthFactor") != null)
                {
                    wf = int.Parse(node.Attributes.GetNamedItem("WidthFactor").Value);
                }

                if (node.Attributes.GetNamedItem("Generic") == null || !bool.Parse(node.Attributes.GetNamedItem("Generic").Value.ToString()))
                {
                    switch (node.Attributes.GetNamedItem("Projection").Value.ToString().ToLowerCase())
                    {
                    case "tan":
                    case "tangent":
                        projection = ProjectionType.Tangent;
                        break;

                    case "mercator":
                        projection = ProjectionType.Mercator;
                        break;

                    case "equirectangular":
                        projection = ProjectionType.Equirectangular;
                        break;

                    case "toast":
                        projection = ProjectionType.Toast;
                        break;

                    case "spherical":
                        projection = ProjectionType.Spherical;
                        break;

                    case "plotted":
                        projection = ProjectionType.Plotted;
                        break;

                    case "skyimage":
                        projection = ProjectionType.SkyImage;
                        break;
                    }

                    string fileType = node.Attributes.GetNamedItem("FileType").Value.ToString();
                    if (!fileType.StartsWith("."))
                    {
                        fileType = "." + fileType;
                    }


                    string thumbnailUrl = "";

                    XmlNode thumbUrl = Util.SelectSingleNode(node, "ThumbnailUrl");
                    if (thumbUrl != null)
                    {
                        if (string.IsNullOrEmpty(thumbUrl.InnerText))
                        {
                            ChromeNode cn = (ChromeNode)(object)thumbUrl;
                            thumbnailUrl = cn.TextContent;
                        }
                        else
                        {
                            thumbnailUrl = thumbUrl.InnerText;
                        }
                    }

                    bool stockSet       = false;
                    bool elevationModel = false;

                    if (node.Attributes.GetNamedItem("StockSet") != null)
                    {
                        stockSet = bool.Parse(node.Attributes.GetNamedItem("StockSet").Value.ToString());
                    }

                    if (node.Attributes.GetNamedItem("ElevationModel") != null)
                    {
                        elevationModel = bool.Parse(node.Attributes.GetNamedItem("ElevationModel").Value.ToString());
                    }

                    string demUrl = "";
                    if (node.Attributes.GetNamedItem("DemUrl") != null)
                    {
                        demUrl = node.Attributes.GetNamedItem("DemUrl").Value.ToString();
                    }

                    string alturl = "";

                    if (node.Attributes.GetNamedItem("AltUrl") != null)
                    {
                        alturl = node.Attributes.GetNamedItem("AltUrl").Value.ToString();
                    }


                    double offsetX = 0;

                    if (node.Attributes.GetNamedItem("OffsetX") != null)
                    {
                        offsetX = double.Parse(node.Attributes.GetNamedItem("OffsetX").Value.ToString());
                    }

                    double offsetY = 0;

                    if (node.Attributes.GetNamedItem("OffsetY") != null)
                    {
                        offsetY = double.Parse(node.Attributes.GetNamedItem("OffsetY").Value.ToString());
                    }

                    string creditText = "";

                    XmlNode credits = Util.SelectSingleNode(node, "Credits");

                    if (credits != null)
                    {
                        creditText = Util.GetInnerText(credits);
                    }

                    string creditsUrl = "";

                    credits = Util.SelectSingleNode(node, "CreditsUrl");

                    if (credits != null)
                    {
                        creditsUrl = Util.GetInnerText(credits);
                    }

                    double meanRadius = 0;

                    if (node.Attributes.GetNamedItem("MeanRadius") != null)
                    {
                        meanRadius = double.Parse(node.Attributes.GetNamedItem("MeanRadius").Value.ToString());
                    }

                    string referenceFrame = null;
                    if (node.Attributes.GetNamedItem("ReferenceFrame") != null)
                    {
                        referenceFrame = node.Attributes.GetNamedItem("ReferenceFrame").Value;
                    }

                    string name = "";
                    if (node.Attributes.GetNamedItem("Name") != null)
                    {
                        name = node.Attributes.GetNamedItem("Name").Value.ToString();
                    }

                    string url = "";
                    if (node.Attributes.GetNamedItem("Url") != null)
                    {
                        url = node.Attributes.GetNamedItem("Url").Value.ToString();
                    }

                    int baseTileLevel = 0;
                    if (node.Attributes.GetNamedItem("BaseTileLevel") != null)
                    {
                        baseTileLevel = int.Parse(node.Attributes.GetNamedItem("BaseTileLevel").Value.ToString());
                    }

                    int tileLevels = 0;
                    if (node.Attributes.GetNamedItem("TileLevels") != null)
                    {
                        tileLevels = int.Parse(node.Attributes.GetNamedItem("TileLevels").Value.ToString());
                    }

                    double baseDegreesPerTile = 0;

                    if (node.Attributes.GetNamedItem("BaseDegreesPerTile") != null)
                    {
                        baseDegreesPerTile = double.Parse(node.Attributes.GetNamedItem("BaseDegreesPerTile").Value.ToString());
                    }


                    bool bottomsUp = false;


                    if (node.Attributes.GetNamedItem("BottomsUp") != null)
                    {
                        bottomsUp = bool.Parse(node.Attributes.GetNamedItem("BottomsUp").Value.ToString());
                    }

                    string quadTreeMap = "";
                    if (node.Attributes.GetNamedItem("QuadTreeMap") != null)
                    {
                        quadTreeMap = node.Attributes.GetNamedItem("QuadTreeMap").Value.ToString();
                    }

                    double centerX = 0;

                    if (node.Attributes.GetNamedItem("CenterX") != null)
                    {
                        centerX = double.Parse(node.Attributes.GetNamedItem("CenterX").Value.ToString());
                    }

                    double centerY = 0;

                    if (node.Attributes.GetNamedItem("CenterY") != null)
                    {
                        centerY = double.Parse(node.Attributes.GetNamedItem("CenterY").Value.ToString());
                    }

                    double rotation = 0;

                    if (node.Attributes.GetNamedItem("Rotation") != null)
                    {
                        rotation = double.Parse(node.Attributes.GetNamedItem("Rotation").Value.ToString());
                    }

                    bool sparse = false;

                    if (node.Attributes.GetNamedItem("Sparse") != null)
                    {
                        sparse = bool.Parse(node.Attributes.GetNamedItem("Sparse").Value.ToString());
                    }

                    return(Imageset.Create(name, url,
                                           type, bandPass, projection, Math.Abs(Util.GetHashCode(url)),
                                           baseTileLevel, tileLevels,
                                           256, baseDegreesPerTile, fileType,
                                           bottomsUp, quadTreeMap,
                                           centerX, centerY,
                                           rotation, sparse,
                                           thumbnailUrl, stockSet, elevationModel, wf, offsetX, offsetY, creditText, creditsUrl, demUrl, alturl, meanRadius, referenceFrame));
                }
                else
                {
                    return(Imageset.CreateGeneric(type, bandPass));
                }
            }
            catch
            {
                return(null);
            }
        }
Пример #15
0
        public static ImageSetHelper FromXMLNode(XmlNode node)
        {
            try
            {
                ImageSetType type = ImageSetType.Sky;



                ProjectionType projection = ProjectionType.Tangent;
                if (node.Attributes["DataSetType"] != null)
                {
                    type = (ImageSetType)Enum.Parse(typeof(ImageSetType), node.Attributes["DataSetType"].Value.ToString(), true);
                }

                BandPass bandPass = BandPass.Visible;

                if (node.Attributes["BandPass"] != null)
                {
                    bandPass = (BandPass)Enum.Parse(typeof(BandPass), node.Attributes["BandPass"].Value.ToString());
                }
                int wf = 1;
                if (node.Attributes["WidthFactor"] != null)
                {
                    wf = Convert.ToInt32(node.Attributes["WidthFactor"].Value);
                }

                if (node.Attributes["Generic"] == null || !Convert.ToBoolean(node.Attributes["Generic"].Value.ToString()))
                {
                    switch (node.Attributes["Projection"].Value.ToString().ToLower())
                    {
                    case "tan":
                    case "tangent":
                        projection = ProjectionType.Tangent;
                        break;

                    case "mercator":
                        projection = ProjectionType.Mercator;
                        break;

                    case "equirectangular":
                        projection = ProjectionType.Equirectangular;
                        break;

                    case "toast":
                        projection = ProjectionType.Toast;
                        break;

                    case "spherical":
                        projection = ProjectionType.Spherical;
                        break;

                    case "plotted":
                        projection = ProjectionType.Plotted;
                        break;

                    case "skyimage":
                        projection = ProjectionType.SkyImage;
                        break;
                    }

                    string fileType = node.Attributes["FileType"].Value.ToString();
                    if (!fileType.StartsWith("."))
                    {
                        fileType = "." + fileType;
                    }

                    string thumbnailUrl;

                    XmlNode thumbUrl = node["ThumbnailUrl"];
                    thumbnailUrl = thumbUrl.InnerText;

                    bool stockSet       = false;
                    bool elevationModel = false;

                    if (node.Attributes["StockSet"] != null)
                    {
                        stockSet = Convert.ToBoolean(node.Attributes["StockSet"].Value.ToString());
                    }

                    if (node.Attributes["ElevationModel"] != null)
                    {
                        elevationModel = Convert.ToBoolean(node.Attributes["ElevationModel"].Value.ToString());
                    }

                    string demUrl = "";
                    if (node.Attributes["DemUrl"] != null)
                    {
                        demUrl = node.Attributes["DemUrl"].Value.ToString();
                    }

                    string alturl = "";

                    if (node.Attributes["AltUrl"] != null)
                    {
                        alturl = node.Attributes["AltUrl"].Value.ToString();
                    }


                    double offsetX = 0;

                    if (node.Attributes["OffsetX"] != null)
                    {
                        offsetX = Convert.ToDouble(node.Attributes["OffsetX"].Value.ToString());
                    }

                    double offsetY = 0;

                    if (node.Attributes["OffsetY"] != null)
                    {
                        offsetY = Convert.ToDouble(node.Attributes["OffsetY"].Value.ToString());
                    }

                    string creditText = "";

                    XmlNode credits = node["Credits"];

                    if (credits != null)
                    {
                        creditText = credits.InnerText;
                    }

                    string creditsUrl = "";

                    credits = node["CreditsUrl"];

                    if (credits != null)
                    {
                        creditsUrl = credits.InnerText;
                    }

                    double meanRadius = 0;

                    if (node.Attributes["MeanRadius"] != null)
                    {
                        meanRadius = Convert.ToDouble(node.Attributes["MeanRadius"].Value.ToString());
                    }
                    string referenceFrame = null;
                    if (node.Attributes["ReferenceFrame"] != null)
                    {
                        referenceFrame = node.Attributes["ReferenceFrame"].Value;
                    }


                    return(new ImageSetHelper(node.Attributes["Name"].Value.ToString(), node.Attributes["Url"].Value.ToString(), type, bandPass, projection, Math.Abs(node.Attributes["Url"].Value.GetHashCode32()), Convert.ToInt32(node.Attributes["BaseTileLevel"].Value), Convert.ToInt32(node.Attributes["TileLevels"].Value), 256, Convert.ToDouble(node.Attributes["BaseDegreesPerTile"].Value), fileType, Convert.ToBoolean(node.Attributes["BottomsUp"].Value.ToString()), node.Attributes["QuadTreeMap"].Value.ToString(), Convert.ToDouble(node.Attributes["CenterX"].Value), Convert.ToDouble(node.Attributes["CenterY"].Value), Convert.ToDouble(node.Attributes["Rotation"].Value), Convert.ToBoolean(node.Attributes["Sparse"].Value.ToString()), thumbnailUrl, stockSet, elevationModel, wf, offsetX, offsetY, creditText, creditsUrl, demUrl, alturl, meanRadius, referenceFrame));
                }
                else
                {
                    return(new ImageSetHelper(type, bandPass));
                }
            }
            catch
            {
                return(null);
            }
        }