Commit 8f83cfa4 authored by Jesse Mapel's avatar Jesse Mapel Committed by GitHub
Browse files

Made Ale::load and Ale::loads optional and renamed files (#344)

* Moved ale.h to Ale.h

* Moved interpolation out of Ale.h

* Normalized test file names

* Fixed double namespacing

* Made load and loads optional

* Renamed Ale.h to Load.h

* Updated doc strings

* Removed more usings from headers
parent 21eb9ecd
Loading
Loading
Loading
Loading
+36 −27
Original line number Diff line number Diff line
@@ -14,10 +14,13 @@ include(GNUInstallDirs)

set(CMAKE_CXX_STANDARD 11)

set(ALE_BUILD_LOAD ON CACHE BOOL "If the C++ Python load interface should be built.")

# Third Party Dependencies
find_package(Eigen3 3.3    REQUIRED NO_MODULE)
find_package(nlohmann_json REQUIRED)

if(ALE_BUILD_LOAD)
  # If there is an Anaconda environment activated, search that for Python first
  if(EXISTS $ENV{CONDA_PREFIX})
    message("Searching $ENV{CONDA_PREFIX} for Python libraries")
@@ -25,25 +28,34 @@ if(EXISTS $ENV{CONDA_PREFIX})
    set(Python_FIND_STRATEGY LOCATION)
  endif()
  find_package(Python REQUIRED COMPONENTS Development)
endif()

# Library setup
set(ALE_BUILD_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/include/")
set(ALE_INSTALL_INCLUDE_DIR "include/ale")
add_library(ale SHARED
            ${CMAKE_CURRENT_SOURCE_DIR}/src/ale.cpp
            ${CMAKE_CURRENT_SOURCE_DIR}/src/InterpUtils.cpp
set(ALE_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/InterpUtils.cpp
                  ${CMAKE_CURRENT_SOURCE_DIR}/src/Rotation.cpp
                  ${CMAKE_CURRENT_SOURCE_DIR}/src/Orientations.cpp
                  ${CMAKE_CURRENT_SOURCE_DIR}/src/States.cpp
                  ${CMAKE_CURRENT_SOURCE_DIR}/src/Isd.cpp
                  ${CMAKE_CURRENT_SOURCE_DIR}/src/Util.cpp)
set(ALE_HEADERS "${ALE_BUILD_INCLUDE_DIR}/ale.h"
                "${ALE_BUILD_INCLUDE_DIR}/InterpUtils.h"
                "${ALE_BUILD_INCLUDE_DIR}/Rotation.h"
                "${ALE_BUILD_INCLUDE_DIR}/Orientations.h"
                "${ALE_BUILD_INCLUDE_DIR}/States.h"
                "${ALE_BUILD_INCLUDE_DIR}/Isd.h"
                "${ALE_BUILD_INCLUDE_DIR}/Util.h")
set(ALE_HEADER_FILES ${ALE_BUILD_INCLUDE_DIR}/InterpUtils.h
                     ${ALE_BUILD_INCLUDE_DIR}/Rotation.h
                     ${ALE_BUILD_INCLUDE_DIR}/Orientations.h
                     ${ALE_BUILD_INCLUDE_DIR}/States.h
                     ${ALE_BUILD_INCLUDE_DIR}/Isd.h
                     ${ALE_BUILD_INCLUDE_DIR}/Util.h)
set(ALE_PRIVATE_LINKS Eigen3::Eigen)
set(ALE_PUBLIC_LINKS nlohmann_json::nlohmann_json)

if(ALE_BUILD_LOAD)
  list(APPEND ALE_SRC_FILES    ${CMAKE_CURRENT_SOURCE_DIR}/src/Load.cpp)
  list(APPEND ALE_HEADER_FILES ${ALE_BUILD_INCLUDE_DIR}/Load.h)
  list(APPEND ALE_PRIVATE_LINKS Python::Python)
endif()

add_library(ale SHARED ${ALE_SRC_FILES})

set_target_properties(ale PROPERTIES
                      VERSION   ${PROJECT_VERSION}
                      SOVERSION 0)
@@ -53,11 +65,8 @@ target_include_directories(ale
                           $<BUILD_INTERFACE:${ALE_BUILD_INCLUDE_DIR}>
                           $<INSTALL_INTERFACE:include>)

target_link_libraries(ale
                      PRIVATE
                      Eigen3::Eigen
                      Python::Python
                      nlohmann_json::nlohmann_json)
target_link_libraries(ale PRIVATE ${ALE_PRIVATE_LINKS}
                          PUBLIC ${ALE_PUBLIC_LINKS})

# Optional build tests
option (ALE_BUILD_TESTS "Build tests" ON)
@@ -89,7 +98,7 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}-config.cmake
              DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})

# Install the headers
install(FILES ${ALE_HEADERS} DESTINATION ${ALE_INSTALL_INCLUDE_DIR})
install(FILES ${ALE_HEADER_FILES} DESTINATION ${ALE_INSTALL_INCLUDE_DIR})

# Install the library
install(TARGETS ale
+1 −1
Original line number Diff line number Diff line
@@ -791,7 +791,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT                  = ./include/ale.h ./ale ./src/
INPUT                  = ./include/Load.h ./ale ./src/

# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding. Doxygen uses
+1 −1
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@

The :mod:`src` module

.. doxygenfile:: ale.h
.. doxygenfile:: Load.h
  :project: ale

.. versionadded:: 0.1.0
+5 −7
Original line number Diff line number Diff line
@@ -15,8 +15,6 @@

namespace ale {

  using json = nlohmann::json;

  class Isd {
    public:

@@ -61,7 +59,7 @@ namespace ale {
    double starting_ephemeris_time;
    double center_ephemeris_time;

    json naif_keywords;
    nlohmann::json naif_keywords;

    PositionInterpolation interpMethod;

include/Load.h

0 → 100644
+39 −0
Original line number Diff line number Diff line
#ifndef ALE_INCLUDE_ALE_H
#define ALE_INCLUDE_ALE_H

#include <nlohmann/json.hpp>

#include <string>

namespace ale {
  /**
   * Load all of the metadata for an image into an ISD string.
   * This method calls the Python driver structure in ALE to load all
   * of the metadata for an image into an ISD string. See the Python
   * loads method for how this is implemented on the Python side.
   *
   * @param filename The filename of the image to load metadata for
   * @param props A JSON formatted properties string to pass to the Python drivers.
   *              Users can specify certain properties that the drivers will use.
   *              Currently kernels and nadir properties are allowed. See the
   *              data_naif driver mix-in for details.
   * @param formatter A string specifying the format of the output ISD string.
   *                  Currently supported formatters are isis, usgscsm, and ale.
   *                  The isis and usgscsm formatters will be deprecated in the future.
   * @param verbose A flag to output what the load function is attempting to do.
   *                If set to true, information about the drivers load attempts
   *                to use will be output to standard out.
   *
   * @returns A string containing a JSON formatted ISD for the image.
   */
  std::string loads(std::string filename, std::string props="", std::string formatter="usgscsm", bool verbose=true);

  /**
   * Load all of the metadata fro an image into a JSON ISD.
   * This method is a convenience wrapper around the loads method that parses the
   * string output of loads into a JSON object.
   */
  nlohmann::json load(std::string filename, std::string props="", std::string formatter="usgscsm", bool verbose=true);
}

#endif // ALE_H
Loading