CMake support for TerraGear, and PLIB/OSG/OpenGL removal.
This commit is contained in:
parent
81244fb0fe
commit
83e6225460
44 changed files with 1087 additions and 314 deletions
97
CMakeLists.txt
Normal file
97
CMakeLists.txt
Normal file
|
@ -0,0 +1,97 @@
|
||||||
|
cmake_minimum_required (VERSION 2.6.4)
|
||||||
|
|
||||||
|
include (CheckFunctionExists)
|
||||||
|
include (CheckCSourceCompiles)
|
||||||
|
include (CheckCXXSourceCompiles)
|
||||||
|
include (CheckIncludeFile)
|
||||||
|
include (CPack)
|
||||||
|
|
||||||
|
project(TerraGear)
|
||||||
|
|
||||||
|
set(CMAKE_DEBUG_POSTFIX "d" CACHE STRING "add a postfix, usually d on windows")
|
||||||
|
set(CMAKE_RELEASE_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
|
||||||
|
set(CMAKE_RELWITHDEBINFO_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
|
||||||
|
set(CMAKE_MINSIZEREL_POSTFIX "" CACHE STRING "add a postfix, usually empty on windows")
|
||||||
|
|
||||||
|
# We have some custom .cmake scripts not in the official distribution.
|
||||||
|
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules;${CMAKE_MODULE_PATH}")
|
||||||
|
|
||||||
|
# Change the default build type to something fast
|
||||||
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
|
set(CMAKE_BUILD_TYPE Release CACHE STRING
|
||||||
|
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
|
||||||
|
FORCE)
|
||||||
|
endif(NOT CMAKE_BUILD_TYPE)
|
||||||
|
|
||||||
|
# check required dependencies
|
||||||
|
find_package(Boost REQUIRED)
|
||||||
|
find_package(ZLIB REQUIRED)
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
find_package(SimGear 2.5.0 REQUIRED)
|
||||||
|
find_package(TIFF) # needed for SRTM
|
||||||
|
find_package(NewMat11)
|
||||||
|
|
||||||
|
check_include_file(unistd.h HAVE_UNISTD_H)
|
||||||
|
check_include_file(sys/time.h HAVE_SYS_TIME_H)
|
||||||
|
check_include_file(windows.h HAVE_WINDOWS_H)
|
||||||
|
|
||||||
|
set(PKGDATADIR ${PREFIX}/share)
|
||||||
|
|
||||||
|
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
set(WARNING_FLAGS -Wall)
|
||||||
|
endif(CMAKE_COMPILER_IS_GNUCXX)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
|
||||||
|
if(MSVC)
|
||||||
|
# turn off various warnings
|
||||||
|
# foreach(warning 4244 4251 4267 4275 4290 4786 4305 4996)
|
||||||
|
# SET(WARNING_FLAGS "${WARNING_FLAGS} /wd${warning}")
|
||||||
|
# endforeach(warning)
|
||||||
|
|
||||||
|
set(MSVC_FLAGS "-DNOMINMAX -D_USE_MATH_DEFINES -D_CRT_SECURE_NO_WARNINGS -D_SCL_SECURE_NO_WARNINGS -D__CRT_NONSTDC_NO_WARNINGS")
|
||||||
|
if (${MSVC_VERSION} EQUAL 1600)
|
||||||
|
set( MSVC_LD_FLAGS "/FORCE:MULTIPLE" )
|
||||||
|
endif (${MSVC_VERSION} EQUAL 1600)
|
||||||
|
endif(MSVC)
|
||||||
|
|
||||||
|
set(NOMINMAX 1)
|
||||||
|
endif(WIN32)
|
||||||
|
|
||||||
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS} -D_REENTRANT")
|
||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${WARNING_FLAGS} ${MSVC_FLAGS} -D_REENTRANT")
|
||||||
|
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${MSVC_LD_FLAGS}")
|
||||||
|
|
||||||
|
include_directories(
|
||||||
|
${Boost_INCLUDE_DIRS}
|
||||||
|
${ZLIB_INCLUDE_DIR}
|
||||||
|
${SIMGEAR_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
|
||||||
|
include_directories(${PROJECT_SOURCE_DIR}/src)
|
||||||
|
include_directories(${PROJECT_BINARY_DIR}/src/Include)
|
||||||
|
|
||||||
|
add_definitions(-DHAVE_CONFIG_H)
|
||||||
|
|
||||||
|
#check_function_exists(mkfifo HAVE_MKFIFO)
|
||||||
|
|
||||||
|
# configure a header file to pass some of the CMake settings
|
||||||
|
# to the source code
|
||||||
|
configure_file (
|
||||||
|
"${PROJECT_SOURCE_DIR}/src/Include/config_cmake.h.in"
|
||||||
|
"${PROJECT_BINARY_DIR}/src/Include/config.h"
|
||||||
|
)
|
||||||
|
|
||||||
|
add_subdirectory(src)
|
||||||
|
#add_subdirectory(gismodules)
|
||||||
|
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
### uninstall target
|
||||||
|
#-----------------------------------------------------------------------------
|
||||||
|
CONFIGURE_FILE(
|
||||||
|
"${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules/cmake_uninstall.cmake.in"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||||
|
IMMEDIATE @ONLY)
|
||||||
|
ADD_CUSTOM_TARGET(uninstall
|
||||||
|
"${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
||||||
|
|
25
CMakeModules/FindNewMat11.cmake
Normal file
25
CMakeModules/FindNewMat11.cmake
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
|
||||||
|
FIND_PATH(NEWMAT_INCLUDE_DIR newmat/newmat.h
|
||||||
|
HINTS $ENV{NEWMAT_DIR}
|
||||||
|
PATH_SUFFIXES include
|
||||||
|
PATHS
|
||||||
|
/usr/local
|
||||||
|
/usr
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
FIND_LIBRARY(NEWMAT_LIBRARY
|
||||||
|
NAMES newmat
|
||||||
|
HINTS
|
||||||
|
$ENV{NEWMAT_DIR}
|
||||||
|
PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64
|
||||||
|
PATHS
|
||||||
|
/usr/local
|
||||||
|
/usr
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(newmat DEFAULT_MSG
|
||||||
|
NEWMAT_LIBRARY NEWMAT_INCLUDE_DIR)
|
219
CMakeModules/FindSimGear.cmake
Normal file
219
CMakeModules/FindSimGear.cmake
Normal file
|
@ -0,0 +1,219 @@
|
||||||
|
# Locate SimGear
|
||||||
|
# This module defines
|
||||||
|
# SIMGEAR_LIBRARIES
|
||||||
|
# SIMGEAR_FOUND, if false, do not try to link to SimGear
|
||||||
|
# SIMGEAR_INCLUDE_DIR, where to find the headers
|
||||||
|
#
|
||||||
|
# $SIMGEAR_DIR is an environment variable that would
|
||||||
|
# correspond to the ./configure --prefix=$SIMGEAR_DIR
|
||||||
|
# used in building SimGear.
|
||||||
|
#
|
||||||
|
# Created by James Turner. This was influenced by the FindOpenAL.cmake module.
|
||||||
|
|
||||||
|
#=============================================================================
|
||||||
|
# Copyright 2005-2009 Kitware, Inc.
|
||||||
|
#
|
||||||
|
# Distributed under the OSI-approved BSD License (the "License");
|
||||||
|
# see accompanying file Copyright.txt for details.
|
||||||
|
#
|
||||||
|
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||||
|
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
# See the License for more information.
|
||||||
|
#=============================================================================
|
||||||
|
# (To distributed this file outside of CMake, substitute the full
|
||||||
|
# License text for the above reference.)
|
||||||
|
|
||||||
|
# Per my request, CMake should search for frameworks first in
|
||||||
|
# the following order:
|
||||||
|
# ~/Library/Frameworks/SimGear.framework/Headers
|
||||||
|
# /Library/Frameworks/SimGear.framework/Headers
|
||||||
|
# /System/Library/Frameworks/SimGear.framework/Headers
|
||||||
|
#
|
||||||
|
# On OS X, this will prefer the Framework version (if found) over others.
|
||||||
|
# People will have to manually change the cache values of
|
||||||
|
# SimGear_LIBRARIES to override this selection or set the CMake environment
|
||||||
|
# CMAKE_INCLUDE_PATH to modify the search paths.
|
||||||
|
|
||||||
|
include(SelectLibraryConfigurations)
|
||||||
|
|
||||||
|
FIND_PATH(SIMGEAR_INCLUDE_DIR simgear/math/SGMath.hxx
|
||||||
|
HINTS $ENV{SIMGEAR_DIR}
|
||||||
|
PATH_SUFFIXES include
|
||||||
|
PATHS
|
||||||
|
~/Library/Frameworks
|
||||||
|
/Library/Frameworks
|
||||||
|
/usr/local
|
||||||
|
/usr
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
|
||||||
|
message(STATUS ${SIMGEAR_INCLUDE_DIR})
|
||||||
|
|
||||||
|
# check for dynamic framework/library
|
||||||
|
FIND_LIBRARY(SIMGEAR_LIBRARIES
|
||||||
|
NAMES simgear SimGear
|
||||||
|
HINTS
|
||||||
|
$ENV{SIMGEAR_DIR}
|
||||||
|
PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64
|
||||||
|
PATHS
|
||||||
|
~/Library/Frameworks
|
||||||
|
/Library/Frameworks
|
||||||
|
/usr/local
|
||||||
|
/usr
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
|
||||||
|
# dependent packages
|
||||||
|
find_package(ZLIB REQUIRED)
|
||||||
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
|
macro(find_sg_component comp libs)
|
||||||
|
set(compLib "sg${comp}")
|
||||||
|
string(TOUPPER "SIMGEAR_${comp}" compLibBase)
|
||||||
|
set( compLibName ${compLibBase}_LIBRARY )
|
||||||
|
|
||||||
|
FIND_LIBRARY(${compLibName}_DEBUG
|
||||||
|
NAMES ${compLib}${CMAKE_DEBUG_POSTFIX}
|
||||||
|
HINTS $ENV{SIMGEAR_DIR}
|
||||||
|
PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64
|
||||||
|
PATHS
|
||||||
|
/usr/local
|
||||||
|
/usr
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
FIND_LIBRARY(${compLibName}_RELEASE
|
||||||
|
NAMES ${compLib}${CMAKE_RELEASE_POSTFIX}
|
||||||
|
HINTS $ENV{SIMGEAR_DIR}
|
||||||
|
PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64
|
||||||
|
PATHS
|
||||||
|
/usr/local
|
||||||
|
/usr
|
||||||
|
/opt
|
||||||
|
)
|
||||||
|
select_library_configurations( ${compLibBase} )
|
||||||
|
|
||||||
|
set(componentLibRelease ${${compLibName}_RELEASE})
|
||||||
|
#message(STATUS "Simgear ${compLibName}_RELEASE ${componentLibRelease}")
|
||||||
|
set(componentLibDebug ${${compLibName}_DEBUG})
|
||||||
|
#message(STATUS "Simgear ${compLibName}_DEBUG ${componentLibDebug}")
|
||||||
|
if (NOT ${compLibName}_DEBUG)
|
||||||
|
if (NOT ${compLibName}_RELEASE)
|
||||||
|
#message(STATUS "found ${componentLib}")
|
||||||
|
list(APPEND ${libs} ${componentLibRelease})
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
list(APPEND ${libs} optimized ${componentLibRelease} debug ${componentLibDebug})
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
|
||||||
|
if(${SIMGEAR_LIBRARIES} STREQUAL "SIMGEAR_LIBRARIES-NOTFOUND")
|
||||||
|
set(SIMGEAR_LIBRARIES "") # clear value
|
||||||
|
set(SIMGEAR_CORE_LIBRARIES "") # clear value
|
||||||
|
|
||||||
|
# note the order here affects the order Simgear libraries are
|
||||||
|
# linked in, and hence ability to link when using a traditional
|
||||||
|
# linker such as GNU ld on Linux
|
||||||
|
set(comps
|
||||||
|
tsync
|
||||||
|
environment
|
||||||
|
nasal
|
||||||
|
bucket
|
||||||
|
bvh
|
||||||
|
util
|
||||||
|
route
|
||||||
|
timing
|
||||||
|
io
|
||||||
|
serial
|
||||||
|
sound
|
||||||
|
structure
|
||||||
|
props
|
||||||
|
xml
|
||||||
|
misc
|
||||||
|
threads
|
||||||
|
debug
|
||||||
|
magvar
|
||||||
|
math)
|
||||||
|
|
||||||
|
set(scene_comps
|
||||||
|
ephem
|
||||||
|
sky
|
||||||
|
material
|
||||||
|
tgdb
|
||||||
|
model
|
||||||
|
screen)
|
||||||
|
|
||||||
|
foreach(component ${comps})
|
||||||
|
find_sg_component(${component} SIMGEAR_CORE_LIBRARIES)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
foreach(component ${scene_comps})
|
||||||
|
find_sg_component(${component} SIMGEAR_LIBRARIES)
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# again link order matters - scene libraires depend on core ones
|
||||||
|
list(APPEND SIMGEAR_LIBRARIES ${SIMGEAR_CORE_LIBRARIES})
|
||||||
|
|
||||||
|
set(SIMGEAR_CORE_LIBRARY_DEPENDENCIES
|
||||||
|
${CMAKE_THREAD_LIBS_INIT}
|
||||||
|
${ZLIB_LIBRARY})
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
list(APPEND SIMGEAR_CORE_LIBRARY_DEPENDENCIES ws2_32.lib)
|
||||||
|
endif(WIN32)
|
||||||
|
|
||||||
|
if(NOT MSVC)
|
||||||
|
# basic timing routines on non windows systems, may be also cygwin?!
|
||||||
|
check_function_exists(clock_gettime clock_gettime_in_libc)
|
||||||
|
if(NOT clock_gettime_in_libc)
|
||||||
|
check_library_exists(rt clock_gettime "" have_rt)
|
||||||
|
if(have_rt)
|
||||||
|
list(APPEND SIMGEAR_CORE_LIBRARY_DEPENDENCIES rt)
|
||||||
|
endif(have_rt)
|
||||||
|
endif(NOT clock_gettime_in_libc)
|
||||||
|
endif(NOT MSVC)
|
||||||
|
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# now we've found SimGear, check its version
|
||||||
|
|
||||||
|
include(CheckCXXSourceRuns)
|
||||||
|
|
||||||
|
message(STATUS "looking for version: ${SimGear_FIND_VERSION}")
|
||||||
|
|
||||||
|
SET(CMAKE_REQUIRED_INCLUDES ${SIMGEAR_INCLUDE_DIR})
|
||||||
|
|
||||||
|
check_cxx_source_runs(
|
||||||
|
"#include <cstdio>
|
||||||
|
#include \"simgear/version.h\"
|
||||||
|
|
||||||
|
#define xstr(s) str(s)
|
||||||
|
#define str(s) #s
|
||||||
|
|
||||||
|
#define MIN_MAJOR ${SimGear_FIND_VERSION_MAJOR}
|
||||||
|
#define MIN_MINOR ${SimGear_FIND_VERSION_MINOR}
|
||||||
|
#define MIN_MICRO ${SimGear_FIND_VERSION_PATCH}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int major, minor, micro;
|
||||||
|
|
||||||
|
/* printf(%d.%d.%d or greater, , MIN_MAJOR, MIN_MINOR, MIN_MICRO); */
|
||||||
|
printf(\"found %s ... \", xstr(SIMGEAR_VERSION));
|
||||||
|
|
||||||
|
sscanf( xstr(SIMGEAR_VERSION), \"%d.%d.%d\", &major, &minor, µ );
|
||||||
|
|
||||||
|
if ( (major < MIN_MAJOR) ||
|
||||||
|
(major == MIN_MAJOR && minor < MIN_MINOR) ||
|
||||||
|
(major == MIN_MAJOR && minor == MIN_MINOR && micro < MIN_MICRO) ) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
"
|
||||||
|
SIMGEAR_VERSION_OK)
|
||||||
|
|
||||||
|
include(FindPackageHandleStandardArgs)
|
||||||
|
FIND_PACKAGE_HANDLE_STANDARD_ARGS(SimGear DEFAULT_MSG
|
||||||
|
SIMGEAR_LIBRARIES SIMGEAR_INCLUDE_DIR SIMGEAR_VERSION_OK)
|
||||||
|
|
22
CMakeModules/cmake_uninstall.cmake.in
Normal file
22
CMakeModules/cmake_uninstall.cmake.in
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
IF(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
|
||||||
|
MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"")
|
||||||
|
ENDIF()
|
||||||
|
|
||||||
|
FILE(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
|
||||||
|
STRING(REGEX REPLACE "\n" ";" files "${files}")
|
||||||
|
|
||||||
|
FOREACH(file ${files})
|
||||||
|
MESSAGE(STATUS "Uninstalling \"${file}\"")
|
||||||
|
IF(EXISTS "${file}")
|
||||||
|
EXEC_PROGRAM(
|
||||||
|
"@CMAKE_COMMAND@" ARGS "-E remove \"${file}\""
|
||||||
|
OUTPUT_VARIABLE rm_out
|
||||||
|
RETURN_VALUE rm_retval
|
||||||
|
)
|
||||||
|
IF(NOT "${rm_retval}" STREQUAL 0)
|
||||||
|
MESSAGE(FATAL_ERROR "Problem when removing \"${file}\"")
|
||||||
|
ENDIF()
|
||||||
|
ELSE()
|
||||||
|
MESSAGE(STATUS "File \"${file}\" does not exist.")
|
||||||
|
ENDIF()
|
||||||
|
ENDFOREACH()
|
6
src/Airports/CMakeLists.txt
Normal file
6
src/Airports/CMakeLists.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
include_directories(${PROJECT_SOURCE_DIR}/src/Lib)
|
||||||
|
include_directories(${PROJECT_SOURCE_DIR}/src/BuildTiles)
|
||||||
|
|
||||||
|
if (NEWMAT_FOUND)
|
||||||
|
add_subdirectory(GenAirports)
|
||||||
|
endif (NEWMAT_FOUND)
|
31
src/Airports/GenAirports/CMakeLists.txt
Normal file
31
src/Airports/GenAirports/CMakeLists.txt
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_executable(genapts
|
||||||
|
apt_surface.hxx apt_surface.cxx
|
||||||
|
build.cxx build.hxx
|
||||||
|
convex_hull.cxx convex_hull.hxx
|
||||||
|
elevations.cxx elevations.hxx
|
||||||
|
global.hxx
|
||||||
|
lights.hxx lights.cxx
|
||||||
|
main.cxx
|
||||||
|
point2d.cxx point2d.hxx
|
||||||
|
poly_extra.cxx poly_extra.hxx
|
||||||
|
runway.cxx runway.hxx
|
||||||
|
rwy_common.cxx rwy_common.hxx
|
||||||
|
rwy_nonprec.cxx rwy_nonprec.hxx
|
||||||
|
rwy_prec.cxx rwy_prec.hxx
|
||||||
|
rwy_simple.cxx rwy_simple.hxx
|
||||||
|
rwy_visual.cxx rwy_visual.hxx
|
||||||
|
taxiway.cxx taxiway.hxx
|
||||||
|
texparams.hxx
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(genapts
|
||||||
|
Polygon Geometry
|
||||||
|
Array Optimize Output poly2tri
|
||||||
|
TriangleJRS
|
||||||
|
${SIMGEAR_CORE_LIBRARIES}
|
||||||
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||||
|
genpolyclip
|
||||||
|
${NEWMAT_LIBRARY})
|
||||||
|
|
|
@ -843,7 +843,6 @@ void build_airport( string airport_id, float alt_m,
|
||||||
|
|
||||||
rwy_polys[i].set_tris( tri );
|
rwy_polys[i].set_tris( tri );
|
||||||
rwy_polys[i].set_texcoords( tc );
|
rwy_polys[i].set_texcoords( tc );
|
||||||
rwy_polys[i].set_tri_mode( GL_TRIANGLES );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "Tesselating base");
|
SG_LOG(SG_GENERAL, SG_DEBUG, "Tesselating base");
|
||||||
|
|
11
src/BuildTiles/CMakeLists.txt
Normal file
11
src/BuildTiles/CMakeLists.txt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
|
||||||
|
|
||||||
|
include_directories(${PROJECT_SOURCE_DIR}/src/Lib)
|
||||||
|
include_directories(${PROJECT_SOURCE_DIR}/src/BuildTiles)
|
||||||
|
|
||||||
|
add_subdirectory(Osgb36)
|
||||||
|
add_subdirectory(Triangulate)
|
||||||
|
add_subdirectory(Clipper)
|
||||||
|
add_subdirectory(GenOutput)
|
||||||
|
add_subdirectory(Match)
|
||||||
|
add_subdirectory(Main)
|
13
src/BuildTiles/Clipper/CMakeLists.txt
Normal file
13
src/BuildTiles/Clipper/CMakeLists.txt
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_library(Clipper STATIC
|
||||||
|
clipper.cxx clipper.hxx priorities.cxx priorities.hxx
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(testclipper testclipper.cxx)
|
||||||
|
|
||||||
|
target_link_libraries(testclipper
|
||||||
|
Clipper Osgb36 Triangulate Polygon Geometry
|
||||||
|
${SIMGEAR_CORE_LIBRARIES}
|
||||||
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||||
|
genpolyclip)
|
5
src/BuildTiles/GenOutput/CMakeLists.txt
Normal file
5
src/BuildTiles/GenOutput/CMakeLists.txt
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_library(GenOutput STATIC
|
||||||
|
genobj.cxx genobj.hxx
|
||||||
|
)
|
28
src/BuildTiles/Main/CMakeLists.txt
Normal file
28
src/BuildTiles/Main/CMakeLists.txt
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_executable(fgfs-construct
|
||||||
|
construct.cxx construct.hxx
|
||||||
|
usgs.cxx main.cxx)
|
||||||
|
|
||||||
|
set_target_properties(fgfs-construct PROPERTIES
|
||||||
|
COMPILE_DEFINITIONS
|
||||||
|
"DEFAULT_USGS_MAPFILE=\"${PKGDATADIR}/usgsmap.txt\";DEFAULT_PRIORITIES_FILE=\"${PKGDATADIR}/default_priorities.txt\"" )
|
||||||
|
|
||||||
|
target_link_libraries(fgfs-construct
|
||||||
|
Clipper Osgb36 Triangulate GenOutput
|
||||||
|
Match
|
||||||
|
Polygon Geometry
|
||||||
|
Array Optimize Output landcover poly2tri
|
||||||
|
TriangleJRS
|
||||||
|
${SIMGEAR_CORE_LIBRARIES}
|
||||||
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||||
|
genpolyclip)
|
||||||
|
|
||||||
|
|
||||||
|
add_executable(fgfs-master
|
||||||
|
master.cxx)
|
||||||
|
|
||||||
|
target_link_libraries(fgfs-master
|
||||||
|
${SIMGEAR_CORE_LIBRARIES}
|
||||||
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||||
|
)
|
|
@ -39,11 +39,14 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#include <plib/sg.h>
|
|
||||||
|
|
||||||
#include <simgear/constants.h>
|
#include <simgear/constants.h>
|
||||||
#include <simgear/bucket/newbucket.hxx>
|
#include <simgear/bucket/newbucket.hxx>
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
|
#include <simgear/misc/sg_dir.hxx>
|
||||||
|
#include <simgear/misc/sg_path.hxx>
|
||||||
|
#include <simgear/math/SGMath.hxx>
|
||||||
|
|
||||||
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
#include <Geometry/poly_support.hxx>
|
#include <Geometry/poly_support.hxx>
|
||||||
#include <Array/array.hxx>
|
#include <Array/array.hxx>
|
||||||
|
@ -82,50 +85,35 @@ double nudge=0.0;
|
||||||
|
|
||||||
|
|
||||||
// Scan a directory and load polygon files.
|
// Scan a directory and load polygon files.
|
||||||
static int actual_load_polys( const string& dir,
|
static int actual_load_polys( const SGPath& dir,
|
||||||
TGConstruct& c,
|
TGConstruct& c,
|
||||||
TGClipper& clipper ) {
|
TGClipper& clipper ) {
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
string base = c.get_bucket().gen_base_path();
|
// string base = c.get_bucket().gen_base_path();
|
||||||
string tile_str = c.get_bucket().gen_index_str();
|
//string tile_str = c.get_bucket().gen_index_str();
|
||||||
string ext;
|
|
||||||
string file, f_index, full_path;
|
|
||||||
int pos;
|
|
||||||
|
|
||||||
ulDir *d;
|
simgear::Dir d(dir);
|
||||||
struct ulDirEnt *de;
|
if (!d.exists()) {
|
||||||
|
cout << "directory not found:" << dir.str() << "\n";
|
||||||
if ( (d = ulOpenDir( dir.c_str() )) == NULL ) {
|
return 0;
|
||||||
cout << "cannot open directory " << dir << "\n";
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// load all matching polygon files
|
BOOST_FOREACH(const SGPath& p, d.children(simgear::Dir::TYPE_FILE)) {
|
||||||
while ( (de = ulReadDir(d)) != NULL ) {
|
string lext = p.complete_lower_extension();
|
||||||
file = de->d_name;
|
if ((lext == "arr") || (lext == "arr.gz") ||
|
||||||
pos = file.find(".");
|
(lext == "fit") || (lext == "fit.gz") || (lext == "ind"))
|
||||||
f_index = file.substr(0, pos);
|
{
|
||||||
|
// skipped!
|
||||||
if ( tile_str == f_index ) {
|
} else if (lext == "osgb36") {
|
||||||
ext = file.substr(pos + 1);
|
cout << "Loading osgb36 poly definition file\n";
|
||||||
cout << file << " " << f_index << " '" << ext << "'" << endl;
|
clipper.load_osgb36_polys( p.str() );
|
||||||
full_path = dir + "/" + file;
|
++counter;
|
||||||
if ( (ext == "arr") || (ext == "arr.gz") ||
|
} else {
|
||||||
(ext == "fit") || (ext == "fit.gz") || (ext == "ind") ) {
|
cout << "ext = '" << lext << "'" << endl;
|
||||||
// skip
|
clipper.load_polys( p.str() );
|
||||||
} else if (ext == "osgb36") {
|
++counter;
|
||||||
cout << "Loading osgb36 poly definition file\n";
|
|
||||||
clipper.load_osgb36_polys( full_path );
|
|
||||||
++counter;
|
|
||||||
} else {
|
|
||||||
cout << "ext = '" << ext << "'" << endl;
|
|
||||||
clipper.load_polys( full_path );
|
|
||||||
++counter;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
} // of directory file children
|
||||||
|
|
||||||
ulCloseDir(d);
|
|
||||||
|
|
||||||
return counter;
|
return counter;
|
||||||
}
|
}
|
||||||
|
@ -745,7 +733,7 @@ static double tri_ele_area( const TGConstruct& c, const TGTriEle tri ) {
|
||||||
|
|
||||||
// caclulate the normal for the specified triangle face
|
// caclulate the normal for the specified triangle face
|
||||||
static Point3D calc_normal( TGConstruct& c, int i ) {
|
static Point3D calc_normal( TGConstruct& c, int i ) {
|
||||||
sgVec3 v1, v2, normal;
|
SGVec3d v1, v2, normal;
|
||||||
|
|
||||||
point_list wgs84_nodes = c.get_wgs84_nodes();
|
point_list wgs84_nodes = c.get_wgs84_nodes();
|
||||||
triele_list tri_elements = c.get_tri_elements();
|
triele_list tri_elements = c.get_tri_elements();
|
||||||
|
@ -786,19 +774,16 @@ static Point3D calc_normal( TGConstruct& c, int i ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( degenerate ) {
|
if ( degenerate ) {
|
||||||
sgSetVec3( normal, p1.x(), p1.y(), p1.z() );
|
normal = normalize(SGVec3d(p1.x(), p1.y(), p1.z()));
|
||||||
sgNormalizeVec3( normal );
|
cout << "Degenerate tri!" << endl;
|
||||||
cout << "Degenerate tri!" << endl;
|
|
||||||
} else {
|
} else {
|
||||||
v1[0] = p2.x() - p1.x();
|
v1[0] = p2.x() - p1.x();
|
||||||
v1[1] = p2.y() - p1.y();
|
v1[1] = p2.y() - p1.y();
|
||||||
v1[2] = p2.z() - p1.z();
|
v1[2] = p2.z() - p1.z();
|
||||||
v2[0] = p3.x() - p1.x();
|
v2[0] = p3.x() - p1.x();
|
||||||
v2[1] = p3.y() - p1.y();
|
v2[1] = p3.y() - p1.y();
|
||||||
v2[2] = p3.z() - p1.z();
|
v2[2] = p3.z() - p1.z();
|
||||||
|
normal = normalize(cross(v1, v2));
|
||||||
sgVectorProductVec3( normal, v1, v2 );
|
|
||||||
sgNormalizeVec3( normal );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Point3D( normal[0], normal[1], normal[2] );
|
return Point3D( normal[0], normal[1], normal[2] );
|
||||||
|
|
5
src/BuildTiles/Match/CMakeLists.txt
Normal file
5
src/BuildTiles/Match/CMakeLists.txt
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_library(Match STATIC
|
||||||
|
match.cxx match.hxx
|
||||||
|
)
|
8
src/BuildTiles/Osgb36/CMakeLists.txt
Normal file
8
src/BuildTiles/Osgb36/CMakeLists.txt
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_library(Osgb36 STATIC
|
||||||
|
osgb36.cxx osgb36.hxx osgbtc.cxx osgbtc.hxx uk.cxx uk.hxx
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(testosgb36 testosgb36.cxx)
|
||||||
|
target_link_libraries(testosgb36 Osgb36)
|
6
src/BuildTiles/Triangulate/CMakeLists.txt
Normal file
6
src/BuildTiles/Triangulate/CMakeLists.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_library(Triangulate STATIC
|
||||||
|
triangle.cxx triangle.hxx
|
||||||
|
trieles.cxx trieles.hxx
|
||||||
|
)
|
6
src/CMakeLists.txt
Normal file
6
src/CMakeLists.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_subdirectory(Prep)
|
||||||
|
add_subdirectory(Lib)
|
||||||
|
add_subdirectory(Airports)
|
||||||
|
add_subdirectory(BuildTiles)
|
4
src/Include/config_cmake.h.in
Normal file
4
src/Include/config_cmake.h.in
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#cmakedefine HAVE_SYS_TIME_H
|
||||||
|
#cmakedefine HAVE_WINDOWS_H
|
||||||
|
|
||||||
|
|
12
src/Lib/Array/CMakeLists.txt
Normal file
12
src/Lib/Array/CMakeLists.txt
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_library(Array STATIC
|
||||||
|
array.cxx array.hxx
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(test_array testarray.cxx)
|
||||||
|
|
||||||
|
target_link_libraries(test_array
|
||||||
|
Array
|
||||||
|
${SIMGEAR_CORE_LIBRARIES}
|
||||||
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES})
|
20
src/Lib/CMakeLists.txt
Normal file
20
src/Lib/CMakeLists.txt
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
|
||||||
|
include_directories(${PROJECT_SOURCE_DIR}/src/Lib)
|
||||||
|
|
||||||
|
# seems unfortunate that lib depends on other dirs
|
||||||
|
include_directories(${PROJECT_SOURCE_DIR}/src/BuildTiles)
|
||||||
|
|
||||||
|
add_subdirectory(Array)
|
||||||
|
add_subdirectory(Dem)
|
||||||
|
add_subdirectory(Geometry)
|
||||||
|
add_subdirectory(HGT)
|
||||||
|
add_subdirectory(Optimize)
|
||||||
|
add_subdirectory(Output)
|
||||||
|
add_subdirectory(Polygon)
|
||||||
|
add_subdirectory(TriangleJRS)
|
||||||
|
add_subdirectory(e00)
|
||||||
|
add_subdirectory(landcover)
|
||||||
|
add_subdirectory(poly2tri)
|
||||||
|
add_subdirectory(shapelib)
|
||||||
|
add_subdirectory(vpf)
|
||||||
|
|
5
src/Lib/DEM/CMakeLists.txt
Normal file
5
src/Lib/DEM/CMakeLists.txt
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_library(DEM STATIC
|
||||||
|
dem.cxx dem.hxx
|
||||||
|
)
|
19
src/Lib/Geometry/CMakeLists.txt
Normal file
19
src/Lib/Geometry/CMakeLists.txt
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_library(Geometry STATIC
|
||||||
|
contour_tree.cxx
|
||||||
|
line.cxx
|
||||||
|
poly_support.cxx
|
||||||
|
rectangle.cxx
|
||||||
|
trinodes.cxx
|
||||||
|
trisegs.cxx
|
||||||
|
util.cxx
|
||||||
|
contour_tree.hxx
|
||||||
|
line.hxx
|
||||||
|
point3d.hxx
|
||||||
|
poly_support.hxx
|
||||||
|
rectangle.hxx
|
||||||
|
trinodes.hxx
|
||||||
|
trisegs.hxx
|
||||||
|
util.hxx
|
||||||
|
)
|
13
src/Lib/HGT/CMakeLists.txt
Normal file
13
src/Lib/HGT/CMakeLists.txt
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_library(HGT STATIC
|
||||||
|
hgt.cxx hgt.hxx
|
||||||
|
srtmbase.cxx srtmbase.hxx
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(test_hgt testhgt.cxx)
|
||||||
|
|
||||||
|
target_link_libraries(test_hgt
|
||||||
|
HGT
|
||||||
|
${SIMGEAR_CORE_LIBRARIES}
|
||||||
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES})
|
|
@ -42,8 +42,9 @@
|
||||||
|
|
||||||
#include <simgear/constants.h>
|
#include <simgear/constants.h>
|
||||||
#include <simgear/io/lowlevel.hxx>
|
#include <simgear/io/lowlevel.hxx>
|
||||||
|
#include <simgear/misc/sg_dir.hxx>
|
||||||
|
|
||||||
#include <plib/ul.h>
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
#include "hgt.hxx"
|
#include "hgt.hxx"
|
||||||
|
|
||||||
|
@ -81,7 +82,7 @@ TGHgt::open ( const SGPath &f ) {
|
||||||
|
|
||||||
// open input file (or read from stdin)
|
// open input file (or read from stdin)
|
||||||
if ( file_name.str() == "-" ) {
|
if ( file_name.str() == "-" ) {
|
||||||
cout << "Loading HGT data file: stdin" << endl;
|
cout << "Loading HGT data file: stdin" << endl;
|
||||||
if ( (fd = gzdopen(0, "r")) == NULL ) { // 0 == STDIN_FILENO
|
if ( (fd = gzdopen(0, "r")) == NULL ) { // 0 == STDIN_FILENO
|
||||||
cout << "ERROR: opening stdin" << endl;
|
cout << "ERROR: opening stdin" << endl;
|
||||||
return false;
|
return false;
|
||||||
|
@ -90,31 +91,24 @@ TGHgt::open ( const SGPath &f ) {
|
||||||
if ( file_name.extension() == "zip" ) {
|
if ( file_name.extension() == "zip" ) {
|
||||||
// extract the .zip file to /tmp and point the file name
|
// extract the .zip file to /tmp and point the file name
|
||||||
// to the extracted file
|
// to the extracted file
|
||||||
SGPath tmp_dir = string( tempnam( 0, "hgt" ) );
|
SGPath tmp_dir_path = string( tempnam( 0, "hgt" ) );
|
||||||
tmp_dir.append( "dummy" );
|
simgear::Dir tmp_dir(tmp_dir_path);
|
||||||
tmp_dir.create_dir( 0700 );
|
|
||||||
cout << "Extracting " << file_name.str() << " to " << tmp_dir.dir() << endl;
|
SGPath dummy = tmp_dir.file( "dummy" );
|
||||||
string command = "unzip -d \"" + tmp_dir.dir() + "\" " + file_name.base();
|
dummy.create_dir( 0700 );
|
||||||
system( command.c_str() );
|
cout << "Extracting " << file_name.str() << " to " << tmp_dir_path.str() << endl;
|
||||||
|
string command = "unzip -d \"" + tmp_dir_path.str() + "\" " + file_name.base();
|
||||||
file_name = tmp_dir.dir();
|
system( command.c_str() );
|
||||||
ulDir *dir = ulOpenDir( tmp_dir.dir().c_str() );
|
|
||||||
if ( dir ) {
|
|
||||||
ulDirEnt *de;
|
|
||||||
while ( ( de = ulReadDir( dir ) ) != 0 ) {
|
|
||||||
if ( !strcmp(de->d_name,".") || !strcmp(de->d_name,"..") || de->d_isdir ) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
SGPath file( de->d_name );
|
|
||||||
string ext = file.extension();
|
|
||||||
if ( ext == "HGT" || ext == "hgt" ) {
|
|
||||||
file_name.append( de->d_name );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ulCloseDir( dir );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
simgear::PathList files = tmp_dir.children(simgear::Dir::TYPE_FILE | simgear::Dir::NO_DOT_OR_DOTDOT);
|
||||||
|
BOOST_FOREACH(const SGPath& file, files) {
|
||||||
|
string ext = file.extension();
|
||||||
|
if ( ext == "HGT" || ext == "hgt" ) {
|
||||||
|
file_name = file;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
remove_tmp_file = true;
|
remove_tmp_file = true;
|
||||||
remove_file_name = file_name.str();
|
remove_file_name = file_name.str();
|
||||||
|
|
||||||
|
@ -203,19 +197,12 @@ TGHgt::~TGHgt() {
|
||||||
delete [] data;
|
delete [] data;
|
||||||
delete [] output_data;
|
delete [] output_data;
|
||||||
if ( remove_tmp_file ) {
|
if ( remove_tmp_file ) {
|
||||||
ulDir *dir = ulOpenDir( remove_file_name.dir().c_str() );
|
simgear::Dir dir(remove_file_name.dir());
|
||||||
if ( dir ) {
|
simgear::PathList files = dir.children(simgear::Dir::TYPE_FILE | simgear::Dir::NO_DOT_OR_DOTDOT);
|
||||||
ulDirEnt *de;
|
BOOST_FOREACH(const SGPath& file, files) {
|
||||||
while ( ( de = ulReadDir( dir ) ) != 0 ) {
|
unlink( file.c_str() );
|
||||||
if ( !strcmp(de->d_name,".") || !strcmp(de->d_name,"..") || de->d_isdir ) {
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
SGPath file( remove_file_name.dir() );
|
|
||||||
file.append( de->d_name );
|
|
||||||
unlink( file.c_str() );
|
|
||||||
}
|
|
||||||
ulCloseDir( dir );
|
|
||||||
}
|
|
||||||
rmdir( remove_file_name.dir().c_str() );
|
rmdir( remove_file_name.dir().c_str() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
9
src/Lib/Optimize/CMakeLists.txt
Normal file
9
src/Lib/Optimize/CMakeLists.txt
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_library(Optimize STATIC
|
||||||
|
genfans.cxx
|
||||||
|
genfans.hxx
|
||||||
|
genstrips.cxx
|
||||||
|
genstrips.hxx
|
||||||
|
)
|
||||||
|
|
5
src/Lib/Output/CMakeLists.txt
Normal file
5
src/Lib/Output/CMakeLists.txt
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_library(Output STATIC
|
||||||
|
output.cxx output.hxx
|
||||||
|
)
|
16
src/Lib/Polygon/CMakeLists.txt
Normal file
16
src/Lib/Polygon/CMakeLists.txt
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_library(Polygon STATIC
|
||||||
|
chop-bin.cxx
|
||||||
|
index.cxx
|
||||||
|
polygon.cxx
|
||||||
|
simple_clip.cxx
|
||||||
|
superpoly.cxx
|
||||||
|
chop.hxx
|
||||||
|
index.hxx
|
||||||
|
names.hxx
|
||||||
|
point2d.hxx
|
||||||
|
polygon.hxx
|
||||||
|
simple_clip.hxx
|
||||||
|
superpoly.hxx
|
||||||
|
)
|
|
@ -43,5 +43,4 @@ void TGSuperPoly::erase() {
|
||||||
normals.erase();
|
normals.erase();
|
||||||
texcoords.erase();
|
texcoords.erase();
|
||||||
tris.erase();
|
tris.erase();
|
||||||
tri_mode = (GLenum)0;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,11 +36,6 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
#ifdef _MSC_VER
|
|
||||||
# include <windows.h>
|
|
||||||
#endif
|
|
||||||
#include <GL/gl.h>
|
|
||||||
|
|
||||||
#include "polygon.hxx"
|
#include "polygon.hxx"
|
||||||
|
|
||||||
class TGSuperPoly {
|
class TGSuperPoly {
|
||||||
|
@ -52,7 +47,6 @@ private:
|
||||||
TGPolygon normals; // corresponding normals
|
TGPolygon normals; // corresponding normals
|
||||||
TGPolygon texcoords; // corresponding texture coordinates
|
TGPolygon texcoords; // corresponding texture coordinates
|
||||||
TGPolygon tris; // triangulation
|
TGPolygon tris; // triangulation
|
||||||
GLenum tri_mode; // GL_TRIANGLE, GL_FAN, GL_TRISTRIP, etc.
|
|
||||||
std::string flag; // For various potential record keeping needs
|
std::string flag; // For various potential record keeping needs
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -76,9 +70,6 @@ public:
|
||||||
inline TGPolygon get_tris() const { return tris; }
|
inline TGPolygon get_tris() const { return tris; }
|
||||||
inline void set_tris( const TGPolygon &p ) { tris = p; }
|
inline void set_tris( const TGPolygon &p ) { tris = p; }
|
||||||
|
|
||||||
inline GLenum get_tri_mode() const { return tri_mode; }
|
|
||||||
inline void set_tri_mode( const GLenum &m ) { tri_mode = m; }
|
|
||||||
|
|
||||||
inline std::string get_flag() const { return flag; }
|
inline std::string get_flag() const { return flag; }
|
||||||
inline void set_flag( const std::string f ) { flag = f; }
|
inline void set_flag( const std::string f ) { flag = f; }
|
||||||
|
|
||||||
|
|
16
src/Lib/TriangleJRS/CMakeLists.txt
Normal file
16
src/Lib/TriangleJRS/CMakeLists.txt
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_library(TriangleJRS STATIC
|
||||||
|
tri_support.c
|
||||||
|
tri_support.h
|
||||||
|
triangle.c
|
||||||
|
triangle.h
|
||||||
|
)
|
||||||
|
|
||||||
|
set_target_properties(TriangleJRS PROPERTIES
|
||||||
|
COMPILE_DEFINITIONS TRILIBRARY )
|
||||||
|
|
||||||
|
add_executable(test_triangle test_triangle.c)
|
||||||
|
|
||||||
|
target_link_libraries(test_triangle
|
||||||
|
TriangleJRS)
|
12
src/Lib/e00/CMakeLists.txt
Normal file
12
src/Lib/e00/CMakeLists.txt
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_library(e00 STATIC
|
||||||
|
e00.hxx e00.cxx
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(teste00 teste00.cxx)
|
||||||
|
|
||||||
|
target_link_libraries(teste00
|
||||||
|
e00
|
||||||
|
${SIMGEAR_CORE_LIBRARIES}
|
||||||
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES})
|
10
src/Lib/landcover/CMakeLists.txt
Normal file
10
src/Lib/landcover/CMakeLists.txt
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_library(landcover STATIC
|
||||||
|
landcover.cxx landcover.hxx
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(test_landcover test-landcover.cxx)
|
||||||
|
|
||||||
|
target_link_libraries(test_landcover
|
||||||
|
landcover)
|
11
src/Lib/poly2tri/CMakeLists.txt
Normal file
11
src/Lib/poly2tri/CMakeLists.txt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_library(poly2tri STATIC
|
||||||
|
construct.c
|
||||||
|
interface.h
|
||||||
|
misc.c
|
||||||
|
monotone.c
|
||||||
|
tri.c
|
||||||
|
triangulate.h
|
||||||
|
)
|
||||||
|
|
22
src/Lib/shapelib/CMakeLists.txt
Normal file
22
src/Lib/shapelib/CMakeLists.txt
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_library(shape STATIC
|
||||||
|
dbfopen.c shpopen.c shapefil.h
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach( c
|
||||||
|
shpcreate
|
||||||
|
shpadd
|
||||||
|
shpdump
|
||||||
|
shputils
|
||||||
|
shptest
|
||||||
|
dbfdump
|
||||||
|
dbfadd
|
||||||
|
dbfcreate
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(${c} ${c}.c)
|
||||||
|
target_link_libraries(${c} shape)
|
||||||
|
endforeach( c )
|
||||||
|
|
||||||
|
|
44
src/Lib/vpf/CMakeLists.txt
Normal file
44
src/Lib/vpf/CMakeLists.txt
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_library(vpf STATIC
|
||||||
|
component.cxx
|
||||||
|
component.hxx
|
||||||
|
contour.cxx
|
||||||
|
contour.hxx
|
||||||
|
coverage.cxx
|
||||||
|
coverage.hxx
|
||||||
|
database.cxx
|
||||||
|
database.hxx
|
||||||
|
feature.cxx
|
||||||
|
feature.hxx
|
||||||
|
label.cxx
|
||||||
|
label.hxx
|
||||||
|
library.cxx
|
||||||
|
library.hxx
|
||||||
|
line.cxx
|
||||||
|
line.hxx
|
||||||
|
polygon.cxx
|
||||||
|
polygon.hxx
|
||||||
|
property.cxx
|
||||||
|
property.hxx
|
||||||
|
table.cxx
|
||||||
|
table.hxx
|
||||||
|
tablemgr.cxx
|
||||||
|
tablemgr.hxx
|
||||||
|
tile.cxx
|
||||||
|
tile.hxx
|
||||||
|
value.cxx
|
||||||
|
value.hxx
|
||||||
|
vpf.hxx
|
||||||
|
vpfbase.cxx
|
||||||
|
vpfbase.hxx
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(vpf-dump vpf-dump.cxx)
|
||||||
|
target_link_libraries(vpf-dump vpf)
|
||||||
|
|
||||||
|
add_executable(vpf-summary vpf-summary.cxx)
|
||||||
|
target_link_libraries(vpf-summary vpf)
|
||||||
|
|
||||||
|
add_executable(vpf-topology vpf-topology.cxx)
|
||||||
|
target_link_libraries(vpf-topology vpf)
|
18
src/Prep/CMakeLists.txt
Normal file
18
src/Prep/CMakeLists.txt
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
|
||||||
|
|
||||||
|
include_directories(${PROJECT_SOURCE_DIR}/src/Lib)
|
||||||
|
|
||||||
|
# seems unfortunate that lib depends on other dirs
|
||||||
|
#include_directories(${PROJECT_SOURCE_DIR}/src/BuildTiles)
|
||||||
|
|
||||||
|
add_subdirectory(GSHHS)
|
||||||
|
add_subdirectory(DemChop)
|
||||||
|
add_subdirectory(E00Lines)
|
||||||
|
add_subdirectory(ShapeFile)
|
||||||
|
add_subdirectory(TGVPF)
|
||||||
|
add_subdirectory(Terra)
|
||||||
|
add_subdirectory(TerraFit)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
37
src/Prep/DemChop/CMakeLists.txt
Normal file
37
src/Prep/DemChop/CMakeLists.txt
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
|
||||||
|
add_executable(demchop demchop.cxx point2d.hxx)
|
||||||
|
|
||||||
|
target_link_libraries(demchop
|
||||||
|
DEM
|
||||||
|
${SIMGEAR_CORE_LIBRARIES}
|
||||||
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES})
|
||||||
|
|
||||||
|
add_executable(hgtchop hgtchop.cxx point2d.hxx)
|
||||||
|
|
||||||
|
target_link_libraries(hgtchop
|
||||||
|
HGT
|
||||||
|
${SIMGEAR_CORE_LIBRARIES}
|
||||||
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES})
|
||||||
|
|
||||||
|
if(TIFF_FOUND)
|
||||||
|
add_executable(srtmchop srtmchop.cxx point2d.hxx)
|
||||||
|
target_link_libraries(srtmchop
|
||||||
|
HGT
|
||||||
|
${TIFF_LIBRARIES}
|
||||||
|
${SIMGEAR_CORE_LIBRARIES}
|
||||||
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES})
|
||||||
|
|
||||||
|
endif(TIFF_FOUND)
|
||||||
|
|
||||||
|
add_executable(fillvoids fillvoids.cxx)
|
||||||
|
target_link_libraries(fillvoids
|
||||||
|
Array
|
||||||
|
${SIMGEAR_CORE_LIBRARIES}
|
||||||
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES})
|
||||||
|
|
||||||
|
add_executable(testassem testassem.cxx)
|
||||||
|
target_link_libraries(testassem
|
||||||
|
Array
|
||||||
|
${SIMGEAR_CORE_LIBRARIES}
|
||||||
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES})
|
||||||
|
|
|
@ -40,13 +40,14 @@
|
||||||
#include <simgear/bucket/newbucket.hxx>
|
#include <simgear/bucket/newbucket.hxx>
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
|
#include <simgear/misc/sg_dir.hxx>
|
||||||
|
|
||||||
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
#include <tiffio.h>
|
#include <tiffio.h>
|
||||||
|
|
||||||
#include <Polygon/point2d.hxx>
|
#include <Polygon/point2d.hxx>
|
||||||
|
|
||||||
#include <plib/ul.h>
|
|
||||||
|
|
||||||
#include <zlib.h>
|
#include <zlib.h>
|
||||||
|
|
||||||
#include <Lib/HGT/srtmbase.hxx>
|
#include <Lib/HGT/srtmbase.hxx>
|
||||||
|
@ -105,14 +106,14 @@ TGSrtmTiff::TGSrtmTiff( const SGPath &file, LoadKind lk ) {
|
||||||
remove_tmp_file = false;
|
remove_tmp_file = false;
|
||||||
output_data = 0;
|
output_data = 0;
|
||||||
if ( lkind == BottomLeft ) {
|
if ( lkind == BottomLeft ) {
|
||||||
data = new short int[MAX_HGT_SIZE][MAX_HGT_SIZE];
|
data = new short int[MAX_HGT_SIZE][MAX_HGT_SIZE];
|
||||||
output_data = new short int[MAX_HGT_SIZE][MAX_HGT_SIZE];
|
output_data = new short int[MAX_HGT_SIZE][MAX_HGT_SIZE];
|
||||||
} else if ( lkind == TopLeft ) {
|
} else if ( lkind == TopLeft ) {
|
||||||
data = new short int[MAX_HGT_SIZE][MAX_HGT_SIZE];
|
data = new short int[MAX_HGT_SIZE][MAX_HGT_SIZE];
|
||||||
} else if ( lkind == BottomRight ) {
|
} else if ( lkind == BottomRight ) {
|
||||||
data = new short int[1][MAX_HGT_SIZE];
|
data = new short int[1][MAX_HGT_SIZE];
|
||||||
} else /* if ( lkind == TopRight ) */ {
|
} else /* if ( lkind == TopRight ) */ {
|
||||||
data = new short int[1][MAX_HGT_SIZE];
|
data = new short int[1][MAX_HGT_SIZE];
|
||||||
}
|
}
|
||||||
TGSrtmTiff::open( file );
|
TGSrtmTiff::open( file );
|
||||||
}
|
}
|
||||||
|
@ -121,38 +122,31 @@ TGSrtmTiff::~TGSrtmTiff() {
|
||||||
delete[] data;
|
delete[] data;
|
||||||
delete[] output_data;
|
delete[] output_data;
|
||||||
if ( remove_tmp_file ) {
|
if ( remove_tmp_file ) {
|
||||||
ulDir *dir = ulOpenDir( remove_file_name.dir().c_str() );
|
simgear::Dir dir(remove_file_name.dir());
|
||||||
if ( dir ) {
|
simgear::PathList files = dir.children(simgear::Dir::TYPE_FILE | simgear::Dir::NO_DOT_OR_DOTDOT);
|
||||||
ulDirEnt *de;
|
BOOST_FOREACH(const SGPath& file, files) {
|
||||||
while ( ( de = ulReadDir( dir ) ) != 0 ) {
|
unlink( file.c_str() );
|
||||||
if ( !strcmp(de->d_name,".") || !strcmp(de->d_name,"..") || de->d_isdir ) {
|
}
|
||||||
continue;
|
|
||||||
}
|
|
||||||
SGPath file( remove_file_name.dir() );
|
|
||||||
file.append( de->d_name );
|
|
||||||
unlink( file.c_str() );
|
|
||||||
}
|
|
||||||
ulCloseDir( dir );
|
|
||||||
}
|
|
||||||
rmdir( remove_file_name.dir().c_str() );
|
rmdir( remove_file_name.dir().c_str() );
|
||||||
}
|
}
|
||||||
if ( tif )
|
if ( tif )
|
||||||
TIFFClose( tif );
|
TIFFClose( tif );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TGSrtmTiff::pos_from_name( string name, string &pfx, int &x, int &y ) {
|
bool TGSrtmTiff::pos_from_name( string name, string &pfx, int &x, int &y ) {
|
||||||
size_t p = name.find( '_' );
|
size_t p = name.find( '_' );
|
||||||
if ( p == string::npos )
|
if ( p == string::npos )
|
||||||
return false;
|
return false;
|
||||||
pfx = name.substr( 0, p );
|
pfx = name.substr( 0, p );
|
||||||
name.erase( 0, p + 1 );
|
name.erase( 0, p + 1 );
|
||||||
p = name.find( '.' );
|
p = name.find( '.' );
|
||||||
if ( p == string::npos )
|
if ( p == string::npos )
|
||||||
return false;
|
return false;
|
||||||
name.erase( p );
|
name.erase( p );
|
||||||
p = name.find( '_' );
|
p = name.find( '_' );
|
||||||
if ( p == string::npos )
|
if ( p == string::npos )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
x = atoi( name.substr( 0, p ).c_str() );
|
x = atoi( name.substr( 0, p ).c_str() );
|
||||||
y = atoi( name.substr( p+1 ).c_str() );
|
y = atoi( name.substr( p+1 ).c_str() );
|
||||||
|
@ -168,31 +162,23 @@ bool TGSrtmTiff::open( const SGPath &f ) {
|
||||||
if ( ext == "zip" ) {
|
if ( ext == "zip" ) {
|
||||||
// extract the .zip file to /tmp and point the file name
|
// extract the .zip file to /tmp and point the file name
|
||||||
// to the extracted file
|
// to the extracted file
|
||||||
SGPath tmp_dir = string( tempnam( 0, "hgt" ) );
|
SGPath tmp_dir_path = string( tempnam( 0, "srtm" ) );
|
||||||
tmp_dir.append( "dummy" );
|
simgear::Dir tmp_dir(tmp_dir_path);
|
||||||
tmp_dir.create_dir( 0700 );
|
SGPath dummy = tmp_dir.file( "dummy" );
|
||||||
cout << "Extracting " << file_name.str() << " to " << tmp_dir.dir() << endl;
|
dummy.create_dir( 0700 );
|
||||||
string command = "unzip -d \"" + tmp_dir.dir() + "\" " + file_name.str();
|
cout << "Extracting " << file_name.str() << " to " << tmp_dir_path.str() << endl;
|
||||||
|
string command = "unzip -d \"" + tmp_dir_path.str() + "\" " + file_name.base();
|
||||||
system( command.c_str() );
|
system( command.c_str() );
|
||||||
|
|
||||||
file_name = tmp_dir.dir();
|
simgear::PathList files = tmp_dir.children(simgear::Dir::TYPE_FILE | simgear::Dir::NO_DOT_OR_DOTDOT);
|
||||||
ulDir *dir = ulOpenDir( tmp_dir.dir().c_str() );
|
BOOST_FOREACH(const SGPath& file, files) {
|
||||||
if ( dir ) {
|
string ext = file.extension();
|
||||||
ulDirEnt *de;
|
if ( ext == "TIF" || ext == "tif" ) {
|
||||||
while ( ( de = ulReadDir( dir ) ) != 0 ) {
|
file_name = file;
|
||||||
if ( !strcmp(de->d_name,".") || !strcmp(de->d_name,"..") || de->d_isdir ) {
|
break;
|
||||||
continue;
|
}
|
||||||
}
|
}
|
||||||
SGPath file( de->d_name );
|
|
||||||
string ext = file.extension();
|
|
||||||
if ( ext == "TIF" || ext == "tif" ) {
|
|
||||||
file_name.append( de->d_name );
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ulCloseDir( dir );
|
|
||||||
}
|
|
||||||
|
|
||||||
remove_tmp_file = true;
|
remove_tmp_file = true;
|
||||||
remove_file_name = file_name.str();
|
remove_file_name = file_name.str();
|
||||||
|
|
||||||
|
@ -232,122 +218,122 @@ bool TGSrtmTiff::load() {
|
||||||
|
|
||||||
tdata_t buf = _TIFFmalloc( TIFFScanlineSize( tif ) );
|
tdata_t buf = _TIFFmalloc( TIFFScanlineSize( tif ) );
|
||||||
if ( lkind == BottomLeft ) {
|
if ( lkind == BottomLeft ) {
|
||||||
uint32 row = 0;
|
uint32 row = 0;
|
||||||
for ( ; row < h; row++ ) {
|
for ( ; row < h; row++ ) {
|
||||||
TIFFReadScanline( tif, buf, row );
|
TIFFReadScanline( tif, buf, row );
|
||||||
uint32 col = 0;
|
uint32 col = 0;
|
||||||
for ( ; col < w; col++ ) {
|
for ( ; col < w; col++ ) {
|
||||||
int16 v = ((int16*)buf)[col];
|
int16 v = ((int16*)buf)[col];
|
||||||
if ( v == -32768 )
|
if ( v == -32768 )
|
||||||
v = 0;
|
v = 0;
|
||||||
data[col][6000-1-row] = v;
|
data[col][6000-1-row] = v;
|
||||||
}
|
}
|
||||||
for ( ; col < 6000; col++ ) {
|
for ( ; col < 6000; col++ ) {
|
||||||
data[col][6000-1-row] = 0;
|
data[col][6000-1-row] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for ( ; row < 6000; row++ ) {
|
for ( ; row < 6000; row++ ) {
|
||||||
uint32 col = 0;
|
uint32 col = 0;
|
||||||
for ( ; col < 6000; col++ ) {
|
for ( ; col < 6000; col++ ) {
|
||||||
data[col][6000-1-row] = 0;
|
data[col][6000-1-row] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int x1 = int( originx / 18000.0 ) + 37,
|
int x1 = int( originx / 18000.0 ) + 37,
|
||||||
y1 = int( 12 - ( originy / 18000.0 ) ),
|
y1 = int( 12 - ( originy / 18000.0 ) ),
|
||||||
x2 = x1 + 1,
|
x2 = x1 + 1,
|
||||||
y2 = y1 - 1;
|
y2 = y1 - 1;
|
||||||
if ( x2 > 72 )
|
if ( x2 > 72 )
|
||||||
x2 -= 72;
|
x2 -= 72;
|
||||||
{
|
{
|
||||||
ostringstream name;
|
ostringstream name;
|
||||||
name << prefix << "_" << std::setfill( '0' ) << std::setw( 2 ) << x2 << "_" << std::setfill( '0' ) << std::setw( 2 ) << y1 << "." << ext;
|
name << prefix << "_" << std::setfill( '0' ) << std::setw( 2 ) << x2 << "_" << std::setfill( '0' ) << std::setw( 2 ) << y1 << "." << ext;
|
||||||
SGPath f = dir;
|
SGPath f = dir;
|
||||||
f.append( name.str() );
|
f.append( name.str() );
|
||||||
if ( f.exists() ) {
|
if ( f.exists() ) {
|
||||||
TGSrtmTiff s( f.str(), BottomRight );
|
TGSrtmTiff s( f.str(), BottomRight );
|
||||||
s.load();
|
s.load();
|
||||||
s.close();
|
s.close();
|
||||||
for ( int i = 0; i < 6000; ++i ) {
|
for ( int i = 0; i < 6000; ++i ) {
|
||||||
data[6000][i] = s.data[0][i];
|
data[6000][i] = s.data[0][i];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for ( int i = 0; i < 6000; ++i ) {
|
for ( int i = 0; i < 6000; ++i ) {
|
||||||
data[6000][i] = 0;
|
data[6000][i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( y2 != 0 ) {
|
if ( y2 != 0 ) {
|
||||||
ostringstream name;
|
ostringstream name;
|
||||||
name << prefix << "_" << std::setfill( '0' ) << std::setw( 2 ) << x1 << "_" << std::setfill( '0' ) << std::setw( 2 ) << y2 << "." << ext;
|
name << prefix << "_" << std::setfill( '0' ) << std::setw( 2 ) << x1 << "_" << std::setfill( '0' ) << std::setw( 2 ) << y2 << "." << ext;
|
||||||
SGPath f = dir;
|
SGPath f = dir;
|
||||||
f.append( name.str() );
|
f.append( name.str() );
|
||||||
if ( f.exists() ) {
|
if ( f.exists() ) {
|
||||||
TGSrtmTiff s( f.str(), TopLeft );
|
TGSrtmTiff s( f.str(), TopLeft );
|
||||||
s.load();
|
s.load();
|
||||||
s.close();
|
s.close();
|
||||||
for ( int i = 0; i < 6000; ++i ) {
|
for ( int i = 0; i < 6000; ++i ) {
|
||||||
data[i][6000] = s.data[i][0];
|
data[i][6000] = s.data[i][0];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for ( int i = 0; i < 6000; ++i ) {
|
for ( int i = 0; i < 6000; ++i ) {
|
||||||
data[i][6000] = 0;
|
data[i][6000] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for ( int i = 0; i < 6000; ++i ) {
|
for ( int i = 0; i < 6000; ++i ) {
|
||||||
data[i][6000] = data[i][6000-1];
|
data[i][6000] = data[i][6000-1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( y2 != 0 ) {
|
if ( y2 != 0 ) {
|
||||||
ostringstream name;
|
ostringstream name;
|
||||||
name << prefix << "_" << std::setfill( '0' ) << std::setw( 2 ) << x2 << "_" << std::setfill( '0' ) << std::setw( 2 ) << y2 << "." << ext;
|
name << prefix << "_" << std::setfill( '0' ) << std::setw( 2 ) << x2 << "_" << std::setfill( '0' ) << std::setw( 2 ) << y2 << "." << ext;
|
||||||
SGPath f = dir;
|
SGPath f = dir;
|
||||||
f.append( name.str() );
|
f.append( name.str() );
|
||||||
if ( f.exists() ) {
|
if ( f.exists() ) {
|
||||||
TGSrtmTiff s( f.str(), TopRight );
|
TGSrtmTiff s( f.str(), TopRight );
|
||||||
s.load();
|
s.load();
|
||||||
s.close();
|
s.close();
|
||||||
data[6000][6000] = s.data[0][0];
|
data[6000][6000] = s.data[0][0];
|
||||||
} else {
|
} else {
|
||||||
data[6000][6000] = 0;
|
data[6000][6000] = 0;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
data[6000][6000] = data[6000][6000-1];
|
data[6000][6000] = data[6000][6000-1];
|
||||||
}
|
}
|
||||||
} else if ( lkind == TopLeft ) {
|
} else if ( lkind == TopLeft ) {
|
||||||
TIFFReadScanline( tif, buf, 0 );
|
TIFFReadScanline( tif, buf, 0 );
|
||||||
uint32 col = 0;
|
uint32 col = 0;
|
||||||
for ( ; col < w; col++ ) {
|
for ( ; col < w; col++ ) {
|
||||||
int16 v = ((int16*)buf)[col];
|
int16 v = ((int16*)buf)[col];
|
||||||
if ( v == -32768 )
|
if ( v == -32768 )
|
||||||
v = 0;
|
v = 0;
|
||||||
data[col][0] = v;
|
data[col][0] = v;
|
||||||
}
|
}
|
||||||
for ( ; col < 6000; col++ ) {
|
for ( ; col < 6000; col++ ) {
|
||||||
data[col][0] = 0;
|
data[col][0] = 0;
|
||||||
}
|
}
|
||||||
} else if ( lkind == BottomRight ) {
|
} else if ( lkind == BottomRight ) {
|
||||||
uint32 row = 0;
|
uint32 row = 0;
|
||||||
for ( ; row < h; row++ ) {
|
for ( ; row < h; row++ ) {
|
||||||
TIFFReadScanline( tif, buf, row );
|
TIFFReadScanline( tif, buf, row );
|
||||||
int16 v = ((int16*)buf)[0];
|
int16 v = ((int16*)buf)[0];
|
||||||
if ( v == -32768 )
|
if ( v == -32768 )
|
||||||
v = 0;
|
v = 0;
|
||||||
data[0][6000-1-row] = v;
|
data[0][6000-1-row] = v;
|
||||||
}
|
}
|
||||||
for ( ; row < 6000; row++ ) {
|
for ( ; row < 6000; row++ ) {
|
||||||
data[0][6000-1-row] = 0;
|
data[0][6000-1-row] = 0;
|
||||||
}
|
}
|
||||||
} else /* if ( lkind == TopRight ) */ {
|
} else /* if ( lkind == TopRight ) */ {
|
||||||
if ( h == 6000 ) {
|
if ( h == 6000 ) {
|
||||||
TIFFReadScanline( tif, buf, h-1 );
|
TIFFReadScanline( tif, buf, h-1 );
|
||||||
int16 v = ((int16*)buf)[0];
|
int16 v = ((int16*)buf)[0];
|
||||||
if ( v == -32768 )
|
if ( v == -32768 )
|
||||||
v = 0;
|
v = 0;
|
||||||
data[0][0] = v;
|
data[0][0] = v;
|
||||||
} else {
|
} else {
|
||||||
data[0][0] = 0;
|
data[0][0] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_TIFFfree(buf);
|
_TIFFfree(buf);
|
||||||
|
|
||||||
|
@ -356,7 +342,7 @@ bool TGSrtmTiff::load() {
|
||||||
|
|
||||||
bool TGSrtmTiff::close() {
|
bool TGSrtmTiff::close() {
|
||||||
if ( tif )
|
if ( tif )
|
||||||
TIFFClose( tif );
|
TIFFClose( tif );
|
||||||
tif = 0;
|
tif = 0;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -365,10 +351,10 @@ int main(int argc, char **argv) {
|
||||||
sglog().setLogLevels( SG_ALL, SG_WARN );
|
sglog().setLogLevels( SG_ALL, SG_WARN );
|
||||||
|
|
||||||
if ( argc != 3 ) {
|
if ( argc != 3 ) {
|
||||||
cout << "Usage " << argv[0] << " <hgt_file> <work_dir>"
|
cout << "Usage " << argv[0] << " <hgt_file> <work_dir>"
|
||||||
<< endl;
|
<< endl;
|
||||||
cout << endl;
|
cout << endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
string hgt_name = argv[1];
|
string hgt_name = argv[1];
|
||||||
|
@ -388,32 +374,32 @@ int main(int argc, char **argv) {
|
||||||
SGBucket b_min( min.x, min.y );
|
SGBucket b_min( min.x, min.y );
|
||||||
|
|
||||||
max.x = (hgt.get_originx() + hgt.get_cols() * hgt.get_col_step()) / 3600.0
|
max.x = (hgt.get_originx() + hgt.get_cols() * hgt.get_col_step()) / 3600.0
|
||||||
- SG_HALF_BUCKET_SPAN;
|
- SG_HALF_BUCKET_SPAN;
|
||||||
max.y = (hgt.get_originy() + hgt.get_rows() * hgt.get_row_step()) / 3600.0
|
max.y = (hgt.get_originy() + hgt.get_rows() * hgt.get_row_step()) / 3600.0
|
||||||
- SG_HALF_BUCKET_SPAN;
|
- SG_HALF_BUCKET_SPAN;
|
||||||
SGBucket b_max( max.x, max.y );
|
SGBucket b_max( max.x, max.y );
|
||||||
|
|
||||||
if ( b_min == b_max ) {
|
if ( b_min == b_max ) {
|
||||||
hgt.write_area( work_dir, b_min );
|
hgt.write_area( work_dir, b_min );
|
||||||
} else {
|
} else {
|
||||||
SGBucket b_cur;
|
SGBucket b_cur;
|
||||||
int dx, dy, i, j;
|
int dx, dy, i, j;
|
||||||
|
|
||||||
sgBucketDiff(b_min, b_max, &dx, &dy);
|
sgBucketDiff(b_min, b_max, &dx, &dy);
|
||||||
cout << "HGT file spans tile boundaries (ok)" << endl;
|
cout << "HGT file spans tile boundaries (ok)" << endl;
|
||||||
cout << " dx = " << dx << " dy = " << dy << endl;
|
cout << " dx = " << dx << " dy = " << dy << endl;
|
||||||
|
|
||||||
if ( (dx > 50) || (dy > 50) ) {
|
if ( (dx > 50) || (dy > 50) ) {
|
||||||
cout << "somethings really wrong!!!!" << endl;
|
cout << "somethings really wrong!!!!" << endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
for ( j = 0; j <= dy; j++ ) {
|
for ( j = 0; j <= dy; j++ ) {
|
||||||
for ( i = 0; i <= dx; i++ ) {
|
for ( i = 0; i <= dx; i++ ) {
|
||||||
b_cur = sgBucketOffset(min.x, min.y, i, j);
|
b_cur = sgBucketOffset(min.x, min.y, i, j);
|
||||||
hgt.write_area( work_dir, b_cur );
|
hgt.write_area( work_dir, b_cur );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
11
src/Prep/E00Lines/CMakeLists.txt
Normal file
11
src/Prep/E00Lines/CMakeLists.txt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
|
||||||
|
add_executable(e00lines
|
||||||
|
main.cxx)
|
||||||
|
|
||||||
|
target_link_libraries(e00lines
|
||||||
|
e00
|
||||||
|
Polygon Geometry Output poly2tri TriangleJRS vpf
|
||||||
|
${SIMGEAR_CORE_LIBRARIES}
|
||||||
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||||
|
genpolyclip)
|
||||||
|
|
21
src/Prep/GSHHS/CMakeLists.txt
Normal file
21
src/Prep/GSHHS/CMakeLists.txt
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
|
||||||
|
add_executable(gshhs
|
||||||
|
main.cxx
|
||||||
|
gshhs.h
|
||||||
|
gshhs_split.cxx gshhs_split.hxx)
|
||||||
|
|
||||||
|
target_link_libraries(gshhs
|
||||||
|
Polygon Geometry Output poly2tri
|
||||||
|
${SIMGEAR_CORE_LIBRARIES}
|
||||||
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||||
|
genpolyclip)
|
||||||
|
|
||||||
|
add_executable(gshhs_debug
|
||||||
|
debug.cxx)
|
||||||
|
|
||||||
|
target_link_libraries(gshhs_debug
|
||||||
|
Polygon Geometry Output poly2tri
|
||||||
|
${SIMGEAR_CORE_LIBRARIES}
|
||||||
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||||
|
genpolyclip)
|
||||||
|
|
18
src/Prep/ShapeFile/CMakeLists.txt
Normal file
18
src/Prep/ShapeFile/CMakeLists.txt
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_executable(shape-decode shape-decode.cxx)
|
||||||
|
|
||||||
|
target_link_libraries(shape-decode
|
||||||
|
shape Polygon Geometry Output poly2tri TriangleJRS vpf
|
||||||
|
${SIMGEAR_CORE_LIBRARIES}
|
||||||
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||||
|
genpolyclip)
|
||||||
|
|
||||||
|
add_executable(noaa-decode noaa-decode.cxx)
|
||||||
|
|
||||||
|
target_link_libraries(noaa-decode
|
||||||
|
shape Polygon Geometry Output poly2tri TriangleJRS vpf
|
||||||
|
${SIMGEAR_CORE_LIBRARIES}
|
||||||
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||||
|
genpolyclip)
|
||||||
|
|
9
src/Prep/TGVPF/CMakeLists.txt
Normal file
9
src/Prep/TGVPF/CMakeLists.txt
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
|
||||||
|
add_executable(tgvpf tgvpf.cxx)
|
||||||
|
|
||||||
|
target_link_libraries(tgvpf
|
||||||
|
Polygon Geometry Output poly2tri TriangleJRS vpf
|
||||||
|
${SIMGEAR_CORE_LIBRARIES}
|
||||||
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES}
|
||||||
|
genpolyclip)
|
||||||
|
|
17
src/Prep/Terra/CMakeLists.txt
Normal file
17
src/Prep/Terra/CMakeLists.txt
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
|
||||||
|
|
||||||
|
add_library(Terra STATIC
|
||||||
|
Array.h Geom.h
|
||||||
|
GreedyInsert.cc GreedyInsert.h
|
||||||
|
Heap.cc Heap.h
|
||||||
|
Map.cc Map.h
|
||||||
|
Mask.cc Mask.h
|
||||||
|
Quadedge.cc Quadedge.h
|
||||||
|
Subdivision.cc Subdivision.h
|
||||||
|
Vec2.h Vec3.h
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(terra_bin
|
||||||
|
cmdline.cc getopt.c getopt.h greedy.cc output.cc terra.cc terra.h version.h)
|
||||||
|
|
||||||
|
target_link_libraries(terra_bin Terra)
|
8
src/Prep/TerraFit/CMakeLists.txt
Normal file
8
src/Prep/TerraFit/CMakeLists.txt
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
|
||||||
|
add_executable(terrafit terrafit.cc)
|
||||||
|
|
||||||
|
target_link_libraries(terrafit
|
||||||
|
Array Terra
|
||||||
|
${SIMGEAR_CORE_LIBRARIES}
|
||||||
|
${SIMGEAR_CORE_LIBRARY_DEPENDENCIES})
|
||||||
|
|
|
@ -42,9 +42,10 @@
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
#include <simgear/bucket/newbucket.hxx>
|
#include <simgear/bucket/newbucket.hxx>
|
||||||
#include <simgear/misc/sg_path.hxx>
|
#include <simgear/misc/sg_path.hxx>
|
||||||
|
#include <simgear/misc/sg_dir.hxx>
|
||||||
#include <simgear/structure/exception.hxx>
|
#include <simgear/structure/exception.hxx>
|
||||||
|
|
||||||
#include <plib/ul.h>
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
#include <Array/array.hxx>
|
#include <Array/array.hxx>
|
||||||
|
|
||||||
|
@ -209,35 +210,21 @@ void fit_file(const std::string& path) {
|
||||||
gzclose(fp);
|
gzclose(fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void walk_path(const std::string& path) {
|
void walk_path(const SGPath& path) {
|
||||||
struct stat statbuf;
|
if (!path.exists()) {
|
||||||
if (stat(path.c_str(),&statbuf)!=0) {
|
SG_LOG(SG_GENERAL, SG_ALERT ,"ERROR: Unable to stat '" << path.str() << "':" << strerror(errno));
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT ,"ERROR: Unable to stat '" << path << "':" << strerror(errno));
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
|
if ((path.lower_extension() == "arr") || (path.complete_lower_extension() == "arr.gz")) {
|
||||||
if (endswith(path,".arr.gz") || endswith(path,".arr")) {
|
fit_file(path.str());
|
||||||
fit_file(path);
|
} else if (path.isDir()) {
|
||||||
} else if (S_ISDIR(statbuf.st_mode)) {
|
simgear::Dir d(path);
|
||||||
ulDir* dir=ulOpenDir(path.c_str());
|
simgear::PathList subdirs = d.children(simgear::Dir::TYPE_DIR | simgear::Dir::NO_DOT_OR_DOTDOT);
|
||||||
if (!dir) {
|
BOOST_FOREACH(const SGPath& p, subdirs) {
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT ,"ERROR: Unable to open directory '" << path << "':" << strerror(errno));
|
walk_path(p);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
struct ulDirEnt* dirent;
|
|
||||||
|
|
||||||
while ((dirent=ulReadDir(dir))) {
|
|
||||||
if (!strcmp(dirent->d_name,".") || !strcmp(dirent->d_name,"..")) {
|
|
||||||
continue; // skip . and ..
|
|
||||||
}
|
|
||||||
SGPath subpath(path);
|
|
||||||
subpath.append(dirent->d_name);
|
|
||||||
walk_path(subpath.str());
|
|
||||||
}
|
|
||||||
|
|
||||||
ulCloseDir(dir);
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void usage(char* progname, const std::string& msg) {
|
void usage(char* progname, const std::string& msg) {
|
||||||
|
@ -311,7 +298,7 @@ int main(int argc, char** argv) {
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, "Max error = " << error_threshold);
|
SG_LOG(SG_GENERAL, SG_INFO, "Max error = " << error_threshold);
|
||||||
if (optind<argc) {
|
if (optind<argc) {
|
||||||
while (optind<argc) {
|
while (optind<argc) {
|
||||||
walk_path(argv[optind++]);
|
walk_path(SGPath(argv[optind++]));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
usage(argv[0],"Insufficient arguments");
|
usage(argv[0],"Insufficient arguments");
|
||||||
|
|
Loading…
Add table
Reference in a new issue