public async Task TestUSCountiesFromWeb() { var client = new HttpClient(); using var rspns = await client.GetAsync("https://flatgeobuf.org/test/data/UScounties.fgb"); if (rspns == null || !rspns.IsSuccessStatusCode) { Assert.Inconclusive("Failed to get USCounties.fgb"); } var strm = await rspns.Content.ReadAsStreamAsync(); if (strm == null) { Assert.Inconclusive("Failed to get USCounties.fgb"); } var ae = await AsyncFeatureEnumerator.Create(strm); Assert.IsNotNull(ae); int numFeaturesRead = 0; while (await ae.MoveNextAsync()) { Console.WriteLine($" {ae.Current.Attributes["FIPS"]} - {ae.Current.Attributes["NAME"]} ({ae.Current.Attributes["STATE"]})"); numFeaturesRead++; } Assert.AreEqual(ae.NumFeatures, numFeaturesRead); }
public async Task TestCountriesUnseekable() { var ae = await AsyncFeatureEnumerator.Create(new UnseekableStream(File.OpenRead("../../../../../../test/data/countries.fgb"))); Assert.IsNotNull(ae); Console.WriteLine(ae.Extent.ToString()); int numFeaturesExpected = ae.NumFeatures; int numFeaturesRead = 0; while (await ae.MoveNextAsync()) { Console.WriteLine($" {ae.Current.Attributes["id"]} - {ae.Current.Attributes["name"]}"); numFeaturesRead++; } Assert.AreEqual(numFeaturesExpected, numFeaturesRead); }
public async Task TestCountriesUnseekableWithFilter() { var rect = new Envelope(-16.1, 32.88, 40.18, 84.17); var ae = await AsyncFeatureEnumerator.Create(new UnseekableStream(File.OpenRead("../../../../../../test/data/countries.fgb")), rect : rect); Assert.IsNotNull(ae); Console.WriteLine(ae.Extent.ToString()); int numFeaturesExpected = ae.NumFeatures; int numFeaturesRead = 0; while (await ae.MoveNextAsync()) { Console.WriteLine($" {ae.Current.Attributes["id"]} - {ae.Current.Attributes["name"]}"); numFeaturesRead++; Assert.IsTrue(rect.Intersects(ae.Current.Geometry.EnvelopeInternal)); } Assert.IsTrue(numFeaturesExpected > numFeaturesRead); }