Exemplo n.º 1
0
OGRFeature *OGRAVCBinLayer::GetNextFeature()

{
    if( bNeedReset )
        ResetReading();

    OGRFeature *poFeature = GetFeature( -3 );

    // Skip universe polygon.
    if( poFeature != NULL && poFeature->GetFID() == 1 
        && psSection->eType == AVCFilePAL )
    {
        OGRFeature::DestroyFeature( poFeature );
        poFeature = GetFeature( -3 );
    }

    while( poFeature != NULL 
           && ((m_poAttrQuery != NULL
                && !m_poAttrQuery->Evaluate( poFeature ) )
               || !FilterGeometry( poFeature->GetGeometryRef() ) ) )
    {
        OGRFeature::DestroyFeature( poFeature );
        poFeature = GetFeature( -3 );
    }

    if( poFeature == NULL )
        ResetReading();

    return poFeature;
}
Exemplo n.º 2
0
static TVector<TMxTree> BuildTrees(const THashMap<TFeature, int, TFeatureHash>& featureToIdx,
                                   const TFullModel& model) {
    TVector<TMxTree> trees(model.ObliviousTrees.GetTreeCount());
    auto& binFeatures = model.ObliviousTrees.GetBinFeatures();
    for (int treeIdx = 0; treeIdx < trees.ysize(); ++treeIdx) {
        auto& tree = trees[treeIdx];
        const int leafCount = model.ObliviousTrees.LeafValues[treeIdx].ysize() / model.ObliviousTrees.ApproxDimension;

        tree.Leafs.resize(leafCount);
        for (int leafIdx = 0; leafIdx < leafCount; ++leafIdx) {
            tree.Leafs[leafIdx].Vals.resize(model.ObliviousTrees.ApproxDimension);
        }

        for (int leafIdx = 0; leafIdx < leafCount; ++leafIdx) {
            for (int dim = 0; dim < model.ObliviousTrees.ApproxDimension; ++dim) {
                tree.Leafs[leafIdx].Vals[dim] = model.ObliviousTrees.LeafValues[treeIdx][leafIdx * model.ObliviousTrees.ApproxDimension + dim];
            }
        }
        auto treeSplitsStart = model.ObliviousTrees.TreeStartOffsets[treeIdx];
        auto treeSplitsStop = treeSplitsStart + model.ObliviousTrees.TreeSizes[treeIdx];
        for (auto splitIdx = treeSplitsStart; splitIdx < treeSplitsStop; ++splitIdx) {
            auto feature = GetFeature(binFeatures[model.ObliviousTrees.TreeSplits[splitIdx]]);
            tree.SrcFeatures.push_back(featureToIdx.at(feature));
        }
    }
    return trees;
}
Exemplo n.º 3
0
/*!
  \brief Get next feature

  \return pointer to OGRFeature instance
*/
OGRFeature *OGRVFKLayer::GetNextFeature()
{
    VFKFeature  *poVFKFeature;

    OGRFeature  *poOGRFeature;
    OGRGeometry *poOGRGeom;

    poOGRFeature = NULL;
    poOGRGeom    = NULL;

    /* loop till we find and translate a feature meeting all our
       requirements
    */
    while (TRUE) {
        /* cleanup last feature, and get a new raw vfk feature */
        if (poOGRGeom != NULL) {
            delete poOGRGeom;
            poOGRGeom = NULL;
        }

        poVFKFeature = (VFKFeature *) poDataBlock->GetNextFeature();
        if (!poVFKFeature)
            return NULL;

        /* skip feature with unknown geometry type */
        if (poVFKFeature->GetGeometryType() == wkbUnknown)
            continue;

        poOGRFeature = GetFeature(poVFKFeature);
        if (poOGRFeature)
            return poOGRFeature;
    }
}
Exemplo n.º 4
0
OGRFeature *OGRTigerLayer::GetNextFeature()

{
/* -------------------------------------------------------------------- */
/*      Read features till we find one that satisfies our current       */
/*      spatial criteria.                                               */
/* -------------------------------------------------------------------- */
    while( iLastFeatureId < nFeatureCount )
    {
        OGRFeature      *poFeature = GetFeature( ++iLastFeatureId );

        if( poFeature == NULL )
            break;

        if( (m_poFilterGeom == NULL
             || FilterGeometry( poFeature->GetGeometryRef() ) )
            && (m_poAttrQuery == NULL
                || m_poAttrQuery->Evaluate( poFeature )) )
            return poFeature;

        delete poFeature;
    }

    return NULL;
}
Exemplo n.º 5
0
OGRFeature *OGRNTFRasterLayer::GetNextFeature()

{
    if( iCurrentFC == 0 )
        iCurrentFC = 1;
    else
    {
        int     iReqColumn, iReqRow;
        
        iReqColumn = (iCurrentFC - 1) / poReader->GetRasterYSize();
        iReqRow = iCurrentFC - iReqColumn * poReader->GetRasterXSize() - 1;

        if( iReqRow + nDEMSample > poReader->GetRasterYSize() )
        {
            iReqRow = 0;
            iReqColumn += nDEMSample;
        }
        else
        {
            iReqRow += nDEMSample;
        }

        iCurrentFC = iReqColumn * poReader->GetRasterYSize()
            + iReqRow + 1;
    }

    return GetFeature( (long) iCurrentFC );
}
Exemplo n.º 6
0
OGRFeature *OGRPCIDSKLayer::GetNextUnfilteredFeature()

{
    try
    {
/* -------------------------------------------------------------------- */
/*      Get the next shapeid.                                           */
/* -------------------------------------------------------------------- */
        if( hLastShapeId == PCIDSK::NullShapeId )
            hLastShapeId = poVecSeg->FindFirst();
        else
            hLastShapeId = poVecSeg->FindNext( hLastShapeId );

        if( hLastShapeId == PCIDSK::NullShapeId )
            return NULL;

        return GetFeature( hLastShapeId );
    }
    catch( const PCIDSK::PCIDSKException& ex )
    {
        CPLError( CE_Failure, CPLE_AppDefined,
                  "PCIDSK Exception while iterating features.\n%s", ex.what() );
        return NULL;
    }
}
OGRFeature *OGRNTFFeatureClassLayer::GetNextFeature()

{
    if( iCurrentFC >= GetFeatureCount() )
        return NULL;

    return GetFeature( (long) iCurrentFC++ );
}
Exemplo n.º 8
0
OGRFeature *OGRDODSLayer::GetNextFeature()

{
    for( OGRFeature *poFeature = GetFeature( iNextShapeId++ );
         poFeature != nullptr;
         poFeature = GetFeature( iNextShapeId++ ) )
    {
        if( FilterGeometry( poFeature->GetGeometryRef() )
            && (m_poAttrQuery == nullptr
                || m_poAttrQuery->Evaluate( poFeature )) )
            return poFeature;

        delete poFeature;
    }

    return nullptr;
}
Exemplo n.º 9
0
void
CacheChild::ExecuteOp(nsIGlobalObject* aGlobal, Promise* aPromise,
                      const CacheOpArgs& aArgs)
{
  mNumChildActors += 1;
  MOZ_ALWAYS_TRUE(SendPCacheOpConstructor(
    new CacheOpChild(GetFeature(), aGlobal, aPromise), aArgs));
}
Exemplo n.º 10
0
void
CacheStorageChild::ExecuteOp(nsIGlobalObject* aGlobal, Promise* aPromise,
                             nsISupports* aParent, const CacheOpArgs& aArgs)
{
  mNumChildActors += 1;
  unused << SendPCacheOpConstructor(
    new CacheOpChild(GetFeature(), aGlobal, aParent, aPromise), aArgs);
}
Exemplo n.º 11
0
OGRFeature *OGRSelafinLayer::GetNextFeature() {
    //CPLDebug("Selafin","GetNextFeature(%li)",nCurrentId+1);
    while (true) {
        OGRFeature *poFeature=GetFeature(++nCurrentId);
        if (poFeature==NULL) return NULL;
        if( (m_poFilterGeom == NULL || FilterGeometry( poFeature->GetGeometryRef() ) ) && (m_poAttrQuery == NULL || m_poAttrQuery->Evaluate( poFeature )) ) return poFeature;
        delete poFeature;
    }
}
Exemplo n.º 12
0
CachePushStreamChild*
CacheChild::CreatePushStream(nsIAsyncInputStream* aStream)
{
  mNumChildActors += 1;
  auto actor = SendPCachePushStreamConstructor(
    new CachePushStreamChild(GetFeature(), aStream));
  MOZ_ASSERT(actor);
  return static_cast<CachePushStreamChild*>(actor);
}
Exemplo n.º 13
0
/*!
  \brief Get feature by fid

  \param nFID feature id (-1 for next)

  \return pointer to OGRFeature
  \return NULL not found
*/
OGRFeature *OGRVFKLayer::GetFeature(long nFID)
{
    VFKFeature *poVFKFeature;
    
    poVFKFeature = poDataBlock->GetFeature(nFID);
    if (!poVFKFeature)
	return NULL;
    
    CPLDebug("OGR_VFK", "OGRVFKLayer::GetFeature(): fid=%ld", nFID);
    
    return GetFeature(poVFKFeature);
}
Exemplo n.º 14
0
  void ForEachFeature(m2::RectD const & rect, TFn && fn) const
  {
    uint32_t const scale = m_value.GetHeader().GetLastScale();
    covering::IntervalsT intervals;
    CoverRect(rect, scale, intervals);

    ForEachIndexImpl(intervals, scale, [&](uint32_t index)
                     {
                       FeatureType ft;
                       if (GetFeature(index, ft))
                         fn(ft);
                     });
  }
Exemplo n.º 15
0
GIntBig OGRSelafinLayer::GetFeatureCount(int bForce) {
    //CPLDebug("Selafin","GetFeatureCount(%i)",bForce);
    if (m_poFilterGeom==NULL && m_poAttrQuery==NULL) return (eType==POINTS)?poHeader->nPoints:poHeader->nElements;
    if (bForce==FALSE) return -1;
    long i=0;
    int nFeatureCount=0;
    long nMax=(eType==POINTS)?poHeader->nPoints:poHeader->nElements;
    while (i<nMax) {
        OGRFeature *poFeature=GetFeature(i++);
        if( (m_poFilterGeom == NULL || FilterGeometry( poFeature->GetGeometryRef() ) ) && (m_poAttrQuery == NULL || m_poAttrQuery->Evaluate( poFeature )) ) ++nFeatureCount;
        delete poFeature;
    }
    return nFeatureCount;
}
Exemplo n.º 16
0
/*!
  \brief Get feature by fid

  \param nFID feature id (-1 for next)

  \return pointer to OGRFeature or NULL not found
*/
OGRFeature *OGRVFKLayer::GetFeature(GIntBig nFID)
{
    IVFKFeature *poVFKFeature;

    poVFKFeature = poDataBlock->GetFeature(nFID);

    if (!poVFKFeature)
        return NULL;

    CPLAssert(nFID == poVFKFeature->GetFID());
    CPLDebug("OGR-VFK", "OGRVFKLayer::GetFeature(): name=%s fid=" CPL_FRMT_GIB, GetName(), nFID);

    return GetFeature(poVFKFeature);
}
Exemplo n.º 17
0
TVector<TMxTree> BuildMatrixnetTrees(const TFullModel& model, TVector<TFeature>* features) {
    THashMap<TFeature, int, TFeatureHash> featureToIdx;
    const auto& modelBinFeatures = model.ObliviousTrees.GetBinFeatures();
    for (auto binSplit : model.ObliviousTrees.TreeSplits) {
        TFeature feature = GetFeature(modelBinFeatures[binSplit]);
        if (featureToIdx.has(feature)) {
            continue;
        }
        int featureIdx = featureToIdx.ysize();
        featureToIdx[feature] = featureIdx;
        features->push_back(feature);
    }

    return BuildTrees(featureToIdx, model);
}
Exemplo n.º 18
0
OGRFeature *OGRCADLayer::GetNextFeature()
{
    OGRFeature *poFeature = GetFeature( nNextFID );
    ++nNextFID;

    if( poFeature == nullptr )
        return nullptr;

    if( ( m_poFilterGeom == nullptr ||  FilterGeometry( poFeature->GetGeometryRef() ) )
        && ( m_poAttrQuery == nullptr || m_poAttrQuery->Evaluate( poFeature ) ) )
    {
        return poFeature;
    }

    return nullptr;
}
Exemplo n.º 19
0
OGRFeature * OGRPCIDSKLayer::GetNextUnfilteredFeature()

{
/* -------------------------------------------------------------------- */
/*      Get the next shapeid.                                           */
/* -------------------------------------------------------------------- */
    if( hLastShapeId == PCIDSK::NullShapeId )
        hLastShapeId = poVecSeg->FindFirst();
    else
        hLastShapeId = poVecSeg->FindNext( hLastShapeId );

    if( hLastShapeId == PCIDSK::NullShapeId )
        return NULL;

    return GetFeature( hLastShapeId );
}
Exemplo n.º 20
0
bool
CacheChild::RecvKeysResponse(const RequestId& requestId, const nsresult& aRv,
                             nsTArray<PCacheRequest>&& aRequests)
{
  NS_ASSERT_OWNINGTHREAD(CacheChild);

  AddFeatureToStreamChild(aRequests, GetFeature());

  nsRefPtr<Cache> listener = mListener;
  if (!listener) {
    StartDestroyStreamChild(aRequests);
    return true;
  }

  listener->RecvKeysResponse(requestId, aRv, aRequests);
  return true;
}
Exemplo n.º 21
0
bool
CacheChild::RecvMatchResponse(const RequestId& requestId, const nsresult& aRv,
                              const PCacheResponseOrVoid& aResponse)
{
  NS_ASSERT_OWNINGTHREAD(CacheChild);

  AddFeatureToStreamChild(aResponse, GetFeature());

  nsRefPtr<Cache> listener = mListener;
  if (!listener) {
    StartDestroyStreamChild(aResponse);
    return true;
  }

  listener->RecvMatchResponse(requestId, aRv, aResponse);
  return true;
}
Exemplo n.º 22
0
	BOOL GetFeatureBoolValue(WCHAR* name, BOOL bDefault)
	{
		CFeature* pFeature = GetFeature(name);
		if (pFeature)
		{
			if (	!wcscmp(pFeature->m_value, L"1") || 
					!wcscmp(pFeature->m_value, L"yes"))
			{
				return TRUE;
			}
			else if (!wcscmp(pFeature->m_value, L"0") || 
						!wcscmp(pFeature->m_value, L"no"))
			{
				return FALSE;
			}
		}

		return bDefault;
	}
Exemplo n.º 23
0
void applyFilterbank( Filterbank *pFilterbank, Features * pFeats )
{

  assert(pFilterbank!=NULL);
  assert(pFeats!=NULL);

  int gabfeatsidx = 0;

  pFilterbank->m_pFeatures = CreateFeatures(pFeats->ncols, pFeats->nrows, pFeats->nfeats*NSCALES*NORIENTATIONS);
  assert(pFilterbank->m_pFeatures!=NULL);

  register int idx, s, k;

  for(idx=0; idx < pFeats->nfeats; idx++)
  {

    DImage* pImgfeats       = GetFeature(pFeats, idx);

    Spectrum *pSpectrumImg  = NULL;
    pSpectrumImg            = DFFT2D(pImgfeats);
    assert(pSpectrumImg!=NULL);

    for( s = 0; s < NSCALES; s++ )
    {
      for( k = 0; k < NORIENTATIONS; k++ )
      {
          Spectrum * pSpectrumConv = MultSpectrum(pSpectrumImg, pFilterbank->m_pSpectralFilterBank[s*NORIENTATIONS+k]);

          DImage   *  pInvImg       = DInvFFT2D(pSpectrumConv);
          DImage   *  pShiftedInvImg = DShift(pInvImg);

          SetFeature(pFilterbank->m_pFeatures, gabfeatsidx, pShiftedInvImg);
          gabfeatsidx++;

          DestroySpectrum(&(pSpectrumConv));
          DestroyDImage(&(pInvImg));
          DestroyDImage(&(pShiftedInvImg));
      }
    }
    DestroyDImage(&(pImgfeats));
    DestroySpectrum(&(pSpectrumImg));
  }
}
Exemplo n.º 24
0
/**
 *0.Initialize feature vectors as zero vectors\n
 *1.Extract intra-syllable features\n
 *2.Extract cross-syllable features\n
 *3.Save features
 */
void SRIPitchFeXor::Extract(Utterance* u, vector< vector<double> >& features, bool extractDelta)
{
	DUMP(__PRETTY_FUNCTION__);

	vector<double> backupPitchContour = u->GetPitchContour();
	stylizer->Stylize(u);
	InitializeFeature(u->GetNumberOfSyllables());
	GetFeature(u);
	SaveFeature(features, u->GetNumberOfSyllables());

	if (extractDelta)
	{
		InitializeDeltaFeature(u->GetNumberOfSyllables());
		GetDeltaFeature(u->GetNumberOfSyllables());
		SaveDeltaFeature(features, u->GetNumberOfSyllables());
		ResetDeltaFeature(u->GetNumberOfSyllables());
	}

	ResetFeature(u->GetNumberOfSyllables());
	u->SetPitchContour(backupPitchContour);
}
Exemplo n.º 25
0
OGRFeature* OGROpenFileGDBSimpleSQLLayer::GetNextFeature()
{
    while(TRUE)
    {
        int nRow = poIter->GetNextRowSortedByValue();
        if( nRow < 0 )
            return NULL;
        OGRFeature* poFeature = GetFeature(nRow + 1);
        if( poFeature == NULL )
            return NULL;

        if( (m_poFilterGeom == NULL
             || FilterGeometry( poFeature->GetGeometryRef() ) )
            && (m_poAttrQuery == NULL ||
                m_poAttrQuery->Evaluate( poFeature ) ) )
        {
            return poFeature;
        }

        delete poFeature;
    }
}
ECode XmlPullParserFactory::IsNamespaceAware(
    /* [out] */ Boolean* isNspAware)
{
    return GetFeature(IXmlPullParser::FEATURE_PROCESS_NAMESPACES, isNspAware);
}
Exemplo n.º 27
0
VOID
EvtIoDeviceControl(
    _In_  WDFQUEUE          Queue,
    _In_  WDFREQUEST        Request,
    _In_  size_t            OutputBufferLength,
    _In_  size_t            InputBufferLength,
    _In_  ULONG             IoControlCode
    )
/*++
Routine Description:

    This event callback function is called when the driver receives an

    (KMDF) IOCTL_HID_Xxx code when handlng IRP_MJ_INTERNAL_DEVICE_CONTROL
    (UMDF) IOCTL_HID_Xxx, IOCTL_UMDF_HID_Xxx when handling IRP_MJ_DEVICE_CONTROL

Arguments:

    Queue - A handle to the queue object that is associated with the I/O request

    Request - A handle to a framework request object.

    OutputBufferLength - The length, in bytes, of the request's output buffer,
            if an output buffer is available.

    InputBufferLength - The length, in bytes, of the request's input buffer, if
            an input buffer is available.

    IoControlCode - The driver or system defined IOCTL associated with the request

Return Value:

    NTSTATUS

--*/
{
    NTSTATUS                status;
    BOOLEAN                 completeRequest = TRUE;
    WDFDEVICE               device = WdfIoQueueGetDevice(Queue);
    PDEVICE_CONTEXT         deviceContext = NULL;
    PQUEUE_CONTEXT          queueContext = GetQueueContext(Queue);
    UNREFERENCED_PARAMETER  (OutputBufferLength);
    UNREFERENCED_PARAMETER  (InputBufferLength);

    deviceContext = GetDeviceContext(device);

    switch (IoControlCode)
    {
    case IOCTL_HID_GET_DEVICE_DESCRIPTOR:   // METHOD_NEITHER
        //
        // Retrieves the device's HID descriptor.
        //
        _Analysis_assume_(deviceContext->HidDescriptor.bLength != 0);
        status = RequestCopyFromBuffer(Request,
                            &deviceContext->HidDescriptor,
                            deviceContext->HidDescriptor.bLength);
        break;

    case IOCTL_HID_GET_DEVICE_ATTRIBUTES:   // METHOD_NEITHER
        //
        //Retrieves a device's attributes in a HID_DEVICE_ATTRIBUTES structure.
        //
        status = RequestCopyFromBuffer(Request,
                            &queueContext->DeviceContext->HidDeviceAttributes,
                            sizeof(HID_DEVICE_ATTRIBUTES));
        break;

    case IOCTL_HID_GET_REPORT_DESCRIPTOR:   // METHOD_NEITHER
        //
        //Obtains the report descriptor for the HID device.
        //
        status = RequestCopyFromBuffer(Request,
                            deviceContext->ReportDescriptor,
                            deviceContext->HidDescriptor.DescriptorList[0].wReportLength);
        break;

    case IOCTL_HID_READ_REPORT:             // METHOD_NEITHER
        //
        // Returns a report from the device into a class driver-supplied
        // buffer.
        //
        status = ReadReport(queueContext, Request, &completeRequest);
        break;

    case IOCTL_HID_WRITE_REPORT:            // METHOD_NEITHER
        //
        // Transmits a class driver-supplied report to the device.
        //
        status = WriteReport(queueContext, Request);
        break;

#ifdef _KERNEL_MODE

    case IOCTL_HID_GET_FEATURE:             // METHOD_OUT_DIRECT

        status = GetFeature(queueContext, Request);
        break;

    case IOCTL_HID_SET_FEATURE:             // METHOD_IN_DIRECT

        status = SetFeature(queueContext, Request);
        break;

    case IOCTL_HID_GET_INPUT_REPORT:        // METHOD_OUT_DIRECT

        status = GetInputReport(queueContext, Request);
        break;

    case IOCTL_HID_SET_OUTPUT_REPORT:       // METHOD_IN_DIRECT

        status = SetOutputReport(queueContext, Request);
        break;

#else // UMDF specific

    //
    // HID minidriver IOCTL uses HID_XFER_PACKET which contains an embedded pointer.
    //
    //   typedef struct _HID_XFER_PACKET {
    //     PUCHAR reportBuffer;
    //     ULONG  reportBufferLen;
    //     UCHAR  reportId;
    //   } HID_XFER_PACKET, *PHID_XFER_PACKET;
    //
    // UMDF cannot handle embedded pointers when marshalling buffers between processes.
    // Therefore a special driver mshidumdf.sys is introduced to convert such IRPs to
    // new IRPs (with new IOCTL name like IOCTL_UMDF_HID_Xxxx) where:
    //
    //   reportBuffer - passed as one buffer inside the IRP
    //   reportId     - passed as a second buffer inside the IRP
    //
    // The new IRP is then passed to UMDF host and driver for further processing.
    //

    case IOCTL_UMDF_HID_GET_FEATURE:        // METHOD_NEITHER

        status = GetFeature(queueContext, Request);
        break;

    case IOCTL_UMDF_HID_SET_FEATURE:        // METHOD_NEITHER

        status = SetFeature(queueContext, Request);
        break;

    case IOCTL_UMDF_HID_GET_INPUT_REPORT:  // METHOD_NEITHER

        status = GetInputReport(queueContext, Request);
        break;

    case IOCTL_UMDF_HID_SET_OUTPUT_REPORT: // METHOD_NEITHER

        status = SetOutputReport(queueContext, Request);
        break;

#endif // _KERNEL_MODE

    case IOCTL_HID_GET_STRING:                      // METHOD_NEITHER

        status = GetString(Request);
        break;

    case IOCTL_HID_GET_INDEXED_STRING:              // METHOD_OUT_DIRECT

        status = GetIndexedString(Request);
        break;

    case IOCTL_HID_SEND_IDLE_NOTIFICATION_REQUEST:  // METHOD_NEITHER
        //
        // This has the USBSS Idle notification callback. If the lower driver
        // can handle it (e.g. USB stack can handle it) then pass it down
        // otherwise complete it here as not inplemented. For a virtual
        // device, idling is not needed.
        //
        // Not implemented. fall through...
        //
    case IOCTL_HID_ACTIVATE_DEVICE:                 // METHOD_NEITHER
    case IOCTL_HID_DEACTIVATE_DEVICE:               // METHOD_NEITHER
    case IOCTL_GET_PHYSICAL_DESCRIPTOR:             // METHOD_OUT_DIRECT
        //
        // We don't do anything for these IOCTLs but some minidrivers might.
        //
        // Not implemented. fall through...
        //
    default:
        status = STATUS_NOT_IMPLEMENTED;
        break;
    }

    //
    // Complete the request. Information value has already been set by request
    // handlers.
    //
    if (completeRequest) {
        WdfRequestComplete(Request, status);
    }
}
Exemplo n.º 28
0
 /**
  * Same as GetFeature.
  */
 inline const ImageFeature operator[](size_t idx) const { return GetFeature(idx); }
Exemplo n.º 29
0
OGRErr OGRGRASSLayer::SetAttributeFilter( const char *query )
{
    CPLDebug ( "GRASS", "SetAttributeFilter: %s", query  );

    if ( query == NULL ) {
	// Release old if any
	if ( pszQuery ) {
	    CPLFree ( pszQuery );
	    pszQuery = NULL;
	}
	if ( paQueryMatch ) {
	    CPLFree ( paQueryMatch );
	    paQueryMatch = NULL;
	}
	return OGRERR_NONE;
    }

    paQueryMatch = (char *) CPLMalloc ( nTotalCount );
    memset ( paQueryMatch, 0x0, nTotalCount );
    pszQuery = strdup ( query );

    OGRLayer::SetAttributeFilter(query); // Otherwise crash on delete

    if ( bHaveAttributes ) {

	if ( !poDriver ) 
	{
	    StartDbDriver();
	}

	if ( poDriver ) 
	{
	    if ( bCursorOpened )
	    {
		db_close_cursor ( poCursor ); 
		bCursorOpened = false;
	    }
	    OpenSequentialCursor();
	    if ( bCursorOpened )
	    {
		SetQueryMatch();
		db_close_cursor ( poCursor );
		bCursorOpened = false;
	    }
	    else
	    {
		CPLFree ( pszQuery );
		pszQuery = NULL;
		return OGRERR_FAILURE;
	    }
	    db_close_database_shutdown_driver ( poDriver );
	    poDriver = NULL;
	}
	else
	{
	    CPLFree ( pszQuery );
	    pszQuery = NULL;
	    return OGRERR_FAILURE;
	}
    }
    else
    {
	// Use OGR to evaluate category match
	for ( int i = 0; i < nTotalCount; i++ ) 
	{
	    OGRFeature *feature = GetFeature(i); 
	    CPLDebug ( "GRASS", "i = %d eval = %d", i, m_poAttrQuery->Evaluate ( feature ) );
	    if ( m_poAttrQuery->Evaluate ( feature ) )
	    {
		paQueryMatch[i] = 1;
	    }
	}
    }
    
    return OGRERR_NONE;
}
Exemplo n.º 30
0
Item* ITMImporter::GetItem(Item *s)
{
	unsigned int i;
	ieByte k1,k2,k3,k4;

	if( !s) {
		return NULL;
	}
	str->ReadDword( &s->ItemName );
	str->ReadDword( &s->ItemNameIdentified );
	str->ReadResRef( s->ReplacementItem );
	str->ReadDword( &s->Flags );
	str->ReadWord( &s->ItemType );
	str->ReadDword( &s->UsabilityBitmask );
	str->Read( s->AnimationType,2 ); //intentionally not reading word!
	for (i=0;i<2;i++) {
		if (s->AnimationType[i]==' ') {
			s->AnimationType[i]=0;
		}
	}
	str->Read( &s->MinLevel, 1 );
	str->Read( &s->unknown1, 1 );
	str->Read( &s->MinStrength,1 );
	str->Read( &s->unknown2, 1 );
	str->Read( &s->MinStrengthBonus, 1 );
	str->Read( &k1,1 );
	str->Read( &s->MinIntelligence, 1 );
	str->Read( &k2,1 );
	str->Read( &s->MinDexterity, 1 );
	str->Read( &k3,1 );
	str->Read( &s->MinWisdom, 1 );
	str->Read( &k4,1 );
	s->KitUsability=(k1<<24) | (k2<<16) | (k3<<8) | k4; //bg2/iwd2 specific
	str->Read( &s->MinConstitution, 1 );
	str->Read( &s->WeaProf, 1 ); //bg2 specific

	//hack for non bg2 weapon proficiencies
	if (!s->WeaProf) {
		s->WeaProf = GetProficiency(s->ItemType);
	}

	str->Read( &s->MinCharisma, 1 );
	str->Read( &s->unknown3, 1 );
	str->ReadDword( &s->Price );
	str->ReadWord( &s->MaxStackAmount );

	//hack for non stacked items, so MaxStackAmount could be used as a boolean
	if (s->MaxStackAmount==1) {
		s->MaxStackAmount = 0;
	}

	str->ReadResRef( s->ItemIcon );
	str->ReadWord( &s->LoreToID );
	str->ReadResRef( s->GroundIcon );
	str->ReadDword( &s->Weight );
	str->ReadDword( &s->ItemDesc );
	str->ReadDword( &s->ItemDescIdentified );
	str->ReadResRef( s->DescriptionIcon );
	str->ReadDword( &s->Enchantment );
	str->ReadDword( &s->ExtHeaderOffset );
	str->ReadWord( &s->ExtHeaderCount );
	str->ReadDword( &s->FeatureBlockOffset );
	str->ReadWord( &s->EquippingFeatureOffset );
	str->ReadWord( &s->EquippingFeatureCount );

	s->Dialog[0] = 0;
	s->DialogName = 0;
	s->WieldColor = 0xffff;
	memset( s->unknown, 0, 26 );

	//skipping header data for iwd2
	if (version == ITM_VER_IWD2) {
		str->Read( s->unknown, 16 );
	}
	//pst data
	if (version == ITM_VER_PST) {
		str->ReadResRef( s->Dialog );
		str->ReadDword( &s->DialogName );
		ieWord WieldColor;
		str->ReadWord( &WieldColor );
		if (s->AnimationType[0]) {
			s->WieldColor = WieldColor;
		}
		str->Read( s->unknown, 26 );
	} else {
	//all non pst
		s->DialogName = core->GetItemDialStr(s->Name);
		core->GetItemDialRes(s->Name, s->Dialog);
	}
	s->ItemExcl=core->GetItemExcl(s->Name);

	s->ext_headers = core->GetITMExt( s->ExtHeaderCount );

	for (i = 0; i < s->ExtHeaderCount; i++) {
		str->Seek( s->ExtHeaderOffset + i * 56, GEM_STREAM_START );
		GetExtHeader( s, s->ext_headers + i );
	}

	//48 is the size of the feature block
	s->equipping_features = core->GetFeatures( s->EquippingFeatureCount);

	str->Seek( s->FeatureBlockOffset + 48*s->EquippingFeatureOffset,
			GEM_STREAM_START );
	for (i = 0; i < s->EquippingFeatureCount; i++) {
		GetFeature(s->equipping_features+i);
	}


	if (!core->IsAvailable( IE_BAM_CLASS_ID )) {
		print( "[ITMImporter]: No BAM Importer Available.\n" );
		return NULL;
	}
	return s;
}