예제 #1
0
        private static IField createRasterField(string string_0, bool bool_0, ISpatialReference ispatialReference_0)
        {
            IFieldEdit2 edit = new Field() as IFieldEdit2;
            IRasterDef  def  = new RasterDef
            {
                Description = "this is a raster catalog",
                IsManaged   = bool_0
            };

            if (string_0.Length == 0)
            {
                string_0 = "RASTER";
            }
            edit.Name_2 = string_0;
            edit.Type_2 = esriFieldType.esriFieldTypeRaster;
            if (ispatialReference_0 == null)
            {
                ispatialReference_0 = new UnknownCoordinateSystem() as ISpatialReference;
            }
            (ispatialReference_0 as ISpatialReferenceResolution).get_XYResolution(true);
            (ispatialReference_0 as ISpatialReferenceResolution).set_XYResolution(true, 0.001);
            (ispatialReference_0 as ISpatialReferenceResolution).SetDefaultXYResolution();
            def.SpatialReference = ispatialReference_0;
            edit.RasterDef       = def;
            return(edit);
        }
예제 #2
0
        public ISpatialReference CreateSpatialReferenceFromDefinitionStr(string str)
        {
            ISpatialReference spatialRef = new UnknownCoordinateSystem() as ISpatialReference;

            try
            {
                string tempFile = System.IO.Path.GetTempFileName();
                string prjFile  = System.IO.Path.ChangeExtension(tempFile, ".prj");
                File.Move(tempFile, prjFile);    //修改文件扩展名

                using (FileStream fs = new FileStream(prjFile, FileMode.Open))
                {
                    StreamWriter sw = new StreamWriter(fs, Encoding.Unicode);
                    sw.WriteLine(str);
                    sw.Flush();
                    sw.Close();

                    spatialRef = new SpatialReferenceEnvironment().CreateESRISpatialReferenceFromPRJFile(prjFile);

                    File.Delete(prjFile);
                }
            }
            catch (Exception ex)
            {
                ErrorMessage = ex.Message;
            }
            return(spatialRef);
        }
예제 #3
0
        public static IGeometryDef CreateGeometryDef(ISpatialReference ispatialReference_0)
        {
            IGeometryDefEdit geometryDefEdit = new GeometryDef() as IGeometryDefEdit;

            geometryDefEdit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;
            geometryDefEdit.AvgNumPoints_2 = 4;
            if (ispatialReference_0 == null)
            {
                ispatialReference_0 = new UnknownCoordinateSystem() as ISpatialReference;
            }
            geometryDefEdit.SpatialReference_2 = ispatialReference_0;
            return(geometryDefEdit);
        }
예제 #4
0
        public static IRasterDef CreateRasterDef(bool bool_0, ISpatialReference ispatialReference_0)
        {
            IRasterDef def = new RasterDef
            {
                Description = "Raster Dataset"
            };

            if (ispatialReference_0 == null)
            {
                ispatialReference_0 = new UnknownCoordinateSystem() as ISpatialReference;
            }
            def.SpatialReference = ispatialReference_0;
            return(def);
        }
예제 #5
0
        private IRasterDef method_0(bool bool_0, ISpatialReference ispatialReference_0)
        {
            IRasterDef rasterDefClass = new RasterDef()
            {
                Description = "Raster Dataset"
            };

            if (ispatialReference_0 == null)
            {
                ispatialReference_0 = new UnknownCoordinateSystem() as ISpatialReference;
            }
            rasterDefClass.SpatialReference = ispatialReference_0;
            return(rasterDefClass);
        }
예제 #6
0
        public static ISpatialReference ConstructCoordinateSystem(IGeodatabaseRelease igeodatabaseRelease_0)
        {
            bool geoDatasetPrecision = GeodatabaseTools.GetGeoDatasetPrecision(igeodatabaseRelease_0);

            ISpatialReference  spatialReference = new UnknownCoordinateSystem() as ISpatialReference;
            IControlPrecision2 controlPrecision = spatialReference as IControlPrecision2;

            controlPrecision.IsHighPrecision = geoDatasetPrecision;
            ISpatialReferenceResolution spatialReferenceResolution = spatialReference as ISpatialReferenceResolution;

            spatialReferenceResolution.ConstructFromHorizon();
            spatialReferenceResolution.SetDefaultXYResolution();
            ISpatialReferenceTolerance spatialReferenceTolerance = spatialReference as ISpatialReferenceTolerance;

            spatialReferenceTolerance.SetDefaultXYTolerance();
            return(spatialReference);
        }
예제 #7
0
        private static IGeometryDef createGeometryDef(ISpatialReference ispatialReference_0)
        {
            IGeometryDefEdit edit = new GeometryDef() as IGeometryDefEdit;

            edit.GeometryType_2 = esriGeometryType.esriGeometryPolygon;
            edit.AvgNumPoints_2 = 4;
            edit.GridCount_2    = 1;
            edit.set_GridSize(0, 1000.0);
            if (ispatialReference_0 == null)
            {
                ispatialReference_0 = new UnknownCoordinateSystem() as ISpatialReference;
            }
            (ispatialReference_0 as ISpatialReferenceResolution).set_XYResolution(true, 0.001);
            (ispatialReference_0 as ISpatialReferenceResolution).SetDefaultXYResolution();
            edit.SpatialReference_2 = ispatialReference_0;
            return(edit);
        }
예제 #8
0
 public static IRasterDataset createFileRasterDataset(IRasterWorkspace2 irasterWorkspace2_0, string string_0,
                                                      int int_0, rstPixelType rstPixelType_0, ISpatialReference ispatialReference_0)
 {
     try
     {
         IRasterDataset dataset = null;
         IPoint         origin  = new Point();
         origin.PutCoords(0.0, 0.0);
         if (ispatialReference_0 == null)
         {
             ispatialReference_0 = new UnknownCoordinateSystem() as ISpatialReference;
         }
         dataset = irasterWorkspace2_0.CreateRasterDataset(string_0, "IMAGINE Image", origin, 200, 100, 1.0, 1.0,
                                                           int_0, rstPixelType_0, ispatialReference_0, true);
         IRawPixels            pixels = null;
         IPixelBlock3          block  = null;
         IPnt                  tlc    = null;
         IPnt                  size   = null;
         IRasterBandCollection bands  = (IRasterBandCollection)dataset;
         pixels = (IRawPixels)bands.Item(0);
         IRasterProps props = (IRasterProps)pixels;
         tlc = new DblPnt();
         tlc.SetCoords(0.0, 0.0);
         size = new DblPnt();
         size.SetCoords((double)props.Width, (double)props.Height);
         block = (IPixelBlock3)pixels.CreatePixelBlock(size);
         pixels.Read(tlc, (IPixelBlock)block);
         object[,] objArray = (object[, ])block.get_PixelDataByRef(0);
         for (int i = 0; i < props.Width; i++)
         {
             for (int j = 0; j < props.Height; j++)
             {
                 objArray[i, j] = (i * j) % 255;
             }
         }
         object cache = pixels.AcquireCache();
         pixels.Write(tlc, (IPixelBlock)block);
         pixels.ReturnCache(cache);
         return(dataset);
     }
     catch (Exception exception)
     {
         Debug.WriteLine(exception.Message);
         return(null);
     }
 }
예제 #9
0
        private IGeometryDef method_2(ISpatialReference ispatialReference_0)
        {
            IGeometryDefEdit @class = new GeometryDef() as IGeometryDefEdit;

            @class.GeometryType_2 = esriGeometryType.esriGeometryPolygon;
            @class.AvgNumPoints_2 = 4;
            @class.GridCount_2    = 1;
            IGeometryDefEdit geometryDefClass = @class as IGeometryDefEdit;

            geometryDefClass.GridSize_2[0] = 1000;
            if (ispatialReference_0 == null)
            {
                ispatialReference_0 = new UnknownCoordinateSystem() as ISpatialReference;
            }
            geometryDefClass.SpatialReference_2 = ispatialReference_0;
            return(geometryDefClass);
        }
 ////private static int _defaultWkid = int.Parse(ConfigurationManager.AppSettings["DefaultSpatialReference"]);
 ////private static int _sqlSR = int.Parse(ConfigurationManager.AppSettings["SqlSpatialReferenceWkid"]);
 /////// <summary>
 /////// The default spatial reference id (probably WGS_84 - id: 4326)
 /////// </summary>
 ////public static int DefaultSpatialReferenceId { get { return _defaultWkid; } }
 /////// <summary>
 /////// The default spatial reference system
 /////// </summary>
 ////public static SpatialReference DefaultSpatialReference { get { return DefaultSpatialReferenceId.ToSpatialReference(); } }
 /////// <summary>
 /////// The spatial reference that will be used when writing geometry data to a SQL Server database.
 /////// </summary>
 ////public static int SqlSpatialReference { get { return _sqlSR; } }
 ////public static int[] ProjectedWkids { get { return _projectedWkids; } }
 ////public static int[] GeographicWkids { get { return _geographicWkids; } }
 /// <summary>
 /// Returns a <see cref="SpatialReference"/> object corresponding to the specified WKID.
 /// </summary>
 /// <param name="wkid">A Well-Known Identifier (WKID) for a spatial reference system.</param>
 /// <returns>
 /// <para>Returns a <see cref="SpatialReference"/> object corresponding to <paramref name="wkid"/>.</para>
 /// <para>
 /// If <paramref name="wkid"/> matches one of the values defined in web.config,
 /// either a <see cref="GeographicCoordinateSystem"/> or <see cref="ProjectedCoordinateSystem"/>
 /// is returned.  Otherwise a <see cref="UnknownCoordinateSystem"/> is returned.
 /// </para>
 /// </returns>
 public static SpatialReference ToSpatialReference(this int wkid)
 {
     SpatialReference sr;
     if (_projectedWkids.Contains(wkid))
     {
         sr = new ProjectedCoordinateSystem();
     }
     else if (_geographicWkids.Contains(wkid))
     {
         sr = new GeographicCoordinateSystem();
     }
     else
     {
         sr = new UnknownCoordinateSystem();
     }
     sr.WKID = wkid;
     sr.WKIDSpecified = true;
     return sr;
 }