Beispiel #1
0
        public static string Deserialize(byte[] bytes)
        {
            var fc      = FeatureCollectionConversions.Deserialize(bytes);
            var writer  = new GeoJsonWriter();
            var geojson = writer.Write(fc);

            return(geojson);
        }
        public void TigerRoadsTest()
        {
            var geojson    = File.ReadAllText("../../../../../../test/data/tiger_roads.geojson");
            var reader     = new GeoJsonReader();
            var fcExpected = reader.Read <FeatureCollection>(geojson);
            var bytes      = FeatureCollectionConversions.Serialize(fcExpected, GeometryType.LineString);
            var fcActual   = FeatureCollectionConversions.Deserialize(bytes);

            Assert.AreEqual(fcExpected.Count, fcActual.Count);
        }
Beispiel #3
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]);
        }
        public void CountriesTest()
        {
            var bytes    = File.ReadAllBytes("../../../../../../test/data/countries.fgb");
            var fcActual = FeatureCollectionConversions.Deserialize(bytes);

            Assert.AreEqual(179, fcActual.Count);

            var rect = new Envelope(12, 12, 56, 56);
            var list = FeatureCollectionConversions.Deserialize(new MemoryStream(bytes), rect).ToList();

            Assert.AreEqual(3, list.Count);
        }
Beispiel #5
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);
        }
        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);
        }
Beispiel #7
0
 public void DeserializePointWithAttributes()
 {
     FeatureCollectionConversions.Deserialize(pointWithAttributesFixture.flatgeobuf);
 }
Beispiel #8
0
 public void DeserializePolygonZ()
 {
     FeatureCollectionConversions.Deserialize(polygonZFixture.flatgeobuf);
 }
Beispiel #9
0
 public void DeserializePoint()
 {
     FeatureCollectionConversions.Deserialize(pointFixture.flatgeobuf);
 }