Beispiel #1
0
	void CFields::RebuildFieldIndexMap() const
	{
		m_mapFieldIndex.clear();

		for(uint32 i = 0; i < m_vecFields.size(); ++i)
		{
			IFieldPtr field = m_vecFields[i];
			if(!field.get())
				continue;
			m_mapFieldIndex.insert(TMapFieldIndex::value_type(field->getName(), (int)i));
		}
	}
Beispiel #2
0
		void SQLiteInsertCursor::init()
		{
		
			CommonLib::CString sSQL = L"INSERT INTO  " + m_pTable->GetDatasetName() + L" ( ";
			CommonLib::CString sValues = " VALUES ( ";


			if(!m_pFieldSet.get())
			{
				m_pFieldSet = new CFieldSet();
				for (int i = 0, sz = m_pSourceFields->GetFieldCount(); i < sz; ++i)
				{
					IFieldPtr pField = m_pSourceFields->GetField(i);
					m_pFieldSet->Add(pField->GetName());
				}
			}

			for (int i = 0; i < m_pFieldSet->GetCount(); ++i)
			{

				const CommonLib::CString& sFieldName = m_pFieldSet->Get(i);
				IFieldPtr pField = m_pSourceFields->GetField(sFieldName);

				if(!pField.get())
				{
					//TO DO error
					m_bValidCursor = false;
				}
				//m_mapFieldInfo.insert(std::make_pair(sFieldName, SFieldInfo(i, pField->GetType())));

				m_vecTypes.push_back(pField->GetType());
				if(i != 0)
				{
					sSQL += L", ";
					sValues += L", ";
				}

				sSQL += m_pFieldSet->Get(i);
				sValues += "?";
				
			}
			
			sValues  += L" )";
			sSQL += L" )";

			sSQL += sValues;

			m_pStmt = m_pDB->prepare_query(sSQL);
			if(!m_pStmt.get())
			{
				 //TO DO error
				m_bValidCursor = false;
				return;
			 
			}

			
			if(m_pTable->GetDatasetType() == dtFeatureClass)
			{
				CSQLiteFeatureClass *pFC = dynamic_cast<CSQLiteFeatureClass*>(m_pTable.get());
				assert(pFC);
				const CommonLib::CString& sRTreeIndex = pFC->GetRTReeIndexName();
				CommonLib::CString sSQL = L"INSERT INTO  " + sRTreeIndex + L"(feature_id, minX, maxX, minY, maxY)" + 
					" VALUES (?, ?, ?, ?, ?)";
				m_pStmtSpatial = m_pDB->prepare_query(sSQL);
				if(!m_pStmtSpatial.get())
				{
					m_bValidCursor = false;
				}
							
				GisGeometry::IEnvelopePtr pEnvelope =  pFC->GetExtent();
				m_comp_params = pEnvelope->GetCompressParams();
				m_ShapeType = CommonLib::CGeoShape::GetGeneralType(pFC->GetGeometryType());
				
			}
			
		}