Ejemplo n.º 1
0
        public static async Task <byte[]> SerializeAsync(string geojson)
        {
            var reader = new GeoJsonReader();
            var fc     = reader.Read <FeatureCollection>(geojson);
            var bytes  = await FeatureCollectionConversions.SerializeAsync(fc, GeometryType.Unknown);

            return(bytes);
        }
Ejemplo n.º 2
0
        static async Task <IFeature> ToDeserializedFeature(string wkt)
        {
            var  f            = MakeFeature(wkt);
            var  fc           = MakeFeatureCollection(f);
            var  geometryType = GeometryConversions.ToGeometryType(f.Geometry);
            byte dimensions   = GetDimensions(f.Geometry);
            var  flatgeobuf   = await FeatureCollectionConversions.SerializeAsync(fc, geometryType, dimensions);

            return(FeatureCollectionConversions.Deserialize(flatgeobuf)[0]);
        }
Ejemplo n.º 3
0
        public async Task PointMutable()
        {
            var f          = MakeFeature("POINT (1.2 -2.1)");
            var fc         = MakeFeatureCollection(f);
            var flatgeobuf = await FeatureCollectionConversions.SerializeAsync(fc, GeometryType.Point, 2);

            var fcOut = FeatureCollectionConversions.Deserialize(flatgeobuf);
            var point = fcOut[0].Geometry as Point;

            point.CoordinateSequence.SetOrdinate(0, 0, 0.01);
            Assert.AreEqual(0.01, point.Coordinate.X);
        }
Ejemplo n.º 4
0
        static async Task <string> RoundTrip(string wkt)
        {
            var  f            = MakeFeature(wkt);
            var  fc           = MakeFeatureCollection(f);
            var  geometryType = GeometryConversions.ToGeometryType(f.Geometry);
            byte dimensions   = GetDimensions(f.Geometry);
            var  flatgeobuf   = await FeatureCollectionConversions.SerializeAsync(fc, geometryType, dimensions);

            var fcOut  = FeatureCollectionConversions.Deserialize(flatgeobuf);
            var wktOut = new WKTWriter(dimensions).Write(fcOut[0].Geometry);

            return(wktOut);
        }