public IEnumerable<object> Get(double latitude, double longitude, bool delivery) { if (!delivery) return Get(latitude, longitude); var point = new Point(latitude, longitude); using (var session = MvcApplication.DocumentStore.OpenSession()) { return session.Query<Restaurant, RestaurantIndex>() .Spatial(x => x.DeliveryArea, x => x.Intersects(point)) .TransformWith<RestaurantsTransformer, RestaurantResult>() .Take(250) .ToList(); } }
private void AppendPointInner(StringBuilder builder, Point point) { if (point.IsEmpty) { builder.Append("EMPTY"); return; } builder.Append("("); AppendCoordinate(builder, point.Coordinate); builder.Append(")"); }
private void AppendPoint(StringBuilder builder, Point point) { builder.Append("POINT"); AppendDimensions(builder, point); builder.Append(" "); AppendPointInner(builder, point); }
private void WritePoint(Point point, WkbBinaryWriter writer) { if (!point.IsEmpty) { WriteEncoding(writer, _settings.Encoding); WriteGeometryType(point, WkbGeometryType.Point, writer); WriteCoordinate(point.Coordinate, writer); } }
private Dictionary<string, object> WritePoint(Point point) { return new Dictionary<string, object> { { "type", "Point" }, { "coordinates", WriteCoordinate(point) } }; }
public void Point() { var reader = new GeoJsonReader(); var geo = new Point(0, 0); Assert.AreEqual(@"{""type"":""Point"",""coordinates"":[0,0]}", geo.ToGeoJson()); Assert.AreEqual(geo, reader.Read(geo.ToGeoJson())); }
private bool TryReadGeoPoint(string value, out ISpatial4nShape result) { var match = Regex.Match(value, @"^ \s* ([+-]?(?:\d+\.?\d*|\d*\.?\d+)) \s* , \s* ([+-]?(?:\d+\.?\d*|\d*\.?\d+)) \s* $", RegexOptions.IgnorePatternWhitespace | RegexOptions.IgnoreCase); if (match.Success) { result = new Point( double.Parse(match.Groups[1].Value, CultureInfo.InvariantCulture), double.Parse(match.Groups[2].Value, CultureInfo.InvariantCulture) ); return true; } result = null; return false; }