Example #1
0
void FoxPro::load(SeekableReadStream *dbf, SeekableReadStream *cdx,
                  SeekableReadStream *fpt) {

	assert(dbf);

	// Read header
	uint32 recordSize, recordCount, firstRecordPos;
	loadHeader(*dbf, recordSize, recordCount, firstRecordPos);
	if (_hasIndex && !cdx)
		throw Exception("Index needed");
	if (_hasMemo && !fpt)
		throw Exception("Memo needed");

	// Read fields
	loadFields(*dbf, recordSize);
	if (_hasMemo && !fpt)
		throw Exception("Memo needed");

	// Read records
	dbf->seek(firstRecordPos);
	loadRecords(*dbf, recordSize, recordCount);

	// Read memos
	if (fpt)
		loadMemos(*fpt);

	// TODO: Read the compound index (CDX) file
}
//*************************************************************************************************
//! This returns the type name of all objects in all factories. This is the name used to 
//! construct the objects dynamically and this name must be unique.
//*************************************************************************************************
void ossimWktProjectionFactory::getTypeNameList(std::vector<ossimString>& typeList) const
{
   if (m_wktProjRecords.empty())
      loadRecords();

   std::map<std::string, ossim_uint32>::iterator db_iter = m_wktProjRecords.begin();
   while (db_iter != m_wktProjRecords.end())
   {
      typeList.push_back(ossimString(db_iter->first));
      db_iter++;
   }
   return;
}
//*************************************************************************************************
//! From keywordlist (as generated typically by ossimWkt class)
//*************************************************************************************************
ossimProjection* ossimWktProjectionFactory::createProjection(const ossimKeywordlist &keywordList,
                                                             const char *prefix) const
{
   // The WKT for the horizontal projection may be part of a compound coordinate system, as
   // indicated by the "COMPD_CS" prefix. Need to remove that prefix first.
   ossimString compd_cs ("COMPD_CS.");
   ossimKeywordlist temp_kwl (keywordList);
   temp_kwl.stripPrefixFromAll(compd_cs);

   ossimProjection* proj = 0;
   ossimString pcs_name = temp_kwl.find(prefix, "PROJCS.name");
   if (pcs_name.empty())
      return 0;

   if (m_wktProjRecords.empty())
      loadRecords();

   // Search the WKT DB for a mapping of projection name to EPSG code. This should take care of
   // majority of cases, like UTM:
   ossimString epsg_code;
   std::map<std::string, ossim_uint32>::const_iterator it = m_wktProjRecords.find(pcs_name.string());
   if (it != m_wktProjRecords.end())
   {
      // Found an entry by this name, fetch the EPSG code:
      epsg_code = ossimString::toString(it->second);
   }
   else
   {
      // The name specified in the WKT could not be found in our WKT->EPSG map.
      // Check for EPSG code in WKT itself:
      ossimString auth_name = temp_kwl.find(prefix, "PROJCS.AUTHORITY.name");
      if (auth_name == "EPSG")
         epsg_code = temp_kwl.find(prefix, "PROJCS.AUTHORITY.param0");
   }

   // Use EPSG if determined:
   if (!epsg_code.empty())
   {
      proj = ossimEpsgProjectionDatabase::instance()->findProjection(epsg_code.toUInt32());
      if (proj)
         return proj;
   }

   // Not EPSG, so check conventional proj spec in WKT:
   ossimString proj_name = temp_kwl.find(prefix, "PROJCS.PROJECTION.name");
   if (proj_name.empty())
      return 0;
   proj_name.downcase();
   proj_name.gsub(" ", "_", true);

   // Note that prefix is ignored. This KWL is assumed to come from ossimWkt that doesn't prefix:
   if (proj_name.contains("transverse_mercator"))
      proj = doTransverseMercator(temp_kwl);
   else if (proj_name.contains("mercator"))
      proj = doMercator(temp_kwl);
   else if (proj_name.contains("lambert"))
      proj = doLambertConformalConic(temp_kwl);
   else if (proj_name.contains("equirectangular"))
      proj = doEquiDistCylindrical(temp_kwl);
   else if (proj_name.contains("cylindrical_equal_area"))
      proj = doEquiAreaCylindrical(temp_kwl);

   return proj;
}