/// <summary> /// create service type MapServer /// </summary> /// <returns>>True if successfully created</returns> public bool CreateService() { try { String token = this.GenerateAGSToken(); string serviceUrl = this.urlRestAdmin + "/ services / create service"; JsonObject jsonObject = new JsonObject(); jsonObject.AddString("serviceName", "Test"); jsonObject.AddString("type", Enum.GetName(typeof(ServiceType)ServiceType.MapServer)); jsonObject.AddString("description", "This is an example"); jsonObject.AddString("capabilities", "Map, Query, Data"); jsonObject.AddString("ClusterName", "default"); jsonObject.AddLong("minInstancesPerNode", 1); jsonObject.AddLong("maxInstancesPerNode", 2); jsonObject.AddLong("maxWaitTime", 60); jsonObject.AddLong("maxStartupTime", 300); jsonObject.AddLong("MaxIdleTime", 1800); jsonObject.AddLong("maxUsageTime", 600); jsonObject.AddLong("recycleInterval", 24); jsonObject.AddString("loadBalancing", Enum.GetName(typeof(LoadBalancing)LoadBalancing.ROUND_ROBIN)); jsonObject.AddString("isolationLevel", Enum GetName(.typeof(IsolationLevel) IsolationLevel HIGH).) JsonObject jsonObjectProperties = new JsonObject(); // see for a list complete http://resources.arcgis.com/en/help/server-admin-api/serviceTypes.html jsonObjectProperties.AddLong("maxBufferCount", 100); // optional 100 jsonObjectProperties.AddString("virtualCacheDir", this.urlRestServer + "/arcgiscache"); // optional jsonObjectProperties.AddLong("maxImageHeight", 2048); // optional 2048 jsonObjectProperties.AddLong("maxRecordCount", 1000); // optional 500 // Starting at ArcGIS 10.1, Map Server Definition ( .msd ) files have been // replaced with Service Definition Draft ( .sddraft ) and Service Definition ( .sd ) files. // In the case of a map service, you must specify a map service definition (MSD) file in your JSON. // This file synthesizes information from your ArcMap document (MXD) in a format that can be understood and // drawn by ArcGIS Server. You must use the arcpy.mapping module to analyze your map and create the MSD before // you can go ahead with creating the service. This part requires a machine licensed for ArcGIS for Desktop. // Other service types do not require you to use arcpy.mapping or create an MSD. jsonObjectProperties.AddString("filePath", @"C:\AvGis\Test\mappa\UTM_ReteFognaria.msd"); // required jsonObjectProperties.AddLong("maxImageWidth", 2048); // optional 2048 jsonObjectProperties.AddBoolean("cacheOnDemand", false); // optional false jsonObjectProperties.AddString("virtualOutputDir", this.urlRestServer + "/arcgisoutput"); jsonObjectProperties.AddString("outputDir", @ "C: \ arcgisserver \ directories \ arcgisoutput") / / required jsonObjectProperties.AddString("supportedImageReturnTypes", "MIME + URL"), / / optional MIME + URL jsonObjectProperties.AddBoolean(" isCached ", false) / / false optional jsonObjectProperties.AddBoolean("ignoreCache", false) / / false optional jsonObjectProperties.AddBoolean("clientCachingAllowed", false) / / optional true jsonObjectProperties.AddString("Cached", @ " C: \ arcgisserver \ directories \ arcgiscache ") / / optional jsonObject.AddJsonObject("properties", jsonObjectProperties); String result = this.GetResult(serviceUrl, "service =" + HttpUtility.UrlEncode(jsonObject.ToJson()) + "& f = json & token =" + token) return(this.HasSuccess(result)); } catch { return(false); } }
private void button_Click(object sender, RoutedEventArgs e) { JsonObject jo = new JsonObject(); try { jo.AddString("host", textBoxHost.Text != "" ? textBoxHost.Text : "127.0.0.1"); jo.AddLong("port", textBoxPort.Text != "" ? long.Parse(textBoxPort.Text) : 27017); jo.AddString("db", textBoxDBName.Text != "" ? textBoxDBName.Text : "torrents"); jo.AddString("user", textBoxUser.Text != "" ? textBoxUser.Text : ""); jo.AddString("pwd", textBoxPassword.Text != "" ? textBoxPassword.Text : ""); jo.AddLong("threadnum", (comboBox.SelectedIndex + 1) * 4); jo.AddString("server", textBoxServer.Text != "" ? textBoxServer.Text : "http://www.ac168.info/bt/"); jo.AddString("target", textBoxTarget.Text != "" ? textBoxTarget.Text : "http://www.ac168.info/bt/thread.php?fid=4&page={0}"); jo.AddString("tor_server", textBoxTorServer.Text != "" ? textBoxTorServer.Text : "http://www.jandown.com/fetch.php"); jo.AddString("save_type", textBoxSaveType.Text != "" ? textBoxSaveType.Text : "db"); jo.AddString("path", textBoxPath.Text != "" ? textBoxPath.Text : "G:\\迅雷下载\\Torrents\\"); jo.AddString("list_identify", textBoxListIdentify.Text != "" ? textBoxListIdentify.Text : "class"); jo.AddString("list_type", textBoxListType.Text != "" ? textBoxListType.Text : "tr"); jo.AddString("list_identify_text", textBoxListIdentifyText.Text != "" ? textBoxListIdentifyText.Text : "tr3 t_one"); jo.AddString("list_element", textBoxListElement.Text != "" ? textBoxListElement.Text : "dd"); jo.AddString("content_identify", textBoxContentIdentify.Text != "" ? textBoxContentIdentify.Text : "class"); jo.AddString("content_type", textBoxContentType.Text != "" ? textBoxContentType.Text : "div"); jo.AddString("content_identify_text", textBoxContentIdentifyText.Text != "" ? textBoxContentIdentifyText.Text : "tpc_content"); StreamWriter sw = new StreamWriter("Config.json", false); sw.Write(jo.ToJson()); sw.Flush(); sw.Close(); } catch { } this.Close(); }
/// <summary> /// convert the current instance in JsonObject /// </summary> /// <returns>object JsonObject</returns> public JsonObject ToJsonObject() { byte[] bytes = Conversion.ToJson(this.Extent); JsonObject jo = new JsonObject(Encoding.UTF8.GetString(bytes)); if (!jo.Exists("spatialReference")) { if (this.SpatialReference.FactoryCode == 0) { jo.AddString("spatialReference", this.SpatialReference.Name); } else { jo.AddLong("spatialReference", (long)this.SpatialReference.FactoryCode); } } JsonObject jsonObjectGeometricNetworkInfo = new JsonObject(); jsonObjectGeometricNetworkInfo.AddString("name", this.Name); jsonObjectGeometricNetworkInfo.AddLong("id", (long)this.ID); jsonObjectGeometricNetworkInfo.AddJsonObject("extent", jo); INetSchema netSchema = (INetSchema)this.GeometricNetwork.Network; INetWeight netWeight; List <JsonObject> weights = new List <JsonObject>(); for (int i = 0; i < netSchema.WeightCount; i++) { netWeight = netSchema.get_Weight(i); JsonObject weight = new JsonObject(); weight.AddLong("id", (long)netWeight.WeightID); weight.AddString("name", netWeight.WeightName); weight.AddString("type", Enum.GetName(typeof(esriWeightType), netWeight.WeightType)); weight.AddLong("bitGateSize", (long)netWeight.BitGateSize); List <JsonObject> weightAssociation = new List <JsonObject>(); IEnumNetWeightAssociation enumNetWeightAssociation = netSchema.get_WeightAssociations(netWeight.WeightID); INetWeightAssociation netWeightAssociation = enumNetWeightAssociation.Next(); while (netWeightAssociation != null) { JsonObject jsonObjectNetWeightAssociation = new JsonObject(); jsonObjectNetWeightAssociation.AddString("fieldName", netWeightAssociation.FieldName); jsonObjectNetWeightAssociation.AddString("tableName", netWeightAssociation.TableName); weightAssociation.Add(jsonObjectNetWeightAssociation); netWeightAssociation = enumNetWeightAssociation.Next(); } weight.AddArray("weightAssociation", weightAssociation.ToArray()); weights.Add(weight); } jsonObjectGeometricNetworkInfo.AddArray("weights", weights.ToArray()); return(jsonObjectGeometricNetworkInfo); }
public JsonObject ToJsonObject() { JsonObject result = new JsonObject(); result.AddString("name", Name); result.AddLong("id", ID); IRasterProps props = Raster as IRasterProps; result.AddLong("rows", props.Width); result.AddLong("columns", props.Height); result.AddJsonObject("extent", Conversion.ToJsonObject(props.Extent)); return result; }
/// <summary> /// convert the current instance in JsonObject /// </summary> /// <returns>object JsonObject</returns> public JsonObject ToJsonObject() { byte[] bytes = Conversion.ToJson(this.Extent); JsonObject jo = new JsonObject(Encoding.UTF8.GetString(bytes)); IEnvelope envelope = this.Extent; if (!jo.Exists("spatialReference")) { if (envelope.SpatialReference.FactoryCode == 0) { jo.AddString("spatialReference", envelope.SpatialReference.Name); } else { jo.AddLong("spatialReference", (long)envelope.SpatialReference.FactoryCode); } } JsonObject jsonObjectRouteLayerInfo = new JsonObject(); jsonObjectRouteLayerInfo.AddString("name", this.Name); jsonObjectRouteLayerInfo.AddLong("id", (long)this.Id); jsonObjectRouteLayerInfo.AddJsonObject("extent", jo); return(jsonObjectRouteLayerInfo); }
public JsonObject ToJsonObject() { JsonObject jo = new JsonObject(); jo.AddString("name", Name); jo.AddLong("id", ID); return jo; }
private JsonObject GetErrorResponse(string message) { var error = new JsonObject(); error.AddLong("code", 0); error.AddString("message", message); var response = new JsonObject(); response.AddJsonObject("error", error); return(response); }
public JsonObject ToJsonObject() { byte[] jsonBytes = Conversion.ToJson((IGeometry)this.Extent); JsonObject env = new JsonObject(Encoding.UTF8.GetString(jsonBytes)); JsonObject jo = new JsonObject(); jo.AddString("name", Name); jo.AddLong("id", ID); jo.AddJsonObject("extent", env); return jo; }
public JsonObject ToJsonObject() { byte[] jsonBytes = Conversion.ToJson((IGeometry)this.Extent); JsonObject env = new JsonObject(Encoding.UTF8.GetString(jsonBytes)); JsonObject jo = new JsonObject(); jo.AddString("name", Name); jo.AddLong("id", ID); jo.AddJsonObject("extent", env); return(jo); }
private byte[] PropertiesResHandler(NameValueCollection boundVariables, string outputFormat, string requestProperties, out string responseProperties) { responseProperties = "{\"Content-Type\" : \"application/json\"}"; JsonObject result = new JsonObject(); result.AddString("layers", this.layerType); result.AddString("returnFormat", this.returnFormat); result.AddLong("maxNumFeatures", this.maxNumFeatures); result.AddBoolean("isEditable", this.isEditable); return(Encoding.UTF8.GetBytes(result.ToJson())); }
private byte[] DeleteFeaturesOperHandler(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 can not parse to jsonobject"); } JsonObject joFC; found = operationInput.TryGetJsonObject("featureClass", out joFC); if (!found || joFC == null) { throw new ArgumentNullException("featureClass can not parse to jsonobject"); } JsonObject joFilter; found = operationInput.TryGetJsonObject("filterWhere", out joFilter); if (!found || joFilter == null) { throw new ArgumentNullException("filterWhere can not parse to jsonobject"); } JsonObject result = new JsonObject(); ConnectionJSObject connJsObj = ParamsParser.ParseConn(joConn); FeatureClassJSObject fcObj = ParamsParser.ParseFeatrureClass(joFC); FilterWhereJSObject filterObj = ParamsParser.ParseFilterWhere(joFilter); bool isok = false; int count = 0; string outMsg = string.Empty; FeaturesHelper helper = new FeaturesHelper(); isok = helper.DeleteFeatures(connJsObj, fcObj, filterObj, out count, out outMsg); result.AddBoolean("isSucess", isok); result.AddLong("recordCount", count); result.AddString("outMsg", outMsg); return(Encoding.UTF8.GetBytes(result.ToJson())); }
/// <summary> /// Convert to JsonObject /// </summary> /// <returns>return JsonObject of instance</returns> public JsonObject ToJsonObject() { JsonObject jsonObject = new JsonObject(); jsonObject.AddLong("id", this.MapLayerInfo.ID); jsonObject.AddString("name", this.MapLayerInfo.Name); jsonObject.AddString("type", this.MapLayerInfo.Type); JsonObject env = Conversion.ToJsonObject((IGeometry)this.MapLayerInfo.Extent, true); jsonObject.AddJsonObject("full extent", env); jsonObject.AddString("description", this.MapLayerInfo.Description); return(jsonObject); }
private byte[] DescribeLayersHandler(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties) { responseProperties = null; JsonObject tResult = new JsonObject(); tResult.AddLong("AvailableLayerCount", m_ExtractableParams.Count); JsonObject tLayersJson = new JsonObject(); foreach (ExtractionLayerConfig layer in m_ExtractableParams){ //int id = layer.LayerID; string lyrName = layer.LayerName; string requestParameter = layer.ParamName; string extractionType = layer.ExtractionType.ToString(); JsonObject tLayerJson = new JsonObject(); //tLayerJson.AddLong("LayerId", id); tLayerJson.AddString("LayerName",lyrName); tLayerJson.AddString("LayerDescription", layer.LayerDescription); tLayerJson.AddString("ExtractionType", extractionType); if (layer.HasCategories) { IFeatureClass tLayerAsFc = (IFeatureClass)layer.LayerDataset; string tCatName = tLayerAsFc.Fields.get_Field(layer.CategoryField).Name; tLayerJson.AddString("CategoryField", tCatName); } tLayersJson.AddObject(requestParameter,tLayerJson); } tResult.AddObject("Extractions", tLayersJson); byte[] tOutput = System.Text.Encoding.UTF8.GetBytes(tResult.ToJson()); return tOutput; }
private JsonObject GetErrorResponse(string message) { var error = new JsonObject(); error.AddLong("code", 0); error.AddString("message", message); var response = new JsonObject(); response.AddJsonObject("error", error); return response; }
/// <summary> /// Build Meta Info /// </summary> private void BuildMeta() { IFeatureClass fc_poi = m_fcName.Open() as IFeatureClass; IGeoDataset ds_poi = fc_poi as IGeoDataset; int xmin = (int)Math.Floor(ds_poi.Extent.XMin); int ymin = (int)Math.Floor(ds_poi.Extent.YMin); int xmax = (int)Math.Ceiling(ds_poi.Extent.XMax); int ymax = (int)Math.Ceiling(ds_poi.Extent.YMax); int size = int.Parse(this.tbxSize.Text); int step = (int)Math.Ceiling((xmax - xmin) * 1.0 / size); string ns = "poi:" + this.tbxCacheName.Text + ":"; IDatabase client = m_redis.GetDatabase(); client.StringSet(ns + "size", size.ToString()); client.StringSet(ns + "xmin", xmin.ToString()); client.StringSet(ns + "ymin", ymin.ToString()); client.StringSet(ns + "xmax", xmax.ToString()); client.StringSet(ns + "ymax", ymax.ToString()); client.StringSet(ns + "step", step.ToString()); JsonObject response = new JsonObject(); List<JsonObject> ls_fields_cache = new List<JsonObject>(); for (int i = 0; i < fc_poi.Fields.FieldCount; i++) { IField field = fc_poi.Fields.get_Field(i); JsonObject js_f = new JsonObject(); js_f.AddString("name", field.Name); js_f.AddString("type", Enum.GetName(typeof(esriFieldType), field.Type)); js_f.AddString("alias", field.AliasName); if (field.Type == esriFieldType.esriFieldTypeString) { js_f.AddString("length", field.Length.ToString()); } else { js_f.AddString("length", ""); } ls_fields_cache.Add(js_f); } response.AddArray("fields", ls_fields_cache.ToArray()); if (fc_poi.ShapeType == esriGeometryType.esriGeometryPoint) { response.AddString("geometryType", "esriGeometryPoint"); } else if (fc_poi.ShapeType == esriGeometryType.esriGeometryPolyline) { response.AddString("geometryType", "esriGeometryPolyline"); } else if (fc_poi.ShapeType == esriGeometryType.esriGeometryPolygon) { response.AddString("geometryType", "esriGeometryPolygon"); } IGeoDataset gds_poi = fc_poi as IGeoDataset; JsonObject js_sr = new JsonObject(); js_sr.AddLong("wkid", gds_poi.SpatialReference.FactoryCode); response.AddJsonObject("spatialReference", js_sr); client.StringSet(ns + "response", response.ToJson()); client.SetAdd("poi:caches", this.tbxCacheName.Text); }
/// <summary> /// Build Cache Backgroud worker /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { int size = int.Parse(this.tbxSize.Text); IFeatureClass fc_poi = m_fcName.Open() as IFeatureClass; IGeoDataset ds_poi = fc_poi as IGeoDataset; int xmin = (int)Math.Floor(ds_poi.Extent.XMin); int ymin = (int)Math.Floor(ds_poi.Extent.YMin); int xmax = (int)Math.Ceiling(ds_poi.Extent.XMax); int ymax = (int)Math.Ceiling(ds_poi.Extent.YMax); List<JsonObject> ls_fields_cache = new List<JsonObject>(); if(!(fc_poi.Extension is IAnnotationClassExtension)) { for (int i = 0; i < fc_poi.Fields.FieldCount; i++) { IField field = fc_poi.Fields.get_Field(i); JsonObject js_f = new JsonObject(); js_f.AddString("name", field.Name); js_f.AddString("type", Enum.GetName(typeof(esriFieldType), field.Type)); js_f.AddString("alias", field.AliasName); if (field.Type == esriFieldType.esriFieldTypeString) { js_f.AddString("length", field.Length.ToString()); } else { js_f.AddString("length", ""); } ls_fields_cache.Add(js_f); } } IDatabase client = m_redis.GetDatabase(); int grid_id=0; string ns = "poi:" + this.tbxCacheName.Text+":"; for (int y = ymin; y <= ymax; y += size) { for (int x = xmin; x <= xmax; x += size) { List<String> str_poi_grid = new List<String>(); List<JsonObject> ls_features = new List<JsonObject>(); //String str_response = client.StringGet(ns+"response"); //JsonObject response = new JsonObject(str_response); JsonObject response = new JsonObject(); IEnvelope box = new EnvelopeClass(); box.XMin = x ; box.YMin = y ; box.XMax = x +size; box.YMax = y +size; ISpatialFilter filter_poi = new SpatialFilterClass(); filter_poi.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; filter_poi.Geometry = box; filter_poi.SubFields = "*"; IFeatureCursor cur_poi = fc_poi.Search(filter_poi, true); IFeature fea_poi = cur_poi.NextFeature(); while (fea_poi != null) { JsonObject js_fea = new JsonObject(); if (!(fea_poi is IAnnotationFeature)) { JsonObject js_attributes = new JsonObject(); int i = 0; foreach (JsonObject js_field in ls_fields_cache) { object value = fea_poi.get_Value(i); string fieldtype; js_field.TryGetString("type", out fieldtype); string fieldname; js_field.TryGetString("name", out fieldname); #region if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeString)) { js_attributes.AddString(fieldname, value.ToString()); } else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeOID)) { js_attributes.AddLong(fieldname, long.Parse(value.ToString())); } else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeInteger)) { if (value.ToString() == "") { value = 0; } js_attributes.AddLong(fieldname, long.Parse(value.ToString())); } else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeSmallInteger)) { if (value.ToString() == "") { value = 0; } js_attributes.AddLong(fieldname, long.Parse(value.ToString())); } else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeDouble)) { if (value.ToString() == "") { value = 0; } js_attributes.AddDouble(fieldname, double.Parse(value.ToString())); } else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeDate)) { if (value.ToString() == "") { value = DateTime.MinValue; } js_attributes.AddDate(fieldname, DateTime.Parse(value.ToString())); } else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeSingle)) { if (value.ToString() == "") { value = 0; } js_attributes.AddBoolean(fieldname, bool.Parse(value.ToString())); } #endregion i++; } js_fea.AddJsonObject("attributes", js_attributes); js_fea.AddJsonObject("geometry", Conversion.ToJsonObject(fea_poi.Shape)); } else { IAnnotationFeature anno_fea = fea_poi as IAnnotationFeature; ITextElement ele = anno_fea.Annotation as ITextElement; //string text = ele.Text.Replace(System.Environment.NewLine, " "); string text = ele.Text; ITextSymbol sym = ele.Symbol; IFontDisp font = sym.Font; double symsize = sym.Size; string fontname = font.Name; decimal fontsize = font.Size; string.Format(@"a"":"""); JsonObject js_symbol = new JsonObject( string.Format(@"{{""type"" : ""esriTS"",""color"": [255,255,255],""haloSize"" : 0,""haloColor"" : [255,255,255,0],""verticalAlignment"" : ""bottom"",""horizontalAlignment"" : ""center"",""size"": {0},""angle"": 0,""xoffset"": 0,""yoffset"": 0,""font"" : {{""family"" : ""{2}"",""size"" : {3},""style"" : ""normal"",""weight"" : ""normal"",""decoration"" : ""none""}},""text"":""{1}""}}",symsize,text,fontname,fontsize)); js_fea.AddJsonObject("symbol", js_symbol); IArea pshp = fea_poi.Shape as IArea; js_fea.AddJsonObject("geometry", Conversion.ToJsonObject(pshp.Centroid)); } ls_features.Add(js_fea); fea_poi = cur_poi.NextFeature(); } response.AddArray("features", ls_features.ToArray()); client.StringSet(ns+grid_id.ToString(), response.ToJson()); ReleaseCOMObject(cur_poi); grid_id++; progressBar1.BeginInvoke((Action)(() => { progressBar1.Increment(1); })); } } MessageBox.Show("Build Cache Successfully!"); this.button1.BeginInvoke((Action)(()=> { ListCaches(); this.button1.Enabled = true; })); }
private byte[] PropertiesResHandler(NameValueCollection boundVariables, string outputFormat, string requestProperties, out string responseProperties) { responseProperties = "{\"Content-Type\" : \"application/json\"}"; JsonObject result = new JsonObject(); result.AddString("layers", this.layerType); result.AddString("returnFormat", this.returnFormat); result.AddLong("maxNumFeatures", this.maxNumFeatures); result.AddBoolean("isEditable", this.isEditable); return Encoding.UTF8.GetBytes(result.ToJson()); }
/// <summary> /// Build Cache Backgroud worker /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { int size = int.Parse(this.tbxSize.Text); IFeatureClass fc_poi = m_fcName.Open() as IFeatureClass; IGeoDataset ds_poi = fc_poi as IGeoDataset; int xmin = (int)Math.Floor(ds_poi.Extent.XMin); int ymin = (int)Math.Floor(ds_poi.Extent.YMin); int xmax = (int)Math.Ceiling(ds_poi.Extent.XMax); int ymax = (int)Math.Ceiling(ds_poi.Extent.YMax); List <JsonObject> ls_fields_cache = new List <JsonObject>(); if (!(fc_poi.Extension is IAnnotationClassExtension)) { for (int i = 0; i < fc_poi.Fields.FieldCount; i++) { IField field = fc_poi.Fields.get_Field(i); JsonObject js_f = new JsonObject(); js_f.AddString("name", field.Name); js_f.AddString("type", Enum.GetName(typeof(esriFieldType), field.Type)); js_f.AddString("alias", field.AliasName); if (field.Type == esriFieldType.esriFieldTypeString) { js_f.AddString("length", field.Length.ToString()); } else { js_f.AddString("length", ""); } ls_fields_cache.Add(js_f); } } IDatabase client = m_redis.GetDatabase(); int grid_id = 0; string ns = "poi:" + this.tbxCacheName.Text + ":"; for (int y = ymin; y <= ymax; y += size) { for (int x = xmin; x <= xmax; x += size) { List <String> str_poi_grid = new List <String>(); List <JsonObject> ls_features = new List <JsonObject>(); //String str_response = client.StringGet(ns+"response"); //JsonObject response = new JsonObject(str_response); JsonObject response = new JsonObject(); IEnvelope box = new EnvelopeClass(); box.XMin = x; box.YMin = y; box.XMax = x + size; box.YMax = y + size; ISpatialFilter filter_poi = new SpatialFilterClass(); filter_poi.SpatialRel = esriSpatialRelEnum.esriSpatialRelIntersects; filter_poi.Geometry = box; filter_poi.SubFields = "*"; IFeatureCursor cur_poi = fc_poi.Search(filter_poi, true); IFeature fea_poi = cur_poi.NextFeature(); while (fea_poi != null) { JsonObject js_fea = new JsonObject(); if (!(fea_poi is IAnnotationFeature)) { JsonObject js_attributes = new JsonObject(); int i = 0; foreach (JsonObject js_field in ls_fields_cache) { object value = fea_poi.get_Value(i); string fieldtype; js_field.TryGetString("type", out fieldtype); string fieldname; js_field.TryGetString("name", out fieldname); #region if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeString)) { js_attributes.AddString(fieldname, value.ToString()); } else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeOID)) { js_attributes.AddLong(fieldname, long.Parse(value.ToString())); } else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeInteger)) { if (value.ToString() == "") { value = 0; } js_attributes.AddLong(fieldname, long.Parse(value.ToString())); } else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeSmallInteger)) { if (value.ToString() == "") { value = 0; } js_attributes.AddLong(fieldname, long.Parse(value.ToString())); } else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeDouble)) { if (value.ToString() == "") { value = 0; } js_attributes.AddDouble(fieldname, double.Parse(value.ToString())); } else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeDate)) { if (value.ToString() == "") { value = DateTime.MinValue; } js_attributes.AddDate(fieldname, DateTime.Parse(value.ToString())); } else if (fieldtype == Enum.GetName(typeof(esriFieldType), esriFieldType.esriFieldTypeSingle)) { if (value.ToString() == "") { value = 0; } js_attributes.AddBoolean(fieldname, bool.Parse(value.ToString())); } #endregion i++; } js_fea.AddJsonObject("attributes", js_attributes); js_fea.AddJsonObject("geometry", Conversion.ToJsonObject(fea_poi.Shape)); } else { IAnnotationFeature anno_fea = fea_poi as IAnnotationFeature; ITextElement ele = anno_fea.Annotation as ITextElement; //string text = ele.Text.Replace(System.Environment.NewLine, " "); string text = ele.Text; ITextSymbol sym = ele.Symbol; IFontDisp font = sym.Font; double symsize = sym.Size; string fontname = font.Name; decimal fontsize = font.Size; string.Format(@"a"":"""); JsonObject js_symbol = new JsonObject( string.Format(@"{{""type"" : ""esriTS"",""color"": [255,255,255],""haloSize"" : 0,""haloColor"" : [255,255,255,0],""verticalAlignment"" : ""bottom"",""horizontalAlignment"" : ""center"",""size"": {0},""angle"": 0,""xoffset"": 0,""yoffset"": 0,""font"" : {{""family"" : ""{2}"",""size"" : {3},""style"" : ""normal"",""weight"" : ""normal"",""decoration"" : ""none""}},""text"":""{1}""}}", symsize, text, fontname, fontsize)); js_fea.AddJsonObject("symbol", js_symbol); IArea pshp = fea_poi.Shape as IArea; js_fea.AddJsonObject("geometry", Conversion.ToJsonObject(pshp.Centroid)); } ls_features.Add(js_fea); fea_poi = cur_poi.NextFeature(); } response.AddArray("features", ls_features.ToArray()); client.StringSet(ns + grid_id.ToString(), response.ToJson()); ReleaseCOMObject(cur_poi); grid_id++; progressBar1.BeginInvoke((Action)(() => { progressBar1.Increment(1); })); } } MessageBox.Show("Build Cache Successfully!"); this.button1.BeginInvoke((Action)(() => { ListCaches(); this.button1.Enabled = true; })); }
/// <summary> /// Build Meta Info /// </summary> private void BuildMeta() { IFeatureClass fc_poi = m_fcName.Open() as IFeatureClass; IGeoDataset ds_poi = fc_poi as IGeoDataset; int xmin = (int)Math.Floor(ds_poi.Extent.XMin); int ymin = (int)Math.Floor(ds_poi.Extent.YMin); int xmax = (int)Math.Ceiling(ds_poi.Extent.XMax); int ymax = (int)Math.Ceiling(ds_poi.Extent.YMax); int size = int.Parse(this.tbxSize.Text); int step = (int)Math.Ceiling((xmax - xmin) * 1.0 / size); string ns = "poi:" + this.tbxCacheName.Text + ":"; IDatabase client = m_redis.GetDatabase(); client.StringSet(ns + "size", size.ToString()); client.StringSet(ns + "xmin", xmin.ToString()); client.StringSet(ns + "ymin", ymin.ToString()); client.StringSet(ns + "xmax", xmax.ToString()); client.StringSet(ns + "ymax", ymax.ToString()); client.StringSet(ns + "step", step.ToString()); JsonObject response = new JsonObject(); List <JsonObject> ls_fields_cache = new List <JsonObject>(); for (int i = 0; i < fc_poi.Fields.FieldCount; i++) { IField field = fc_poi.Fields.get_Field(i); JsonObject js_f = new JsonObject(); js_f.AddString("name", field.Name); js_f.AddString("type", Enum.GetName(typeof(esriFieldType), field.Type)); js_f.AddString("alias", field.AliasName); if (field.Type == esriFieldType.esriFieldTypeString) { js_f.AddString("length", field.Length.ToString()); } else { js_f.AddString("length", ""); } ls_fields_cache.Add(js_f); } response.AddArray("fields", ls_fields_cache.ToArray()); if (fc_poi.ShapeType == esriGeometryType.esriGeometryPoint) { response.AddString("geometryType", "esriGeometryPoint"); } else if (fc_poi.ShapeType == esriGeometryType.esriGeometryPolyline) { response.AddString("geometryType", "esriGeometryPolyline"); } else if (fc_poi.ShapeType == esriGeometryType.esriGeometryPolygon) { response.AddString("geometryType", "esriGeometryPolygon"); } IGeoDataset gds_poi = fc_poi as IGeoDataset; JsonObject js_sr = new JsonObject(); js_sr.AddLong("wkid", gds_poi.SpatialReference.FactoryCode); response.AddJsonObject("spatialReference", js_sr); client.StringSet(ns + "response", response.ToJson()); client.SetAdd("poi:caches", this.tbxCacheName.Text); }
private byte[] NetworkTraceHandler(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties) { var watch = System.Diagnostics.Stopwatch.StartNew(); responseProperties = null; string traceTypeStr; bool found = operationInput.TryGetString(TracingDirParameterName, out traceTypeStr); if (!found || string.IsNullOrEmpty(traceTypeStr)) { throw new ArgumentNullException(TracingDirParameterName + " is required"); } traceTypeStr = traceTypeStr.ToUpper(); bool?isUpstream = null; if ("TRACE_UPSTREAM" == traceTypeStr) { isUpstream = true; } else if ("TRACE_DOWNSTREAM" == traceTypeStr) { isUpstream = false; } if (false == isUpstream.HasValue) { throw new ArgumentException("Not valid Trace_Task_type"); } long?outEPSG; found = operationInput.TryGetAsLong(OutputEPSGParameterName, out outEPSG); if (!found || !outEPSG.HasValue || outEPSG <= 0) { throw new ArgumentNullException(OutputEPSGParameterName + " is required"); } if (outEPSG < 1) { throw new ArgumentException(OutputEPSGParameterName + " is not valid"); } JsonObject flagJSON = null; object[] flagArray = null; JsonObject[] flagJsonArray = null; if (false == operationInput.TryGetJsonObject(FlagParameterName, out flagJSON) || null == flagJSON) { throw new ArgumentNullException(FlagParameterName + " is required"); } if (flagJSON.TryGetArray("features", out flagArray)) { try { flagJsonArray = flagArray.Cast <JsonObject>().ToArray(); } catch { throw new ArgumentException("invalid Flags json format"); } } //Found the flag List <int> ftrList = null; if (null != flagJsonArray && 1 == flagJsonArray.Length) { JsonObject flagFeature = null; if (flagJsonArray[0].TryGetJsonObject("geometry", out flagFeature)) { if (null == flagFeature) { throw new ArgumentException("invalid Flags json format with geometry"); } double? x, y; long? epsg; JsonObject srsObj; if (true == flagFeature.TryGetJsonObject("spatialReference", out srsObj)) { if (false == srsObj.TryGetAsLong("wkid", out epsg) || epsg <= 0) { throw new ArgumentException("No valid wikd found for flag feature."); } } else { throw new ArgumentException("No spatial reference found for flag feature."); } if (flagFeature.TryGetAsDouble("x", out x) && flagFeature.TryGetAsDouble("y", out y)) { if (!x.HasValue || !y.HasValue) { throw new ArgumentException("invalid Flag coordinate"); } IPoint pnt1 = new PointClass(); pnt1.X = x.Value; pnt1.Y = y.Value; IGeometryArray pntArr1 = new GeometryArrayClass(); pntArr1.Add(pnt1); IGeometryArray geomArr = AOUtilities.TransfromGeometriesFrom2((uint)epsg, (uint)this.m_networkEPSG, pntArr1); if (null == geomArr || 1 != geomArr.Count) { throw new ArgumentException("invalid Flag coordinate for reprojection"); } pnt1 = geomArr.get_Element(0) as IPoint; StartFlagEdge flag = NetworkHelper.GetStartFlagEdge(this.m_networkContext, pnt1.X, pnt1.Y, TracingSOE.m_searchDistance, TracingSOE.m_searchTolerance, FlowLineName, this.m_flowDirFieldIndex, InvalidFlowDirValue, logger); StopperJunctions stoppers = null; if (null != flag) { List <IPoint> barrierPnts = null; JsonObject barriersJSON = null; object[] barrierArray = null; JsonObject[] barrierJsonArray = null; if (true == operationInput.TryGetJsonObject(BarrierParameterName, out barriersJSON) || null != barriersJSON) { if (barriersJSON.TryGetArray("features", out barrierArray)) { try { barrierJsonArray = barrierArray.Cast <JsonObject>().ToArray(); barrierPnts = ParseVirtualBarriers(barrierJsonArray, (uint)epsg); } catch { throw new ArgumentException("invalid Barriers json format"); } } if (null != barrierPnts && barrierPnts.Count > 0) { stoppers = NetworkHelper.GetStoppers(this.m_networkContext, barrierPnts, isUpstream.Value, TracingSOE.m_searchDistance, TracingSOE.m_searchTolerance, FlowLineName, JunctionName, logger); } } } ftrList = AOUtilities.StreamTrace(this.m_networkContext.GeometricNetwork, flag, this.m_disabledFeatureClassIDs, stoppers, isUpstream.Value, this.m_maxFeatureCount, logger); } } } IRecordSet records = null; if (null != ftrList && ftrList.Count > 0) { records = AOUtilities.GetRecordSetFromFeatureClass(this.m_networkContext.GetEdgeFeatureClassByAliasName(FlowLineName), ftrList, this.m_outputFields, (uint)outEPSG.Value); } JsonObject result = new JsonObject(); if (null != records) { result.AddJsonObject("value", new JsonObject(System.Text.Encoding.UTF8.GetString(Conversion.ToJson(records)))); } else { result.AddString("output", "{}"); } watch.Stop(); this.logger.LogMessage(ServerLogger.msgType.debug, "NetworkTraceHandler", 973, "Tracing taked: " + watch.ElapsedMilliseconds.ToString() + " ms"); result.AddLong("time(ms)", watch.ElapsedMilliseconds); return(Encoding.UTF8.GetBytes(result.ToJson())); }
private byte[] PostData(NameValueCollection boundVariables, JsonObject operationInput, string outputFormat, string requestProperties, out string responseProperties) { responseProperties = null; string userID; bool found = operationInput.TryGetString("userID", out userID); if (!found || string.IsNullOrEmpty(userID)) throw new ArgumentNullException("userID"); JsonObject data; found = operationInput.TryGetJsonObject("data", out data); if (!found || (data == null)) throw new ArgumentNullException("data"); object[] records; data.TryGetArray("records", out records); int recordsPosted = -1; if (records.Length > 0) recordsPosted = PostRecords(records, userID); JsonObject result = new JsonObject(); result.AddLong("recordsPosted", recordsPosted); return Encoding.UTF8.GetBytes(result.ToJson()); }
/// <summary> /// create service type MapServer /// </summary> /// <returns>>True if successfully created</returns> public bool CreateService() { try { string token = this.GenerateAGSToken(); string serviceUrl = this.urlRestAdmin + "/services/createService"; JsonObject jsonObject = new JsonObject(); jsonObject.AddString("serviceName", "Test"); //服务类型 jsonObject.AddString("type", Enum.GetName(typeof(ServiceType), ServiceType.GPServer)); jsonObject.AddString("description", "This is an example"); //不同的服务类型,其capabilities是不同的,地图服务的为Map,query和data // jsonObject.AddString("capabilities", "Map,Query,Data"); jsonObject.AddString("capabilities", "Uploads");//gp 服务的capabilities jsonObject.AddString("clusterName", "default"); jsonObject.AddLong("minInstancesPerNode", 1); jsonObject.AddLong("maxInstancesPerNode", 2); jsonObject.AddLong("maxWaitTime", 60); jsonObject.AddLong("maxStartupTime", 300); jsonObject.AddLong("maxIdleTime", 1800); jsonObject.AddLong("maxUsageTime", 600); jsonObject.AddLong("recycleInterval", 24); jsonObject.AddString("loadBalancing", Enum.GetName(typeof(LoadBalancing), LoadBalancing.ROUND_ROBIN)); jsonObject.AddString("isolationLevel", Enum.GetName(typeof(IsolationLevel), IsolationLevel.HIGH)); JsonObject jsonObjectProperties = new JsonObject(); // see for a list complete http://resources.arcgis.com/en/help/server-admin-api/serviceTypes.html jsonObjectProperties.AddLong("maxBufferCount", 100); // optional 100 jsonObjectProperties.AddString("virtualCacheDir", this.urlRestServer + "/arcgiscache"); // optional jsonObjectProperties.AddLong("maxImageHeight", 2048); // optional 2048 jsonObjectProperties.AddLong("maxRecordCount", 1000); // optional 500 //10.1中服务是通过msd的形式发布的,所以创建地图服务时候将mxd转换成msd的形式,创建msd的形式而其他服务的数据发布形式,参考上面的链接 // jsonObjectProperties.AddString("filePath", @"C:\AvGis\Test\mappa\UTM_ReteFognaria.msd"); //地图服务 required jsonObjectProperties.AddString("toolbox", @"d:\Buffer.tbx"); //gp服务使用的是路径创建gp服务的路径 jsonObjectProperties.AddLong("maxImageWidth", 2048); // optional 2048 jsonObjectProperties.AddBoolean("cacheOnDemand", false); // optional false jsonObjectProperties.AddString("virtualOutputDir", this.urlRestServer + "/arcgisoutput"); jsonObjectProperties.AddString("outputDir", @"C:\arcgisserver\directories\arcgisoutput"); jsonObjectProperties.AddString("jobsDirectory", @"C:\arcgisserver\directories\arcgisjobs"); // required jsonObjectProperties.AddString("supportedImageReturnTypes", "MIME+URL"); // optional MIME+URL jsonObjectProperties.AddBoolean("isCached", false); // optional false jsonObjectProperties.AddBoolean("ignoreCache", false); // optional false jsonObjectProperties.AddBoolean("clientCachingAllowed", false); // optional true jsonObjectProperties.AddString("cacheDir", @"C:\arcgisserver\directories\arcgiscache"); // optional jsonObject.AddJsonObject("properties", jsonObjectProperties); string result = this.GetResult(serviceUrl, "service=" + HttpUtility.UrlEncode(jsonObject.ToJson()) + "&f=json&token=" + token); return(this.HasSuccess(result)); } catch { return(false); } }
/// <summary> /// create service type MapServer /// </summary> /// <returns>>True if successfully created</returns> public bool CreateService() { try { String token = this . GenerateAGSToken (); string serviceUrl = this . urlRestAdmin + "/ services / create service" ; JsonObject jsonObject = new JsonObject(); jsonObject.AddString ( "serviceName" , "Test" ); jsonObject.AddString ( "type" , Enum . GetName ( typeof ( ServiceType ) ServiceType . MapServer)); jsonObject.AddString ( "description" , "This is an example" ); jsonObject.AddString ( "capabilities" , "Map, Query, Data" ); jsonObject.AddString ( "ClusterName" , "default" ); jsonObject.AddLong ( "minInstancesPerNode" , 1); jsonObject.AddLong ( "maxInstancesPerNode" , 2); jsonObject.AddLong ( "maxWaitTime" , 60); jsonObject.AddLong ( "maxStartupTime" , 300); jsonObject.AddLong ( "MaxIdleTime" , 1800); jsonObject.AddLong ( "maxUsageTime" , 600); jsonObject.AddLong ( "recycleInterval" , 24); jsonObject.AddString ( "loadBalancing" , Enum . GetName ( typeof ( LoadBalancing ) LoadBalancing . ROUND_ROBIN)); jsonObject.AddString ( "isolationLevel" , Enum GetName (. typeof ( IsolationLevel ) IsolationLevel HIGH).) JsonObject jsonObjectProperties = new JsonObject (); // see for a list complete http://resources.arcgis.com/en/help/server-admin-api/serviceTypes.html jsonObjectProperties.AddLong("maxBufferCount", 100); // optional 100 jsonObjectProperties.AddString("virtualCacheDir", this.urlRestServer + "/arcgiscache"); // optional jsonObjectProperties.AddLong("maxImageHeight", 2048); // optional 2048 jsonObjectProperties.AddLong("maxRecordCount", 1000); // optional 500 // Starting at ArcGIS 10.1, Map Server Definition ( .msd ) files have been // replaced with Service Definition Draft ( .sddraft ) and Service Definition ( .sd ) files. // In the case of a map service, you must specify a map service definition (MSD) file in your JSON. // This file synthesizes information from your ArcMap document (MXD) in a format that can be understood and // drawn by ArcGIS Server. You must use the arcpy.mapping module to analyze your map and create the MSD before // you can go ahead with creating the service. This part requires a machine licensed for ArcGIS for Desktop. // Other service types do not require you to use arcpy.mapping or create an MSD. jsonObjectProperties.AddString("filePath", @"C:\AvGis\Test\mappa\UTM_ReteFognaria.msd"); // required jsonObjectProperties.AddLong("maxImageWidth", 2048); // optional 2048 jsonObjectProperties.AddBoolean("cacheOnDemand", false); // optional false jsonObjectProperties.AddString("virtualOutputDir", this.urlRestServer + "/arcgisoutput"); jsonObjectProperties.AddString ( "outputDir" , @ "C: \ arcgisserver \ directories \ arcgisoutput" ) / / required jsonObjectProperties.AddString ( "supportedImageReturnTypes" , "MIME + URL" ), / / optional MIME + URL jsonObjectProperties.AddBoolean ( " isCached " , false ) / / false optional jsonObjectProperties.AddBoolean ( "ignoreCache" , false ) / / false optional jsonObjectProperties.AddBoolean ( "clientCachingAllowed" , false ) / / optional true jsonObjectProperties.AddString ( "Cached" , @ " C: \ arcgisserver \ directories \ arcgiscache " ) / / optional jsonObject.AddJsonObject ( "properties" , jsonObjectProperties); String result = this . GetResult (serviceUrl, "service =" + HttpUtility . UrlEncode (jsonObject.ToJson ()) + "& f = json & token =" + token) return this . HasSuccess (result); } catch { return false; } }
/// <summary> /// create service type MapServer /// </summary> /// <returns>>True if successfully created</returns> public bool CreateService() { try { string token = this.GenerateAGSToken(); string serviceUrl = this.urlRestAdmin + "/services/createService"; JsonObject jsonObject = new JsonObject(); jsonObject.AddString("serviceName", "Test"); //服务类型 jsonObject.AddString("type", Enum.GetName(typeof(ServiceType), ServiceType.GPServer)); jsonObject.AddString("description", "This is an example"); //不同的服务类型,其capabilities是不同的,地图服务的为Map,query和data // jsonObject.AddString("capabilities", "Map,Query,Data"); jsonObject.AddString("capabilities","Uploads");//gp 服务的capabilities jsonObject.AddString("clusterName", "default"); jsonObject.AddLong("minInstancesPerNode", 1); jsonObject.AddLong("maxInstancesPerNode", 2); jsonObject.AddLong("maxWaitTime", 60); jsonObject.AddLong("maxStartupTime", 300); jsonObject.AddLong("maxIdleTime", 1800); jsonObject.AddLong("maxUsageTime", 600); jsonObject.AddLong("recycleInterval", 24); jsonObject.AddString("loadBalancing", Enum.GetName(typeof(LoadBalancing), LoadBalancing.ROUND_ROBIN)); jsonObject.AddString("isolationLevel", Enum.GetName(typeof(IsolationLevel), IsolationLevel.HIGH)); JsonObject jsonObjectProperties = new JsonObject(); // see for a list complete http://resources.arcgis.com/en/help/server-admin-api/serviceTypes.html jsonObjectProperties.AddLong("maxBufferCount", 100); // optional 100 jsonObjectProperties.AddString("virtualCacheDir", this.urlRestServer + "/arcgiscache"); // optional jsonObjectProperties.AddLong("maxImageHeight", 2048); // optional 2048 jsonObjectProperties.AddLong("maxRecordCount", 1000); // optional 500 //10.1中服务是通过msd的形式发布的,所以创建地图服务时候将mxd转换成msd的形式,创建msd的形式而其他服务的数据发布形式,参考上面的链接 // jsonObjectProperties.AddString("filePath", @"C:\AvGis\Test\mappa\UTM_ReteFognaria.msd"); //地图服务 required jsonObjectProperties.AddString( "toolbox",@"d:\Buffer.tbx");//gp服务使用的是路径创建gp服务的路径 jsonObjectProperties.AddLong("maxImageWidth", 2048); // optional 2048 jsonObjectProperties.AddBoolean("cacheOnDemand", false); // optional false jsonObjectProperties.AddString("virtualOutputDir", this.urlRestServer + "/arcgisoutput"); jsonObjectProperties.AddString("outputDir", @"C:\arcgisserver\directories\arcgisoutput"); jsonObjectProperties.AddString("jobsDirectory", @"C:\arcgisserver\directories\arcgisjobs"); // required jsonObjectProperties.AddString("supportedImageReturnTypes", "MIME+URL"); // optional MIME+URL jsonObjectProperties.AddBoolean("isCached", false); // optional false jsonObjectProperties.AddBoolean("ignoreCache", false); // optional false jsonObjectProperties.AddBoolean("clientCachingAllowed", false); // optional true jsonObjectProperties.AddString("cacheDir", @"C:\arcgisserver\directories\arcgiscache"); // optional jsonObject.AddJsonObject("properties", jsonObjectProperties); string result = this.GetResult(serviceUrl, "service=" +HttpUtility.UrlEncode(jsonObject.ToJson()) + "&f=json&token=" + token); return this.HasSuccess(result); } catch { return false; } }
public JsonObject ToJsonObject() { JsonObject result = new JsonObject(); if (DisplayFieldName != null) { result.AddString("displayFieldName", DisplayFieldName); } if (Fields.Count > 0) { JsonObject[] fields = new JsonObject[Fields.Count]; for (int i = 0; i < Fields.Count; i += 1) { IField field = Fields[i]; JsonObject fjson = new JsonObject(); fjson.AddString("name", field.Name); fjson.AddString("alias", field.AliasName); fjson.AddString("type", FIELD_TYPE_NAMES[(int)field.Type]); fjson.AddLong("length", field.Length); fields[i] = fjson; } result.AddArray("fields", fields); } if (GeometryType != esriGeometryType.esriGeometryAny) { result.AddString("geometryType", GEOMETRY_TYPE_NAMES[(int)GeometryType]); } if (Features.Count > 0) { JsonObject[] features = new JsonObject[Features.Count]; for (int i = 0; i < Features.Count; i += 1) { features[i] = Features[i].ToJsonObject(); } result.AddArray("features", features); } return result; }