![]() |
NAVTOR SDK
v.3.0
Software Development Kit for fast and efficient development of ECDIS, ECS and generic marine applications
|
The anti-grounding function notifies the mariner of shallow water, low height bridges and other sea conditions that may lead a ship to go aground or touch a low height. The information about the sea areas is acquired from the electronic chart and safety depth, safety contour, ship's height and guard zone preset by the mariner.
The anti-grounding function in the SDK is implemented inside workspace factory component.
To start it use the following code:
sdk::gdb::IGroundingCheckSP grounding_check =
wks_factory.GetInterface<sdk::gdb::IGroundingCheck>();
sdk::geometry::IGeometrySP zone;
sdk::gdb::IQueryParametersSP params;
sdk::gdb::IFeatureFilterSP filter;
sdk::gdb::IGroundingCheckResultSP result;
SDKResult gc_res = grounding_check->PerformGroundingCheck(
zone, params, filter, &result);
| zone | A geometry which could be a guard zone around the ship or multi-surface zone of the route that is used as the spatial filter of the request. The anti-grounding functions check features of the geo database intersecting with the specified guard zone. The geometry container for the guard zone can be created using the IWorkspaceFactoryUtil::CreateGeometry method. |
| params | Parameters of the check; you have to specify parameters of the grounding check function such as kGetFeaturesParameter_GroundingCheck_SafetyDepth for the safety depth, kGetFeaturesParameter_GroundingCheck_SafetyContour for the safety contour, kGetFeaturesParameter_GroundingCheck_SafetyHeight for the safety height. There are more parameters, see them in the description of the IGroundingCheck interface. |
| filter | Can be used to control feature iteration. It also can be used to cancel feature iteration and quickly finish the function. |
| result | As a result of the grounding check the function returns a component which holds dangerous features not passed the check. Each returned feature has an attribute gdb::senc::kFAC_ALRGID defining the identifier of the alert group it belongs to. In addition returned multipoint features have an attribute kFAC_XD_IDX pointing to the geometry vertices intersecting with the guard zone. The function can also return the geometry of the remainder of the dataset the object belongs to (attribute kFAC_DS_CVR). |
Grounding check result can be asked for all the features:
sdk::gdb::IEnumFeatureSP features_enum;
SDKResult res = result->GetFeatures(&features_enum);
Or for the features which belong to the specific zone surface, if multi-surface zone was used for the check:
sdk::gdb::IEnumFeatureSP features_enum;
sdk::geometry::IGeometrySP zone_geometry;
SDKResult res = result->GetFeaturesByIndex(
zone_index, &features_enum, &zone_geometry);
If provided by SDK grounding check renderer is used, grounding check result can be passed to it:
(See grounding_check_demo for the sample how danger objects scene layer is created)
grounding_check_layer->SetProperty(
sdk::vis::kSceneLayerProperty_Data, sdk::ScopedAny(result));
It is also possible to filter returned danger features using special component - GroundingCheckAlerts filter.
This filter contain a tree of alert groups described in Presentation library 4.0.1 sections 10.5.9 - 10.5.12.
Alert group descriptions can be read from this filter, also it stores alert group states and allows to check whether
feature is on or off directly or it can be set into grounding check result to filter the features it returns.
To create this filter use the following code:
sdk::gdb::IGroundingCheckAlertsSP alerts;
wks_util->GetGroundingCheckAlerts(
sdk::ScopedAny(sdk::gdb::kPRSP_S101), &alerts);
To get available alert groups:
sdk::ISDKTreeItemSP item;
alerts->GetTree(&item);
// Go through alert group tree and get descriptions
cur_item->GetChild(&child);
cur_item->GetNext(&next_item);
sdk::ISDKPropertiesSP item_properties = cur_item.GetInterface();
To change alert group state:
alerts->SetState(group_id, sdk::gdb::kGroundingCheckAlertsState_Checked);
To check feature (returned from grounding check) whether it is switched on or off:
alerts->GetFeatureState(feature, state);
To use alert groups component as a filter for the grounding check result:
grounding_check_result->SetAlertsFilter(alerts);
More information can be found in the ECDIS Demo and ECDIS Demo for GL samples.
C++
#include <base/inc/base_types.h>
#include <geometry/inc/geometry/geometry.h>
#include <geometry/inc/geometry/geometry_edit.h>
#include <datalayer/inc/geodatabase/gdb_workspace.h>
#include <datalayer/inc/geodatabase/gdb_dataset.h>
#include <datalayer/inc/geodatabase/gdb_feature.h>
using namespace SDK_NAMESPACE;
using namespace SDK_GDB_NAMESPACE;
using namespace SDK_GEOMETRY_NAMESPACE;
class FeatureFilter;
bool GroundingCheck(const IWorkspaceFactotySP& workspace_factory,
const SDKGeoPoint* guard_zone, int guard_zone_point_count,
double safety_contour, double safety_depth, double safety_height) {
IWorkspaceFactoryUtilSP util =
workspace_factory.GetInterface<IWorkspaceFactoryUtil>();
if (!util)
return false;
IGeometryEditSP geometry_container;
if (SDK_FAILED(util->CreateGeometry(kGMT_Surface, &geometry_container))) {
LOG << "Failed to get a geometry container";
return false;
}
IQueryParametersSP parameters;
if (SDK_FAILED(util->CreateQueryParameters(&parameters))) {
LOG << "Failed to get a query parameters container";
return false;
}
if (SDK_FAILED(geometry_container->AddPoints(kGMPT_GeoPoint, guard_zone,
guard_zone_point_count, 0, 0))) {
LOG << "Failed to add points into the geometry container";
return false;
}
IGeometrySP geometry_filter = geometry_container.GetInterface<IGeometry>();
if (!geometry_filter) {
LOG << "Failed to get IGeometry";
return false;
}
parameters->SetParameter(
kGetFeaturesParameter_Flags,
ScopedAny(kGetFeaturesFlags_GroundingCheck));
parameters->SetParameter(
kGetFeaturesParameter_GroundingCheck_SafetyContour,
ScopedAny(safety_contour));
parameters->SetParameter(
kGetFeaturesParameter_GroundingCheck_SafetyDepth,
ScopedAny(safety_depth));
parameters->SetParameter(
kGetFeaturesParameter_GroundingCheck_SafetyHeight,
ScopedAny(safety_height));
sdk::gdb::IGroundingCheckSP grounding_check =
workspace_factory.GetInterface<sdk::gdb::IGroundingCheck>();
IFeatureFilterSP filter = new FeatureFilter();
IGroundingCheckResultSP grounding_check_result;
SDKResult gc_res = grounding_check->PerformGroundingCheck(
zone_geometry, gc_params, filter, &grounding_check_result);
// Get features
// Set into renderer
}
class FeatureFilter : public IFeatureFilter {
public:
FeatureFilter() throw() : m_stop_iteration(false) {
}
void StopIteration() {
m_stop_iteration = true;
}
// IFeatureFilter implementation
virtual GDBResult SDK_CALLTYPE CheckFeature(IFeature* feature,
CheckFeatureResult* check_result) throw() {
if (!check_result) {
return Err_NULLPointer;
}
*check_result = m_stop_iteration ?
CheckFeatureResult_Stop : CheckFeatureResult_Ok;
return Ok;
}
private:
bool m_stop_iteration;
};