示例#1
0
        public string FromObjectToGeoJSON(IEnumerable <Source> sources)
        {
            try
            {
                SourceFeatureCollection sourceFeatureCollection = new SourceFeatureCollection();
                sourceFeatureCollection.Features = new SourceFeature[sources.Count()];

                int i = 0;
                foreach (Source source in sources)
                {
                    SourceFeature    sourceFeature = new SourceFeature();
                    SourceProperties properties    = new SourceProperties();
                    properties.SourceDirection          = source.SourceDirection;
                    properties.SourceName               = source.SourceName;
                    properties.IsOnLine                 = source.IsOnline.ToString();
                    sourceFeature.Properties            = properties;
                    sourceFeatureCollection.Features[i] = sourceFeature;
                    i++;
                }
                StringBuilder Builder = new System.Text.StringBuilder();
                StringWriter  Writer  = new System.IO.StringWriter(Builder);

                new JsonSerializer().Serialize(Writer, sourceFeatureCollection);

                return(Builder.ToString());
            }
            catch (Exception ex)
            {
                ExceptionUtility.Warn(ex, this.GetType());
                return(ExceptionUtility.BadRequestMessage);
            }
        }
示例#2
0
 protected IFeature CreateTargetFeature()
 {
     return((IFeature)SourceFeature.Clone());
 }