/// <summary> /// Serializes a value. /// </summary> /// <param name="context">The serialization context.</param> /// <param name="value">The value.</param> protected override void SerializeValue(BsonSerializationContext context, GeoJsonBoundingBox <TCoordinates> value) { var bsonWriter = context.Writer; // serialize min and max to a dummy document and then flatten the two arrays and serialize that var document = new BsonDocument(); using (var documentWriter = new BsonDocumentWriter(document)) { var documentContext = BsonSerializationContext.CreateRoot(documentWriter, typeof(BsonDocument)); documentWriter.WriteStartDocument(); documentWriter.WriteName("min"); documentContext.SerializeWithChildContext(_coordinatesSerializer, value.Min); documentWriter.WriteName("max"); documentContext.SerializeWithChildContext(_coordinatesSerializer, value.Max); documentWriter.WriteEndDocument(); } var flattenedArray = new BsonArray(); flattenedArray.AddRange(document["min"].AsBsonArray); flattenedArray.AddRange(document["max"].AsBsonArray); context.SerializeWithChildContext(BsonArraySerializer.Instance, flattenedArray); }
private void SerializeBoundingBox(BsonSerializationContext context, GeoJsonBoundingBox <TCoordinates> boundingBox) { if (boundingBox != null) { context.Writer.WriteName("bbox"); context.SerializeWithChildContext(_boundingBoxSerializer, boundingBox); } }
private void SerializeBoundingBox(BsonWriter bsonWriter, GeoJsonBoundingBox <TCoordinates> boundingBox) { if (boundingBox != null) { bsonWriter.WriteName("bbox"); _boundingBoxSerializer.Serialize(bsonWriter, typeof(GeoJsonBoundingBox <TCoordinates>), boundingBox, null); } }
public async Task <IAsyncCursor <BsonDocument> > GetBoundedGeoDataAsync <TCoordinates>(GeoJsonBoundingBox <TCoordinates> boundingBox) where TCoordinates : GeoJsonCoordinates { var filter = new BsonDocument(); return(await Collection().FindAsync(filter)); }
public async Task <IAsyncCursor <Penalty> > GetBoundedPenaltyAsync <TCoordinates>(GeoJsonBoundingBox <TCoordinates> boundingBox) where TCoordinates : GeoJsonCoordinates { var filter = new BsonDocument(); var gdColl = Collection(); var docList = await gdColl.FindAsync(filter); return(docList); }