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

Conversion from double to string #28

Open
LiberQuack opened this issue May 30, 2016 · 5 comments
Open

Conversion from double to string #28

LiberQuack opened this issue May 30, 2016 · 5 comments

Comments

@LiberQuack
Copy link

After saving a Point into MongoDB I realized it converts double to String

As I know... GeoJSON specify numbers inside the array coordinates. Am I wrong?

@grundid
Copy link
Member

grundid commented May 30, 2016

Thanks for mentioning this. I haven't tried these classes with MongoDB yet. I would assume that mongo would serialize the LngLatAlt class as an object with several properties instead of an array.
Is this right? Could you please share some code and/or how Mongo saves this?

@notanyron in this situation an array for all properties would be better ;)

@Babbleshack
Copy link
Contributor

"geometry" : {
         "type" : "FeatureCollection",
         "features" : [
                 {
                         "type" : "Feature",
                         "properties" : {

                         },
                         "geometry" : {
                                 "type" : "Point",
                                 "coordinates" : [
                                         "36.394900225",
                                         "-24.135984854"
                                 ]
                         }
                 }
         ]
 }

When deserilizing the LngLatAlt object i.e. the coordinates array under geometry, Unexpected token (VALUE_STRING) when binding data into LngLatAlt exception is thrown.

@Ruckley
Copy link

Ruckley commented Jan 25, 2017

I believe the LngLatAltSerializer needs to be fixed as well. If you look at the geoJson specifications position data should be given as an array of doubles not strings.
http://geojson.org/geojson-spec.html#geometry-objects

Theres also the problem that the Double to String conversion in LngLatAltSerializer is performed on lng and lat but not alt. So a 3d point ends up with two strings and a double.

I came accorss this problem when I was trying to use geojson generated by this api with MongoDB. MongoDB is designed to work wth the geoJson spec and so cannot create indexes for the generated geoJson as it expects arrays of Doubles not Strings when dealing with locations.

This problem could be corrected by removing the fastDoubleToString method from the LngLatAltSerializer.

@Babbleshack
Copy link
Contributor

Did you fix this?

@Ruckley
Copy link

Ruckley commented Jan 31, 2017

The fix has been merged, LngLatAlt positions serialize to an array of doubles now

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

4 participants