Extracting Safety Countour Line from an ENC set

1671
6
Jump to solution
06-04-2021 04:30 PM
KennSebesta
New Contributor III

I'd love a simple worked example of how to extract the Safety Countour Line from a set of ENCs. It doesn't have to be any particular ENC, just enough breadcrumbs to let get me started so I can expand from there.

A post over in Java SDK land, hints at how to get at the data, but doesn't go all the way to providing a worked example.

P.S. FWIW, it would be great to get the Safety Countour Line directly as requested in the above link. Obviously, the system knows where it is because it draws it dynamically from the data. I understand that there is a limitation, although I don't quite understand why the limitation allows drawing the data but not providing the polyline directly.

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
JamesBallard1
Esri Regular Contributor

Hi @KennSebesta ,

I have some code that I was able to add to that existing sample code that should help. This is added within the MapView declaration.

MapView {
        id: mapView
        anchors.fill: parent

        // identify layers on mouse click
        onMouseClicked: {
            // for every EncLayer, clear all selection on every mouse click
            map.operationalLayers.forEach(function(layer) {
               if (layer.layerType === Enums.LayerTypeEncLayer)
                   layer.clearSelection();
            });

            const screenX = mouse.x;
            const screenY = mouse.y;
            const tolerance = 12;
            const returnPopups = false;
            const maxResults = 3;
            mapView.identifyLayersWithMaxResults(screenX, screenY, tolerance, returnPopups, maxResults);
        }

        // handle the identify results
        onIdentifyLayersStatusChanged: {
            if (identifyLayersStatus !== Enums.TaskStatusCompleted)
                return;

            console.log("identified on", identifyLayersResults.length, "layers");

            // for the result of every layer in the map...
            for (let i = 0; i < identifyLayersResults.length; i++) {
                const identifyLayerResult = identifyLayersResults[i];
                let layerContent = identifyLayerResult.layerContent;
                let encFeatures = identifyLayerResult.geoElements;

                // for all geoelements of that layer's results...
                for (let j = 0; j < encFeatures.length; ++j) {
                    let encFeature = encFeatures[j];
                    layerContent.selectFeature(encFeature);
                    console.log("found EncFeature", encFeature.description, encFeature.acronym,
                                JSON.stringify(encFeature.attributes.attributesJson));
                }
            }
        }

 

With that code you can identify the EncFeatures to locate the Safety Contour Line feature(s), and get their geometry. As mentioned in the other post, there is no way to query for features and search for only the Contour features, but you can identify them and get their geometry. In the sample code you can adjust the max number of features identified on each mouse click.

Let us know if this is helpful.

View solution in original post

6 Replies
JamesBallard1
Esri Regular Contributor

Hi @KennSebesta . Can you please provide some more details? I'm not clear on what you mean by "extract". Are you wanting to identify the Safety Contour Line and get its geometry?

We do provide an ENC sample for the Qt C++ SDK but I am guessing you'll need a bit more assistance than simply displaying the ENC dataset.

https://github.com/Esri/arcgis-runtime-samples-qt/tree/main/ArcGISRuntimeSDKQt_CppSamples/Layers/Add... 

We're eager to help once we get some more details.

KennSebesta
New Contributor III

@JA , thanks for the rapid response. Indeed, I was able to make the ENC example work in my application and just came back from using it on a 4 days' sail on the open ocen. The SDK performed admirably, and was our go-to solution when the B&G chartplotter continuously crashed (leaving the autopilot on and the crew locked out, but that's a story for another day). We're very impressed by the suitability and stability of Qt and ArcGIS.

Now we'd like to do something very similar to the use case described by the poster in the Java SDK community. Effectively, we'd like to know how far a boat is from running aground. This would be very easy with the geometry engine's intersection algorithm, but first we'd need to extract the local depth contour-- i.e. identify the Safety Contour Line and turn its geometry into an ArcGIS object.

0 Kudos
JamesBallard1
Esri Regular Contributor

Hi @KennSebesta ,

I have some code that I was able to add to that existing sample code that should help. This is added within the MapView declaration.

MapView {
        id: mapView
        anchors.fill: parent

        // identify layers on mouse click
        onMouseClicked: {
            // for every EncLayer, clear all selection on every mouse click
            map.operationalLayers.forEach(function(layer) {
               if (layer.layerType === Enums.LayerTypeEncLayer)
                   layer.clearSelection();
            });

            const screenX = mouse.x;
            const screenY = mouse.y;
            const tolerance = 12;
            const returnPopups = false;
            const maxResults = 3;
            mapView.identifyLayersWithMaxResults(screenX, screenY, tolerance, returnPopups, maxResults);
        }

        // handle the identify results
        onIdentifyLayersStatusChanged: {
            if (identifyLayersStatus !== Enums.TaskStatusCompleted)
                return;

            console.log("identified on", identifyLayersResults.length, "layers");

            // for the result of every layer in the map...
            for (let i = 0; i < identifyLayersResults.length; i++) {
                const identifyLayerResult = identifyLayersResults[i];
                let layerContent = identifyLayerResult.layerContent;
                let encFeatures = identifyLayerResult.geoElements;

                // for all geoelements of that layer's results...
                for (let j = 0; j < encFeatures.length; ++j) {
                    let encFeature = encFeatures[j];
                    layerContent.selectFeature(encFeature);
                    console.log("found EncFeature", encFeature.description, encFeature.acronym,
                                JSON.stringify(encFeature.attributes.attributesJson));
                }
            }
        }

 

With that code you can identify the EncFeatures to locate the Safety Contour Line feature(s), and get their geometry. As mentioned in the other post, there is no way to query for features and search for only the Contour features, but you can identify them and get their geometry. In the sample code you can adjust the max number of features identified on each mouse click.

Let us know if this is helpful.

KennSebesta
New Contributor III

Marvelous! I've started integrating this into my code and am excited by the results.

 

P.S. IMHO, it's worth building an additional SDK example purely to highlight your code. In part because it's so useful and yet so simple, and in part because the bit of code in the `for j=...` block requires a very high degree of familiarity with the SDK.

0 Kudos
JamesBallard1
Esri Regular Contributor

@KennSebesta that's great to hear! I will pass along your suggestion to our sample team. We do have samples that showcase identifying features, but I see what you're saying for the ENC sample; it's not much to add.

0 Kudos