Exemple #1
0
        public override void PreExecute()
        {
            this._relation                = (relationType)ComponentMetaData.CustomPropertyCollection["Spatial Relation"].Value;
            this._targetCache             = new OGRBufferCache();
            this._joinCache               = new OGRBufferCache();
            this._targetColumnInfoMapList = new List <columnInfoMap>();
            this._joinColumnInfoMapList   = new List <columnInfoMap>();
            this._targetID                = ComponentMetaData.InputCollection["Target Input"].ID;
            this._joinID = ComponentMetaData.InputCollection["Join Input"].ID;

            IDTSOutput100 defaultOutput = ComponentMetaData.OutputCollection[0];
            IDTSInput100  targetInput   = ComponentMetaData.InputCollection["Target Input"];

            foreach (IDTSInputColumn100 inputColumn in targetInput.InputColumnCollection)
            {
                if (((string)ComponentMetaData.CustomPropertyCollection["Target Input Geometry Column"].Value).Equals(inputColumn.Name))
                {
                    this._targetGeomIndex = BufferManager.FindColumnByLineageID(targetInput.Buffer, inputColumn.LineageID);
                }
                foreach (IDTSOutputColumn100 outputColumn in defaultOutput.OutputColumnCollection)
                {
                    if (outputColumn.Name.Equals(targetInput.Name + "." + inputColumn.Name))
                    {
                        columnInfoMap ci = new columnInfoMap();
                        ci.inputBufferIndex  = BufferManager.FindColumnByLineageID(targetInput.Buffer, inputColumn.LineageID);
                        ci.outputBufferIndex = BufferManager.FindColumnByLineageID(defaultOutput.Buffer, outputColumn.LineageID);
                        this._targetColumnInfoMapList.Add(ci);
                    }
                }
            }

            IDTSInput100 joinInput = ComponentMetaData.InputCollection["Join Input"];

            foreach (IDTSInputColumn100 inputColumn in joinInput.InputColumnCollection)
            {
                if (((string)ComponentMetaData.CustomPropertyCollection["Join Input Geometry Column"].Value).Equals(inputColumn.Name))
                {
                    this._joinGeomIndex = BufferManager.FindColumnByLineageID(joinInput.Buffer, inputColumn.LineageID);
                }
                foreach (IDTSOutputColumn100 outputColumn in defaultOutput.OutputColumnCollection)
                {
                    if (outputColumn.Name.Equals(joinInput.Name + "." + inputColumn.Name))
                    {
                        columnInfoMap ci = new columnInfoMap();
                        ci.inputBufferIndex  = BufferManager.FindColumnByLineageID(joinInput.Buffer, inputColumn.LineageID);
                        ci.outputBufferIndex = BufferManager.FindColumnByLineageID(defaultOutput.Buffer, outputColumn.LineageID);
                        this._joinColumnInfoMapList.Add(ci);
                    }
                }
            }
        }
Exemple #2
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();
            }
        }