POST
|
Using some input from a fellow GeoNet'er, and getting some more learning under my belt, I was able to get this working, today. (A nice way to start a weekend!) Here's the code I used, for the benefit of others: Geodatabase { id: gdb_geofence path: AppFramework.resolvedPathUrl( outputGeofencing ) onLoadStatusChanged: { if(Enums.LoadStatusLoaded === gdb_geofence.loadStatus) { var layer = ArcGISRuntimeEnvironment.createObject("FeatureLayer") layer.featureTable = gdb_geofence.geodatabaseFeatureTablesByTableName["fake_brushview_polygons"] gdbLayers.push( layer ); map.operationalLayers.append(layer); layer.featureTable.queryFeaturesStatusChanged.connect( function() { if (layer.featureTable.queryFeaturesStatus === Enums.TaskStatusCompleted) { //Create array for features and collect them var features = [] while (layer.featureTable.queryFeaturesResult.iterator.hasNext) { features.push( layer.featureTable.queryFeaturesResult.iterator.next() ); } console.log( "number of features in array: ", features.length ); //Get the current map point var newPoint = mapView.locationDisplay.location.position //set default value for not being in a zone, before checking: var inAZone = false; for( var i = 0; i < features.length; i++ ) { var zoneGeometry = features.geometry var withinZone = GeometryEngine.within( newPoint, zoneGeometry ); if( withinZone ) { inAZone = true debugMessage.text = features.attributes.attributesJson.name } if( !inAZone ) { debugMessage.text = "Not currently in a Zone" } console.log( i, features.attributes.attributesJson.name, " withinZone is set to ", withinZone ); } } }); layer.featureTable.queryFeatures( queryParameters ); } } }
... View more
12-01-2017
01:57 PM
|
0
|
0
|
616
|
POST
|
Right, but I'm not getting to the geometry level. I used exactly what you're describing, successfully, with the iterator, with online resources. But I can't get a successful return to my query to the Geodatabase. In other words, I never get "Query Complete!" in my console, in my above code, even though I'm getting the layer showing up on my map.
... View more
11-30-2017
12:44 PM
|
0
|
2
|
616
|
POST
|
Yes, that was when I was simply trying to get GeometryEngine working with online layers. No problem doing that, but I run into difficulty when I try to get my offline data (runtime content) to the same place, where I can run GeometryEngine.within against individual features. (Polygons) The error that I referenced in my last post was really throwing me, but it sounds like it may be a known bug, and ignorable. (?) Beyond that, I've tinkered for a while and have the following code loading the geodatabase polygon on my map, no problem. However, when querying, I never get queryFeaturesStatus to be "Complete". I get a value of 1 from my console. Loading to the map implies that the data is present, just not sure how to drill down to features, so that I can do my "within" call, like what worked for me, with online resources. Perhaps there's a better way! Any thoughts? 🙂 FeatureLayer { id: gdbFeatureLayer // obtain the feature table from the geodatabase by name featureTable: gdb.geodatabaseFeatureTablesByTableName["fake_brushview_polygons"] onLoadStatusChanged: { map.operationalLayers.append( gdbFeatureLayer ); onQueryFeaturesStatusChanged: { console.log( "queryFeaturesStatus: ",gdbFeatureLayer.featureTable.queryFeaturesStatus ); if( gdbFeatureLayer.featureTable.queryFeaturesStatus === Enums.TaskStatusCompleted ) { console.log( "Query Complete!" ); } } } // create the geodatabase Geodatabase { id: gdb path: AppFramework.resolvedPathUrl( outputGeofencing ) } }
... View more
11-30-2017
12:05 PM
|
0
|
4
|
616
|
POST
|
Thanks, yes, I've worked with the Feature Layer (Geodatabase) code, as well. I can load a geodatabase to the displayed map...but I've yet to get it to successfully query against it. One clue is that even the barebones Feature Layer (Geodatabase) example is getting an error in my console?: MyApp.qml:100:39: Unable to assign [undefined] to QmlFeatureTable* I've worked with this code, as well as the "Generate Geodatabase" sample; I can make features show on the map, but that's not the end game for me. I need to be able to use GeometryEngine against it (within), and can't seem to get to that extra step. Thank you for pointing out that I'm using sample code for the older runtime, that's a start!
... View more
11-27-2017
01:34 PM
|
0
|
6
|
616
|
POST
|
I found the following sample code on the Esri GitHub AppStudio wiki: Working with Offline content · Esri/arcgis-appstudio-samples Wiki · GitHub I'm specifically interested in the 2nd section, "Adding offline geodatabase to your app". This is critical to my application; I need to get a queryable featureTable in there, so that I can do a simple geofence, the user's current location against offline-stored polygons. I started out using the existing Feature Layer sample code, then placed the code from above in the FeatureLayerQuery.qml code, within the Map section, (replacing the existing FeatureLayer and ServiceFeatureTable sections). When I go to run the query in the app, it stops with 'Cannot assign to non-existent property "onStatusChanged"'. In the editor, I'm getting invalid property name flags for featureServiceLayerId, enableLabels, onStatusChanged. (graphic included of what I see). I'm guessing that this code sample has worked for others, since it's been on GitHub for over a year, so I must have something missing or wrong. Barring an explanation of this, does anyone have a link to actual working code, of an offline geodatabase, being queried via GeometryEngine? Nothing I've tried where I simply replace online code with a gdb has worked, to date. Thanks for any assistance! --Ray
... View more
11-27-2017
12:56 PM
|
0
|
8
|
852
|
POST
|
Hi Aneeqa, sorry, I've been out of the office for a holiday over the last week. I'm sorry to say that I've had no luck getting this to work, so far. Most of the feedback that I've gotten simply keeps pointing me back to the same AppStudio samples, with the counsel that "it works just the same with offline content". Alas, that has not been my experience.
... View more
11-27-2017
12:39 PM
|
0
|
1
|
638
|
POST
|
Excellent, this appears to have solved my problem! Thanks so much --Ray
... View more
11-02-2017
11:57 AM
|
0
|
0
|
576
|
POST
|
Great idea to try to get my SR's in sync, thanks for the response! So I did this (code below). It didn't seem to solve my problem, but the console.log seems to show that the geom1 value becomes null. Does that mean that the newPoint that I'm passing to GeometryEngine is not really a "geometry", and could be part of my problem? Console.log shows newPoint as a QDeclarativePosition if I get it from the code below, and as a QMLPoint if I get it from mapView.currentViewpointCenter.center.
var newPoint = mapView.locationDisplay.positionSource.position var geom1 = GeometryEngine.project( newPoint, mySpatialReference ); var geom2 = GeometryEngine.project( zoneGeometry, mySpatialReference ); var withinZone = GeometryEngine.within( geom1, geom2 ) console.log( "withinZone", withinZone, geom1, geom2 )
Edit: adding in my spatial reference object for good measure:
SpatialReference { id: mySpatialReference wkid: 4326 }
... View more
11-02-2017
11:08 AM
|
0
|
2
|
576
|
POST
|
I want to do a check of GPS location against geofence polygons at intervals, perhaps once a minute. Based upon some example code I found, I've attemped to use GeometryEngine's within operation to compare the point geometry with the polygon geometry. Using the markup/JS below, when I execute: zoneBoundaries.queryFeatures(queryParameters); I always get withinZone as false, even with one huge polygon geometry to test against. I'm having difficulty figuring out how to troubleshoot this. Any suggestions? I really like the GeometryEngine approach to this, and would like to get this working! Thanks for any tips/assistance. --Ray //Feature service for spatial query ServiceFeatureTable { id: zoneBoundaries url: "https://services3.arcgis.com/pKp5WOFjeV9KSSfr/ArcGIS/rest/services/fake_brushview_polygons/FeatureServer/0" onQueryFeaturesStatusChanged: { if (queryFeaturesStatus === Enums.TaskStatusCompleted) { //Create array for features var features = [] // get the features while (queryFeaturesResult.iterator.hasNext) { console.log( "Counting.." ); features.push(queryFeaturesResult.iterator.next()); } console.log( "number of features in array: ", features.length ); //assign geometry of first feature to var: var zoneGeometry = features[0].geometry console.log("zoneGeometry", zoneGeometry) //Get the current map point //var newPoint = mapView.currentViewpointCenter.center var newPoint = mapView.locationDisplay.positionSource.position console.log("newPoint", newPoint) //Check to see if currrent point is within zone boundary var withinZone = GeometryEngine.within(newPoint, zoneGeometry) console.log("withinZone", withinZone) } } } //Parameters for query QueryParameters { id: queryParameters whereClause: "1=1" returnGeometry: true }
... View more
11-02-2017
07:11 AM
|
0
|
5
|
781
|
POST
|
Hmmm, so perhaps you're on to something here. When I attempt to run their provided example geodatabase, I get 1 for both loadStatus and featureTable.queryFeatureStatus. If I change things to try to use my gdb, the loadStatus is 0, and the featureTable comes up as undefined. I'm not getting the geodatabase loaded properly, somehow.
... View more
10-10-2017
01:00 PM
|
0
|
3
|
638
|
POST
|
Hi, thanks Kaushik, Sorry for the delay, I got bounced around to another project for a bit! Yes, when I log the path, it does appear that it's correctly pointing to my existing .geodatabase file in the correct folder. I was hoping you might be on to something, there, that would have been something that I could have fixed! Any other thoughts? Thanks, --Ray
... View more
10-05-2017
10:06 AM
|
0
|
5
|
638
|
POST
|
I'm figuring out the workflows for an AppStudio app that involves a query of the current GPS location against a feature service of polygons. I've got it working for a feature service in ArcGIS Online, but need to work out how to make this an Offline operation, since connectivity could be an issue. I've explored the examples for generating Runtime Content in ArcMap (a .geodatabase file), sample code below. With a featuretable declared, I assumed that I could query against that, but I get no data in my result. One clue is that get an error: "Unable to assign [undefined] to QmlFeatureTable", even on the stock Esri example code, for the "featureTable:" line. Their data appears on the map, but I nothing I've tried, as far as querying features, seems to work. I'm not concerned about map display, I need to execute a query against a layer of polygons, as I would using the REST API, to see if my GPS "point" gets a return. Is there an established way to get there? I'm still a rookie with using QML/Javascript with AppStudio, so I could be missing something basic. Also worth mentioning, I've looked at the MobileMapPackage process, as well; I like that since I can easily generate it in ArcGIS Pro, but have had no luck querying against that, either. Thanks for any info! --Ray Sample code: QueryParameters { id: params } FeatureLayer { // obtain the feature table from the geodatabase by name featureTable: gdb.geodatabaseFeatureTablesByTableName["Trailheads"] // create the geodatabase Geodatabase { id: gdb path: AppFramework.resolvedPathUrl(copyLocalData(inputGDB, outputGDB)) } onLoadStatusChanged: { console.log( "Load Status: ", loadStatus ); params.whereClause = "1=1"; featureTable.queryFeatures( params ); onQueryFeaturesStatusChanged: { console.log( JSON.stringify( FeatureQueryResult )); } } }
... View more
10-01-2017
11:59 AM
|
0
|
7
|
1143
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:24 AM
|