Geo search on mobile

Ok, I searched a little “wider” and following a couple of articles I ended up finding a way to do it :smile:

References:

Beware that there are some syntax errors in this. Use ArrayExpression instead of Expression as you can find out from this excellent article:

The final code looks like this snippet:

                var  _expType = Expression.Property(TYPE).EqualTo(Expression.String(typeof(Lake).Name))
                var _points = ArrayExpression.Variable("points");
                var _lat = ArrayExpression.Variable("points.lat");
                var _lon = ArrayExpression.Variable("points.lon");
                var expGeo = ArrayExpression.Any(_points).In(Expression.Property("points"))
                    .Satisfies(_lat.Between(Expression.Double(55.5), Expression.Double(55.6))
                    .And(_lon.Between(Expression.Double(11.0), Expression.Double(11.5))));
                var _condition = _expType.And(expGeo);

                using (var query = QueryBuilder.Select(
                        SelectResult.All())
                       .From(dbSource)
                       .Where(_condition)
                    )
                {
                    var result = query?.Execute()?.AllResults();
                    list.AddRange(result?.ToObjects<T>(AppConstants.DB_NAME));
                }

Obviously, I just need to fit in the real position params in the above example :smile: :innocent:

1 Like