diff --git a/fastcarto/dump-fastdb/CMakeLists.txt b/fastcarto/dump-fastdb/CMakeLists.txt index 5b1e038..fe0c301 100644 --- a/fastcarto/dump-fastdb/CMakeLists.txt +++ b/fastcarto/dump-fastdb/CMakeLists.txt @@ -2,8 +2,13 @@ project(dump-fastdb) set(PROJECT_NAME dump-fastdb) set(PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -march=native -DNDEBUG") -set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -march=native -DNDEBUG") +if(MSVC) + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2 /arch:AVX2 /DNDEBUG") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /O2 /arch:AVX2 /DNDEBUG") +else() + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -march=native -DNDEBUG") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -march=native -DNDEBUG") +endif() include_directories(${CMAKE_CURRENT_SOURCE_DIR}) @@ -23,4 +28,3 @@ target_link_libraries(${PROJECT_NAME} fastdb) - diff --git a/fastcarto/fastdb/include/fastdb.h b/fastcarto/fastdb/include/fastdb.h index 6d7ca44..e162b2e 100644 --- a/fastcarto/fastdb/include/fastdb.h +++ b/fastcarto/fastdb/include/fastdb.h @@ -60,7 +60,7 @@ namespace wx u8* pdata; }; - class MemoryStream :public WriteStream + class fastdb_api MemoryStream :public WriteStream { public: class Impl; diff --git a/fastcarto/fastdb/src/FastVectorDb.cpp b/fastcarto/fastdb/src/FastVectorDb.cpp index 3ebb2e5..faf3efb 100644 --- a/fastcarto/fastdb/src/FastVectorDb.cpp +++ b/fastcarto/fastdb/src/FastVectorDb.cpp @@ -1,16 +1,17 @@ #include "FastVectorDb_p.h" #include "FastVectorDbLayer_p.h" #include -#include #ifdef _WIN32 #include + #include + #include #else #include + #include + #include #endif -#include - namespace wx { FastVectorDb::Impl::Impl(void *pdata, size_t size, fnFreeDbBuffer fnFreeBuffer, void *cookie) @@ -128,16 +129,36 @@ printf("\nFastVectorDB:A fast vector database for local cache\n\ Author: wenyongning@njnu.edu.cn\n"); printf("loading [%s] ...",filename); #endif - int fd = open(filename, O_RDONLY); // 打开文件获取描述符 +#ifdef _WIN32 + int fd = _open(filename, _O_RDONLY | _O_BINARY); if (fd == -1) - { + { + printf("Error opening file: %s\n", strerror(errno)); + return NULL; + } + + struct _stat fileStat; + if (_fstat(fd, &fileStat) == -1) + { + printf("Error getting file status: %s\n", strerror(errno)); + _close(fd); + return NULL; + } + size_t size = fileStat.st_size; + void* pdata = malloc(sizeof(u8)*size+64); + _read(fd, pdata, size); + _close(fd); +#else + int fd = open(filename, O_RDONLY); + if (fd == -1) + { printf("Error opening file: %s\n", strerror(errno)); return NULL; } struct stat fileStat; if (fstat(fd, &fileStat) == -1) - { // 通过描述符获取状态 + { printf("Error getting file status: %s\n", strerror(errno)); close(fd); return NULL; @@ -146,6 +167,7 @@ printf("loading [%s] ...",filename); void* pdata = malloc(sizeof(u8)*size+64); read(fd,pdata,size); close(fd); +#endif auto db = load(pdata,size,free_data_buffer,0); if(db) { diff --git a/fastcarto/lib/gaiageo/CMakeLists.txt b/fastcarto/lib/gaiageo/CMakeLists.txt index a47f1ca..3ee58c5 100644 --- a/fastcarto/lib/gaiageo/CMakeLists.txt +++ b/fastcarto/lib/gaiageo/CMakeLists.txt @@ -14,7 +14,9 @@ include_directories(${CUR_PROJ_DIR}/headers/spatialite) include_directories(${CUR_PROJ_DIR}/src) #设置生成库 add_library(${CUR_PROJ_NAME} STATIC ${all_files}) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") +if(NOT WIN32) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") +endif() #设置链接目录 link_directories(${BIN_DIR}) diff --git a/fastcarto/make-fastdb/CMakeLists.txt b/fastcarto/make-fastdb/CMakeLists.txt index 0698089..f0f3850 100644 --- a/fastcarto/make-fastdb/CMakeLists.txt +++ b/fastcarto/make-fastdb/CMakeLists.txt @@ -2,8 +2,13 @@ project(make-fastdb) set(PROJECT_NAME make-fastdb) set(PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -march=native -DNDEBUG") -set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -march=native -DNDEBUG") +if(MSVC) + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2 /arch:AVX2 /DNDEBUG") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /O2 /arch:AVX2 /DNDEBUG") +else() + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -march=native -DNDEBUG") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -march=native -DNDEBUG") +endif() find_package(GDAL REQUIRED)