資源簡介
ArcGIS的prj文件是一個專門用來描述坐標系投影的文件,里面定義了坐標系的名稱、長短半軸、基準面、投影參數等一些其他重要的信息。proj4是C用語言編寫的專門用來處理各個坐標系之間的轉換的開源庫。可以實現經緯度坐標轉平面坐標或者兩個不同的橢球體之間的坐標系轉換,運算精度高,計算準確,在很多GIS項目和軟件中都有使用
代碼片段和文件信息
#include?
#include?
#include?“prj2proj4.h“
#include
#include?
#include?
#include???
using?namespace?std;
bool?is_prj(?wstring?file_name?)
{
int?pos?=?file_name.rfind(L‘.‘);
wstring?ext_name?=?file_name.substr(?pos?+?1?);
transform(ext_name.begin()?ext_name.end()?ext_name.begin()?::tolower);?
if?(?ext_name?==?L“prj“?)
{
return?true;
}
return?false;
}
int?get_all_path_list(?const?TCHAR*?rootDir??vector&srcFiles?)
{
WIN32_FIND_DATA?fd;
ZeroMemory(&fd?sizeof(WIN32_FIND_DATA));
HANDLE?hFile;
TCHAR?tmpPath[256];
TCHAR?subPath[256];
ZeroMemory(?tmpPath?256*sizeof(TCHAR)?);
ZeroMemory(?subPath?256*sizeof(TCHAR)?);
BOOL?bRet?=?TRUE;
static?int?nFileSize?=?0?;
//define?the?format?of?the?basepath
wcscpy(tmpPath?rootDir);
if(tmpPath[wcslen(tmpPath)?-1]?!=?L‘\\‘)
{
wcscat(tmpPath?L“\\“);
}
wcscat(tmpPath?L“*“);
hFile?=?FindFirstFile(tmpPath?&fd);
while?(hFile?!=?INVALID_HANDLE_VALUE?&&?bRet)
{
if?(fd.dwFileAttributes?==?FILE_ATTRIBUTE_DIRECTORY?&&?
wcscmp(fd.cFileName?L“.“)?&&?wcscmp(fd.cFileName?L“..“))
{
wcscpy(subPath?rootDir);
if(subPath[wcslen(subPath)?-1]?!=?L‘\\‘)
{
wcscat(subPath?L“\\“);
}
wcscat(subPath?fd.cFileName);
get_all_path_list(?subPath??srcFiles?);
}
else?if(!wcscmp(fd.cFileName?L“.“)?||?!wcscmp(fd.cFileName?L“..“))
{
}
else
{
if?(?is_prj(?fd.cFileName?)?)
{
nFileSize++;
wstring?strdir?=?rootDir;
strdir?+=?L“\\“;?
strdir?+=?fd.cFileName;
srcFiles.push_back(?strdir?);
}
}
bRet?=?FindNextFile(hFile?&fd);
}
FindClose(hFile);
return?nFileSize;
}
string?unicode_to_mbcs(std::wstring?wstr?)
{
int??len?=?0;
len?=?(int)wstr.length();
int??ansiLen?=?::WideCharToMultiByte(?CP_ACP?0?wstr.c_str()?-1?NULL?0?NULL?NULL);?
char*??pAnsi;?
pAnsi?=?new??char[ansiLen+1];?
memset(pAnsi0(ansiLen+1)*sizeof(char));?
::WideCharToMultiByte(?CP_ACP?0?wstr.c_str()?-1?(LPSTR)pAnsi?ansiLen?NULL?NULL);?
string?str?=?pAnsi;
delete[]?pAnsi;
return??str;
}
int?main(?int?argc?char*?argv[]?)
{
/*prj_file?prg_f;
prg_f.load_doc(?“E:\\接收文件\\程振冀\\Coordinate?Systems\\Projected?Coordinate?Systems\\Gauss?Kruger\\Xian?1980\\Xian?1980?3?Degree?GK?Zone?35.prj“?);
char*?str?=?prg_f.generate_proj4_str(?);*/
vector?prj_name_list;
get_all_path_list(?L“E:\\接收文件\\程振冀\\Coordinate?Systems“??prj_name_list?);
int?file_num?=?prj_name_list.size();
FILE*?pf?=?fopen(?“E:\\接收文件\\程振冀\\Coordinate?Systems\\prj.txt“??“w“?);
prj_file?prg_f;
for?(?int??i?=?0?;?i? {
string?prj_path?=?unicode_to_mbcs(?prj_name_list.at(i));
fwrite(?prj_path.c_str()??1???prj_path.size()??pf?);
fwrite(?“\n“??1??1??pf?);
char?epsg[8]={0};
prg_f.load_doc(?prj_path.c_str()?);
char*?str?=?prg_f.generate_proj4_str(?epsg?);
fwr
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2015-10-26?23:19??prj2proj4\
?????目錄???????????0??2015-10-26?22:50??prj2proj4\Debug\
?????文件???????10850??2015-08-12?16:30??prj2proj4\Debug\BuildLog.htm
?????文件??????305474??2015-08-12?16:30??prj2proj4\Debug\MainCpp.obj
?????文件??????????67??2015-08-12?16:30??prj2proj4\Debug\mt.dep
?????文件?????????663??2015-04-08?11:24??prj2proj4\Debug\prj2proj4.exe.em
?????文件?????????728??2015-04-08?11:24??prj2proj4\Debug\prj2proj4.exe.em
?????文件?????????621??2015-08-12?16:30??prj2proj4\Debug\prj2proj4.exe.intermediate.manifest
?????文件???????35066??2015-08-11?19:35??prj2proj4\Debug\prj2proj4.obj
?????文件???????27954??2015-04-08?11:24??prj2proj4\Debug\prj_def.obj
?????文件??????494592??2015-08-12?16:30??prj2proj4\Debug\vc90.idb
?????文件??????290816??2015-08-12?16:30??prj2proj4\Debug\vc90.pdb
?????文件????????3243??2015-08-11?19:46??prj2proj4\MainCpp.cpp
?????文件????????8454??2015-08-11?19:34??prj2proj4\prj2proj4.cpp
?????文件????????2296??2015-08-11?19:34??prj2proj4\prj2proj4.h
?????文件????????5124??2015-07-13?16:59??prj2proj4\prj2proj4.vcproj
?????文件????????2025??2017-01-10?23:36??prj2proj4\prj2proj4.vcproj.Lenovo-wb.wb-admin.user
?????文件????????2004??2015-10-26?20:10??prj2proj4\prj2proj4.vcproj.WB.tcxt-yangzy.user
?????文件????????4767??2015-04-07?20:08??prj2proj4\prj_def.cpp
?????文件????????1072??2015-04-07?14:32??prj2proj4\prj_def.h
- 上一篇:SVNService.exe
- 下一篇:ABAQUS_裂紋
評論
共有 條評論