[JAVA-3074] Can't extract geo keys - Reason: can't project geometry into spherical CRS Created: 07/Nov/18 Updated: 11/Sep/19 Resolved: 08/Nov/18 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | Write Operations |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | Vladimir B | Assignee: | Unassigned |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
JBOSS WildFly 13 + Springboot 2.0.3.Release |
||
| Attachments: |
|
| Description |
|
I'm using java code to insert a new record to DB document which is worker (user) and has its location's address defined with text fields and location field contains lat/_lng _coordinates. Worker result = this.workerRepository.insert(worker);
Involved fields and their definitions: public interface WorkerRepository extends MongoRepository<Worker, String> worker's location field: /** The location. */
Getting the exception for SPECIFIC CITY (despite all, I saw this exception with other addresses, but currently don't have logs): Krasnoyarsk or Красноярск (lat/lng coordinates have been provided by Google geoCode API): can't project geometry into spherical CRS: { lat: 56.0126925, lng: 92.922417 }
The full exception will attach to the ticket. Please ignore ??? in some fields, it is deal only of printing.
|
| Comments |
| Comment by Vladimir B [ 09/Nov/18 ] |
|
10x for your help! It is what you pointed to: order of coordinates. It should be lng as first, and next is lat.
|
| Comment by Kelsey Schubert [ 08/Nov/18 ] |
|
Hi walkmypet, lat=32.0852999, lng=34.78176759999997 are both less than 90 degrees, so neither would through an error despite being parsed to the wrong values. Krasnoyarsk, Russia is just above 90 degrees in longitude, consequently when the document is inserted in way that causes mongod to parse this value as a latitude, it throws an error since latitude may not exceed 90 degrees. This explains your observation that any locations further east in your application fail to be inserted. Please note that the JAVA project is for reporting bugs or feature suggestions for the MongoDB Java Driver. For MongoDB-related support discussion please post on the mongodb-user group or Stack Overflow with the mongodb tag. A question like this involving more discussion would be best posted on the mongodb-users group. Kind regards,
|
| Comment by Vladimir B [ 08/Nov/18 ] |
|
Hi, Kelsey. Thank you for your investigation. But I feel, that there is another cause. There are 3 reasons.
1) Look at the highlighted text in my ticket: Getting the exception for SPECIFIC CITY (despite all, I saw this exception with other addresses, but currently don't have logs): Krasnoyarsk or Красноярск (lat/_lng _coordinates have been provided by Google geoCode API): can't project geometry into spherical CRS: { lat: 56.0126925, lng_: 92.922417 }_ 2) My comment since today _I have added two more exceptions with the same problem. Looks like, we cannot insert to DB any address that located eastern from Krasnoyarsk, Russia._ _[DEBUG] 2018-11-08 23:18:29.947 [http-nio-8080-exec-2] RequestResponseBodyMethodProcessor - Written [Worker(type=[SITTER], title=?????, dob=Wed Nov 08 23:18:02 IST 2000, gender=m, addresses=[Place(id=1, type=PRIMARY, radius=0.0, country=???????, region=????-???????? ?????, city=????-????, county=null, street=null, houseNum=null, placeId=ChIJH3w7GaZMHRURkD-WwKJy-8E, formattedAddress=????-????, ???????, *location=Place.PlacePoint(lat=32.0852999, lng=34.78176759999997))]*, pictures=null, supportedPets=null, attainments=null, additionalInfo=null, prices=null, quizzes=null)] as "application/json" using [org.springframework.http.converter.json.MappingJackson2HttpMessageConverter@1b07ea1f]
|
| Comment by Kelsey Schubert [ 08/Nov/18 ] |
|
Hi walkmypet, Looking at the errors that you've provided. It appears that your are using legacy coordinate pairs with embedded documents. Note that when you use embedded documents for coordinate pairs, the ordering matters from the linked documentation:
As lng is the second field, MongoDB interprets it as the latitude. Since this value is greater than 90, it throws an error. To resolve this issue, I would suggest using GeoJSON objects, or more simply reordering the fields in this embedded document. Kind regards, |
| Comment by Vladimir B [ 08/Nov/18 ] |
|
I have added two more exceptions with the same problem. Looks like, we cannot insert to DB any address that located eastern from Krasnoyarsk, Russia. It's weird! Appreciate your work and waiting for news... |
| Comment by Jeffrey Yemin [ 07/Nov/18 ] |
|
Hi walkmypet Sorry to hear you're having trouble. However, until we get more information I'm going to change the issue type to Question and lower the priority to Major. Someone will follow up with a request for additional information. |