Exemplo n.º 1
0
        /// <summary>
        /// Reads the specified json.
        /// </summary>
        /// <param name="json">The json.</param>
        /// <returns>A <see cref="FeatureCollection"/> with all data contained.</returns>
        public T Read <T>(string json)
        {
            TopoJsonSerializer g = new TopoJsonSerializer(_factory);

            using (StringReader sr = new StringReader(json))
                return(g.Deserialize <T>(new JsonTextReader(sr)));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Writes the specified feature.
        /// </summary>
        /// <param name="feature">The feature.</param>
        /// <returns></returns>
        public string Write(IFeature feature)
        {
            if (feature == null)
                throw new ArgumentNullException("feature");

            IGeometryFactory factory = GeometryFactory.Default;
            JsonSerializer g = new TopoJsonSerializer(factory);
            StringBuilder sb = new StringBuilder();
            using (StringWriter sw = new StringWriter(sb))
                g.Serialize(sw, feature);
            return sb.ToString();
        }
        /// <summary>
        /// Writes the specified feature.
        /// </summary>
        /// <param name="feature">The feature.</param>
        /// <returns></returns>
        public string Write(IFeature feature)
        {
            if (feature == null)
            {
                throw new ArgumentNullException("feature");
            }

            IGeometryFactory factory = GeometryFactory.Default;
            JsonSerializer   g       = new TopoJsonSerializer(factory);
            StringBuilder    sb      = new StringBuilder();

            using (StringWriter sw = new StringWriter(sb))
                g.Serialize(sw, feature);
            return(sb.ToString());
        }