Finding a different and disappearing feature in identify query

1280
7
Jump to solution
10-03-2022 06:20 AM
Labels (2)
tanerkoka
Occasional Contributor II

Hi,

I  using ArcGIS_Runtime_SDK_Qt_Windows_100_14_1 sdk. Im  using Qt Creator 7.0.2 Based on Qt 6.2.3 (MSVC 2019, 64 bit)  and Kits Qt 5.15.2   (Android  Clang Multi -Abi and  MinGW 64-bit ) .

When I want to query two layers in an identify query ( mapView.identifyLayersWithMaxResults) , feature disappears. This event happens in some cases. As a result of the query  identifyLayersResults lenght is 0 and I am not getting any error.How can I solve this problem ?

Below is the video taken during Identify:

 All the codes used are as follows:

KgmMapObject.qml

import QtQuick 2.6
import QtQuick.Controls 2.2
import Esri.ArcGISRuntime 100.14

Rectangle {
id: appWindowObj
clip: true


property string msgText: ""

MapView {
id:mainViewObj
anchors.fill: parent
attributionTextVisible:false
// set focus to enable keyboard navigation
Component.onCompleted: {

forceActiveFocus();
}

 

Map {


Basemap {

WebTiledLayer {

templateUrl: "http://.../wmts/.../gm_grid/{level}/{col}/{row}.png"


}
}

FeatureLayer {

ServiceFeatureTable {
url: "https://.../arcgis/rest/services/.../FeatureServer/0"
}


}

FeatureLayer {

ServiceFeatureTable {

url: "https://.../arcgis/rest/services/.../FeatureServer/1"

}


}


ViewpointCenter {

Point {
x: 3894007.968960
y: 4749476.7008
spatialReference: SpatialReference { wkid: 3857 }
}
targetScale: 7000000
}

}


onMouseClicked: {
const screenX = mouse.x;
const screenY = mouse.y;
const tolerance = 12;
const returnPopups = false;
const maxResults = 1;
mainViewObj.identifyLayersWithMaxResults(screenX, screenY, tolerance, returnPopups, maxResults);
}

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

msgText = "";
const results = mainViewObj.identifyLayersResults;

for (let i = 0; i < results.length; i++) {
const result = results[i];
const count = geoElementsCountFromResult(result);
const layerName = result.layerContent.name;

msgText += "%1 : %2".arg(layerName).arg(count);
// add new line character if not the final element in array
if (i !== results.length)
msgText += "\n";


}

if (msgText.length > 0)
msgDialog.open();

}

onErrorChanged: {
if (error)
{
console.log("error:", error.message, error.additionalMessage)

msgText=error.message+" "+error.additionalMessage;
msgDialog.open();

}

}

}

function geoElementsCountFromResult(layerObjResult) {
const tempResults = [layerObjResult];


let count = 0;
let index = 0;

while (index < tempResults.length) {
const identifyResult = tempResults[index];

count += identifyResult.geoElements.length;if (identifyResult.sublayerResults.length > 0) {
tempResults.push(identifyResult.sublayerResults[index]);
}


index += 1;
}

return count;
}

Dialog {
id: msgDialog
modal: true
x: Math.round(parent.width - width) / 2
y: Math.round(parent.height - height) / 2
standardButtons: Dialog.Ok
property alias text : textLabel.text
Text {
id: textLabel
text: msgText
}
}


}

main.qml

import QtQuick 2.12
import QtQuick.Controls 2.12


ApplicationWindow {
id: window
width: 360
height: 520
visible: true


KgmMapObject{
id: kgmMapObj
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
anchors.bottom: parent.bottom
visible: true
}


}

The content of one of the FeatureServices used is below as an image:

 

esri1.PNG

 

esri2.PNG

 

 

 

 

 

 

0 Kudos
1 Solution

Accepted Solutions
tanerkoka
Occasional Contributor II

Thanks @MichaelBranscomb problem was solved. I followed the method you suggested and the problem was solved.

The codes I use are as follows:

Feature Layers definition:

FeatureLayer {
id: roadsFeatureLayer

visible:false

ServiceFeatureTable {
id: roadsFeatureTable
url: "https://......./arcgis/rest/services/../.../MapServer/0"
featureRequestMode: Enums.FeatureRequestModeManualCache
}

}

 

FeatureLayer {
id: closedRoadsFeatureLayer

visible:false

ServiceFeatureTable {
id: closedRoadsFeatureTable
url: "https://......./arcgis/rest/services/../.../MapServer/1"
featureRequestMode: Enums.FeatureRequestModeManualCache
}

}

Query parameter for feature layer tables:

QueryParameters {
id: params
whereClause: "1=1"
}

İdentify Query Layers with mouse  clicked:

onMouseClicked: {
const screenX = mouse.x;
const screenY = mouse.y;
const tolerance = 12;
const returnPopups = false;
const maxResults = 1;
mainViewObj.identifyLayersWithMaxResults(screenX, screenY, tolerance, returnPopups, maxResults);
}

Query feature Layer Tables with enable /disable Images with click event  buttons:

Image {
id: roads_img
source: favorite ? "/Resources/ky_a.png" : "/Resources/ky_k.png"
enabled: roadsFeatureTable.loadStatus === Enums.LoadStatusLoaded
height: 45
width: 45
fillMode: Image.PreserveAspectFit

anchors {
top: mainViewObj.top
right:mainViewObj.right
topMargin: 10
rightMargin: 10

}

property bool favorite : false

MouseArea{
anchors.fill: parent
onClicked: {

roads_img.favorite = !roads_img.favorite

if(roads_img.favorite==true){

roadsFeatureLayer.visible=true
roadsFeatureTable.populateFromService(params, true, ["*"]);

}
else
roadsFeatureLayer.visible=false

}
}
}

 

Image {
id: closedRoads_img
source: favorite ? "/Resources/cls_ky_a.png" : "/Resources/cls_ky_k.png"
enabled: closedRoadsFeatureTable.loadStatus === Enums.LoadStatusLoaded
height: 45
width: 45
fillMode: Image.PreserveAspectFit

anchors {
top: mainViewObj.top
right:mainViewObj.right
topMargin: 10
rightMargin: 10

}

property bool favorite : false

MouseArea{
anchors.fill: parent
onClicked: {

closedRoads_img.favorite = !closedRoads_img.favorite

if(closedRoads_img.favorite==true){

closedRoadsFeatureLayer.visible=true
closedRoadsFeatureTable.populateFromService(params, true, ["*"]);

}
else
closedRoadsFeatureLayer.visible=false

}
}
}

 

 

View solution in original post

7 Replies
Gela
by Esri Contributor
Esri Contributor

Hello,

Let's walk through your code and try to flag down what's happening 🙂 

Could you clarify what 

fieldsModel.clear()

 is doing? 

0 Kudos
tanerkoka
Occasional Contributor II

Hi ,

I clear ListModel before identify result . I use ListModel to appear on Dialog . I open the dialog with the open() method after  filling Feature(result from identify) value in List Model .  

Here is codes below:

ListModel {
id:fieldsModel
}

 

Dialog {

id: identifyDialog

title:"Yol Bilgisi"
modality: Qt.NonModal

 

contentItem: Rectangle {
id: dialogRectangle

border.color: "black"
border.width: 3
radius: 10
color: "white"
width : 375 * scaleFactor
height: 250 *scaleFactor

Column {
id: identifyColumn
anchors {
fill: parent
topMargin: 20 * scaleFactor
bottomMargin: 10 * scaleFactor
leftMargin:10 * scaleFactor
rightMargin: 10 * scaleFactor
}
spacing: 5 * scaleFactor
clip: true

Repeater {
model: fieldsModel
clip: true
Row {
id: row
spacing: 2
Label {
id: nameLabel
text: name + ": "
font.bold:true
color: "black"
horizontalAlignment: Text.AlignLeft
font.pixelSize: 12 * scaleFactor

}
Label {
text: value
width:(345*scaleFactor)-nameLabel.width
color: "black"
horizontalAlignment: Text.left
font.pixelSize: 12 * scaleFactor
wrapMode: Text.WordWrap
}
}
}
}

 

0 Kudos
TroyFoster
Occasional Contributor

I dont do QML but with

function geoElementsCountFromResult(identifyLayerResult) 

Isnt "identifyLayerResult" a claimed variable name at the global scope?  Maybe refactor that to something more unique and see if the behavior persists?

0 Kudos
tanerkoka
Occasional Contributor II

Hi,

I edited the method and even removed the method completely, instead I used count (const count=result.geoElements.length) in a different way, but the same result still persists 😞

At the same time, during the tests, it finds the value of the randomly (e.g. feature above a road in a  in different place) found feature in the identify query and the feature is lost. Sometimes, the feature disappears before the attribute  are found, sometimes it works properly, in short, it is not stable.

Feature sometimes comes back after operations like zoom in/out after feature is lost.Can we come up with a solution to renew (using resetFeaturesVisible() , resetRenderer() metods or zooming in a little) the FeatureLayer to solve the problem? 

It is an important problem for us to see the details of the closed roads in traffic, in order to avoid traffic accidents.Can you help for solving problem ?

Thanks

0 Kudos
JesseCloutier
Esri Community Manager

@Gela Now that there's more detail provided around this issue, is it something you'd be able to offer troubleshooting help with?

Jesse Cloutier
Community Manager, Engagement & Content
0 Kudos
MichaelBranscomb
Esri Frequent Contributor

I wonder if the act of identifying the feature from the service populates additional attribute fields and values on which there is another condition for visibility? Are you still able to reproduce this issue if you set the ServiceFeatureTable to ManualCache mode and use the method populateFromService(QueryParameters parameters, bool clearCache, list<string> outFields), requesting all fields as outFields, typically as a "*". For more info see ServiceFeatureTable QML Type | ArcGIS Runtime API for Qt | ArcGIS Developers.

tanerkoka
Occasional Contributor II

Thanks @MichaelBranscomb problem was solved. I followed the method you suggested and the problem was solved.

The codes I use are as follows:

Feature Layers definition:

FeatureLayer {
id: roadsFeatureLayer

visible:false

ServiceFeatureTable {
id: roadsFeatureTable
url: "https://......./arcgis/rest/services/../.../MapServer/0"
featureRequestMode: Enums.FeatureRequestModeManualCache
}

}

 

FeatureLayer {
id: closedRoadsFeatureLayer

visible:false

ServiceFeatureTable {
id: closedRoadsFeatureTable
url: "https://......./arcgis/rest/services/../.../MapServer/1"
featureRequestMode: Enums.FeatureRequestModeManualCache
}

}

Query parameter for feature layer tables:

QueryParameters {
id: params
whereClause: "1=1"
}

İdentify Query Layers with mouse  clicked:

onMouseClicked: {
const screenX = mouse.x;
const screenY = mouse.y;
const tolerance = 12;
const returnPopups = false;
const maxResults = 1;
mainViewObj.identifyLayersWithMaxResults(screenX, screenY, tolerance, returnPopups, maxResults);
}

Query feature Layer Tables with enable /disable Images with click event  buttons:

Image {
id: roads_img
source: favorite ? "/Resources/ky_a.png" : "/Resources/ky_k.png"
enabled: roadsFeatureTable.loadStatus === Enums.LoadStatusLoaded
height: 45
width: 45
fillMode: Image.PreserveAspectFit

anchors {
top: mainViewObj.top
right:mainViewObj.right
topMargin: 10
rightMargin: 10

}

property bool favorite : false

MouseArea{
anchors.fill: parent
onClicked: {

roads_img.favorite = !roads_img.favorite

if(roads_img.favorite==true){

roadsFeatureLayer.visible=true
roadsFeatureTable.populateFromService(params, true, ["*"]);

}
else
roadsFeatureLayer.visible=false

}
}
}

 

Image {
id: closedRoads_img
source: favorite ? "/Resources/cls_ky_a.png" : "/Resources/cls_ky_k.png"
enabled: closedRoadsFeatureTable.loadStatus === Enums.LoadStatusLoaded
height: 45
width: 45
fillMode: Image.PreserveAspectFit

anchors {
top: mainViewObj.top
right:mainViewObj.right
topMargin: 10
rightMargin: 10

}

property bool favorite : false

MouseArea{
anchors.fill: parent
onClicked: {

closedRoads_img.favorite = !closedRoads_img.favorite

if(closedRoads_img.favorite==true){

closedRoadsFeatureLayer.visible=true
closedRoadsFeatureTable.populateFromService(params, true, ["*"]);

}
else
closedRoadsFeatureLayer.visible=false

}
}
}