Sorting Results by Distance
I have a workflow to find nearby dentists by creating a buffer around the user's current location and querying all the features inside the buffer. The workflow does what it's supposed to, but I want the results to be sorted by distance.
I referenced the Find near me (https://support.geocortex.com/essentialsGSCForum?sub-nav=forum&main-nav=essentials&#!/feedtype=SINGLE_QUESTION_DETAIL&criteria=ALLQUESTIONS&id=90660000000TSgPAAW) question a lot, particularly the example workflow provided in the answers. I compared my workflow to the example several times, and I don't notice anything different. I paid particularly close attention to where the temporary distance field is created for the feature. In the screenshot below, 'fsSearchFeatures' is the variable for the query results. and 'userGeomCast' is the current location of the user.
I even made an alert to show the names and distances of all the results, which is when I realized that the same distance was assigned to all of the results.
Does anybody have any ideas as to why the same distance would be applied to every result and what I can do to fix it?
_img_ alt="User-added image" src="https://latitudegeo--c.na53.content.force.com/servlet/rtaImage?eid=906f2000000fyAw&feoid=Body&refid=0EMf2000000kCxM"_/_img_
0
-
Update
I tried switching Geometry 1 and Geometry 2 in the distance task. It assigned different distances to each feature, but sorted them from east to west. I then realized that the minimum distance is 7,830 miles. I used Google maps to take some measurements, and that seems to be the distance to (0,0), off the coast of Africa. I'm wondering if it has something to do with coordinate systems. However, this workflow allows users to choose whether to use their current location or enter in an address. I've been working with the current location part of the workflow, but the address search part of the workflow sorts the results properly with the exact same technique. It must have something to do with the Get Current Position Task...0 -
Get Current Position Activity: This activity always reports positions using the WGS84 (4326) spatial reference. This may not match the spatial reference of your application.Perhaps you have to add a Project Single Geometry Task?0 -
Hello Nico,
Thank you for the suggestion! I had actually been having a problem with the results highlights matching up, so I changed the data frame in the mxd I published the service from to WGS84 and applied a transformation. That fixed the misalligned hightlights. But would the actual feature class have to be in WGS84 as well for this to work? If so, I can project the feature class in ArcMap and overwite the service.
I tried using a Project Single Geometry Task, but it doesn't like the feature set variable.0 -
In case of a featureset, you should use the Project Task. 0 -
I used the project Task, but the result is an IList Graphic, so I can't add a distance field to it. 0 -
Hi Denise,
Try using Project Single Geometry Task, instead of Project Task. It just gives back a single geometry result. You could use that to project the user location point to match the other featureset.
(for cases where you get back an IList of Graphics though, you can always create a new featureset and then use AddRangeToCollection to push the IList into myFSVariable.Features)
Hope that helps!
-Amanda0 -
Hello Amanda,
I used the Project Single Geometry Task on the user location point, but it made no difference. I tried projecting the feature set as well, but I still can't figure out how to convert the IList Graphic Results back to a feature set. I don't get how Add Range to Collection fits in. Do I need to use Create Collection rather than Assign to create a new feature set?0
Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.
Kommentare
7 Kommentare