-
Notifications
You must be signed in to change notification settings - Fork 46
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
Adding area field to data #40
Comments
Yea, even I think km2 is the best option for the unit, it's widely used. Don't mention the unit in the what do you think? I'm open to suggestions @amanpalariya |
I was thinking of not mentioning the unit in the data at all and just keep it limited to the documentation. If we include |
Hmm, interesting thought. @amanpalariya I think we can tackle it by structuring the area schema as follows: ...
"area": {
value: 10000,
unit: "sq. Km"
}
... I think it's worth mentioning the unit in our API itself just for easier access and most times when using this library, developers may wanna show the unit too. |
If we don't want to deliver area unit then as @amanpalariya mentioned, we might use JSDocs (for methods) and
That actually could be a thing if we want to deliver english units such as square miles. But I think we should not focus on format/name of unit itself (let users handle this with their own i18n/translates/dictionaries). The question is, do we want to deliver that for a users or should they calculate it by themselves? If we want to handle this it could be something like: {
// ...,
"area": {
"km2": 312679, // square kilometers
"mi2": 120726 // square miles
}
} |
@sthiepaan Nice idea! 👍 This way, the area is provided in two major units. But, if done this way, we will have to maintain consistency in Extending @sthiepaan's idea, we can store area in km2 in So, {
//...,
"area": 312769
} But the method returns 👇 {
//...,
"area": {
"km2": 312679,
"mi2": 120726,
}
} |
From my point of view, API should just return the date that it contain. Even if we have methods to grab specific data, we do not modify the output. If we create some functionality to convert the data, then we need to take care at least for correctness of calculated data and units rounding. I would leave calculations for API consumers so they can decide what format they want to have. So just to summarize I think there are two proper ways:
|
Yeah, @sthiepaan I agree. I think the unit conversions should be left to the consumer itself. Let's proceed with this |
Since we are going with 👇 {
//...,
"area": {
"km2": 312679,
"mi2": 120726,
}
} So, we will have to create test to check that area in km2 equals area in mi2. I think I shall begin working on it now. |
The
area
is one of the very important stats for a country. So, it should be added to the data.@bhatvikrant What should be the unit of area? I think km2 would be the best.
So, the schema will be
Should we mention the unit in the data? 🤔
I guess it would be best to store
area
as adouble
and mention the unit in documentation only.The text was updated successfully, but these errors were encountered: