I'm querying a map service and using the polygon ring coordinates to the use as input geometry for another map service query. It looks like I'm not able to guarantee the point order of the first result and treats this as an outside ring (applying incorrect selections on the second query).
For example, I may have this as the initial ring:
{
"rings": [
[
[
-80.0929469116589,
26.6756462518988
],
[
-80.0924963005446,
26.6756390617361
],
[
-80.0924828894995,
26.6753730253964
],
[
-80.092965687122,
26.675375422123
],
[
-80.0929469116589,
26.6756462518988
]
]
]
}
However, this selects features "outside" of that ring and it needs it to be in this order:
{
"rings": [
[
[
-80.0929469116589,
26.6756462518988
],
[
-80.092965687122,
26.675375422123
],
[
-80.0924828894995,
26.6753730253964
],
[
-80.0924963005446,
26.6756390617361
],
[
-80.0929469116589,
26.6756462518988
]
]
]
}
Here's the basic code I am using to get the ring feature:
ringFeat = ''
qFl = 'https://services1.arcgis.com/sDAPyc2rGRn7vf9B/ArcGIS/rest/services/polySelectionLayer/FeatureServer/0/query'
sql = "OBJECTID=2"
qFlParams = urllib.urlencode({'f': 'json',
'geometryType': 'esriGeometryPolygon',
'geometry': '',
'spatialRel': 'esriSpatialRelIntersects',
'outSR': '4326',
'outFields': 'OBJECTID',
'returnGeometry': 'true',
'where': sql,
'token': token
})
reqFl = urllib2.Request(qFl, qFlParams)
errchk1 = ''
try:
response = urllib2.urlopen(reqFl)
except urllib2.HTTPError, e:
errchk1 = str(e.code)
except urllib2.URLError, e:
errchk1 = str(e.code)
if errchk1 == '':
jsonResult = json.load(response)
appCount = len(jsonResult['features'])
if appCount > 0:
for feature in jsonResult['features']:
ringFeat = feature['geometry']
print json.dumps(ringFeat)
finalRing = json.dumps(ringFeat)