OData / WebApi

OData Web API: A server library built upon ODataLib and WebApi
https://docs.microsoft.com/odata
Other
855 stars 475 forks source link

Support geo related functions. #779

Open chinadragon0515 opened 8 years ago

chinadragon0515 commented 8 years ago

Support geo related functions

Assemblies affected

Prefer to be in breaking change release

Reproduce steps

  1. Have a entity whose type is GeographyPoint,
  2. submit request http://localhost:18384/api/Spatial/People?$filter=geo.distance(PointLocation,geography'SRID=0;Point(142.1 64.1)') gt 0

    Expected result

The person will be returned.

Actual result

message: "Unknown function 'geo.distance'.", type: "System.NotImplementedException", stacktrace: " at System.Web.OData.Query.Expressions.FilterBinder.BindSingleValueFunctionCallNode(SingleValueFunctionCallNode node) at System.Web.OData.Query.Expressions.FilterBinder.Bind(QueryNode node) at System.Web.OData.Query.Expressions.FilterBinder.BindBinaryOperatorNode(BinaryOperatorNode binaryOperatorNode) at System.Web.OData.Query.Expressions.FilterBinder.Bind(QueryNode node) at System.Web.OData.Query.Expressions.FilterBinder.BindExpression(SingleValueNode expression, RangeVariable rangeVariable, Type elementType) at System.Web.OData.Query.Expressions.FilterBinder.Bind(FilterClause filterClause, Type filterType, IEdmModel model, IAssembliesResolver assembliesResolver, ODataQuerySettings querySettings) at System.Web.OData.Query.FilterQueryOption.ApplyTo(IQueryable query, ODataQuerySettings querySettings, IAssembliesResolver assembliesResolver) at System.Web.OData.Query.ODataQueryOptions.ApplyTo(IQueryable query, ODataQuerySettings querySettings) at System.Web.OData.Query.ODataQueryOptions.ApplyTo(IQueryable query, ODataQuerySettings querySettings, AllowedQueryOptions ignoreQueryOptions) at Microsoft.Restier.Publishers.OData.RestierController.ApplyQueryOptions(IQueryable queryable, ODataPath path, Boolean applyCount, Boolean& isIfNoneMatch, ETag& etag) in D:\dev\githome\RESTier.vin\src\Microsoft.Restier.Publishers.OData\RestierController.cs:line 607 at Microsoft.Restier.Publishers.OData.RestierController.d__7.MoveNext() in D:\dev\githome\RESTier.vin\src\Microsoft.Restier.Publishers.OData\RestierController.cs:line 126

Aumnia commented 8 years ago

Hi, is this close or in the plan? I've found various samples but it appears there is currently no way to do geo.distance and geo.intersect with WebAPI via OData v4 and EF6, correct? Is there anything we can do to help? What's blocking?

Avyakta commented 5 years ago

I followed this article but am getting the error: “LINQ to Entities does not recognize the method ‘System.Nullable`1[System.Double] Distance(Microsoft.Spatial.Geography, Microsoft.Spatial.Geography)’ method, and this method cannot be translated into a store expression.”