Query Feature Layer / Create Layer from Shapefile

4162
14
04-12-2016 05:18 AM
DanielBachmann1
New Contributor

Hi,

I'm trying to use the runtime sdk to load a shapefile and dynamically change the geometry shown by querying the attribute table. I created an EsriRuntimeQt::LocalFeatureService for an "empty" mpk file and added the Shapefile using the approach from QtSampleApplication_10.2.6_win64 to a ArcGISDynamicMapServiceLayer. Then I created a local Feature service (pointing to the same mpk-file) and created a FeatureLayer in the slot called on layerCreateComplete().

But creating a FeatureLayer in this method like

m_featureLayer = new EsriRuntimeQt::ArcGISFeatureLayer(m_dynamicLocalServiceLayer->url()+"/0",this);

m_featureLayer->setOperationMode(EsriRuntimeQt::QueryMode::SelectionOnly);

m_map->addLayer(m_featureLayer);    connect(m_featureLayer, SIGNAL(layerCreateComplete()), this, SLOT(onFeatureLayerCreateComplete()));

connect(m_featureLayer, SIGNAL(layerCreateError(QString)), this, SLOT(onFeatureLayerCreateError(QString)));

fails. None of the slots above is called.

What am I missing?

Thanks,

Daniel

0 Kudos
14 Replies
DanielBachmann1
New Contributor

Created the mpk-File offline in ArcMap and the FeatureLayer shows up.

!!!But it is extremely slow!!!

Layer has 900 Polylines with about 1000 points each so the raw geometry is about 7MB of raw geometrie data (shp is 11MB). But the FeatureLayer uses nearly 2GB of RAM and renders really slow.

Realtime queries on the data seam to be impossible. Is this expected behaviour? Or is it just the wrong way to online change the number of features shown in a layer?

0 Kudos
LucasDanzinger
Esri Frequent Contributor

Something doesn't sound right. Are you trying to make an ArcGISDynamicMapServiceLayer, or ArcGISFeatureLayer? The dynamic layer should be much faster, but I see your code is for ArcGIS Feature Layer.

0 Kudos
DanielBachmann1
New Contributor

If I use a ArcGISDynamicMapServiceLayer it is much faster. But I was not able to restrict the number of features drawn from that layer, is this possible?. I'm new to the runtimeAPI, so I most likely missed something...

0 Kudos
YueWu1
by Esri Regular Contributor
Esri Regular Contributor

Hi Daniel,

I don't think ArcGISDynamicLayers can restrict or limited the number of features return like ArcGISFeaturelayer. Dynamic Layer is more useful to dynamically change layer appearance and behavior in your map service. Determining which layers will appear in a map, layer symbology, layer order and position, labeling, and more, can be achieved on the server through the use of dynamic layers. In this way, dynamic layers can increase the amount of interaction that users are able to have with your maps.

Have you tried to use definitionExpression to limit the features return from ArcGISFeaturelayer first? ArcGIS Runtime SDK for Qt QML API: ArcGISFeatureLayer Class Reference

Then you can debug that event handle to see why that SLOT is not calling.

0 Kudos
DanielBachmann1
New Contributor

Hi,

so I will not be able to dynamically query Feature-Layers of that size with the runtime SDK?

All possible subsets of the Feature-Layer should be drawable... But creating the Featurelayer and showing all Features needs approx. 3 to 5 Minutes to finish on my i7 (in ReleaseMode) and as mentioned earlier uses 2gb of main memory and this is a rather small dataset.

0 Kudos
LucasDanzinger
Esri Frequent Contributor

What specifically do you want to do? What do you mean by dynamically query? In general, ArcGISDynamicMapServiceLayer will be better for performance than the Feature Layer, because it is sending back dynamically generated images, versus complex geometries and symbols. If you need to only show features that match some given query, then you will need to use a FeatureLayer. If you can upload some sample code/project and data, that would be helpful too.

0 Kudos
DanielBachmann1
New Contributor

The layer consists of polylines which should be first shown completely. The number of polylines to show should then be limited by querying the associated attribute table. You can think of a slider which is used to restrict the maximum allowed value of one attribute resulting in a subset of "valid" features.

May be this is only achieved with the ArcObjects SDK directly?

0 Kudos
YueWu1
by Esri Regular Contributor
Esri Regular Contributor

Hi Daniel,

I found this similar concept in JavaScript Raster layer slider | ArcGIS API for JavaScript

You should able to do this in RuntimeQt as well.

0 Kudos
LucasDanzinger
Esri Frequent Contributor

Hi Daniel,

You have a few options. The first is ArcGISDynamicMapServiceLayer, and that will give better performance, but applying a definition expression is the tricky part. If the service supports dynamic layers, then you could get the dynamic layer info, and set definition expression here - https://developers.arcgis.com/qt/cpp/api-reference/class_esri_runtime_qt_1_1_layer_info.html#a8b4ab8.... I am trying to confirm if you can turn on dynamic layer info support or not with local services right now… I will get back to you on that.

Otherwise, you could also go the feature layer route, but it sounds like you are having some performance issues. I would try a few things for this:

- Set max allowable offset, to generalize the geometries - ArcGIS Runtime SDK for Qt C++ API: EsriRuntimeQt::ArcGISFeatureLayer Class Reference

- Limit the out fields to only what you need - ArcGIS Runtime SDK for Qt C++ API: EsriRuntimeQt::ArcGISFeatureLayer Class Reference 

- Instead of ArcGISFeatureLayer, try using the GeodatabaseFeatureServiceTable and the FeatureLayer

We will soon have native support for shapefiles, so you don't need to spin up local server at all for this. It should be a very simple and straight forward way for you to do this with our upcoming release, but for now, there are unfortunately a few hoops to jump through.

Hope this helps.

Luke

0 Kudos