Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't find a codec for class com.mongodb.client.model.geojson.Point #169

Open
derwaldgeist opened this issue Jul 3, 2019 · 5 comments
Open

Comments

@derwaldgeist
Copy link

derwaldgeist commented Jul 3, 2019

I'm trying to use MongoDB Mobile for GeoJSON data. Unfortunately, this does not seem to work out of the box. If I try to find a document based on a nearSphere query, I get this error:

org.bson.codecs.configuration.CodecConfigurationException: Can't find a codec for class com.mongodb.client.model.geojson.Point.
        at org.bson.codecs.configuration.CodecCache.getOrThrow(CodecCache.java:46)
        at org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:63)
        at org.bson.codecs.configuration.ProvidersCodecRegistry.get(ProvidersCodecRegistry.java:37)
        at com.mongodb.client.model.BuildersHelper.encodeValue(BuildersHelper.java:37)
        at com.mongodb.client.model.Filters$GeometryOperatorFilter.toBsonDocument(Filters.java:1209)
        at com.mongodb.internal.operation.Operations.createFindOperation(Operations.java:142)
        at com.mongodb.internal.operation.Operations.findFirst(Operations.java:125)
        at com.mongodb.internal.operation.SyncOperations.findFirst(SyncOperations.java:80)
        at com.mongodb.client.internal.FindIterableImpl.first(FindIterableImpl.java:199)

How can this codec be set-up?

@mehiretab
Copy link

Mongodb stitch is not supporting geo-queries. look their official doc here https://docs.mongodb.com/stitch/mongodb/mongodb-service-limitations/

@derwaldgeist
Copy link
Author

derwaldgeist commented Sep 16, 2019

Thanks for the info. This is pretty sad, because it makes location-based apps impossible. Well, I ended up implementing my own database anyways, since the Mongo Mobile SDK was a monster, way too big to be included in my app. Would love to see a light-weight version that supports GeoJSON, though, as this would be an ideal fit to my use-case.

@mehiretab
Copy link

I hope this will be fix in future releases as mongodb-stitch is child in the industry.
Could you share how you solved your problem?

@derwaldgeist
Copy link
Author

I did not use MongoDB at all. Instead I used a simple hash map for my purposes and calculate the nearest object by iterating over this map. This was ok, because there are never more than 20-30 objects in the vicinity.

The objects themselves are retrieved from the server, where a "real MongoDB" supports geospatial queries. My use-case was to cache a selection of these objects locally on the device, to notify the user about objects in the vicinity when the app runs in background.

I also thought about SQLlite as an alternative, but even this was kinda oversized for my purpose. The only big advantage MongoDB would have in this case is simplicity (for the queries).

@mehiretab
Copy link

Due to the doc I haven't tried it in my mongodb stitch app. but when I trying to execute Geo queries like $near. it works perfectly... I'm wondering

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants