Пример #1
0
 public static HandleRef getCPtrAndSetReference(GCP obj, object parent) {
   if (obj != null)
   {
     obj.swigParentRef = parent;
     return obj.swigCPtr;
   }
   else
   {
     return new HandleRef(null, IntPtr.Zero);
   }
 }
Пример #2
0
        internal static GCP __ReadCArrayItem_GDAL_GCP(IntPtr carray, int index)
        {
            IntPtr cPtr = GdalPINVOKE.__ReadCArrayItem_GDAL_GCP(carray, index);
            GCP    ret  = (cPtr == IntPtr.Zero) ? null : new GCP(cPtr, false, ThisOwn_false());

            if (GdalPINVOKE.SWIGPendingException.Pending)
            {
                throw GdalPINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Пример #3
0
 public static HandleRef getCPtrAndSetReference(GCP obj, object parent)
 {
     if (obj != null)
     {
         obj.swigParentRef = parent;
         return(obj.swigCPtr);
     }
     else
     {
         return(new HandleRef(null, IntPtr.Zero));
     }
 }
Пример #4
0
 public static HandleRef getCPtrAndDisown(GCP obj, object parent) {
   if (obj != null)
   {
     obj.swigCMemOwn = false;
     obj.swigParentRef = parent;
     return obj.swigCPtr;
   }
   else
   {
     return new HandleRef(null, IntPtr.Zero);
   }
 }
Пример #5
0
 public static HandleRef getCPtrAndDisown(GCP obj, object parent)
 {
     if (obj != null)
     {
         obj.swigCMemOwn   = false;
         obj.swigParentRef = parent;
         return(obj.swigCPtr);
     }
     else
     {
         return(new HandleRef(null, IntPtr.Zero));
     }
 }
Пример #6
0
        public GCP[] GetGCPs()
        {
            /*hello*/
            IntPtr cPtr   = __GetGCPs();
            int    length = GetGCPCount();

            GCP[] ret = null;
            if (cPtr != IntPtr.Zero && length > 0)
            {
                ret = new GCP[length];
                for (int i = 0; i < length; i++)
                {
                    ret[i] = __ReadCArrayItem_GDAL_GCP(cPtr, i);
                }
            }
            GC.KeepAlive(this);
            return(ret);
        }
Пример #7
0
 public static int GCPsToGeoTransform(GCP[] pGCPs, double[] argout, int bApproxOK) {
   int ret = 0;
   if (pGCPs != null && pGCPs.Length > 0)
    {
        IntPtr cPtr = __AllocCArray_GDAL_GCP(pGCPs.Length);
        if (cPtr == IntPtr.Zero)
           throw new ApplicationException("Error allocating CArray with __AllocCArray_GDAL_GCP");
           
        try {   
            for (int i=0; i < pGCPs.Length; i++)
               __WriteCArrayItem_GDAL_GCP(cPtr, i, pGCPs[i]);
            
            ret = GCPsToGeoTransform(pGCPs.Length, cPtr, argout, bApproxOK);
        }
        finally
        {
           __FreeCArray_GDAL_GCP(cPtr);
        }
    }
    return ret;
  }
Пример #8
0
 internal static void __WriteCArrayItem_GDAL_GCP(IntPtr carray, int index, GCP value)
 {
     GdalPINVOKE.__WriteCArrayItem_GDAL_GCP(carray, index, GCP.getCPtr(value));
     if (GdalPINVOKE.SWIGPendingException.Pending) throw GdalPINVOKE.SWIGPendingException.Retrieve();
 }
Пример #9
0
 public static double GDAL_GCP_get_GCPZ(GCP gcp)
 {
     double ret = GdalPINVOKE.GDAL_GCP_get_GCPZ(GCP.getCPtr(gcp));
     if (GdalPINVOKE.SWIGPendingException.Pending) throw GdalPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }
Пример #10
0
 private void __WriteCArrayItem_GDAL_GCP(IntPtr carray, int index, GCP value) {
   GdalPINVOKE.Dataset___WriteCArrayItem_GDAL_GCP(swigCPtr, carray, index, GCP.getCPtr(value));
   if (GdalPINVOKE.SWIGPendingException.Pending) throw GdalPINVOKE.SWIGPendingException.Retrieve();
 }
Пример #11
0
 public static HandleRef getCPtr(GCP obj) {
   return (obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr;
 }
Пример #12
0
public GCP[] GetGCPs() {
      /*hello*/
      IntPtr cPtr = __GetGCPs();
      int length = GetGCPCount();
      GCP[] ret = null;
      if (cPtr != IntPtr.Zero && length > 0)
      {
          ret = new GCP[length];
          for (int i=0; i < length; i++)
              ret[i] = __ReadCArrayItem_GDAL_GCP(cPtr, i);
      }
      GC.KeepAlive(this);
      return ret;
  }
Пример #13
0
public CPLErr SetGCPs(GCP[] pGCPs, string pszGCPProjection) {
     CPLErr ret = 0;
     if (pGCPs != null && pGCPs.Length > 0)
     {
         IntPtr cPtr = __AllocCArray_GDAL_GCP(pGCPs.Length);
         if (cPtr == IntPtr.Zero)
            throw new ApplicationException("Error allocating CArray with __AllocCArray_GDAL_GCP");
            
         try {
             for (int i=0; i < pGCPs.Length; i++)
                __WriteCArrayItem_GDAL_GCP(cPtr, i, pGCPs[i]);
             
             ret = __SetGCPs(pGCPs.Length, cPtr, pszGCPProjection);
         }
         finally
         {
            __FreeCArray_GDAL_GCP(cPtr);
         }
     }
     GC.KeepAlive(this);
     return ret;
  }
Пример #14
0
    public static void Main(string[] args)
    {
        if (args.Length < 1) usage();

        // Using early initialization of System.Console
        Console.WriteLine("Writing sample: " + args[0]);

        int bXSize, bYSize;
        int w, h;

        w = 100;
        h = 100;

        if (args.Length > 1)
            w = int.Parse(args[1]);

        if (args.Length > 2)
            h = int.Parse(args[2]);

        bXSize = w;
        bYSize = 1;

        //try
        {
            /* -------------------------------------------------------------------- */
            /*      Register driver(s).                                             */
            /* -------------------------------------------------------------------- */
            Gdal.AllRegister();

            /* -------------------------------------------------------------------- */
            /*      Get driver                                                      */
            /* -------------------------------------------------------------------- */
            Driver drv = Gdal.GetDriverByName("GTiff");

            if (drv == null)
            {
                Console.WriteLine("Can't get driver.");
                System.Environment.Exit(-1);
            }

            Console.WriteLine("Using driver " + drv.LongName);

            /* -------------------------------------------------------------------- */
            /*      Open dataset.                                                   */
            /* -------------------------------------------------------------------- */
            string[] options = new string [] {"BLOCKXSIZE=" + bXSize, "BLOCKYSIZE=" + bYSize};
            Dataset ds = drv.Create(args[0], w, h, 1, DataType.GDT_Byte, options);

            if (ds == null)
            {
                Console.WriteLine("Can't open " + args[0]);
                System.Environment.Exit(-1);
            }

            /* -------------------------------------------------------------------- */
            /*      Setting corner GCPs.                                            */
            /* -------------------------------------------------------------------- */
            GCP[] GCPs = new GCP[] {
                new GCP(44.5, 27.5, 0, 0, 0, "info0", "id0"),
                new GCP(45.5, 27.5, 0, 100, 0, "info1", "id1"),
                new GCP(44.5, 26.5, 0, 0, 100, "info2", "id2"),
                new GCP(45.5, 26.5, 0, 100, 100, "info3", "id3")
            };
            ds.SetGCPs(GCPs, "");

            Band ba = ds.GetRasterBand(1);

            byte [] buffer = new byte [w * h];

            for (int i = 0; i < w; i++)
            {
                for (int j = 0; j < h; j++)
                {
                    buffer[i * w + j] = (byte)(i * 256 / w);
                }
            }

            ba.WriteRaster(0, 0, w, h, buffer, w, h, 0, 0);

            ba.FlushCache();
            ds.FlushCache();

        }
        /*catch (Exception e)
        {
            Console.WriteLine("Application error: " + e.Message);
        }*/
    }
Пример #15
0
 public static HandleRef getCPtr(GCP obj)
 {
     return((obj == null) ? new HandleRef(null, IntPtr.Zero) : obj.swigCPtr);
 }
Пример #16
0
 public static void GDAL_GCP_set_Info(GCP gcp, string pszInfo)
 {
     GdalPINVOKE.GDAL_GCP_set_Info(GCP.getCPtr(gcp), pszInfo);
     if (GdalPINVOKE.SWIGPendingException.Pending) throw GdalPINVOKE.SWIGPendingException.Retrieve();
 }
Пример #17
0
 public static void GDAL_GCP_set_GCPZ(GCP gcp, double dfGCPZ)
 {
     GdalPINVOKE.GDAL_GCP_set_GCPZ(GCP.getCPtr(gcp), dfGCPZ);
     if (GdalPINVOKE.SWIGPendingException.Pending) throw GdalPINVOKE.SWIGPendingException.Retrieve();
 }
Пример #18
0
 public static string GDAL_GCP_Info_get(GCP gcp)
 {
     string ret = GdalPINVOKE.GDAL_GCP_Info_get(GCP.getCPtr(gcp));
     if (GdalPINVOKE.SWIGPendingException.Pending) throw GdalPINVOKE.SWIGPendingException.Retrieve();
     return ret;
 }