예제 #1
0
                public static Value Create(RowCursor cursor, ColInfo info)
                {
                    Contracts.AssertValue(cursor);
                    Contracts.AssertValue(info);

                    MethodInfo meth;

                    if (info.Type is VectorType vecType)
                    {
                        Func <RowCursor, ColInfo, ValueVec <int> > d = CreateVec <int>;
                        meth = d.GetMethodInfo().GetGenericMethodDefinition().MakeGenericMethod(vecType.ItemType.RawType);
                    }
                    else
                    {
                        Func <RowCursor, ColInfo, ValueOne <int> > d = CreateOne <int>;
                        meth = d.GetMethodInfo().GetGenericMethodDefinition().MakeGenericMethod(info.Type.RawType);
                    }
                    return((Value)meth.Invoke(null, new object[] { cursor, info }));
                }
        public override IRowCursor[] GetRowCursorSet(out IRowCursorConsolidator consolidator, Func<int, bool> predicate, int n, IRandom rand = null)
        {
            Host.CheckValue(predicate, nameof(predicate));
            Host.CheckValueOrNull(rand);

            var inputPred = _bindings.GetDependencies(predicate);
            var active = _bindings.GetActive(predicate);
            var inputs = Source.GetRowCursorSet(out consolidator, inputPred, n, rand);
            Host.AssertNonEmpty(inputs);

            if (inputs.Length == 1 && n > 1 && _bindings.AnyNewColumnsActive(predicate))
                inputs = DataViewUtils.CreateSplitCursors(out consolidator, Host, inputs[0], n);
            Host.AssertNonEmpty(inputs);

            var cursors = new IRowCursor[inputs.Length];
            for (int i = 0; i < inputs.Length; i++)
                cursors[i] = new RowCursor(this, inputs[i], active);
            return cursors;
        }
            public CursorType(InfiniteLoopViewCursorDataFrame view, Func <int, bool> needCol, RowCursor otherValues)
            {
                _needCol = needCol;

                _view              = view;
                _state             = CursorState.NotStarted;
                _otherValues       = otherValues;
                _wait              = true;
                _position          = 0;
                _batch             = 1;
                _container         = null;
                _positionDataFrame = -1;
                _columnsSchema     = _view._columnsSchema;
                _columns           = new Dictionary <int, int>();
                for (int i = 0; i < view.ReplacedCol.Length; ++i)
                {
                    _columns[view.ReplacedCol[i]] = i;
                }
            }
        private static Feature GetFeature(Geodatabase geodatabase, string featureClassName, long objectID)
        {
            using (FeatureClass featureClass = geodatabase.OpenDataset <FeatureClass>(featureClassName))
            {
                QueryFilter queryFilter = new QueryFilter()
                {
                    ObjectIDs = new List <long>()
                    {
                        objectID
                    }
                };

                using (RowCursor cursor = featureClass.Search(queryFilter))
                {
                    System.Diagnostics.Debug.Assert(cursor.MoveNext());
                    return((Feature)cursor.Current);
                }
            }
        }
예제 #5
0
        public static Delegate GetGetterChoice <T1, T2, T3>(RowCursor cur, int col)
        {
            Delegate res = null;

            try
            {
                res = cur.GetGetter <T1>(col);
                if (res != null)
                {
                    return(res);
                }
            }
            catch (Exception)
            {
            }
            try
            {
                res = cur.GetGetter <T2>(col);
                if (res != null)
                {
                    return(res);
                }
            }
            catch (Exception)
            {
            }
            try
            {
                res = cur.GetGetter <T3>(col);
                if (res != null)
                {
                    return(res);
                }
            }
            catch (Exception)
            {
            }
            if (res == null)
            {
                throw Contracts.ExceptNotImpl($"Unable to get a getter for column {col} of type {typeof(T1)} or {typeof(T2)} or {typeof(T3)} from schema\n{SchemaHelper.ToString(cur.Schema)}.");
            }
            return(res);
        }
예제 #6
0
        private void EstimatorCore <T>(RowCursor cursor, ColumnCodec col,
                                       out Func <long> fetchWriteEstimator, out IValueWriter writer)
        {
            ValueGetter <T> getter = cursor.GetGetter <T>(col.SourceIndex);
            IValueCodec <T> codec  = col.Codec as IValueCodec <T>;

            _host.AssertValue(codec);
            IValueWriter <T> specificWriter = codec.OpenWriter(Stream.Null);

            writer = specificWriter;
            T val = default(T);

            fetchWriteEstimator = () =>
            {
                getter(ref val);
                specificWriter.Write(in val);
                return(specificWriter.GetCommitLengthEstimate());
            };
        }
예제 #7
0
 private void SaveOwnShip()
 {
     if (CheckCanSave())
     {
         var task = QueuedTask.Run(() =>
         {
             using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(GeoDataTool.DefaultProject.DefaultGeodatabasePath))))
             {
                 FeatureClass ownShip = geodatabase.OpenDataset <FeatureClass>(ConstDefintion.ConstFeatureClass_OwnShip);
                 string shapeField    = ownShip.GetDefinition().GetShapeField();
                 QueryFilter qf       = new QueryFilter()
                 {
                     ObjectIDs = new List <long>()
                     {
                         1
                     }
                 };
                 geodatabase.ApplyEdits(() =>
                 {
                     using (RowCursor rowCursor = ownShip.Search(qf, false))
                     {
                         while (rowCursor.MoveNext())
                         {
                             using (Row row = rowCursor.Current)
                             {
                                 row[ConstDefintion.ConstFieldName_sog]    = double.Parse(sog);
                                 row[ConstDefintion.ConstFieldName_cog]    = double.Parse(cog);
                                 row[ConstDefintion.ConstFieldName_length] = double.Parse(length);
                                 row[ConstDefintion.ConstFieldName_width]  = double.Parse(width);
                                 MapPoint p         = MapPointBuilder.CreateMapPoint(double.Parse(locationX), double.Parse(locationY), 0, SpatialReferenceBuilder.CreateSpatialReference(4326));
                                 MapPoint p_project = GeometryEngine.Instance.Project(p, SpatialReferenceBuilder.CreateSpatialReference(3857)) as MapPoint;
                                 row[shapeField]    = p_project as ArcGIS.Core.Geometry.Geometry;
                                 row.Store();
                             }
                         }
                     }
                 });
             }
         });
         task.Wait();
     }
 }
예제 #8
0
파일: Main.cs 프로젝트: agrc/TrailsAddin
        private string GetUSNGID_Point(MapPoint point)
        {
            SpatialQueryFilter filter = new SpatialQueryFilter()
            {
                FilterGeometry      = point,
                SpatialRelationship = SpatialRelationship.Intersects,
                SubFields           = "GRID1MIL,GRID100K"
            };
            RowCursor cursor = USNGLayer.Search(filter);

            cursor.MoveNext();
            Row    row      = cursor.Current;
            string grid1mil = (string)row["GRID1MIL"];
            string grid100k = (string)row["GRID100K"];

            cursor.Dispose();

            // this code is from gregs roads code: https://gist.github.com/gregbunce/1733a741d8b4343a7a60fc42acf5086b
            double dblMeterX = (double)point.X;
            double dblMeterY = (double)point.Y;

            // add .5 to so when we conver to long and the value gets truncated, it will still regain our desired value (if you need more info on this, talk to Bert)
            dblMeterX = dblMeterX + .5;
            dblMeterY = dblMeterY + .5;
            long lngMeterX = (long)dblMeterX;
            long lngMeterY = (long)dblMeterY;

            // trim the x and y meter values to get the needed four characters from each value
            string strMeterX_NoDecimal = lngMeterX.ToString();
            string strMeterY_NoDecimal = lngMeterY.ToString();

            // remove the begining characters
            strMeterX_NoDecimal = strMeterX_NoDecimal.Remove(0, 1);
            strMeterY_NoDecimal = strMeterY_NoDecimal.Remove(0, 2);

            //remove the ending characters
            strMeterY_NoDecimal = strMeterY_NoDecimal.Remove(strMeterY_NoDecimal.Length - 1);
            strMeterX_NoDecimal = strMeterX_NoDecimal.Remove(strMeterX_NoDecimal.Length - 1);

            // piece all the unique_id fields together
            return(grid1mil + grid100k + strMeterX_NoDecimal + strMeterY_NoDecimal);
        }
예제 #9
0
        // Illustrates updating a feature in a File GDB.
        private static async Task FileGeodatabaseWorkFlow()
        {
            using (Geodatabase fileGeodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"C:\Data\LocalGovernment.gdb"))))
                using (FeatureClass featureClass = fileGeodatabase.OpenDataset <FeatureClass>("PollingPlace"))
                {
                    EditOperation editOperation = new EditOperation();
                    editOperation.Callback(context =>
                    {
                        QueryFilter queryFilter = new QueryFilter {
                            WhereClause = "FULLADD LIKE '///%Lily Cache Ln///%'"
                        };

                        using (RowCursor rowCursor = featureClass.Search(queryFilter, false))
                        {
                            while (rowCursor.MoveNext())
                            {
                                using (Feature feature = (Feature)rowCursor.Current)
                                {
                                    MapPoint mapPoint = feature.GetShape() as MapPoint;

                                    // In order to update the Map and/or the attribute table.
                                    // Has to be called before any changes are made to the row
                                    context.Invalidate(feature);

                                    // Note that to update the shape, you will need to create a new Shape object.

                                    feature.SetShape(new MapPointBuilder(mapPoint.X + 1, mapPoint.Y + 1, mapPoint.SpatialReference).ToGeometry());
                                    feature.Store();

                                    // Has to be called after the store too
                                    context.Invalidate(feature);
                                }
                            }
                        }
                    }, featureClass);

                    bool editResult = editOperation.Execute();

                    // This is required to persist the changes to the disk.
                    bool saveResult = await Project.Current.SaveEditsAsync();
                }
        }
예제 #10
0
파일: Main.cs 프로젝트: agrc/TrailsAddin
        private async void AddSelectedToTemp()
        {
            await QueuedTask.Run(() =>
            {
                using (RowCursor segmentsCursor = SegmentsLayer.GetSelection().Search(null))
                {
                    EditOperation operation = new EditOperation();
                    operation.Name          = "add selected to temp segments";
                    List <string> newIDs    = new List <string>();
                    while (segmentsCursor.MoveNext())
                    {
                        var id = EnsureIDForSegment(segmentsCursor.Current, operation);

                        if (tempSegmentIDs.Contains(id))
                        {
                            MessageBox.Show($"This segment ({id}) has already been selected for the current part. Try creating a new part.");
                            continue;
                        }

                        CopyRowValues(segmentsCursor.Current, currentPart, operation);

                        newIDs.Add(id);
                    }

                    tempSegmentIDs.AddRange(newIDs);

                    operation.SetOnUndone(() =>
                    {
                        tempSegmentIDs.RemoveRange(tempSegmentIDs.Count - newIDs.Count, newIDs.Count);
                    });

                    bool success = operation.Execute();
                    if (!success)
                    {
                        MessageBox.Show(operation.ErrorMessage);
                    }

                    SegmentsLayer.ClearSelection();
                    TempSegmentsLayer.ClearSelection();
                }
            });
        }
            public Cursor(IChannelProvider provider, Bindings bindings, RowCursor input, bool[] active)
                : base(provider, input)
            {
                Ch.CheckValue(bindings, nameof(bindings));
                Ch.CheckValue(input, nameof(input));
                Ch.CheckParam(active == null || active.Length == bindings.ColumnCount, nameof(active));

                _bindings = bindings;
                _active   = active;
                var length = _bindings.InfoCount;

                _getters = new Delegate[length];
                for (int iinfo = 0; iinfo < length; iinfo++)
                {
                    if (_bindings.SrcCols[iinfo] < 0)
                    {
                        _getters[iinfo] = MakeGetter(iinfo);
                    }
                }
            }
예제 #12
0
        /// <summary>
        /// Returns the getters for all columns.
        /// </summary>
        public static Delegate[] GetAllGetters(RowCursor cur)
        {
            var sch = cur.Schema;
            var res = new List <Delegate>();

            for (int i = 0; i < sch.Count; ++i)
            {
                if (sch[i].IsHidden)
                {
                    continue;
                }
                var getter = GetColumnGetter(cur, i, sch);
                if (getter == null)
                {
                    throw Contracts.Except($"Unable to get getter for column {i} from schema\n{SchemaHelper.ToString(sch)}.");
                }
                res.Add(getter);
            }
            return(res.ToArray());
        }
예제 #13
0
        public override RowCursor[] GetRowCursorSet(Func <int, bool> predicate, int n, Random rand = null)
        {
            Host.CheckValue(predicate, nameof(predicate));
            Host.CheckValueOrNull(rand);

            bool[]           active;
            Func <int, bool> inputPred = GetActive(predicate, out active);
            var inputs = Source.GetRowCursorSet(inputPred, n, rand);

            Host.AssertNonEmpty(inputs);

            // No need to split if this is given 1 input cursor.
            var cursors = new RowCursor[inputs.Length];

            for (int i = 0; i < inputs.Length; i++)
            {
                cursors[i] = CreateCursorCore(inputs[i], active);
            }
            return(cursors);
        }
예제 #14
0
        void LoadCache <TClass>(Random rand, RowCursor cur, int classColumn, TClass valueClass, IChannel ch)
        {
            _cacheReplica = new Dictionary <RowId, int>();
            var    hist  = new Dictionary <TClass, long>();
            var    gid   = cur.GetIdGetter();
            var    gcl   = cur.GetGetter <TClass>(classColumn);
            RowId  did   = default(RowId);
            TClass cl    = default(TClass);
            long   nbIn  = 0;
            long   nbOut = 0;
            int    rep;

            while (cur.MoveNext())
            {
                gcl(ref cl);
                gid(ref did);
                if (!hist.ContainsKey(cl))
                {
                    hist[cl] = 1;
                }
                else
                {
                    ++hist[cl];
                }
                if (cl.Equals(valueClass))
                {
                    rep = NextPoisson(_args.lambda, rand);
                    ++nbIn;
                }
                else
                {
                    rep = 1;
                    ++nbOut;
                }
                _cacheReplica[did] = rep;
            }
            if (nbIn == 0)
            {
                ch.Warning(MessageSensitivity.UserData, "Resample on a condition never happened: nbIn={0} nbOut={1}", nbIn, nbOut);
            }
        }
예제 #15
0
        /// <summary>
        /// Fetches a Row from an Element
        /// </summary>
        /// <param name="utilityNetwork">The utility network to which the element belongs</param>
        /// <param name="element">An element in a utility network</param>
        /// <returns>The Row corresponding to the Element (if any)</returns>
        public static Row FetchRowFromElement(UtilityNetwork utilityNetwork, Element element)
        {
            // Get the table from the element
            using (Table table = utilityNetwork.GetTable(element.NetworkSource))
                using (TableDefinition tableDefinition = table.GetDefinition())
                {
                    // Create a query filter to fetch the appropriate row
                    QueryFilter queryFilter = new QueryFilter()
                    {
                        WhereClause = tableDefinition.GetGlobalIDField() + " = {" + element.GlobalID.ToString().ToUpper() + "}"
                    };

                    // Fetch and return the row
                    RowCursor rowCursor = table.Search(queryFilter);
                    if (rowCursor.MoveNext())
                    {
                        return(rowCursor.Current);
                    }
                    return(null);
                }
        }
예제 #16
0
        /// <summary>
        /// Returns oids of features filtered by spatial relationship. Honors definition queries on the layer.
        /// </summary>
        public static IEnumerable <long> FilterLayerOidsByGeometry(
            BasicFeatureLayer layer, ArcGIS.Core.Geometry.Geometry filterGeometry,
            SpatialRelationship spatialRelationship = SpatialRelationship.Intersects)
        {
            var qf = new SpatialQueryFilter()
            {
                FilterGeometry      = filterGeometry,
                SpatialRelationship = spatialRelationship
            };
            var oids = new List <long>();

            using (RowCursor rowCursor = layer.Search(qf))
            {
                while (rowCursor.MoveNext())
                {
                    oids.Add(rowCursor.Current.GetObjectID());
                }
            }

            return(oids);
        }
예제 #17
0
        /// <summary>
        /// Returns features filtered by spatial relationship. Honors definition queries on the layer.
        /// </summary>
        public static IEnumerable <Feature> FilterLayerFeaturesByGeometry(
            BasicFeatureLayer layer, ArcGIS.Core.Geometry.Geometry filterGeometry,
            SpatialRelationship spatialRelationship = SpatialRelationship.Intersects)
        {
            var qf = new SpatialQueryFilter()
            {
                FilterGeometry      = filterGeometry,
                SpatialRelationship = spatialRelationship
            };
            var features = new List <Feature>();

            using (RowCursor rowCursor = layer.Search(qf))
            {
                while (rowCursor.MoveNext())
                {
                    features.Add((Feature)rowCursor.Current);
                }
            }

            return(features);
        }
예제 #18
0
        /// <summary>
        /// Performs a spatial query against the table/feature class.
        /// </summary>
        /// <remarks>It is assumed that the feature class and the search geometry are using the same spatial reference.</remarks>
        /// <param name="searchTable">The table/feature class to be searched.</param>
        /// <param name="searchGeometry">The geometry used to perform the spatial query.</param>
        /// <param name="spatialRelationship">The spatial relationship used by the spatial filter.</param>
        /// <returns></returns>
        public static async Task <RowCursor> SearchAsync(this Table searchTable, Geometry searchGeometry, SpatialRelationship spatialRelationship)
        {
            RowCursor rowCursor = null;

            await QueuingTaskFactory.StartNew(() =>
            {
                // define a spatial query filter
                var spatialQueryFilter = new SpatialQueryFilter
                {
                    // passing the search geometry to the spatial filter
                    FilterGeometry = searchGeometry,
                    // define the spatial relationship between search geometry and feature class
                    SpatialRelationship = spatialRelationship
                };

                // apply the spatial filter to the feature class in question
                rowCursor = searchTable.Search(spatialQueryFilter);
            });

            return(rowCursor);
        }
 public void fillList(QueryFilter filter)
 {
     if (resolutionNames.SelectedItem != null)
     {
         symbols = new List <string>();
         string parent       = "Wydzielenia";
         var    precintLayer = getPrecintLayer();
         Task   t            = QueuedTask.Run(() =>
         {
             precints          = precintLayer.GetTable().Search(filter);
             string symbolName = config.getConfig(parent, "precintSymbol");
             while (precints.MoveNext())
             {
                 var fields = precints.Current;
                 symbols.Add((string)fields.GetOriginalValue(fields.FindField(symbolName)));
             }
         });
         t.Wait();
         createRow();
     }
 }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="value">value which will replace the value</param>
        /// <param name="column">column to be replaced</param>
        /// <param name="otherValues">cursor which contains the others values</param>
        /// <param name="schema">schema to replace if otherValues is null</param>
        public TemporaryViewCursorRow(TRowValue value, int[] columns = null, Schema schema = null, RowCursor otherValues = null,
                                      Dictionary <string, Delegate> overwriteRowGetter = null)
        {
            var columnsSchema = SchemaDefinition.Create(typeof(TRowValue), SchemaDefinition.Direction.Read);

            if (columns == null)
            {
                columns = columnsSchema.Select((c, i) => i).ToArray();
            }
            if (columns.Length != columnsSchema.Count)
            {
                throw Contracts.Except($"Dimension mismatch expected columns is {columns.Length}, number of fields for {typeof(TRowValue)} is {columnsSchema.Count}.");
            }
            _columns            = columns;
            _otherValues        = otherValues;
            _schema             = otherValues == null ? schema : otherValues.Schema;
            _value              = value;
            _columnsSchema      = columnsSchema;
            _overwriteRowGetter = overwriteRowGetter;
            Contracts.AssertValue(_schema);
        }
예제 #21
0
        public sealed override IRowCursor[] GetRowCursorSet(out IRowCursorConsolidator consolidator,
                                                            Func <int, bool> predicate, int n, IRandom rand = null)
        {
            Host.CheckValue(predicate, nameof(predicate));
            Host.CheckValueOrNull(rand);

            var inputPred = _bindings.GetDependencies(predicate);
            var active    = _bindings.GetActive(predicate);
            var inputs    = Source.GetRowCursorSet(out consolidator, inputPred, n, rand);

            Host.AssertNonEmpty(inputs);

            // No need to split if this is given 1 input cursor.
            var cursors = new IRowCursor[inputs.Length];

            for (int i = 0; i < inputs.Length; i++)
            {
                cursors[i] = new RowCursor(Host, _bindings, inputs[i], active);
            }
            return(cursors);
        }
예제 #22
0
        public override RowCursor[] GetRowCursorSet(IEnumerable <Schema.Column> columnsNeeded, int n, Random rand = null)
        {
            Host.CheckValueOrNull(rand);

            var predicate = RowCursorUtils.FromColumnsToPredicate(columnsNeeded, OutputSchema);
            Func <int, bool> inputPred = GetActive(predicate, out bool[] active);

            var inputCols = Source.Schema.Where(x => inputPred(x.Index));
            var inputs    = Source.GetRowCursorSet(inputCols, n, rand);

            Host.AssertNonEmpty(inputs);

            // No need to split if this is given 1 input cursor.
            var cursors = new RowCursor[inputs.Length];

            for (int i = 0; i < inputs.Length; i++)
            {
                cursors[i] = CreateCursorCore(inputs[i], active);
            }
            return(cursors);
        }
        public async void LoadFile(MapPoint point)
        {
            if (await CheckRequirements())
            {
                await QueuedTask.Run(() =>
                {
                    SpatialQueryFilter spatialFilter  = new SpatialQueryFilter();
                    spatialFilter.FilterGeometry      = point;
                    spatialFilter.SpatialRelationship = SpatialRelationship.Intersects;

                    using (RowCursor cursor = _selectedFeatureLayer.GetFeatureClass().Search(spatialFilter, false))
                    {
                        int fieldindex = cursor.FindField(_selectedField);

                        while (cursor.MoveNext())
                        {
                            using (Row row = cursor.Current)
                            {
                                string rowValue = Convert.ToString(row.GetOriginalValue(fieldindex));

                                string filePath = _fileWorkspace + @"\" + AddPrefixAndSuffix(rowValue) + _fileExtension;

                                if (!File.Exists(filePath))
                                {
                                    MessageBox.Show("File Does Not Exist", "Hmm...");
                                    return;
                                }

                                SaveFileExtensionsToDisk(_fileExtension);

                                Process.Start(filePath);
                            }

                            return;
                        }
                        MessageBox.Show("Select a feature from the '" + _selectedFeatureLayer.Name + "' feature layer", "Woah Woah Woah");
                    }
                });
            }
        }
        protected static List <object> PopulatePoolData(Table table, QueryFilter queryFilter)
        {
            var list = new List <Object>();
            IReadOnlyList <Subtype> subtypes = table.GetDefinition().GetSubtypes();

            using (RowCursor rowCursor = table.Search(queryFilter, false))
            {
                while (rowCursor.MoveNext())
                {
                    using (Row current = rowCursor.Current)
                    {
                        list.Add(new PoolData
                        {
                            APN      = Convert.ToString(current["APN"]),
                            Address  = Convert.ToString(current["Address"]),
                            PoolType = subtypes.First(subtype => subtype.GetCode().Equals(current["Pool_Type"])).GetName(),
                        });
                    }
                }
            }
            return(list);
        }
예제 #25
0
            public Cursor(IChannelProvider provider, RowCursor input, SchemaImpl schema, Func<int, bool> predicate)
                : base(provider, input)
            {
                _schemaImpl = schema;
                _active = Utils.BuildArray(_schemaImpl.ColumnCount, predicate);
                _cachedGetters = new Delegate[_schemaImpl.ColumnCount];
                _colSizes = new int[_schemaImpl.ColumnCount];

                int sizeColumnsLim = _schemaImpl.Mode == UngroupMode.First ? 1 : _schemaImpl.PivotColumnCount;
                _fixedSize = 0;
                var needed = new List<Func<int>>();
                for (int i = 0; i < sizeColumnsLim; i++)
                {
                    var info = _schemaImpl.GetPivotColumnInfo(i);
                    if (info.Size > 0)
                    {
                        if (_fixedSize == 0)
                            _fixedSize = info.Size;
                        else if (_schemaImpl.Mode == UngroupMode.Inner && _fixedSize > info.Size)
                            _fixedSize = info.Size;
                        else if (_schemaImpl.Mode == UngroupMode.Outer && _fixedSize < info.Size)
                            _fixedSize = info.Size;
                    }
                    else
                    {
                        // This will also create and cache a getter for the pivot column.
                        // That's why MakeSizeGetter is an instance method.
                        var rawItemType = info.ItemType.RawType;
                        Func<int, Func<int>> del = MakeSizeGetter<int>;
                        var mi = del.GetMethodInfo().GetGenericMethodDefinition().MakeGenericMethod(rawItemType);
                        var sizeGetter = (Func<int>)mi.Invoke(this, new object[] { info.Index });
                        needed.Add(sizeGetter);
                    }
                }

                _sizeGetters = needed.ToArray();
                Ch.Assert(_fixedSize > 0 || _sizeGetters.Length > 0);

            }
예제 #26
0
        /// <summary>
        /// Called when the sketch finishes. This is where we will create the sketch operation and then execute it.
        /// </summary>
        /// <param name="geometry">The geometry created by the sketch.</param>
        /// <returns>A Task returning a Boolean indicating if the sketch complete event was successfully handled.</returns>
        ///
        private Task <List <long> > GetRelateObjectIDs(Geometry geometry)
        {
            return(QueuedTask.Run(() =>
            {
                var polygonLayers = ActiveMapView.Map.GetLayersAsFlattenedList().OfType <FeatureLayer>().Where(lyr => lyr.ShapeType == esriGeometryType.esriGeometryPolygon);
                var relateObjectIDList = new List <long>();
                foreach (FeatureLayer polygonLayer in polygonLayers)
                {
                    using (RowCursor searchCursor = polygonLayer.Search())
                    {
                        while (searchCursor.MoveNext())
                        {
                            using (Feature feature = (Feature)searchCursor.Current)
                            {
                                //the sketch geometry needs to be projected to the polygon layer spatial reference
                                var sr = polygonLayer.GetSpatialReference();
                                Geometry geometry_prj = (Polyline)GeometryEngine.Instance.Project(geometry, sr);

                                // Process the feature.
                                if (GeometryEngine.Instance.Relate(geometry_prj, feature.GetShape(), "F***T****"))
                                {
                                    var oid = feature.GetObjectID();
                                    //Debug.WriteLine(feature.GetObjectID().ToString() + "passes test F***T****");
                                    relateObjectIDList.Add(oid);
                                }
                                else
                                {
                                    var oid = feature.GetObjectID();
                                    //Debug.WriteLine(feature.GetObjectID().ToString() + "does NOT pass test F***T****");
                                }
                            }
                        }
                        //Debug.WriteLine("list of featues that pass F***T**** test:");
                        //Debug.WriteLine(string.Join(",", relateObjectIDList.ToArray()));
                    }
                }
                return relateObjectIDList; //calling function can test for exmple that these are two seperate polygon object ID's
            }));
        }
예제 #27
0
        public unsafe void TrainWithValidation(IChannel ch, int rowCount, int colCount,
                                               RowCursor cursor, ValueGetter <float> labGetter,
                                               ValueGetter <uint> rowGetter, ValueGetter <uint> colGetter,
                                               RowCursor validCursor, ValueGetter <float> validLabGetter,
                                               ValueGetter <uint> validRowGetter, ValueGetter <uint> validColGetter)
        {
            if (_pMFModel != null)
            {
                MFDestroyModel(ref _pMFModel);
                _host.Assert(_pMFModel == null);
            }

            MFNode[]  nodes      = ConstructLabeledNodesFrom(ch, cursor, labGetter, rowGetter, colGetter, rowCount, colCount);
            MFNode[]  validNodes = ConstructLabeledNodesFrom(ch, validCursor, validLabGetter, validRowGetter, validColGetter, rowCount, colCount);
            MFProblem prob       = new MFProblem();
            MFProblem validProb  = new MFProblem();

            fixed(MFNode *nodesPtr = &nodes[0])
            fixed(MFNode * validNodesPtrs = &validNodes[0])
            {
                prob.R   = nodesPtr;
                prob.M   = rowCount;
                prob.N   = colCount;
                prob.Nnz = nodes.Length;

                validProb.R   = validNodesPtrs;
                validProb.M   = rowCount;
                validProb.N   = colCount;
                validProb.Nnz = nodes.Length;

                ch.Info("Training {0} by {1} problem on {2} examples with a {3} by {4} validation set including {5} examples",
                        prob.M, prob.N, prob.Nnz, validProb.M, validProb.N, validProb.Nnz);

                fixed(MFParameter *pParam = &_mfParam)
                {
                    _pMFModel = MFTrainWithValidation(&prob, &validProb, pParam);
                }
            }
        }
예제 #28
0
        protected StandardScalarCursor(RowCursor input, RoleMappedData data, CursOpt opt, Action <CursOpt> signal = null)
            : base(input, signal)
        {
            Contracts.AssertValue(data);

            if ((opt & CursOpt.Weight) != 0)
            {
                _getWeight     = Row.GetOptWeightFloatGetter(data);
                _keepBadWeight = (opt & CursOpt.AllowBadWeights) != 0;
            }
            if ((opt & CursOpt.Group) != 0)
            {
                _getGroup     = Row.GetOptGroupGetter(data);
                _keepBadGroup = (opt & CursOpt.AllowBadGroups) != 0;
            }
            if ((opt & CursOpt.Id) != 0)
            {
                _getId = Row.GetIdGetter();
            }
            Weight = 1;
            Group  = 0;
        }
        protected List <WaterMainData> PopulateWatermainData(Table table, QueryFilter queryFilter)
        {
            var list = new List <WaterMainData>();

            using (RowCursor rowCursor = table.Search(queryFilter, false))
            {
                while (rowCursor.MoveNext())
                {
                    using (Row current = rowCursor.Current)
                    {
                        list.Add(new WaterMainData
                        {
                            FacilityID = Convert.ToString(current["FACILITYID"]),
                            RemainingLifeExpectancy = Convert.ToInt32(current["REMLIF"]),
                            RelativeScore           = Convert.ToString(current["SCORE"]),
                            PipeMaterial            = Convert.ToString(current["MATERIAL"])
                        });
                    }
                }
            }
            return(list);
        }
예제 #30
0
        public static T GetRow <T>([NotNull] Table table, long oid)
            where T : Row
        {
            Assert.ArgumentNotNull(table, nameof(table));

            QueryFilter filter = CreateFilter(new[] { oid });

            using (RowCursor cursor = table.Search(filter, false))
            {
                if (!cursor.MoveNext())
                {
                    return(null);
                }

                var result = (T)cursor.Current;

                // todo daro: remove later when GetRow is used intensively throughout the solution
                Assert.False(cursor.MoveNext(), "more than one row found");

                return(result);
            }
        }