OGRFeature* OGRCARTODBTableLayer::GetFeature( GIntBig nFeatureId )
{

    if( bDeferedCreation && RunDeferedCreationIfNecessary() != OGRERR_NONE )
        return NULL;
    FlushDeferedInsert();

    GetLayerDefn();
    
    if( osFIDColName.size() == 0 )
        return OGRCARTODBLayer::GetFeature(nFeatureId);

    CPLString osSQL = osSELECTWithoutWHERE;
    osSQL += " WHERE ";
    osSQL += OGRCARTODBEscapeIdentifier(osFIDColName).c_str();
    osSQL += " = ";
    osSQL += CPLSPrintf(CPL_FRMT_GIB, nFeatureId);

    json_object* poObj = poDS->RunSQL(osSQL);
    json_object* poRowObj = OGRCARTODBGetSingleRow(poObj);
    if( poRowObj == NULL )
    {
        if( poObj != NULL )
            json_object_put(poObj);
        return OGRCARTODBLayer::GetFeature(nFeatureId);
    }

    OGRFeature* poFeature = BuildFeature(poRowObj);
    json_object_put(poObj);

    return poFeature;
}
Example #2
0
int UI_Deaggregate (ObjectiveClass* objective)
{
	int						f,fid;
	VehicleID				classID;
	Falcon4EntityClassType* classPtr;
	float					x,y,z;
	FeatureClassDataType*	fc;
	ObjClassDataType*		oc;
	BSPLIST					*drawptr;
	Tpoint					objPos;
	C_Window				*win;
	C_Text					*txt;
	C_TreeList				*tree;
	TREELIST				*item,*parent,*root;
	C_Entity				*recon_ent;
	C_Feature				*feat;

	if(gUIViewer == NULL)
		return(0);

	CloseAllRenderers(RECON_WIN);
	win=gMainHandler->FindWindow(RECON_WIN);
	if(win == NULL)
		return(0);

	tree=(C_TreeList*)win->FindControl(RECON_TREE);
	if(!tree)
		return(0);

	root=tree->Find(objective->GetTeam());
	if(!root)
	{
		txt=new C_Text;
		txt->Setup(C_DONT_CARE,0);
		txt->SetFixedWidth(100);
		txt->SetFont(tree->GetFont());
		txt->SetText(TeamInfo[objective->GetTeam()]->GetName());
		txt->SetFGColor(0xc0c0c0);

		root=tree->CreateItem(objective->GetTeam(),C_TYPE_ROOT,txt);
		if(root)
			tree->AddItem(tree->GetRoot(),root);

	}
	if(!root)
		return(0);

	recon_ent=BuildObjective(objective);

	parent=tree->CreateItem(objective->GetCampID(),C_TYPE_MENU,recon_ent);
	if(parent)
		tree->AddChildItem(root,parent);

	// Set up the init data structure.
	oc = objective->GetObjectiveClassData();
	fid = oc->FirstFeature;
	for (f=0; f<oc->Features; f++,fid++)
	{
		classID = static_cast<short>(objective->GetFeatureID(f));
		if (classID)
		{
			fc = GetFeatureClassData (classID);
			if (!fc || fc->Flags & FEAT_VIRTUAL)
				continue;
			objective->GetFeatureOffset(f, &y, &x, &z);
			objPos.x=x+objective->XPos();
			objPos.y=y+objective->YPos();
			objPos.z=z;
			classPtr = &Falcon4ClassTable[fc->Index];
			if(classPtr != NULL)
			{
				drawptr=LoadFeature(objective->GetCampID() << 16 | f,classPtr->visType[objective->GetFeatureStatus(f)],&objPos,(float)FeatureEntryDataTable[fid].Facing);
				if(drawptr != NULL)
				{
//					if(objective->GetFeatureValue(f))
//					{
						((DrawableObject*)drawptr)->GetPosition(&objPos);

						feat=BuildFeature(objective,f,&objPos);
						if(feat)
						{
							item=tree->CreateItem(objective->GetCampID() << 16 | f,C_TYPE_ITEM,feat);
							if(item)
								tree->AddChildItem(parent,item);
						}
//					}
				}
			}
		}
	}
	tree->RecalcSize();
	if(tree->Parent_)
		tree->Parent_->RefreshClient(tree->GetClient());
	return(1);
}