/// <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 ZNetWeightAssocation(ZGeometricNetwork geometricNetwork, INetWeightAssociation netWeightAssociation) { this.NetworkClass = geometricNetwork.NetworkClasses.FirstOrDefault(n => n.Path.Table == netWeightAssociation.TableName); if (this.NetworkClass == null) { return; } this.Field = this.NetworkClass.Fields.FirstOrDefault(f => f.Name == netWeightAssociation.FieldName); }