Exemplo n.º 1
0
        private byte[] GetFeaturesOperHandler(NameValueCollection boundVariables,
                                              JsonObject operationInput,
                                              string outputFormat,
                                              string requestProperties,
                                              out string responseProperties)
        {
            responseProperties = null;

            JsonObject joConn;
            bool       found = operationInput.TryGetJsonObject("connectionString", out joConn);

            if (!found || joConn == null)
            {
                throw new ArgumentNullException("connectionString");
            }

            JsonObject joFC;

            found = operationInput.TryGetJsonObject("featureClass", out joFC);
            if (!found || joFC == null)
            {
                throw new ArgumentNullException("featureClass");
            }

            JsonObject joFilter;

            found = operationInput.TryGetJsonObject("filterWhere", out joFilter);
            if (!found || joFilter == null)
            {
                throw new ArgumentNullException("filterWhere");
            }

            JsonObject result = new JsonObject();

            ConnectionJSObject   connJsObj = ParamsParser.ParseConn(joConn);
            FeatureClassJSObject fcObj     = ParamsParser.ParseFeatrureClass(joFC);
            FilterWhereJSObject  filterObj = ParamsParser.ParseFilterWhere(joFilter);

            List <FeatureObject> features;
            string         outMsg = string.Empty;
            FeaturesHelper helper = new FeaturesHelper();

            features = helper.GetFeatures(connJsObj, fcObj, filterObj, out outMsg);
            List <JsonObject> featureList = new List <JsonObject>();

            foreach (FeatureObject fo in features)
            {
                JsonObject jo = new JsonObject();
                jo.AddArray("attributes", fo.attributes.ToArray());
                jo.AddJsonObject("geometry", Conversion.ToJsonObject(fo.geometry));
                featureList.Add(jo);
            }
            result.AddArray("features", featureList.ToArray());
            result.AddString("outMsg", outMsg);

            return(Encoding.UTF8.GetBytes(result.ToJson()));
        }