工作中遇到的一些小问题,总结的小知识记录:C++/Qt,夹杂点GIS。
解决方案一:
读取源文件Cache内容,新建一个可读可写的目的文件,拷贝Cache到其中;
解决方案二:
目的文件改变其权限:
QFile::setPermissions(Public_canshufile,QFileDevice::ReadOther|QFileDevice::WriteOther);
// Qt处理
QString strLongitude = QString::number(dLongitude, 'f', 15);
strLongitude.remove(QRegExp("0+$"));
strLongitude.remove(QRegExp("\\.$"));
// std处理
std::stringstream ss;
ss << std::setfill('0') << std::setprecision(14) << std::fixed << m_dDegree;
std::string str = ss.str();
属性名最多为10字符;
dbf属性表最多255个字段;
shp文件和dbf文件最大2GB;
每个shp只能是一种几何类型;
Type Bytes Minimum Value Maximum Value
(Signed/Unsigned) (Signed/Unsigned)
TINYINT 1 -128 127
0 255
SMALLINT 2 -32768 32767
0 65535
MEDIUMINT 3 -8388608 8388607
0 16777215
INT 4 -2147483648 2147483647
0 4294967295
BIGINT 8 -9223372036854775808 9223372036854775807
0 18446744073709551615
// 精确到100纳秒级别的时间戳
FILETIME fileTime;
long long now_long;
GetSystemTimeAsFileTime(&fileTime);
now_long = (long long(fileTime.dwHighDateTime) << 32) + fileTime.dwLowDateTime;
std::cout << "micro time from 1601.1.1:00:00:00 is: " << (now_long / 10) << std::endl;
// 获取当前时间
char date0[64] = {0};
time_t setTime;
time(&setTime);
tm* ptm = localtime(&setTime);
strftime(date0, 64, "%Y-%m-%d %H:%M:%S",ptm);
std::string TimeStampToDate( time_t nTimestamp )
{
if (nTimestamp < 0)
{
return "";
}
char date0[64] = {0};
time_t tt = nTimestamp;
struct tm *ttime;
ttime = localtime(&tt);
strftime(date0, 64, "%Y-%m-%d %H:%M:%S",ttime);
return date0;
}
time_t DateToTimeStamp( const std::string& strDate )
{
if (strDate.empty())
{
return -1;
}
struct tm tt;
sscanf(strDate.c_str(), "%d-%d-%d %d:%d:%d",
&tt.tm_year,
&tt.tm_mon,
&tt.tm_mday,
&tt.tm_hour,
&tt.tm_min,
&tt.tm_sec);
tt.tm_year -= 1900;
tt.tm_mon -= 1;
// std::cout << "tt.tm_year:" << tt.tm_year << std::endl;
// std::cout << "tt.tm_mon:" << tt.tm_mon << std::endl;
// std::cout << "tt.tm_mday:" << tt.tm_mday << std::endl;
// std::cout << "tt.tm_hour:" << tt.tm_hour << std::endl;
// std::cout << "tt.tm_min:" << tt.tm_min << std::endl;
// std::cout << "tt.tm_sec:" << tt.tm_sec << std::endl;
// std::cout << "tt.tm_isdst:" << tt.tm_isdst << std::endl;
// std::cout << "tt.tm_wday:" << tt.tm_wday << std::endl;
return mktime(&tt);
}
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
#include
#include
std::stringstream ss;
ss << "经度:" << std::setfill('0') << std::fixed << std::setprecision(6) << vPt.x << "°";
QString strDiver;
LPCSTR lpcwstrDriver = "D:/";
ULARGE_INTEGER liFreeBytesAvailable, liTotalBytes, liTotalF reeBytes;
if (GetDiskFreeSpaceEx(lpcwstrDriver, &liFreeBytesAvailable, &liTotalBytes, &liTotalFreeBytes))
{
//磁盘总空间
qDebug() << "liTotalBytes=" << liTotalBytes.QuadPart / 1024 / 1024 / 1024 << "G";
//磁盘剩余空间
qDebug() << "liTotalFreeBytes=" << liTotalFreeBytes.QuadPart / 1024 / 1024 / 1024 << "G";
}