mongo-csharp-driver / GeoJsonObjectModel
AGENTS.md3.2k starsChanged 4 months agoApache-2.0View on GitHub
Strongly-typed GeoJSON (RFC 7946) for use with MongoDB geospatial filters and indexes. Used by FilterDefinitionBuilder.GeoIntersects / GeoWithin / Near / NearSphere, IndexKeysDefinitionBuilder.Geo2DSphere, and the $geoNear aggregation stage. PipelineStageDefinitionBuilder.GeoNear exposes two public static convenience overloads — one taking a GeoJsonPoint<TCoordinates> and one taking a double[] — that both delegate to an internal static generic overload taking a TPoint directly. There is no GeoNearOperation class; geoNear is expressed as a pipeline stage. Generic over a coordinate type TCoordinates. Two-tier hierarchy: Geometries accept…
Trending
Quiet since September.about the whole repository
Who's talking about mongodb/mongo-csharp-driver
- jbogard/MongoDB.Driver.Core.Extensions.DiagnosticSources“Support for latest MongoDB library with signing”GitHub · Jul 28, 2024 · 13 reactions
- opensearch-project/opensearch-net“[FEATURE] Add LINQ Support to the OpenSearch C# Client”GitHub · Sep 18, 2023 · 5 reactions
- nopSolutions/nopCommerce“MongoDB database support”GitHub · Apr 30, 2019 · 4 reactions
- microsoft/aspire“MongoDB.Driver v3 breaks Aspire.MongoDB.Driver integration”GitHub · Oct 18, 2024 · 3 reactions
- jbogard/MongoDB.Driver.Core.Extensions.DiagnosticSources“Deprecate this package”GitHub · Apr 21, 2026 · 2 reactions
The biggest 5 of 40 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 40
Talked about on GitHub (40 times).
On GitHub · 40
- Jul 28, 2024Support for latest MongoDB library with signing — jbogard/MongoDB.Driver.Core.Extensions.DiagnosticSources13 reactions · 5 comments
- Sep 18, 2023[FEATURE] Add LINQ Support to the OpenSearch C# Client — opensearch-project/opensearch-net5 reactions · 1 comment
- Apr 30, 2019MongoDB database support — nopSolutions/nopCommerce4 reactions · 24 comments
- Oct 18, 2024MongoDB.Driver v3 breaks Aspire.MongoDB.Driver integration — microsoft/aspire3 reactions · 9 comments
- Apr 21, 2026Deprecate this package — jbogard/MongoDB.Driver.Core.Extensions.DiagnosticSources2 reactions · 1 comment
35 more on GitHub
- Nov 5, 2025Corrected Membership Session Handling — OrleansContrib/Orleans.Providers.MongoDB2 reactions · 2 comments
- Jun 4, 2016Support .NET Core — tugberkugurlu/AspNetCore.Identity.MongoDB2 reactions · 1 comment
- Jul 12, 2026Upgrade MongoDB.Driver to 3.9.0 to fix Snappier and SharpCompress vulnerabilities — madelson/DistributedLock1 reaction
- May 28, 2026Upgrade MongoDB.Driver to 3.9.0 — abpframework/abp1 reaction · 1 comment
- May 12, 2026Upgrade MongoDB.Driver to 3.8.1 — abpframework/abp1 reaction
- Mar 19, 2026bump MongoDB.Driver to 3.7.1 — abpframework/abp1 reaction
- Jan 18, 2026Update MongoDB.Driver package version to 3.6.0 — abpframework/abp1 reaction · 1 comment
- Nov 20, 2025Update MongoDB.Driver to version 3.5.1 — abpframework/abp1 reaction
- Jan 30, 2023Hangfire.Mongo is incompatible with the MongoDB.Driver LINQ3 provider — gottscj/Hangfire.Mongo1 reaction · 1 comment
- Jun 6, 2022Mongo Driver Compatibility — alirezanet/Gridify1 reaction · 3 comments
- Mar 31, 2015Support for 2.0 async driver — RobThree/MongoRepository1 reaction · 35 comments
- Sep 29, 2026Bump MongoDB.Driver from 2.11.5 to 2.19.0 — ramonaoldf/run-devops0 reactions
- Sep 15, 2026Bump the nuget group with 1 update — ApurvSinghal/ApurvXam0 reactions
- Aug 2, 2026Bump MongoDB.Driver from 2.8.1 to 2.19.0 — mohaom/TailwindTraders-Website0 reactions
- Jan 12, 2025Bump MongoDB.Driver from 2.14.1 to 2.19.0 in /src/Infrastructure — vigovlugt/LeagueOfItemsBackend0 reactions
- Aug 6, 2024Update dependency MongoDB.Driver to 2.19.0 [SECURITY] — MrDariusAD/DynamicFilter0 reactions
- Aug 6, 2024Update dependency MongoDB.Driver to 2.12.2 [SECURITY] — ShamKarthikS-Hexaware/recicd0 reactions
- Aug 6, 2024Update dependency MongoDB.Driver to 2.12.2 [SECURITY] — MrDariusAD/GirlfriendAdventskalender0 reactions
- Jan 15, 2024Bump MongoDB.Driver.Core and MongoDB.Bson — kravvya/GardenLog.V20230 reactions
- Nov 17, 2023build(deps): bump MongoDb_Version from 2.19.0 to 2.22.0 — AntonioFalcaoJr/EventualShop0 reactions
- Mar 28, 2023Bump MongoDB.Driver from 2.19.0 to 2.19.1 — eincioch/dotnet-microservices-boilerplate0 reactions
- Mar 27, 2023Bump MongoDB.Driver from 2.19.0 to 2.19.1 — niaz-ali-khan/microservise0 reactions
- Mar 3, 2023Bump MongoDB.Driver from 2.13.1 to 2.19.0 in /DotNet/POC/DatabaseBenchmark — AdamNagy/Nadam.Tryouts0 reactions
- Mar 3, 2023Bump MongoDB.Driver from 2.12.3 to 2.19.0 in /Esiur.Stores.MongoDB — esiur/esiur-dotnet0 reactions
- Oct 17, 2022Bump MongoDB.Driver from 2.17.1 to 2.18.0 in /src/backend — ScottishTapWater/OrderBook0 reactions
- Oct 17, 2022fix(deps): bump MongoDB.Driver from 2.16.1 to 2.18.0 — Manu0912/doppler-push-contact0 reactions
- Oct 17, 2022Bump MongoDB.Driver from 2.13.0 to 2.18.0 — uruk-project/uruk-server0 reactions
- Oct 17, 2022Bump MongoDB.Driver from 2.15.1 to 2.18.0 — joelbyford/ApiPatternsClient0 reactions
- Oct 14, 2022Bump MongoDB.Driver from 2.13.1 to 2.18.0 in /examples/AspNetCoreMvc — brucehu123/opentelemetry-dotnet-instrumentation0 reactions
- Oct 14, 2022Bump MongoDB.Driver from 2.12.4 to 2.18.0 in /services/common/Platform.Common — frogsbreath-games/eucre0 reactions
- Oct 14, 2022Bump MongoDB.Driver from 2.12.4 to 2.18.0 in /services/lobby/Platform.Lobby.Tests — frogsbreath-games/eucre0 reactions
- Oct 14, 2022Bump MongoDB.Driver from 2.12.4 to 2.18.0 in /services/eucre-game/Games.Eucre.Api — frogsbreath-games/eucre0 reactions
- Oct 14, 2022Bump MongoDB.Driver from 2.12.4 to 2.18.0 in /services/weather/Weather.Api — frogsbreath-games/eucre0 reactions
- Oct 14, 2022Bump MongoDB.Driver from 2.12.4 to 2.18.0 in /services/library/Platform.Library.Api — frogsbreath-games/eucre0 reactions
- May 24, 2022Bump MongoDB.Driver from 2.13.1 to 2.15.1 in /examples/AspNetCoreMvc — brucehu123/opentelemetry-dotnet-instrumentation0 reactions
In this repository35 other files it gives its agents.
- AGENTS.mdAGENTS.md
- src/MongoDB.Bson/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Authentication/AGENTS.mdAGENTS.md
- src/MongoDB.Driver.Authentication.AWS/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Core/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Core/Bindings/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Core/Events/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Core/Logging/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Core/Operations/AGENTS.mdAGENTS.md
- src/MongoDB.Driver.Encryption/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Encryption/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/GridFS/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Linq/AGENTS.mdAGENTS.md
- src/MongoDB.Driver/Search/AGENTS.mdAGENTS.md
- tests/MongoDB.Driver.TestHelpers/AGENTS.mdAGENTS.md
- tests/MongoDB.Driver.Tests/Specifications/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- src/MongoDB.Bson/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver.Authentication.AWS/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Authentication/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Core/Bindings/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Core/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Core/Events/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Core/Logging/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Core/Operations/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver.Encryption/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Encryption/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/GeoJsonObjectModel/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/GridFS/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Linq/CLAUDE.mdCLAUDE.md
- src/MongoDB.Driver/Search/CLAUDE.mdCLAUDE.md
- tests/MongoDB.Driver.TestHelpers/CLAUDE.mdCLAUDE.md
- tests/MongoDB.Driver.Tests/Specifications/CLAUDE.mdCLAUDE.md
The file
Files
GeoJSON Object Model — AGENTS.md
Strongly-typed GeoJSON (RFC 7946) for use with MongoDB geospatial filters and indexes. Used by FilterDefinitionBuilder.GeoIntersects / GeoWithin / Near / NearSphere, IndexKeysDefinitionBuilder.Geo2DSphere, and the $geoNear aggregation stage. PipelineStageDefinitionBuilder.GeoNear exposes two public static convenience overloads — one taking a GeoJsonPoint<TCoordinates> and one taking a double[] — that both delegate to an internal static generic overload taking a TPoint directly. There is no GeoNearOperation class; geoNear is expressed as a pipeline stage.
GeoJSON object types
Generic over a coordinate type TCoordinates. Two-tier hierarchy:
- Geometries — extend
GeoJsonGeometry<T>, which itself extendsGeoJsonObject<T>. The seven geometry types areGeoJsonPoint<T>,GeoJsonLineString<T>,GeoJsonPolygon<T>,GeoJsonMultiPoint<T>,GeoJsonMultiLineString<T>,GeoJsonMultiPolygon<T>,GeoJsonGeometryCollection<T>. - Features —
GeoJsonFeature<T>andGeoJsonFeatureCollection<T>. These extendGeoJsonObject<T>directly; they are not geometries and don't participate in theGeoJsonGeometry<T>hierarchy.
Geometries accept GeoJsonObjectArgs<T> (bounding box, CRS, extra members); GeoJsonFeature<T> accepts GeoJsonFeatureArgs<T>, a subclass of GeoJsonObjectArgs<T> that adds Id and Properties. The args parameter is optional on every geometry constructor (each type has both a (coordinates) and a (args, coordinates) overload) — omit it when you don't need a bounding box, CRS, or extra members.
Coordinate types
GeoJson2DCoordinates(raw[x, y], no CRS opinion) — the driver does not prevent its use against a2dsphereindex when(x, y)happen to be(lon, lat), butGeoJson2DGeographicCoordinatesis the documented choice so the lon/lat semantics are explicit at the type level. Note the two are wire-compatible: both render as a 2-element BSON array, so picking the "wrong" 2D type produces the same on-the-wire shape — the distinction is purely client-side type discipline. Discriminator routing is unaffected by this choice: coordinate types are not themselves serialized as standalone discriminated objects (they sit inside a geometry that carries thetypediscriminator), so swapping 2D coordinate flavours does not change how the enclosing geometry deserialises.GeoJson2DGeographicCoordinates(lon, lat) — most commonGeoJson2DProjectedCoordinates(Easting, Northing)GeoJson3DCoordinates,GeoJson3DGeographicCoordinates,GeoJson3DProjectedCoordinates
All derive from GeoJsonCoordinates. Geometry instances, feature instances, and coordinate instances are immutable in the sense that their declared members have no public setters once constructed (coordinate types are not themselves geometries or features — they sit inside them). One caveat: GeoJsonObject<T> stores reference-typed args fields by reference (_extraMembers = args.ExtraMembers, _coordinateReferenceSystem = args.CoordinateReferenceSystem, _boundingBox = args.BoundingBox in the ctor). Of these, ExtraMembers is a BsonDocument which is plainly mutable; CoordinateReferenceSystem and BoundingBox are reference-held but their concrete types have no public mutators today — still, treat all three as reference-shared with the caller and don't mutate them post-construction (or rebuild the underlying instance). The GeoJsonObjectArgs<T> / GeoJsonFeatureArgs<T> carrier types passed to the geometry / feature constructors expose { get; set; } properties and are mutable builders — don't keep mutating them after handing them to a constructor.
Serializers
GeoJsonObjectModel/Serializers/ — one per concrete type. There are two parallel discriminator dispatchers: GeoJsonObjectSerializer<T> (used when the static type is GeoJsonObject<T>) and GeoJsonGeometrySerializer<T> (used when the static type is constrained to GeoJsonGeometry<T>, e.g. inside a GeometryCollection). Each reads the type discriminator (Point, LineString, Polygon, …) via a switch over the discriminator string and routes to the right concrete serializer. Built on ClassSerializerBase. Adding a new geometry type requires three coordinated changes: (1) create the new geometry type and its dedicated serializer under GeoJsonObjectModel/Serializers/; (2) update the discriminator switch in both GeoJsonObjectSerializer<T> and GeoJsonGeometrySerializer<T> so the new type discriminator routes to it; and (3) annotate the new type with [BsonSerializer(typeof(NewTypeSerializer))] — this is the established pattern used by every existing geometry (see GeoJsonObject.cs, GeoJsonPoint.cs, …). An explicit BsonSerializer.RegisterSerializer(typeof(NewType), new NewTypeSerializer()) at startup is only required as a fallback if you cannot decorate the type (e.g. third-party type you don't own). The dispatcher edit in step (2) handles the case where the caller statically holds a GeoJsonObject<T> / GeoJsonGeometry<T> reference and the discriminator decides the concrete subtype; step (3) handles the case where code holds the new type directly. Both paths are needed.
Common pitfalls
- [lon, lat] order. GeoJSON is
[longitude, latitude], not[lat, lon]. The single most common bug.2dsphereindex queries with swapped coords return wildly wrong results without erroring. - Polygon winding. Follow the RFC 7946 right-hand rule — outer rings counter-clockwise, holes (inner rings) clockwise — for portability. Modern
2dsphereis more lenient than older versions about winding (recent server releases interpret a non-CCW ring as the smaller of the two regions when no CRS is supplied), but relying on that lenience varies by server version and CRS, and reversed winding has historically caused queries to match the entire Earth, nothing, or fail at index/query time withBadValue(e.g. for self-intersecting or oversized rings). Validate with the2dsphereindex against the server version you target, not just a generic GeoJSON validator. - Antimeridian crossing. A polygon that crosses ±180° longitude must be split, or use
$geoWithinwith$centerSpherecarefully on a2dsphereindex —2dsphereinterprets each ring on a sphere. - CRS confusion. The driver sets no client-side CRS default —
CoordinateReferenceSystemisnullunless you supply one. (Older references to a "default WGS84 (degrees)" describe the server-side2dsphereassumption, not a client-side default; do not "fix" this paragraph back to say the driver defaults to WGS84.) Coordinate interpretation is up to the server-side index type: a2dsphereindex assumes WGS84 lon/lat in degrees. Note that legacy2dindexes are not the target of this object model — they require legacy[x, y]arrays or embedded docs and do not consume GeoJSON documents. Projected coordinate systems require explicit CRS viaGeoJsonObjectArgs.CoordinateReferenceSystem. Within a single geometry the driver's compile-time split (GeoJson2DGeographicCoordinatesvsGeoJson2DProjectedCoordinates— sibling subclasses ofGeoJsonCoordinateswith no inheritance link, so neither is convertible to the other) prevents accidental mixing; the hazard is across different documents in the same collection (one stored as geographic, another as projected, both lacking CRS) — distance and area computations on that data will be silently wrong. - 2D vs 3D types. Choose at compile time. Mixing 2D and 3D in the same collection is legal at the BSON level but breaks most clients' assumptions. The third dimension (altitude) is ignored by all standard geospatial query operators.
- Bounding boxes (
bbox). Optional. Server-side2dspheredoes not key off the user-suppliedbboxfield — it computes its own S2 cell covering — sobboxis informational/client-side only (e.g., your code may use it for prefiltering). An inaccuratebboxcannot cause server-side spatial-index misses, but it can mislead any client-side filters that consult it.
How to test
dotnet test tests/MongoDB.Driver.Tests/MongoDB.Driver.Tests.csproj -f net10.0 \
--filter "FullyQualifiedName~GeoJsonObjectModel"Local MongoDB only; no environment variables. For any modified geometry type, include a round-trip serializer test that serializes to BSON and deserializes back. Prefer asserting BSON-byte equality (compare the raw bytes / BsonDocument against an expected document) — it catches element-ordering and representation drift that a field-level deep-equality check would miss.
Spec links
- GeoJSON RFC 7946:
https://datatracker.ietf.org/doc/html/rfc7946 - MongoDB geospatial server operators:
$geoIntersects,$geoWithin,$near,$nearSphere,2dsphereindex (the correspondingFilterDefinitionBuildermethods areGeoIntersects/GeoWithin/Near/NearSphere)
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

