0

Looking at this:

var t = ctx.Layer
   .Where(c => c.Geometry.Intersects(boundingBox))
  .Select(s => new
  {
      Geometry = SqlSpatialFunctions.Reduce(s.Geometry, degreesPerPixel),
      s.column1,
      s.column2,
      s.column3,
      s.column4,
      s.column5,
      s.column6,
      s.column7,
      s.column8,
      s.column9,
  }).ToArray();

its rather anoying that one would have to write all the columns again just to run a function on a column. Is there better ways to do this?

2 Answers 2

1

"Better" in terms of not having to write all the properties:

var t = ctx.Layer
.Where(c => c.Geometry.Intersects(boundingBox))
.Select(s => new
{
  Geometry = SqlSpatialFunctions.Reduce(s.Geometry, degreesPerPixel),
  Layer = s
}).ToArray();
Sign up to request clarification or add additional context in comments.

Comments

0

Heres what I did. Very similar to the answer by Eren.

public static  class VectorLayerHelperExtensions
{
    public static IEnumerable<OgrEntity> Reduce(this IQueryable<OgrEntity> query, double threshold)
    {
        return query.Select(s => new
                  {
                      g = SqlSpatialFunctions.Reduce(s.Geometry, threshold),
                      s
                  }).AsEnumerable().Select(t => { t.s.Geometry = t.g; return t.s; });
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.