Hello, ThinkGeo Team!
In the structure Feature like to have a public property to set the geography, for example
public byte[] WellKnownBinary { get; set; }
This is due to the fact that the LINQ to Entities does not support parameterized constructors, and we have to use an extra operation to retrieve the data and then convert them into objects of Feature, which leads to excess consumption of memory.
As we do now:
public class FeatureDto
{
public long Id { get; set; }
public DbGeography Geography { get; set; }
}
...
IQueryable<FeatureDto> query = (_context.Geography.
Where(g => g.Geography.Intersects(extent)).
Select(g => new FeatureDto
{
Id = g.Id,
Geography = g.Geography
}));
FeatureDto[] features = query.ToArray();
InMemoryFeatureLayer layer = new InMemoryFeatureLayer();
layer.Open();
layer.FeatureSource.BeginTransaction();
foreach (var feature in features)
{
layer.FeatureSource.AddFeature(new Feature(
feature.Geography.AsBinary(),
feature.Id.ToString(CultureInfo.InvariantCulture)));
}
layer.FeatureSource.CommitTransaction();
layer.Close();
We want:
IQueryable<Feature> query = (_context.Geography.
Where(g => g.Geography.Intersects(extent)).
Select(g => new Feature
{
Id = g.Id.ToString(CultureInfo.InvariantCulture), WellKnownBinary = g.Geography.AsBinary()
}));
...
Thank you.