How can I get the feature withn a service area?

1000
8
03-26-2012 04:02 AM
ShreyPrasad
New Contributor
hi,

  I am able to create the service area using REST, but now I want to get all the feature, from all the feature layers , which are covered in that Service area. After getting those feature also want to export the feature to a shape file.

Any help on this will be appreciated.

Thanks
0 Kudos
8 Replies
nicogis
MVP Frequent Contributor
A solution is creating a gp that it creates two output a service area (you draw on client) and zip file with shapefile. Then you call from client gp.
0 Kudos
ShreyPrasad
New Contributor
A solution is creating a gp that it creates two output a service area (you draw on client) and zip file with shapefile. Then you call from client gp.


ciava.at
Thank for the reply.But I was using SOE for the same. But while passingthe the polygon XY to the REST(vertices more than 50 ) it was showing error No 404. If i send less vertices, say10 ,&  then intersecting the service area polygon with the desired feature class  to get the features out of it, I am not getting any features.

can you please guide me on this
0 Kudos
nicogis
MVP Frequent Contributor
for error when you call 'more than 50' do you use in esri.request option: usePost?
var requestHandle = esri.request({ 
    url: url.path, 
    content: url.query, 
   ..
 }, {usePost:true});



for intersect: can you post part of code for soe or give me futher details what do you do in soe?
0 Kudos
ShreyPrasad
New Contributor
for error when you call 'more than 50' do you use in esri.request option: usePost?
var requestHandle = esri.request({ 
    url: url.path, 
    content: url.query, 
   ..
 }, {usePost:true});



for intersect: can you post part of code for soe or give me futher details what do you do in soe?


Thanks ciava


Below is the code which I am using hope that will  be sufficent for you.



//For Javascript
function ProcessCluster(TempServicePoly) {
      var i = 0;
      var PolygonText = "";
      if (TempServicePoly != null) {
          GlobalGeom = TempServicePoly;
          for (i = 0; i < GlobalGeom.geometry.rings[0].length; i++) {
              PolygonText += GlobalGeom.geometry.rings[0][0] + "," + GlobalGeom.geometry.rings[0][1] + "|";
          }
         
         
        //  alert(PolygonText);
               var content = {
              //'text':  point.x + " " + point.y,
              'text': PolygonText,
              'f': "json"
          };
          // Do the SOE query.



          esri.request({
              url: soeURL,
              content: content,
               usePost: true,
              callbackParamName: "callback",
              load: function(response) {
                  listFeatureDetails(response);
                
              },
              error: function(error) {
                  console.log(error);
              }
          });
      }
  }
-----------------------------------------------------------
//SOE Code


        private byte[] ServiceAreaIntersectHandler(System.Collections.Specialized.NameValueCollection boundVariables,
        ESRI.ArcGIS.SOESupport.JsonObject operationInput,
        string outputFormat,
        string requestProperties,
        out string responseProperties)
        {

            object missing = Type.Missing;


            responseProperties = null;

            // Deserialize location
            string Polygonstring;
            if (!operationInput.TryGetString("text", out Polygonstring))
                throw new ArgumentNullException("text");
            IPointCollection pPolygonofPoints = new PolygonClass();
            string[] pointarray = Polygonstring.TrimEnd('|').Split('|');
            for (int i = 0; i < pointarray.Length; i++)
            {
                if (pointarray.Trim() != "")
                {
                    IPoint pPoint = new PointClass();
                    pPoint.X = Convert.ToDouble(pointarray.Split(',')[0]);
                    pPoint.Y = Convert.ToDouble(pointarray.Split(',')[1]);
                    pPolygonofPoints.AddPoint(pPoint, ref missing, ref missing);
                }

            }
            IPolygon QueryPolygon = pPolygonofPoints as IPolygon;


            if (QueryPolygon == null)
                throw new ArgumentException("SpatialQuerySOEREST: invalid QueryPolygon", "QueryPolygon");


            IMapServer3 mapServer = (IMapServer3)serverObjectHelper.ServerObject;
            string mapName = mapServer.DefaultMapName;


                       IMapServerDataAccess dataAccess = (IMapServerDataAccess)mapServer;

            // Get access to the source feature class
            m_fcToQuery = (IFeatureClass)dataAccess.GetDataSource(mapName, 0);
         
                      clsServiceAreaIntsection objclsServiceAreaIntsection = new clsServiceAreaIntsection();
            string outFeatureString = objclsServiceAreaIntsection.ReturnSelectedFeatures(QueryPolygon,m_fcToQuery,out ValidateString);
                       
          


                     JsonObject resultJsonObject = new JsonObject();
                   resultJsonObject.AddString("OutputVal", outFeatureString);

            // Get byte array of json and return results
            byte[] result = Encoding.UTF8.GetBytes(resultJsonObject.ToJson());
            return result;
        }
----------------------------------------------

//SOE Class Code
   public string ReturnSelectedFeatures(IPolygon Poly, IFeatureClass pQueryFC, out string ValidationStatus)
        {

            string outReturnString = string.Empty;
            ValidationStatus = string.Empty;
            ITopologicalOperator pTopoLogicalOpt = null;
            ISpatialFilter pSF = new SpatialFilterClass();
            IFeature pFeature = null;
            string ValueStroe = string.Empty;
            string CurrentOID = string.Empty; 
            string Building_Name = string.Empty; 
            try
            {
                pSF.Geometry = Poly;
                pSF.SpatialRel = ESRI.ArcGIS.Geodatabase.esriSpatialRelEnum.esriSpatialRelIntersects;
                IFeatureCursor resultsFeatureCursor = pQueryFC.Search(pSF, true);
                pFeature = resultsFeatureCursor.NextFeature();           <-------// Always this feature is null
                while (pFeature != null)
                {
                    CurrentOID = pFeature.get_Value(pFeature.Fields.FindField("OBJECTID")).ToString().Trim();
                    Building_Name = pFeature.get_Value(pFeature.Fields.FindField("Building_n")).ToString().Trim();
                    ValueStroe = CurrentOID + "," + Building_Name + "|" + ValueStroe;
                    pFeature = resultsFeatureCursor.NextFeature();
                }

                outReturnString = ValueStroe;
                return outReturnString;
            }
            catch (Exception ex)
            {
                return ex.ToString();
                throw ex;
            }
        }


--------------------------
Can i directly pass the Feature to SOE in form of JSON and convert that JSON to the Feature in SOE ..?


After using the {USEPOST:TRUE }then also the result is same..
0 Kudos
nicogis
MVP Frequent Contributor
usePost is in options parameter, not in request: (see http://help.arcgis.com/en/webapi/javascript/arcgis/help/jsapi/namespace_esri.htm)

esri.request({
url: soeURL,
content: content,
callbackParamName: "callback",
load: function(response) {
listFeatureDetails(response);
},
error: function(error) {
console.log(error);
}
}, {usePost: true});


From soe you can serialize polygon (arcobjects) and send to client deserialized (json):

JsonObject jsonPolygon;
            if (!operationInput.TryGetJsonObject("myNameParameter", out jsonPolygon))
                throw new ArgumentNullException("myNameParameter");
            //deserialize
            IPolygon pg= Conversion.ToGeometry(jsonPoint, esriGeometryType.esriGeometryPolygon) as IPolygon;
....

            //serialize polygon (for example)
            JsonObject jsonObjectGeometry = Conversion.ToJsonObject(myPolygon);
            
            JsonObject resultJsonObject = new JsonObject();
            resultJsonObject.AddJsonObject("geometry", jsonObjectGeometry);
            ...

            // Get byte array of json and return results
            byte[] result = Encoding.UTF8.GetBytes(resultJsonObject.ToJson());
            return result;


            



from client send polygon in esri.request
    var polygon = dojo.toJson(mygeometry.toJson())


from client deserialize polygon
    var polygon = new esri.geometry.Polygon(polygonJson); 
0 Kudos
ShreyPrasad
New Contributor
Tried using  the thing you suggested but still the 404 page not found, service unavailable is continuing. Whenever I try to send small feature in SOE it is showing the following error "Unable to load /arcgisserver/apis/javascript/proxy/proxy.ashx?http://XX.XX.XX.XX/ArcGIS/rest/services/Page_Laout_Test/MapServer/exts/SimpleRESTSOE/(FunctionName) status:12031. and if i directly put the values on the REST endpoint it is howing the following message


{
  "error" :
  {
    "code" : 500,
    "message" : "An unexpected error occurred processing the request.",
    "details" : []
  }
}
0 Kudos
nicogis
MVP Frequent Contributor
you try debugging the soe.
- start service with soe capabilites
- in vs set a break point and attach process to soc managed ( see debugging soes http://help.arcgis.com/en/sdk/10.0/arcobjects_net/conceptualhelp/0001/0001000009st000000.htm )
-run code javascript
-in .net the execution stop in break point
0 Kudos
ShreyPrasad
New Contributor
How can  I debug the application from the Javascript . I tried to put  breakpoint in the SOE but of no use. Currently whenever i am running the application I am getting the following error inthe javascript code. "Unable to load /arcgisserver/apis/javascript/proxy/proxy.ashx?http://XX.XX.XX.XX/ArcGIS/rest/services/Test/MapServer/exts/SimpleRESTSOE/Generation status:12030" - this is when I am going through the Javascript page . I am not able to debug the SOE. How can I do it I have tried many time but it was of no use.
0 Kudos