Select to view content in your preferred language

Returning XY Event Source Graphics With Query Task

3047
11
12-14-2010 08:21 AM
PaulHuppé
Deactivated User
Hi,

I have a service that contains an XY Event Source layer.  When I use a Query Task, to interrogate the service, for that layer, it only returns attribute data and not the graphics, in my case, points.  Is there a way for the Query Task to return the graphics as well for this type of layer.  Or, am I stuck having to get the XY values from the attribute data and recreate the points on the Graphics Layer?

Even worse, if I use the Identify Task to interrogate that same service/layer, nothing gets returned!

Thanks,
Paul
0 Kudos
11 Replies
DarinaTchountcheva
Frequent Contributor
Paul,

Go to the REST services directory, navigate to the service and then to the layer in question, and see if the Shape field is in there. Maybe the Shape field was not selected in the .mxd file and that's why you can get geometry back, and run spatial queries.

If it is, try running a query in there to see what results you will get.
If it is not in there, open the .mxd file, open the properties of the event layer, go to the Fields tab, and check the shape field. Save the document, restart the service, clear the REST cache, and try again.

Good Luck!
0 Kudos
PaulHuppé
Deactivated User
Hi,

The Shape field is there. I tried running a query with the REST interface, and got results back looking like:


# results: 1000

65034

Point:
X: -62.233333
Y: 41.4

65034

Point:
X: -62.516666
Y: 42.0000000000001

.......

So, it seems to return points.

I just found my problem!!!!  In my code, as was treating the results as polygons instead of points!!!!

Paul
0 Kudos
PaulHuppé
Deactivated User
I do get points back, but they do not display in the correct location.  In the MXD, for the Coordinate System of the Data Frame, I selected Canada Lambert Conformal Conic as the projection (WKID=102002) and when I call the query task, I specify the OutputSpatialReference to be equal to the Map.SpatialReference.  I verified with the debugger, and the Map.Spatialreference.WKID is equal to 102002.

The original XY event source data's coordinates are in lat/long and it that is currently what gets returned.  They do not get projected to the specified OutputSpatialReference desired and therefore, the graphics do not show in the proper locations.
0 Kudos
PaulHuppé
Deactivated User
To show the results, I have made a screen capture (see attachment).  When I select points from the XY event layer data, the selected result points all end up one on top of the other at the same location.  See near the arrow at the bottom of the map.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
As long as your REST end point is returning geographical coordinates, you will run into this issue.

At this time, I have no clue.
Try a web request like this one (after changing the url to your layer):
http://serverapps.esri.com/ArcGIS/rest/services/California/MapServer/2/query?text=&geometry=&geometr...

You should get non geographical coordinates.

Note: a workaround might be you to use a map in geographical coordinates, so a TiledMapServiceLayer using a geographical spatial reference.
0 Kudos
PaulHuppé
Deactivated User
I tried to do a query like you suggested and still get lat/longs.  The url was:

http://myservernamehere.mydomain/ArcGIS/rest/services/TestGeology/MapServer/0/query?text=&geometry=%7B%22xmin%22%3A359116.578934065%2C%22ymin%22%3A3862731.70544748%2C%22xmax%22%3A401068.487002091%2C%22ymax%22%3A3890699.6441595%2C%22spatialReference%22%3A%7B%22wkid%22%3A102002%7D%7D&geometryType=esriGeometryEnvelope&inSR=102002&spatialRel=esriSpatialRelIntersects&relationParam=&objectIds=&where=&time=&returnCountOnly=false&returnIdsOnly=false&returnGeometry=true&maxAllowableOffset=&outSR=102002&outFields=PHOTO_NUM%2CPHOTO_LAT%2CPHOTO_LONG&f=html


And the result is shown in the attachment.
0 Kudos
DominiqueBroux
Esri Frequent Contributor
Strange:confused:

Sorry, I can't help more. Could it be an event layer projection limitation?
Try asking in the REST API or Server forums, perhaps more luck.
0 Kudos
PaulHuppé
Deactivated User
I agree, very strange!:confused:  I will try those forums as you suggest.
Thanks,
Paul
0 Kudos
PaulHuppé
Deactivated User
After asking my question on the ArcGIS Server - REST API forum, it looks like it is a known bug.  Here is the response from Ravi Narayanan (ESRI):

This sounds related to this bug in MapServer (NIM051154)
http://resources.arcgis.com/content/...D=TklNMDUxMTU0

Does the query return correct results if a spatial filter is not used and if a WHERE clause is used? If so, then it is related to the above issue which will be addressed in 10.0 SP2.


I tested with REST using only a WHERE clause and no spatial filter, and the results do come back with projected coordinates.

The big question now is: when is 10.0 SP2 coming out???
0 Kudos