Exemple #1
0
        public override void ProcessInput(int inputID, PipelineBuffer buffer)
        {
            OGRBufferCache cache     = null;
            int            geomIndex = -1;

            if (inputID == this._targetID)
            {
                cache     = this._targetCache;
                geomIndex = this._targetGeomIndex;
            }
            else if (inputID == this._joinID)
            {
                cache     = this._joinCache;
                geomIndex = this._joinGeomIndex;
            }

            while (buffer.NextRow())
            {
                object[] bufferRow = new object[buffer.ColumnCount];
                for (int i = 0; i < buffer.ColumnCount; i++)
                {
                    if (buffer[i] is BlobColumn)
                    {
                        int    blobSize = (int)buffer.GetBlobLength(i);
                        byte[] blob     = buffer.GetBlobData(i, 0, blobSize);
                        bufferRow[i] = blob;
                    }
                    else
                    {
                        bufferRow[i] = buffer[i];
                    }
                }
                Geometry          geom = Geometry.CreateFromWkb((byte[])bufferRow[geomIndex]);
                OGRBufferCacheRow row  = new OGRBufferCacheRow(bufferRow, geom);
                cache.add(row);
            }

            if (buffer.EndOfRowset)
            {
                this._inputCount += 1;
            }

            if (this._inputCount == 2)
            {
                this._targetCache.createSpatialIndex();

                foreach (OGRBufferCacheRow row in this._joinCache)
                {
                    List <OGRBufferCacheRow> results = null;
                    switch (this._relation)
                    {
                    case relationType.contains:
                        results = this._targetCache.contains(row);
                        break;

                    case relationType.crosses:
                        results = this._targetCache.crosses(row);
                        break;

                    case relationType.equals:
                        results = this._targetCache.equals(row);
                        break;

                    case relationType.intersects:
                        results = this._targetCache.intersects(row);
                        break;

                    case relationType.overlaps:
                        results = this._targetCache.overlaps(row);
                        break;

                    case relationType.touches:
                        results = this._targetCache.touches(row);
                        break;

                    case relationType.within:
                        results = this._targetCache.within(row);
                        break;
                    }

                    if (results.Count > 0)
                    {
                        foreach (OGRBufferCacheRow resultRow in results)
                        {
                            this._outputBuffer.AddRow();

                            foreach (columnInfoMap ci in this._joinColumnInfoMapList)
                            {
                                this._outputBuffer[ci.outputBufferIndex] = row[ci.inputBufferIndex];
                            }
                            foreach (columnInfoMap ci in this._targetColumnInfoMapList)
                            {
                                this._outputBuffer[ci.outputBufferIndex] = resultRow[ci.inputBufferIndex];
                            }
                        }
                    }
                }
                this._outputBuffer.SetEndOfRowset();
            }
        }