-
-
Notifications
You must be signed in to change notification settings - Fork 167
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
Support number type for "Feature.Id" property #100
Comments
Do you have any good ideas or even a pull request with this in? Personally I think that leaving as a string gives the most options to everyone as you can easily put a number into a string but not the other way around. |
It's indeed possible to somewhat "stringify" a number, but that's not very reliable — and breaks for example the identity As for a solution in GeoJSON.Net, I don't really know, I'm no C# expert to be honest.
Or would you see another solution? |
So being that c# is a strongly typed language it wouldn't have the issues of typing like you get in Javascript so the I would suggest that the consumer of GoeJSON.Net could cast or parse the Id property to an int if needed using one of the many int methods
or
or
This is what I'd have to do under the hood anyway.
|
Indeed, when you have control over the consumer of GeoJSON.Net, you can manually (try to) convert the string ID to a number ID. See what another C++ library does for the feature ID: https://github.com/mapbox/geometry.hpp/blob/master/include/mapbox/geometry/feature.hpp#L47. using identifier = mapbox::util::variant<uint64_t, int64_t, double, std::string>; Is it out of the question to have the |
Hi @dalbani and @matt-lethargic ! Could it be possible to say that
The problem here is that now Id MUST be a string, even if it represents a number. |
Hey guys, had some thinking time. C++ supports variant types which much better than C# by the seems of it. We can easily serialize to a number value if the Id has been set to one. I've created a banch 'Issue100' that addresses this. I'm not keen on setting the Id to type 'object' as it can be set to anything not just a number or a string. I am concerned about putting this straight in as it could be classed as a breaking change so would need a version bump. @xfischer any thoughts on that? |
.... I'm happy to put this into version 2.x though |
Thanks a lot @matt-lethargic for the time spent in writing the code of the pull request. |
@matt-lethargic's PR is neat and works. OK with @dalbani for the downside of getting back a string. I wish I had more time to test the Issue100 branch, but I don't ! |
As per the RFC:
Would it possible for GeoJSON.Net to support a number value for
Feature.Id
, in addition to a string value?The text was updated successfully, but these errors were encountered: