Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-2464

There is no way to specify the CRS using the Mongo C# driver

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Read Operations
    • None

      I am using the Within query and I need to specify the CRS so that it works for "big polygons" so I have tired this:
       
                  GeoJsonCoordinateReferenceSystem crs = new GeoJsonNamedCoordinateReferenceSystem("urn:x-mongodb:crs:strictwinding:EPSG:4326");
                  GeoJsonObjectArgs<GeoJson2DGeographicCoordinates> args = new GeoJsonObjectArgs<GeoJson2DGeographicCoordinates>();
                  args.CoordinateReferenceSystem = crs;
       
      and use it in this call:
       
                 IMongoQuery geoQuery = Query.Within<GeoJson2DGeographicCoordinates>(MongoItem.PolygonRegionProperty, new GeoJsonPolygon<GeoJson2DGeographicCoordinates>(args, new GeoJsonPolygonCoordinates<GeoJson2DGeographicCoordinates>(new GeoJsonLinearRingCoordinates<GeoJson2DGeographicCoordinates>(polygon.Select(i => new GeoJson2DGeographicCoordinates(i.Longitude, i.Latitude))))));
       
      but this returns this:
       
      "$geometry" : { "type" : "Polygon", "crs" : { "type" : "name", "properties" :

      { "name" : "urn:x-mongodb:crs:strictwinding:EPSG:4326" }

      }, "coordinates" : [[[-34.353119999999997, -50.140853], [-34.353119999999997, 76.184997999999993], [146.24300500000001, 76.184997999999993], [146.24300500000001, -50.140853], [-34.353119999999997, -50.140853]]] } } }
       
      whereas I need this:
       
              "$geometry" :{ 
                  "type" : "Polygon", "coordinates" : [[[-34.353119999999997, -50.140853], [146.24300500000001, -50.140853], [146.24300500000001, 
       
      76.184997999999993], [-34.353119999999997, 76.184997999999993], [-34.353119999999997, -50.140853]]],    
                  crs:

      {                 type: "name",                 properties: \{ name: "urn:x-mongodb:crs:strictwinding:EPSG:4326" }

                  } 
              }
       
      i.e. the crs setting is in the wrong place and I cannot work out how to get it in the correct place. There is no way to set the CRS correctly using the within query.

            Assignee:
            kelsey.schubert@mongodb.com Kelsey Schubert
            Reporter:
            ihannah@meniscus.co.uk Ian Hannah
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: