Ejemplo n.º 1
0
 /// <summary>
 /// Converts an Esri enumerable interface to a DotNet IEnumerable.
 /// </summary>
 /// <param name="esriEnum">An enumerable Esri interface.</param>
 /// <returns>The adapted dotnet enumeration.</returns>
 public static IEnumerable <INetWeightAssociation> Enumerate(this IEnumNetWeightAssociation esriEnum)
 {
     esriEnum.Reset();
     for (var item = esriEnum.Next(); item != null; item = esriEnum.Next())
     {
         yield return(item);
     }
 }
Ejemplo n.º 2
0
        /// <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 ZNetWeight(ZGeometricNetwork geometricNetwork, INetWeight netWeight, IEnumNetWeightAssociation enumNetWeightAssociation)
        {
            // Initialize collections
            this.NetWeightAssocations = new ObservableCollection<ZNetWeightAssocation>();

            // Weight name
            this.Name = netWeight.WeightName;

            // Weight type
            this.WeightType = netWeight.WeightType.ToZWeightType();
            if (this.WeightType == ZWeightType.BitGate) {
                this.BitGateSize = netWeight.BitGateSize;
            }

            // Add network assocations
            INetWeightAssociation netWeightAssocation = enumNetWeightAssociation.Next();
            while (netWeightAssocation != null) {
                this.NetWeightAssocations.Add(new ZNetWeightAssocation(geometricNetwork, netWeightAssocation));
                netWeightAssocation = enumNetWeightAssociation.Next();
            }
        }