[SERVER-14360] Add support for SWEREF99TM coordinates in geo Created: 26/Jun/14  Updated: 28/Dec/23

Status: Backlog
Project: Core Server
Component/s: Geo, Index Maintenance
Affects Version/s: 2.6.3
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: daniel moqvist Assignee: Backlog - Query Integration
Resolution: Unresolved Votes: 4
Labels: qi-geo
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
Related
is related to SERVER-30522 TopoJSON Support! Backlog
Assigned Teams:
Query Integration
Participants:

 Description   

We are building an API which contains geometries in both WGS84 and SWEREF99TM coordinate system, so the end user can choose what coordinate system to use.
We have indexed the collection as follows:

db.test.ensureIndex({"WGS84" : "2dsphere"},{ "min": -180, "max": 180})
db.test.ensureIndex({"SWEREF99TM" : "2dsphere"},{ "min": 250000, "max": 7680000.0})

We can insert WGS84 geometries without any problem, but the SWEREF99TM geometries throws the error:

WriteConcern detected an error 'insertDocument :: caused by :: 16755 Can't extract geo keys from object, malformed geometry?

I downloaded the source code for mongodb and found the following in geoparser.cpp:

bool isValidLngLat(double lng, double lat) {
    return lat >= -90 && lat <= 90 && lng >= -180 && lng <= 180;
}

This means that we cannot use coordinate systems other than WGS84. My SWEREF99TM is a valid GEOJSON (checked with geojsonlint.com).

I have made a simple c# program to reproduce the problem.

string gj = "{\"SWEREF99TM\":{\"type\":\"LineString\",\"coordinates\":[[380694.924325359, 6167754.54137404], [380640.498108361, 6167711.07075937]]}}";
BsonDocument bdGeo = BsonSerializer.Deserialize<BsonDocument>(gj);
MongoClient client = new MongoClient("mongodb://localhost");
client.GetServer().GetDatabase("test").GetCollection("test").Save(bdGeo); //throws WriteConcern detected an error 'insertDocument :: caused by :: 16755 Can't extract geo keys from object, malformed geometry?

The boundary of SWEREF99TM is

minX = 250000;
maxX = 920000;
minY = 6100000;
maxY = 7680000;

So, this can be considered as a bug/feature request so we can use coordinate systems other than WGS84 with 2dsphere indexes and and the new geotypes like MultiLineStrings.

Untli now we had only simple geometries like Points and LineStrings and used 2d index, but from now we have to support MultiLineStrings and to Index this we have to use the new 2dsphere indexing feature.

More about SWEREF99TM http://www.lantmateriet.se/en/Maps-and-geographic-information/GPS-and-geodetic-surveys/Reference-systems/Two-dimensional-systems/SWEREF-99-projections/



 Comments   
Comment by Adam Wamai Egesa [ 16/Apr/18 ]

When using any geographic data I believe this issue to be of quite vital importance due to inaccuracies present especially on the northern hemisphere in the WGS84 coordinate sysem. Which I've heard from representatives in Swedish authorities is why they predominantly use and publically make available geodata in the SWEREF99TM and RT90 coordinate systems, SWEREF99TM being the newer of the two.

As has been mentioned this is in line with the GeoJSON spec section 4. Where WGS84 is the official coordinate system "However, where all involved parties have a prior arrangement, alternative coordinate reference systems can be used without risk of data being misinterpreted.". So *any *alternate coordinate reference system is fair game.

It's been quite some time since this feature was last proposed so has the needed background work for this been completed for this to be "feasible"?

Or do you have any other updates on if and in that case approximately when we should expect to see this feature being implemented?

Comment by Greg Studer [ 26/Jun/14 ]

There will need to be some background work done before this becomes feasible, unfortunately - though since this is a projected CRS it is likely a version of the 2d index would be more applicable.

Generated at Thu Feb 08 03:34:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.