Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions fastcarto/dump-fastdb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand All @@ -23,4 +28,3 @@ target_link_libraries(${PROJECT_NAME} fastdb)




2 changes: 1 addition & 1 deletion fastcarto/fastdb/include/fastdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace wx
u8* pdata;
};

class MemoryStream :public WriteStream
class fastdb_api MemoryStream :public WriteStream
{
public:
class Impl;
Expand Down
34 changes: 28 additions & 6 deletions fastcarto/fastdb/src/FastVectorDb.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#include "FastVectorDb_p.h"
#include "FastVectorDbLayer_p.h"
#include <stdlib.h>
#include <sys/stat.h>

#ifdef _WIN32
#include <io.h>
#include <sys/stat.h>
#include <fcntl.h>
#else
#include <unistd.h>
#include <sys/stat.h>
#include <fcntl.h>
#endif

#include <fcntl.h>

namespace wx
{
FastVectorDb::Impl::Impl(void *pdata, size_t size, fnFreeDbBuffer fnFreeBuffer, void *cookie)
Expand Down Expand Up @@ -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;
Expand All @@ -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)
{
Expand Down
4 changes: 3 additions & 1 deletion fastcarto/lib/gaiageo/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Expand Down
9 changes: 7 additions & 2 deletions fastcarto/make-fastdb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down