Skip to content

Commit

Permalink
initial work for query in other geo coord system
Browse files Browse the repository at this point in the history
  • Loading branch information
104H authored and mmeijerdfki committed Aug 24, 2024
1 parent 81cd1a4 commit 85d1592
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 1 deletion.
2 changes: 2 additions & 0 deletions seerep_msgs/core/query.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ struct Query
// polygon defined above
bool inMapFrame; // if false the query polygon is in geodetic coordinates,
// otherwise in map frame
std::string
coordinateSystem; // the geodetic coordinate system in which the polygon is defined
std::optional<Timeinterval> timeinterval; ///< only do temporal query if set
std::optional<std::unordered_map<std::string, std::vector<std::string>>>
label; ///< only do semantic query if set
Expand Down
1 change: 1 addition & 0 deletions seerep_msgs/fbs/query.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ table Query {
polygon:Polygon2D;
polygonSensorPosition:Polygon2D;
fullyEncapsulated:bool;
coordinateSystem:string;
inMapFrame:bool;
timeinterval:TimeInterval;
label:[LabelCategory];
Expand Down
1 change: 1 addition & 0 deletions seerep_msgs/protos/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ message Query
bool withoutdata = 10;
uint32 maxNumData = 11;
bool sortByTime = 12;
string coordinateSystem = 13;
}
5 changes: 4 additions & 1 deletion seerep_srv/seerep_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ find_package(catkin REQUIRED COMPONENTS tf2)
find_package(CGAL REQUIRED)
set(CGAL_DO_NOT_WARN_ABOUT_CMAKE_BUILD_TYPE TRUE)

# https://github.com/OSGeo/PROJ/issues/3682
pkg_check_modules(PROJ REQUIRED IMPORTED_TARGET)

configure_file(include/SeerepCoreConfig.h.in SeerepCoreConfig.h)

include_directories(
Expand Down Expand Up @@ -66,9 +69,9 @@ target_link_libraries(
${Boost_LOG_LIBRARY}
${Boost_LOG_SETUP_LIBRARY}
${catkin_LIBRARIES}
${CURL_LIBRARIES}
CGAL::CGAL
proj
${CURL_LIBRARIES}
jsoncpp
)

Expand Down
2 changes: 2 additions & 0 deletions seerep_srv/seerep_core/include/seerep_core/core_project.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef SEEREP_CORE_CORE_PROJECT_H_
#define SEEREP_CORE_CORE_PROJECT_H_

#include <proj.h>

#include <boost/uuid/uuid.hpp> // uuid class
#include <boost/uuid/uuid_generators.hpp> // generators
#include <boost/uuid/uuid_io.hpp> // streaming operators etc.
Expand Down
6 changes: 6 additions & 0 deletions seerep_srv/seerep_core/src/core_project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const std::string CoreProject::getVersion()
return m_version;
}

// <<<<<<< HEAD
seerep_core_msgs::Polygon2D
CoreProject::transformToMapFrame(const seerep_core_msgs::Polygon2D polygon)
{
Expand Down Expand Up @@ -113,10 +114,15 @@ CoreProject::getDataset(seerep_core_msgs::Query& query)
// is the query not in map frame?
if (query.polygon && !query.inMapFrame)
{
if (query.coordinateSystem != "")
{
// TODO add transformation using the EPSG code
}
query.polygon.value() = transformToMapFrame(query.polygon.value());
}

result.dataOrInstanceUuids = m_coreDatasets->getData(query);

return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,8 @@ class CoreFbConversion
*/
static bool fromFbQueryInMapFrame(const seerep::fb::Query* query);

static std::string fromFbQueryCoordinateSystem(const seerep::fb::Query* query);

/**
* @brief extracts the fullyEncapsulated flag of the flatbuffer query message
* @param query the flatbuffer message
Expand Down
11 changes: 11 additions & 0 deletions seerep_srv/seerep_core_fb/src/core_fb_conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ CoreFbConversion::fromFb(const seerep::fb::Query* query,
queryCore.polygon = fromFbQueryPolygon(query);
queryCore.polygonSensorPos = fromFbQueryPolygonSensorPosition(query);
queryCore.fullyEncapsulated = fromFbQueryFullyEncapsulated(query);
queryCore.coordinateSystem = fromFbQueryCoordinateSystem(query);
queryCore.inMapFrame = fromFbQueryInMapFrame(query);
queryCore.sortByTime = query->sortByTime();

Expand Down Expand Up @@ -562,6 +563,16 @@ CoreFbConversion::fromFbSparqlQuery(const seerep::fb::Query* query)
return std::nullopt;
}

std::string CoreFbConversion::fromFbQueryCoordinateSystem(const seerep::fb::Query* query)
{
if (flatbuffers::IsFieldPresent(query, seerep::fb::Query::VT_COORDINATESYSTEM))
{
return query->coordinateSystem()->str();
}

return "";
}

std::optional<std::string>
CoreFbConversion::fromFbOntologyURI(const seerep::fb::Query* query)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,14 @@ class CorePbConversion
*/
static void fromPbInMapFrame(const seerep::pb::Query& query,
seerep_core_msgs::Query& queryCore);
/**
* @brief converts the coordinate systen string of the protobuf query message
* to seerep core specific message
* @param query the protobuf query message
* @param queryCore query message in seerep core format
*/
static void fromPbCoordinateSystem(const seerep::pb::Query& query,
seerep_core_msgs::Query& queryCore);
/**
* @brief converts the fullyEncapsulated flag of the protobuf query message to
* seerep core specific message
Expand Down
7 changes: 7 additions & 0 deletions seerep_srv/seerep_core_pb/src/core_pb_conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ CorePbConversion::fromPb(const seerep::pb::Query& query,
fromPbWithOutData(query, queryCore);
fromFbQueryMaxNumData(query, queryCore);
fromPbFullyEncapsulated(query, queryCore);
fromPbCoordinateSystem(query, queryCore);
fromPbInMapFrame(query, queryCore);
queryCore.sortByTime = query.sortbytime();

Expand Down Expand Up @@ -378,6 +379,12 @@ void CorePbConversion::fromPbInMapFrame(const seerep::pb::Query& query,
queryCore.inMapFrame = query.inmapframe();
}

void CorePbConversion::fromPbCoordinateSystem(const seerep::pb::Query& query,
seerep_core_msgs::Query& queryCore)
{
queryCore.coordinateSystem = query.coordinatesystem();
}

void CorePbConversion::fromPbFullyEncapsulated(
const seerep::pb::Query& query, seerep_core_msgs::Query& queryCore)
{
Expand Down

0 comments on commit 85d1592

Please sign in to comment.