0

I have soe which accepts {x:-112,y:35} as input parameter. how can I modify the soe code so that I can pass more than one point as my input parameters like {x:-112,y:35},{x:-113,36},{x:-113.5,y:34} and so on Thanks!

closed as off-topic by Fezter, Paul, BradHards, Devdatta Tengshe, PolyGeo Oct 31 '13 at 6:09

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about software development are off-topic here unless they relate directly to Geographical Information Systems, but they can be asked on Stack Overflow." – Fezter, Paul, BradHards
If this question can be reworded to fit the rules in the help center, please edit the question.

  • What GIS software and version are you wanting to use to do this? – PolyGeo Oct 31 '13 at 3:43
  • 1
    Are you talking about a SOE for ArcGIS Server? If so, what version? What is your development language? You need to provide more information before we can answer this question. – Devdatta Tengshe Oct 31 '13 at 5:40
  • yes, SOE for ArcGIS Server, 10.2 Development language is c# .net I want to modify the existing FindNearFeature esri sample to accept more than one point. where do I change in the code so that it accepts more than one set of x,y? – user23484 Oct 31 '13 at 6:15
1

To start, you should use the esri json featureset spec which includes properties for geometry and attributes.

{
    "features" : [
{
    "geometry" : {"x" : -104.44, "y" : 34.83},
    "attributes" : {"Id" : 43, "Name" : "Feature 1"}
},
{
     "geometry" : {"x" : -100.65, "y" : 33.69},
     "attributes" : {"Id" : 67, "Name" : "Feature 2"}
}
]
} 

The first thing you'll want to do is convert it to IGeometry. If your using C#, you may find this this NicoGIS favorite helpful for converting a json geometry to IGeometry. http://nicogis.blogspot.com/search/label/SOE

public IGeometry ConvertAnyJsonGeometry(JsonObject jsonObjectGeometry)
    {
        object[] objArray;

        if (jsonObjectGeometry.TryGetArray("rings", out objArray))
        {
            return Conversion.ToGeometry(jsonObjectGeometry, esriGeometryType.esriGeometryPolygon);
        }

        if (jsonObjectGeometry.TryGetArray("paths", out objArray))
        {
            return Conversion.ToGeometry(jsonObjectGeometry, esriGeometryType.esriGeometryPolyline);
        }

        if (jsonObjectGeometry.TryGetArray("points", out objArray))
        {
            return Conversion.ToGeometry(jsonObjectGeometry, esriGeometryType.esriGeometryMultipoint);
        }

        try
        {
            return Conversion.ToGeometry(jsonObjectGeometry, esriGeometryType.esriGeometryPoint);
        }
        catch
        {
            try
            {
                return Conversion.ToGeometry(jsonObjectGeometry, esriGeometryType.esriGeometryEnvelope);
            }
            catch
            {
                return null;
            }
        }
    }  

I included this one in an SOE post with some other helpful SOE snippets: http://bcdcspatial.blogspot.com/search/label/Server%20Object%20Extensions

  • right now the way it is, the format is {"x" : -113, "y" : 37} If I just add {Geometry:{{"x" : -113, "y" : 37},{"x" : -109, "y" : 37}}, then it errors out. the json string looks like this "{\"x\":-113,\"y\":37}", it ignores the second set of x and y values. My soe is similar to FindNearFeatures samples provided by esri. I am trying to modify it to accept more than single set x,y value. – user23484 Oct 31 '13 at 5:41
  • what is the error? – bcollins Oct 31 '13 at 13:58

Not the answer you're looking for? Browse other questions tagged or ask your own question.