コード例 #1
0
        public void adjustErrors()
        {
            if (!checkInputs())
            {
                return;
            }
            int          depIndex = plotFtrClass.FindField(DependentField);
            IQueryFilter qf       = new QueryFilterClass();

            qf.SubFields   = plotFtrClass.OIDFieldName + "," + plotFtrClass.ShapeFieldName + "," + DependentField;
            qf.WhereClause = "NOT " + dependentFld + " is NULL";
            //Console.WriteLine(qf.WhereClause);
            tPlots = plotFtrClass.FeatureCount(qf);
            //Console.WriteLine("Total Records = " + tPlots.ToString());
            dataArray = new double[tPlots, bndCnt + 1];
            allData   = new double[tPlots][][];
            IFeatureCursor ftrCur = plotFtrClass.Search(qf, true);
            IFeature       ftr    = ftrCur.NextFeature();
            int            ftrCnt = 0;

            while (ftr != null)
            {
                //Console.WriteLine("Getting values for point " + ftrCnt.ToString());
                object     depVlobj = ftr.get_Value(depIndex);
                double     depVl    = System.Convert.ToDouble(depVlobj);
                IPoint     pnt      = (IPoint)ftr.Shape;
                double[]   rwVls;
                double[][] rsPlotValues = getValues(pnt, out rwVls);//one row for each set of variables missing the center value; geoErro^2-1*bandCnt
                dataArray[ftrCnt, bndCnt] = depVl;
                allData[ftrCnt]           = rsPlotValues;
                for (int i = 0; i < bndCnt; i++)
                {
                    dataArray[ftrCnt, i] = rwVls[i];
                }
                ftr    = ftrCur.NextFeature();
                ftrCnt = ftrCnt + 1;
            }
            System.Runtime.InteropServices.Marshal.ReleaseComObject(ftrCur);
            int[] newPlotsRwClm = findBestCell(); //returns the row number of the cell that has the best correlation. will use this to determin new plot location.
            //Console.WriteLine("exporting feature class");
            outFtrClass  = ftrUtil.exportFeatures(plotFtrClass, outftrclasspath, null);
            qf.SubFields = "*";
            IFeatureCursor uCur = outFtrClass.Update(qf, true);
            IFeature       uFtr = uCur.NextFeature();

            ftrCnt = 0;
            while (uFtr != null)
            {
                //Console.WriteLine("Updating plot " + ftrCnt.ToString());
                int    bestCell = newPlotsRwClm[ftrCnt];
                IPoint pnt      = (IPoint)uFtr.ShapeCopy;
                IPoint nPnt     = updatePnt(bestCell, pnt);
                uFtr.Shape = nPnt;
                uCur.UpdateFeature(uFtr);
                uFtr   = uCur.NextFeature();
                ftrCnt = ftrCnt + 1;
            }
            System.Runtime.InteropServices.Marshal.ReleaseComObject(uCur);
        }
コード例 #2
0
        private static void CreateNewPoints(string inPath, string outPath, rasterUtil rsUtil, featureUtil ftrUtil, geoDatabaseUtility geoUtil, bool prnd = true, int cShift = 5)
        {
            IFeatureClass  ftrCls    = geoUtil.getFeatureClass(inPath);
            IFeatureClass  newFtrCls = ftrUtil.exportFeatures(ftrCls, outPath, null);
            IFeatureCursor uCur      = newFtrCls.Update(null, true);
            IFeature       ftr       = uCur.NextFeature();

            if (prnd)
            {
                System.Random rnd = new Random();
                while (ftr != null)
                {
                    IPoint opnt = (IPoint)ftr.ShapeCopy;
                    IPoint pnt  = new PointClass();
                    double rndx = rnd.NextDouble() * 10;
                    double rndy = rnd.NextDouble() * 10;
                    pnt.PutCoords(opnt.X + rndx, opnt.Y + rndy);
                    ftr.Shape = pnt;
                    uCur.UpdateFeature(ftr);
                    ftr = uCur.NextFeature();
                }
            }
            else
            {
                while (ftr != null)
                {
                    IPoint opnt = (IPoint)ftr.ShapeCopy;
                    IPoint pnt  = new PointClass();
                    pnt.PutCoords(opnt.X + cShift, opnt.Y + cShift);
                    ftr.Shape = pnt;
                    uCur.UpdateFeature(ftr);
                    ftr = uCur.NextFeature();
                }
            }
            System.Runtime.InteropServices.Marshal.ReleaseComObject(uCur);
        }