A Lat/Lon "Box" that is used in a GroundOverlay to describe how to stretch the image over the terrain.
Inheritance: geObject
Ejemplo n.º 1
0
        private void processRasterLayer(LayerProperties layerProps, geFolder folder)
        {
            IRasterLayer currentLayer = layerProps.Layeru as IRasterLayer;

            //get coordinates for image :D
            geAngle90 north;
            geAngle90 south;
            geAngle180 east;
            geAngle180 west;
            Double coordlat, coordlong;
            IPoint refPoint;

            refPoint = currentLayer.AreaOfInterest.LowerLeft;

            //coordinate system.
            IGeographicCoordinateSystem gcs;
            SpatialReferenceEnvironment sre = new SpatialReferenceEnvironment();

            //create coordinate system for WGS 84 (Google earth)
            gcs = sre.CreateGeographicCoordinateSystem((int)esriSRGeoCSType.esriSRGeoCS_WGS1984);

            //spatial reference
            ISpatialReference pointToSpatialReference;
            pointToSpatialReference = gcs;

            //project point to google earth projection
            refPoint.Project(pointToSpatialReference);

            //and get coordinates
            refPoint.QueryCoords(out coordlong, out coordlat);
            //left = west point and lower = south
            west= new geAngle180(coordlong);
            south = new geAngle90(coordlat);

            //and upper right
            refPoint = currentLayer.AreaOfInterest.UpperRight;

            //project point to google earth projection
            refPoint.Project(pointToSpatialReference);
            //x.ToString("{0:0.00}");

            //and get coordinates
            refPoint.QueryCoords(out coordlong, out coordlat);

            //north and east
            north = new geAngle90(coordlat);
            east = new geAngle180(coordlong);

            //so I have all coordinates, now I create the overlay.
            geGroundOverlay.geLatLonBox latlonbox = new geGroundOverlay.geLatLonBox(north,south,east,west);
            geGroundOverlay overlay = new geGroundOverlay(latlonbox);

            //copy image to current folder...
            string name =  System.IO.Path.GetDirectoryName(Path);
            name = System.IO.Path.Combine(name, currentLayer.Name);
            File.Copy(currentLayer.FilePath, name,true);

               // overlay.Icon.Href = currentLayer.FilePath;
            overlay.Icon = new geIcon(System.IO.Path.GetFileName(name));
            overlay.Name = currentLayer.Name;
            overlay.Description = currentLayer.FilePath;
            overlay.StyleUrl = "#Shape2KMLGeneratedStyle";

            switch (layerProps.AltitudeMode)
            {
                case AltitudeMode.absolute:
                    overlay.AltitudeMode = geAltitudeModeEnum.absolute;
                    overlay.Altitude = layerProps.Altitude;
                    //use altitude from field , do that later...
                    break;
                case AltitudeMode.clampToGround:
                    overlay.AltitudeMode = geAltitudeModeEnum.clampToGround;
                    break;
                case AltitudeMode.relativeToGround:
                    overlay.AltitudeMode = geAltitudeModeEnum.relativeToGround;
                    overlay.Altitude = layerProps.Altitude;
                    //use altitude from field , do that later...
                    break;
                default:
                    break;
            }

            //and add overlay to folder. THAT "simple"
            folder.Features.Add(overlay);
        }