Ejemplo n.º 1
0
        public void Measure_performance_query_items_from_GDB()
        {
            Polygon polygon = PolygonConstruction
                              .StartPolygon(0, 0)
                              .LineTo(0, 20)
                              .LineTo(20, 20)
                              .LineTo(20, 0)
                              .ClosePolygon();

            Polygon areaOfInterest = PolygonConstruction
                                     .StartPolygon(0, 0)
                                     .LineTo(0, 100)
                                     .LineTo(100, 100)
                                     .LineTo(100, 0)
                                     .ClosePolygon();

            var rowCount = 10000;

            TestUtils.InsertRows(_emptyIssuesGdb, _featureClassName, polygon, rowCount);

            try
            {
                var uri = new Uri(_emptyIssuesGdb, UriKind.Absolute);

                var geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(uri));

                var table = geodatabase.OpenDataset <Table>(_featureClassName);
                Dictionary <Geodatabase, List <Table> > tablesByGeodatabase = new Dictionary <Geodatabase, List <Table> >
                {
                    { geodatabase, new List <Table> {
                          table
                      } }
                };

                IRepository         stateRepository = new XmlWorkItemStateRepository(@"C:\temp\states.xml", null, null);
                IWorkItemRepository repository      = new IssueItemRepository(tablesByGeodatabase, stateRepository);

                IWorkList workList = new GdbQueryWorkList(repository, "work list");
                workList.AreaOfInterest = areaOfInterest;

                var filter = GdbQueryUtils.CreateSpatialFilter(areaOfInterest);

                var watch = new Stopwatch();
                watch.Start();

                IEnumerable <IWorkItem> items = workList.GetItems(filter);

                watch.Stop();
                Console.WriteLine($"{watch.ElapsedMilliseconds} ms");

                Assert.AreEqual(rowCount, items.Count());
            }
            finally
            {
                TestUtils.DeleteAllRows(_emptyIssuesGdb, _featureClassName);
            }
        }
Ejemplo n.º 2
0
        public void Respect_AreaOfInterest_LearningTest()
        {
            Polygon polygon = PolygonConstruction
                              .StartPolygon(0, 0)
                              .LineTo(0, 20)
                              .LineTo(20, 20)
                              .LineTo(20, 0)
                              .ClosePolygon();

            Polygon areaOfInterest = PolygonConstruction
                                     .StartPolygon(100, 100)
                                     .LineTo(100, 120)
                                     .LineTo(120, 120)
                                     .LineTo(120, 100)
                                     .ClosePolygon();

            var rowCount = 4;

            TestUtils.InsertRows(_emptyIssuesGdb, _featureClassName, polygon, rowCount);

            try
            {
                var uri = new Uri(_emptyIssuesGdb, UriKind.Absolute);

                var geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(uri));

                var table = geodatabase.OpenDataset <Table>(_featureClassName);
                Dictionary <Geodatabase, List <Table> > tablesByGeodatabase = new Dictionary <Geodatabase, List <Table> >
                {
                    { geodatabase, new List <Table> {
                          table
                      } }
                };

                IRepository         stateRepository = new XmlWorkItemStateRepository(@"C:\temp\states.xml", null, null);
                IWorkItemRepository repository      = new IssueItemRepository(tablesByGeodatabase, stateRepository);

                IWorkList workList = new MemoryQueryWorkList(repository, "work list");
                workList.AreaOfInterest = areaOfInterest;

                IEnumerable <IWorkItem> items = workList.GetItems();

                Assert.AreEqual(0, items.Count());
            }
            finally
            {
                TestUtils.DeleteAllRows(_emptyIssuesGdb, _featureClassName);
            }
        }
Ejemplo n.º 3
0
        public void WorkItemService_LearningTest()
        {
            Polygon polygon = PolygonConstruction
                              .StartPolygon(0, 0)
                              .LineTo(0, 20)
                              .LineTo(20, 20)
                              .LineTo(20, 0)
                              .ClosePolygon();

            var rowCount = 4;

            TestUtils.InsertRows(_emptyIssuesGdb, _featureClassName, polygon, rowCount);

            try
            {
                var uri = new Uri(_emptyIssuesGdb, UriKind.Absolute);

                var geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(uri));
                var table       = geodatabase.OpenDataset <Table>(_featureClassName);
                Dictionary <Geodatabase, List <Table> > tablesByGeodatabase = new Dictionary <Geodatabase, List <Table> >
                {
                    { geodatabase, new List <Table> {
                          table
                      } }
                };

                IRepository         stateRepository = new XmlWorkItemStateRepository(@"C:\temp\states.xml", null, null);
                IWorkItemRepository repository      = new IssueItemRepository(tablesByGeodatabase, stateRepository);

                IWorkList workList = new GdbQueryWorkList(repository, "work list");

                var items = workList.GetItems().Cast <IssueItem>().ToList();

                Assert.AreEqual("Bart", items[0].IssueCodeDescription);
                Assert.AreEqual("Bart", items[1].IssueCodeDescription);
                Assert.AreEqual("Bart", items[2].IssueCodeDescription);
                Assert.AreEqual("Bart", items[3].IssueCodeDescription);
            }
            finally
            {
                TestUtils.DeleteAllRows(_emptyIssuesGdb, _featureClassName);
            }
        }
Ejemplo n.º 4
0
        public void SetUp()
        {
            // http://stackoverflow.com/questions/8245926/the-current-synchronizationcontext-may-not-be-used-as-a-taskscheduler
            SynchronizationContext.SetSynchronizationContext(new SynchronizationContext());

            _geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(_issuesGdb, UriKind.Absolute)));


            _table0 = _geodatabase.OpenDataset <Table>(_featureClass);

            var tablesByGeodatabase = new Dictionary <Geodatabase, List <Table> >
            {
                { _geodatabase, new List <Table> {
                      _table0
                  } }
            };

            IRepository stateRepository = new XmlWorkItemStateRepository(@"C:\temp\states.xml", null, null);

            _repository = new IssueItemRepository(tablesByGeodatabase, stateRepository);
        }