public void BeginExecuteQueryBlockUntilDone()
        {
            MockRepository   mocks        = new MockRepository();
            IFeatureProvider adapted      = mocks.CreateMock <IFeatureProvider>();
            IExtents         iExtentsStub =
                MockRepository.GenerateStub <IExtents>();
            FeatureQueryExpression featureQueryExpressionStub =
                MockRepository.GenerateStub <FeatureQueryExpression>(iExtentsStub, SpatialOperation.Intersects);

            _returnReaderStub = MockRepository.GenerateStub <IFeatureDataReader>();
            _sleepInterval    = 750;

            using (mocks.Unordered())
            {
                Expect.Call(adapted.ExecuteFeatureQuery(featureQueryExpressionStub))
                .Do(new ExecuteQueryDelegate(executeQueryMock));
            }
            mocks.ReplayAll();

            AsyncFeatureProviderAdapter adapter = new AsyncFeatureProviderAdapter(adapted);
            IAsyncResult ar = adapter.BeginExecuteQuery(featureQueryExpressionStub, null);

            Assert.NotNull(ar);

            Stopwatch timer = Stopwatch.StartNew();

            Assert.Same(_returnReaderStub, adapter.EndExecuteQuery(ar));
            timer.Stop();

            Assert.True(ar.IsCompleted);
            Assert.False(ar.CompletedSynchronously);
            Assert.True(timer.ElapsedMilliseconds > 500L);

            mocks.VerifyAll();
        }
Пример #2
0
        protected override void IndexListChanged(Object sender, ListChangedEventArgs e)
        {
            switch (e.ListChangedType)
            {
            case ListChangedType.ItemAdded:
                FeatureDataRow feature = this[e.NewIndex].Row as FeatureDataRow;
                Debug.Assert(feature != null);
                if (_extents == null)
                {
                    _extents = feature.Extents;
                }
                else
                {
                    _extents.ExpandToInclude(feature.Extents);
                }
                break;

            case ListChangedType.Reset:
            case ListChangedType.ItemChanged:
            case ListChangedType.ItemDeleted:
                recomputeExtents();
                break;

            default:
                break;
            }

            base.IndexListChanged(sender, e);
        }
Пример #3
0
        /// <summary>
        /// The extents of the data source.
        /// </summary>
        /// <returns>
        /// An <see cref="IExtents"/> instance describing the extents of the
        /// data available in the data source.
        /// </returns>
        public override IExtents GetExtents()
        {
            if (_extents != null)
            {
                return(_extents);
            }

            if (_geometries.Count == 0)
            {
                _extents = _geoFactory.CreateExtents();
            }
            else
            {
                foreach (IGeometry g in Geometries)
                {
                    if (g.IsEmpty)
                    {
                        continue;
                    }

                    if (_extents == null)
                    {
                        _extents = g.Extents;
                    }
                    else
                    {
                        _extents.ExpandToInclude(g.Extents);
                    }
                }
            }

            return(_extents);
        }
Пример #4
0
        public void AddingRowToTableTriggersViewListChangedItemAddedNotification()
        {
            FeatureProvider  data  = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory);
            FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory);

            IExtents halfBounds = data.GetExtents();

            halfBounds.Scale(0.5);

            FeatureQueryExpression query  = FeatureQueryExpression.Intersects(halfBounds);
            IFeatureDataReader     reader = data.ExecuteFeatureQuery(query);

            table.Load(reader, LoadOption.OverwriteChanges, null);
            FeatureDataView view = new FeatureDataView(table);

            Boolean addNotificationOccured = false;

            view.ListChanged += delegate(Object sender, ListChangedEventArgs e)
            {
                if (e.ListChangedType == ListChangedType.ItemAdded)
                {
                    addNotificationOccured = true;
                }
            };

            FeatureDataRow row = table.NewRow();

            row["Oid"]         = Guid.NewGuid();
            row["FeatureName"] = "New row";
            row.Geometry       = _factories.GeoFactory.CreatePoint2D(44, 44);
            table.AddRow(row);

            Assert.True(addNotificationOccured);
        }
Пример #5
0
        public void MovingRowTriggersViewListChangedItemMovedNotification()
        {
            // TODO: implement MovingRowTriggersViewListChangedItemMovedNotification
            FeatureProvider  data  = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory);
            FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory);

            IExtents halfBounds = data.GetExtents();

            halfBounds.Scale(0.5);

            FeatureQueryExpression query  = FeatureQueryExpression.Intersects(data.GetExtents());
            IFeatureDataReader     reader = data.ExecuteFeatureQuery(query);

            table.Load(reader, LoadOption.OverwriteChanges, null);
            FeatureDataView view = new FeatureDataView(table);

            Boolean addNotificationOccured = false;

            view.ListChanged += delegate(Object sender, ListChangedEventArgs e)
            {
                if (e.ListChangedType == ListChangedType.ItemMoved)
                {
                    addNotificationOccured = true;
                }
            };

            Assert.True(addNotificationOccured);
        }
Пример #6
0
        private static void filterSelected(ILayer layer, IMapView2D view, IExtents worldBounds)
        {
            if (layer == null)
            {
                return;
            }

            FeatureLayer filterLayer = layer as FeatureLayer;

            if (filterLayer != null)
            {
                if (layer.Enabled &&
                    filterLayer.AreFeaturesSelectable &&
                    layer.IsVisibleWhen(isInView(view.WorldWidth)))
                {
                    SpatialBinaryExpression spatialExpression
                        = SpatialBinaryExpression.Intersects(new FeaturesCollectionExpression(filterLayer.Features),
                                                             new ExtentsExpression(worldBounds));
                    filterLayer.SelectedFilter = filterLayer.SelectedFilter == null
                        ? new FeatureQueryExpression(new AllAttributesExpression(), spatialExpression, null)
                        : new FeatureQueryExpression(filterLayer.SelectedFilter, spatialExpression);
                }
            }

            IEnumerable <ILayer> layers = layer as IEnumerable <ILayer>;

            if (layers != null)
            {
                foreach (ILayer child in layers)
                {
                    filterSelected(child, view, worldBounds);
                }
            }
        }
Пример #7
0
        public void ChangeViewSpatialFilterTriggersNotification()
        {
            FeatureProvider        data   = DataSourceHelper.CreateFeatureDatasource(_factories.GeoFactory);
            FeatureDataTable       table  = new FeatureDataTable(_factories.GeoFactory);
            FeatureQueryExpression query  = FeatureQueryExpression.Intersects(data.GetExtents());
            IFeatureDataReader     reader = data.ExecuteFeatureQuery(query);

            table.Load(reader, LoadOption.OverwriteChanges, null);
            FeatureDataView view = new FeatureDataView(table);

            Boolean resetNotificationOccured = false;

            view.ListChanged += delegate(Object sender, ListChangedEventArgs e)
            {
                if (e.ListChangedType == ListChangedType.Reset)
                {
                    resetNotificationOccured = true;
                }
            };

            Assert.False(resetNotificationOccured);

            IExtents queryExtents = _factories.GeoFactory.CreateExtents2D(0, 0, 10, 10);
            SpatialBinaryExpression expression = SpatialBinaryExpression.Intersects(queryExtents);

            view.SpatialFilter = expression;

            Assert.True(resetNotificationOccured);
        }
        public void Insert(IExtents bounds, TItem entry, ISpatialIndexNode <IExtents, TItem> node, INodeSplitStrategy <IExtents, TItem> nodeSplitStrategy, IndexBalanceHeuristic heuristic, out ISpatialIndexNode <IExtents, TItem> newSiblingFromSplit)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            if (!(node is QuadTreeNode <TItem>))
            {
                throw new ArgumentException("Parameter 'node' must be of type QuadTreeNode<TItem>", "node");
            }

            QuadTreeNode <TItem> quadTreeNode = node as QuadTreeNode <TItem>;

            insertEntryRecursive(quadTreeNode, entry, nodeSplitStrategy, heuristic, out newSiblingFromSplit);

            if (newSiblingFromSplit != null)
            {
                if (quadTreeNode.ItemCount == 4)
                {
                    throw new QuadTreeIndexInsertOverflowException();
                }

                quadTreeNode.Add(newSiblingFromSplit);
            }
        }
        public void RenderFeatureTest()
        {
            IFeatureProvider   provider       = DataSourceHelper.CreateGeometryDatasource(_factories.GeoFactory);
            TestVectorRenderer vectorRenderer = new TestVectorRenderer();
            BasicGeometryRenderer2D <RenderObject> geometryRenderer =
                new BasicGeometryRenderer2D <RenderObject>(vectorRenderer);

            FeatureDataTable       features = new FeatureDataTable(_factories.GeoFactory);
            IExtents               extents  = provider.GetExtents();
            FeatureQueryExpression query    = new FeatureQueryExpression(extents.ToGeometry(),
                                                                         SpatialOperation.Intersects,
                                                                         provider);

            features.Merge(provider.ExecuteFeatureQuery(query) as IEnumerable <IFeatureDataRecord>,
                           provider.GeometryFactory);

            foreach (FeatureDataRow feature in features)
            {
                IGeometry           g = feature.Geometry;
                List <RenderObject> renderedObjects = new List <RenderObject>(geometryRenderer.RenderFeature(feature));

                for (Int32 i = 0; i < renderedObjects.Count; i++)
                {
                    RenderObject ro = renderedObjects[i];
                }
            }
        }
        public void BeginExecuteQueryCallBackNotification()
        {
            CallBackHelper callBackRecorder = new CallBackHelper();

            MockRepository  mocks        = new MockRepository();
            IRasterProvider adapted      = mocks.CreateMock <IRasterProvider>();
            IExtents        iExtentsStub =
                MockRepository.GenerateStub <IExtents>();
            RasterQueryExpression RasterQueryExpressionStub =
                MockRepository.GenerateStub <RasterQueryExpression>(iExtentsStub, SpatialOperation.Intersects);

            _returnStreamStub = MockRepository.GenerateStub <Stream>();
            _sleepInterval    = 500;

            using (mocks.Unordered())
            {
                Expect.Call(adapted.ExecuteRasterQuery(RasterQueryExpressionStub))
                .Do(new ExecuteQueryDelegate(executeQueryMock));
            }
            mocks.ReplayAll();

            AsyncRasterProviderAdapter adapter = new AsyncRasterProviderAdapter(adapted);
            IAsyncResult ar = adapter.BeginExecuteQuery(RasterQueryExpressionStub, callBackRecorder.CallBack);

            Assert.NotNull(ar);
            Assert.False(ar.IsCompleted);

            Thread.Sleep(1000);

            Assert.Same(ar, callBackRecorder.Result);
            Assert.True(ar.IsCompleted);
            Assert.Same(_returnStreamStub, adapter.EndExecuteQuery(ar));

            mocks.VerifyAll();
        }
Пример #11
0
        private static ISpatialIndexNode <IExtents, TItem> findNodeForItem(TItem item,
                                                                           ISpatialIndexNode <IExtents, TItem> node)
        {
            foreach (TItem nodeItem in node.Items)
            {
                if (item.Equals(nodeItem))
                {
                    return(node);
                }
            }

            IExtents itemBounds = item.Bounds;

            // TODO: I think a breadth-first search would be more efficient here
            foreach (ISpatialIndexNode <IExtents, TItem> child in node.SubNodes)
            {
                if (child.Intersects(itemBounds))
                {
                    ISpatialIndexNode <IExtents, TItem> found = findNodeForItem(item, child);

                    if (found != null)
                    {
                        return(found);
                    }
                }
            }

            return(null);
        }
        public void BeginExecuteQueryPollingNotification()
        {
            MockRepository   mocks        = new MockRepository();
            IFeatureProvider adapted      = mocks.CreateMock <IFeatureProvider>();
            IExtents         iExtentsStub =
                MockRepository.GenerateStub <IExtents>();
            FeatureQueryExpression featureQueryExpressionStub =
                MockRepository.GenerateStub <FeatureQueryExpression>(iExtentsStub, SpatialOperation.Intersects);

            _returnReaderStub = MockRepository.GenerateStub <IFeatureDataReader>();
            _sleepInterval    = 1000;

            using (mocks.Unordered())
            {
                Expect.Call(adapted.ExecuteFeatureQuery(featureQueryExpressionStub))
                .Do(new ExecuteQueryDelegate(executeQueryMock));
            }
            mocks.ReplayAll();

            AsyncFeatureProviderAdapter adapter = new AsyncFeatureProviderAdapter(adapted);
            IAsyncResult ar = adapter.BeginExecuteQuery(featureQueryExpressionStub, null);

            Assert.NotNull(ar);
            Assert.False(ar.IsCompleted);
            while (!ar.IsCompleted)
            {
                Thread.Sleep(350);
            }

            Assert.True(ar.IsCompleted);
            Assert.Same(_returnReaderStub, adapter.EndExecuteQuery(ar));

            mocks.VerifyAll();
        }
Пример #13
0
        private static ISpatialIndexNode <IExtents, TItem> findParentNode(ISpatialIndexNode <IExtents, TItem> lookFor,
                                                                          ISpatialIndexNode <IExtents, TItem> searchNode)
        {
            foreach (ISpatialIndexNode <IExtents, TItem> node in searchNode.SubNodes)
            {
                if (node.Equals(lookFor))
                {
                    return(searchNode);
                }
            }

            IExtents itemBounds = lookFor.Bounds;

            // TODO: I think a breadth-first search would be more efficient here
            foreach (ISpatialIndexNode <IExtents, TItem> child in searchNode.SubNodes)
            {
                if (child.Intersects(itemBounds))
                {
                    ISpatialIndexNode <IExtents, TItem> found = findParentNode(lookFor, child);

                    if (found != null)
                    {
                        return(found);
                    }
                }
            }

            return(null);
        }
Пример #14
0
        /// <summary>
        /// Creates a new index branch node with the given extents.
        /// </summary>
        /// <returns>A new branch node for the R-Tree.</returns>
        protected internal virtual RTreeNode <TItem> CreateNode(int level, IExtents extents)
        {
            RTreeNode <TItem> node = CreateNode(level);

            node.Bounds = extents;
            return(node);
        }
Пример #15
0
 public RasterQueryExpression(IExtents extents, SpatialOperation op)
     : base(new AllBandsExpression(), new SpatialBinaryExpression(new ExtentsExpression(extents),
                                                                  op,
                                                                  new ThisExpression()))
 {
     checkOp(op);
 }
Пример #16
0
        private void onSpatialReferenceChanged()
        {
            _geoFactory = _geoFactory.Clone();
            _geoFactory.SpatialReference = SpatialReference;

            foreach (ILayer layer in _layers)
            {
                if (!layer.SpatialReference.EqualParams(SpatialReference))
                {
                    if (layer.CoordinateTransformation != null)
                    {
                        // TODO: do we ever need to support multiple transforms?
                        throw new InvalidOperationException("The layer already has a coordinate transform.");
                    }

                    layer.CoordinateTransformation
                        = CoordinateTransformFactory.CreateFromCoordinateSystems(layer.SpatialReference,
                                                                                 SpatialReference);
                }
            }

            _extents = null;

            raisePropertyChanged(SpatialReferenceProperty.Name);
        }
Пример #17
0
 public IEnumerable <TResult> Query <TResult>(IExtents query, Func <TItem, TResult> selector)
 {
     foreach (TItem item in Query(query))
     {
         yield return(selector(item));
     }
 }
Пример #18
0
        public void TestGetExtentsByOid()
        {
            GeometryServices services = new GeometryServices();

            MsSqlServer2008Provider <long> search = new MsSqlServer2008Provider <long>(services.DefaultGeometryFactory,
                                                                                       ConfigurationManager.
                                                                                       ConnectionStrings["sql2008"].
                                                                                       ConnectionString,
                                                                                       "dbo",
                                                                                       "vw_iMARS_BRANCH", "ACSId", "Geom")
            {
                DefaultProviderProperties
                    = new ProviderPropertiesExpression(
                          new ProviderPropertyExpression[]
                {
                    new WithNoLockExpression(true),
                    new ForceIndexExpression(true)
                })
            };


            IExtents extents = search.GetExtentsByOid(1);

            Assert.IsNotNull(extents);
            Assert.IsFalse(extents.IsEmpty);
        }
        public void IFeatureProviderMethodsPassThroughAdapter()
        {
            MockRepository   mocks   = new MockRepository();
            IFeatureProvider adapted = mocks.CreateMock <IFeatureProvider>();
            IGeometryFactory iGeometryFactoryStub =
                MockRepository.GenerateStub <IGeometryFactory>();
            FeatureDataTable featureDataTableStub =
                MockRepository.GenerateStub <FeatureDataTable>(iGeometryFactoryStub);
            IFeatureDataReader iFeatureDataReaderStub =
                MockRepository.GenerateStub <IFeatureDataReader>();
            IExtents iExtentsStub =
                MockRepository.GenerateStub <IExtents>();
            FeatureQueryExpression featureQueryExpressionStub =
                MockRepository.GenerateStub <FeatureQueryExpression>(iExtentsStub, SpatialOperation.Intersects);
            FeatureQueryExecutionOptions featureQueryExecutionOptionsStub =
                new FeatureQueryExecutionOptions();
            DataTable dataTableStub =
                MockRepository.GenerateStub <DataTable>();
            CultureInfo cultureInfoStub =
                MockRepository.GenerateStub <CultureInfo>(1);

            using (mocks.Unordered())
            {
                Expect.Call(adapted.CreateNewTable())
                .Return(featureDataTableStub);
                Expect.Call(adapted.ExecuteFeatureQuery(featureQueryExpressionStub, featureQueryExecutionOptionsStub))
                .Return(iFeatureDataReaderStub);
                Expect.Call(adapted.ExecuteFeatureQuery(featureQueryExpressionStub))
                .Return(iFeatureDataReaderStub);
                adapted.GeometryFactory = iGeometryFactoryStub;
                Expect.Call(adapted.GeometryFactory)
                .Return(iGeometryFactoryStub);
                Expect.Call(adapted.GetFeatureCount())
                .Return(3);
                Expect.Call(adapted.GetSchemaTable())
                .Return(dataTableStub);
                Expect.Call(adapted.Locale)
                .Return(cultureInfoStub);
                adapted.SetTableSchema(featureDataTableStub);
            }
            mocks.ReplayAll();

            AsyncFeatureProviderAdapter adapter = new AsyncFeatureProviderAdapter(adapted);

            Assert.Same(featureDataTableStub, adapter.CreateNewTable());
            Assert.Same(iFeatureDataReaderStub,
                        adapter.ExecuteFeatureQuery(featureQueryExpressionStub, featureQueryExecutionOptionsStub));
            Assert.Same(iFeatureDataReaderStub,
                        adapter.ExecuteFeatureQuery(featureQueryExpressionStub));
            adapter.GeometryFactory = iGeometryFactoryStub;
            Assert.Same(iGeometryFactoryStub, adapter.GeometryFactory);
            Assert.Equal(3, adapter.GetFeatureCount());
            Assert.Same(dataTableStub, adapter.GetSchemaTable());
            Assert.Same(cultureInfoStub, adapter.Locale);
            adapter.SetTableSchema(featureDataTableStub);

            mocks.VerifyAll();
        }
 public FeatureQueryExpression(IExtents extents,
                               SpatialOperation op,
                               IEnumerable <IFeatureDataRecord> features)
     : base(new AllAttributesExpression(),
            new SpatialBinaryExpression(new ExtentsExpression(extents),
                                        op,
                                        new FeaturesCollectionExpression(features)))
 {
 }
Пример #21
0
        public void Add(IExtents tileBounds, Bitmap tile)
        {
            QuadTreeNode <Bitmap> tileNode = new QuadTreeNode <Bitmap>();

            tileNode.Value = tile;
#warning This doesn't compile in Orcas B2, but it does in VS2005
            //tileNode.BoundingBox = tileBounds;
            AddItem(tileNode);
        }
Пример #22
0
        public ExtentsExpression(IExtents extents)
        {
            if (extents == null)
            {
                throw new ArgumentNullException("extents");
            }

            _extents = extents;
        }
Пример #23
0
 public IEnumerable <TItem> Query(IExtents query, Predicate <TItem> predicate)
 {
     foreach (TItem item in Query(query))
     {
         if (predicate(item))
         {
             yield return(item);
         }
     }
 }
Пример #24
0
        public void GetExtentsTest()
        {
            ShapeFileProvider shapeFile = new ShapeFileProvider(BcRoadsShapeFile, _geoFactory);
            IExtents          expected  = _geoFactory.CreateExtents2D(
                7332083.2127965018, 236823.71867240831,
                7538428.618, 405610.34692560317);
            IExtents actual = shapeFile.GetExtents();

            Assert.AreEqual(expected, actual);
        }
Пример #25
0
 public IEnumerable <TItem> Query(IExtents bounds, Predicate <TItem> predicate)
 {
     foreach (TItem item in IntersectTreeRecursive(bounds, Root as RTreeNode <TItem>))
     {
         if (predicate(item))
         {
             yield return(item);
         }
     }
 }
        public void IProviderMethodsPassThroughAdapter()
        {
            MockRepository            mocks         = new MockRepository();
            IRasterProvider           adapted       = mocks.CreateMock <IRasterProvider>();
            ICoordinateTransformation transformStub =
                MockRepository.GenerateStub <ICoordinateTransformation>();
            Expression queryStub =
                MockRepository.GenerateStub <Expression>();
            Object objectStub =
                MockRepository.GenerateStub <Object>();
            IExtents extentsStub =
                MockRepository.GenerateStub <IExtents>();
            ICoordinateSystem coordinateSystemStub =
                MockRepository.GenerateStub <ICoordinateSystem>();

            using (mocks.Unordered())
            {
                adapted.Close();
                Expect.Call(adapted.ConnectionId)
                .Return("connectionid");
                adapted.CoordinateTransformation = transformStub;
                Expect.Call(adapted.CoordinateTransformation)
                .Return(transformStub);
                Expect.Call(adapted.ExecuteQuery(queryStub))
                .Return(objectStub);
                Expect.Call(adapted.GetExtents())
                .Return(extentsStub);
                Expect.Call(adapted.IsOpen)
                .Return(true);
                adapted.Open();
                Expect.Call(adapted.SpatialReference)
                .Return(coordinateSystemStub);
                //adapted.Srid = 1;
                Expect.Call(adapted.Srid)
                .Return("2");
            }

            mocks.ReplayAll();

            AsyncRasterProviderAdapter adapter = new AsyncRasterProviderAdapter(adapted);

            adapter.Close();
            Assert.Equal("connectionid", adapter.ConnectionId);
            adapter.CoordinateTransformation = transformStub;
            Assert.Same(transformStub, adapter.CoordinateTransformation);
            Assert.Same(objectStub, adapter.ExecuteQuery(queryStub));
            Assert.Same(extentsStub, adapter.GetExtents());
            Assert.True(adapter.IsOpen);
            adapter.Open();
            Assert.Same(coordinateSystemStub, adapter.SpatialReference);
            //adapter.Srid = 1;
            Assert.Equal("2", adapter.Srid);

            mocks.VerifyAll();
        }
Пример #27
0
        public void MapExtentsReflectTheUnderlyingLayersCorrectlyWhenUsingAddLayer()
        {
            Map map = new Map(_factories.GeoFactory);

            GeometryLayer layer = new GeometryLayer("Geom layer",
                                                    DataSourceHelper.CreateGeometryDatasource(_factories.GeoFactory));

            map.AddLayer(layer);
            IExtents box = map.Extents;

            Assert.Equal(_factories.GeoFactory.CreateExtents2D(0, 0, 120, 100), box);
        }
Пример #28
0
        public ComputationExtents(IExtents extents)
        {
            if (extents == null) throw new ArgumentNullException("extents");

            ICoordinate min = extents.Min;
            ICoordinate max = extents.Max;

            XMin = min[Ordinates.X];
            YMin = min[Ordinates.Y];
            XMax = max[Ordinates.X];
            YMax = max[Ordinates.Y];

            _hasValue = 1;
        }
Пример #29
0
        public void EmptyMapDefaultsAreCorrect()
        {
            Map      map          = new Map(_factories.GeoFactory);
            IExtents emptyExtents = _factories.GeoFactory.CreateExtents();
            IPoint   emptyPoint   = _factories.GeoFactory.CreatePoint();

            Assert.Equal(emptyExtents, map.Extents);
            // changed to null from Point.Empty
            Assert.Equal(emptyPoint.Coordinate, map.Center);
            Assert.NotNull(map.Layers);
            Assert.Equal(0, map.Layers.Count);
            Assert.Equal(StandardMapView2DMapTools.None, map.ActiveTool);
            Assert.NotNull(map.SelectedLayers);
        }
Пример #30
0
        private IEnumerable <Bitmap> recursiveNodeSearch(IExtents searchBounds, QuadTreeNode <Bitmap> node)
        {
            // If search bounds are only partially by node bounds, then return node's value,
            // since successive searches will be incomplete.
            if (node.Bounds.Intersects(searchBounds) && !node.Bounds.Contains(searchBounds))
            {
                yield return(node.Value);

                yield break;
            }

            // The node must cover the search bounds, so see if it has more than
            // one child node which intersects the search bounds. If so, then that must
            // be the best resolution tiles to satisfy the search request, as the bitmaps can
            // be resampled upward. If there is only one child, recurse downward on that child.
            Int32[] intersectNodes     = new Int32[4];
            Int32   intersectNodeIndex = -1;

            for (Int32 nodeIndex = 0; nodeIndex < node.ItemCount; nodeIndex++)
            {
                QuadTreeNode <Bitmap> testNode = Items[nodeIndex];

                if (testNode.Bounds.Intersects(searchBounds))
                {
                    intersectNodes[++intersectNodeIndex] = nodeIndex;
                }
            }

            // This should not be possible with the first bounds-check in this function
            Debug.Assert(intersectNodeIndex > -1);

            // If more than one node intersects the searchBounds, we must be at the correct resolution.
            // Otherwise, keep searching down the index.
            if (intersectNodeIndex > 0)
            {
                foreach (Int32 nodeIndex in intersectNodes)
                {
                    yield return(node.Items[nodeIndex].Value);
                }
            }
            else
            {
                foreach (
                    Bitmap tile in recursiveNodeSearch(searchBounds, node.Items[intersectNodes[intersectNodeIndex]]))
                {
                    yield return(tile);
                }
            }
        }
Пример #31
0
        public void LoadIntersectingLayerData(IExtents region)
        {
            if (region == null)
            {
                throw new ArgumentNullException("region");
            }

            SpatialBinaryExpression exp = new SpatialBinaryExpression(new ExtentsExpression(region),
                                                                      SpatialOperation.Intersects,
                                                                      new LayerExpression(this));

            QueryExpression query = GetQueryFromSpatialBinaryExpression(exp);

            LoadLayerData(query);
        }
Пример #32
0
        protected override void ReadV8(ByteReader reader)
        {
            base.ReadV8(reader);
            PartitionFlags = reader.ReadI32();
            FileName = reader.ReadMbString();

            // Read the box either way, if the mask is set, this is a reserved field...do we ignore it?
            TransformedBoundingBox = reader.ReadBBoxF32();

            Area = reader.ReadF32();
            MinVertexCount = reader.ReadI32();
            MaxVertexCount = reader.ReadI32();
            MinNodeCount= reader.ReadI32();
            MaxNodeCount = reader.ReadI32();
            MinPolygonCount = reader.ReadI32();
            MaxPolygonCount = reader.ReadI32();

            if ( ( PartitionFlags & 0x00000001 ) != 0 ) {
                UnTransformedBoundingBox = reader.ReadBBoxF32();
            }
        }
Пример #33
0
        public IGeometry ToGeometry(IExtents envelopeInternal)
        {
            ICoordinate[] verticies = new ICoordinate[5];

            ICoordinate min = envelopeInternal.Min;
            ICoordinate max = envelopeInternal.Max;

            verticies[0] = max;
            verticies[1] = CoordinateFactory.Create(min[Ordinates.X], max[Ordinates.Y]);
            verticies[2] = min;
            verticies[3] = CoordinateFactory.Create(max[Ordinates.X], min[Ordinates.Y]);
            verticies[4] = max;

            LinearRing ring = new LinearRing(verticies);
            ring.Factory = this;
            Polygon p = new Polygon(ring);
            p.Factory = this;
            return p;
        }
Пример #34
0
 public IExtents CreateExtents(IExtents first)
 {
     return new Extents(this, first);
 }
Пример #35
0
 public IExtents CreateExtents(IExtents first, IExtents second, IExtents third)
 {
     return new Extents(this, first, second, third);
 }
Пример #36
0
		private static void filterSelected(ILayer layer, IMapView2D view, IExtents worldBounds)
		{
			if (layer == null)
			{
				return;
			}

            FeatureLayer filterLayer = layer as FeatureLayer;

			if (filterLayer != null)
			{
				if (layer.Enabled && 
                    filterLayer.AreFeaturesSelectable && 
                    layer.IsVisibleWhen(isInView(view.WorldWidth)))
				{
                    SpatialBinaryExpression spatialExpression 
                        = SpatialBinaryExpression.Intersects(new FeaturesCollectionExpression(filterLayer.Features),
				                                             new ExtentsExpression(worldBounds));
					filterLayer.SelectedFilter = filterLayer.SelectedFilter == null 
                        ? new FeatureQueryExpression(new AllAttributesExpression(), spatialExpression, null)
                        : new FeatureQueryExpression(filterLayer.SelectedFilter, spatialExpression);
				}
			}

		    IEnumerable<ILayer> layers = layer as IEnumerable<ILayer>;

            if (layers != null)
			{
				foreach (ILayer child in layers)
				{
					filterSelected(child, view, worldBounds);
				}
			}
		}
Пример #37
0
 protected override void ReadV8(ByteReader reader)
 {
     VersionNumber = reader.ReadI16();
     UntransformedBoundingBox = reader.ReadBBoxF32();
 }
Пример #38
0
        public ExtentsExpression(IExtents extents)
        {
            if (extents == null) throw new ArgumentNullException("extents");

            _extents = extents;
        }
        private static void WriteExtents(StringBuilder sb, IExtents extents, string coordinateFormatString)
        {
            sb.Append("[");
            sb.AppendFormat(
                string.Format("{0},{1},{2},{3}",
                              string.Format(CultureInfo.InvariantCulture.NumberFormat, coordinateFormatString,
                                            extents.Min[Ordinates.X]),
                              string.Format(CultureInfo.InvariantCulture.NumberFormat, coordinateFormatString,
                                            extents.Min[Ordinates.Y]),
                              string.Format(CultureInfo.InvariantCulture.NumberFormat, coordinateFormatString,
                                            extents.Max[Ordinates.X]),
                              string.Format(CultureInfo.InvariantCulture.NumberFormat, coordinateFormatString,
                                            extents.Max[Ordinates.Y])));

            sb.Append("]");
        }
Пример #40
0
        protected override void ReadV8(ByteReader reader)
        {
            base.ReadV8(reader);

            // Read the transformed box
            TransformedBoundingBox = reader.ReadBBoxF32();
            // Read the untransformed box
            UntransformedBoundingBox = reader.ReadBBoxF32();
            Area = reader.ReadF32();
            MinVertexCount = reader.ReadI32();
            MaxVertexCount = reader.ReadI32();
            MinNodeCount= reader.ReadI32();
            MaxNodeCount = reader.ReadI32();
            MinPolygonCount = reader.ReadI32();
            MaxPolygonCount = reader.ReadI32();
            Size = reader.ReadI32();
            CompressionLevel = reader.ReadF32();
        }
Пример #41
0
 internal GeometryDataReader(GeometryProvider provider, IExtents bounds)
 {
     _provider = provider;
     _bounds = bounds;
 }