rugk / crops-parser

🌱🍎🍆 A shell script to parse the data by the Food and Agriculture Organization of the United Nations on crops/fruits.
Other
15 stars 4 forks source link

Ideas about special cases #18

Closed rugk closed 7 years ago

rugk commented 7 years ago

Questions for each case:

  1. Should this be handled in the parser (i.e. should it change the entries in the YAML file?) or can/should/may StreetComplete handle this when parsing/using the YAML file?
  2. In any case, how should it be done?
  3. Are syntax changes necessary?

Some special cases:

  1. Sometimes the source data is so broad to not differentiate between two different OSM tags. This is e.g. the case for lime vs lemon trees. 1.1. This script could split these into two entries. But what to do with the data ("value in tonnes")? Duplicate/bisect? (IMHO this would be faking the data) Or maybe ignore the "top-5" limit for this case and just add one item more? 1.3. Possible synax: trees=lemon_tree|trees=lime_tree
  2. Sometimes we decided we include a crop and then re-tag it under a different tag. Should this information be included in the YAML file? 2.3. Possible synax: landuse=farmland+crop=hemp (retag this orchard as landuse=farmland)
westnordost commented 7 years ago

Well, I am not that sure anyway about whether any order (in tonnes) is still relevant. Didn't we decide to let the user start typing the name and present him a list of matching entries?

Anyway:

  1. Generally it is not a problem to have more data in the YAML than is actually used in the quest. While iterating through the file, the quest can ignore the entries it doesn't know (i.e. has no translation/image for).
  2. It is already done automatically. The only thing you need to do is to place the file, i.e. named "orchardCrops.yml" in /res/country_metadata. Then, you need to add List<String> orchardCrops; (same name as the file) to CountryInfo.java. Finally, you (or me or anyone) need to once execute the gradle task generateMetadata to execute a python script that copies over the metadata in the source format into the format that fits for the CountryInfo. When you implement a quest, you can simply access your CountryInfo object from there and it will have all the information for the country the quest is in - in that case, it will have the list of orchardCrops as they are defined in orchardCrops.yml.
  3. Well, looking at the result file, you should decide for a format: either directly OSM tags ("trees=apple_trees") or simple names ("apples") and then go with it. Now, one entry to be displayed needs: an osm tag, a localized string (and perhaps an image). Have a look at i.e. AddSportForm.java to see how is the preferred way to supply this data.
westnordost commented 7 years ago

Special cases:

  1. Well, depends on for what the list you generated is used in the end. See my first paragraph in the first comment - what do you need a top 5 for? Or any top X? Just to order the results when the user starts typing? There are not that many different fruits that each start with the same first few letters. Or do you want to show image+text in a "quick select" for these 5, additionally to the search field? Anyway, there are lime trees and lemon trees, both should be included then in the list (with comma)
  2. The information simply needs to be somewhere. Whether it is in the YML or in Java code makes no big difference I guess. Just keep in mind that the names you use in the YML are then the "identifier" of that list item. For the sports quest, the identifer is the same as the OSM value for the sport key. My personal opinion is that if the crops that belong into farmland are in the vast minority, simply use the OSM values for trees (and respectively crops) as the names in the YML and make the distinction programmatically in the quest.
rugk commented 7 years ago

First the first three questions were related to the special cases.

Didn't we decide to let the user start typing the name and present him a list of matching entries?

No. Pictures are nicer… As for 1. – okay, somehow needs to be split. Created https://github.com/rugk/crops-parser/issues/20 for that.

As for 2. we'll do it in Java… okay.

I think this issue can be closed, then.

rugk commented 7 years ago

Maybe just another thing about 2.: Maybe add a column "landuse=?" in the osmcrops.csv? Just to collect the information there?

westnordost commented 7 years ago

+shrug+. You are implementing the quest, right? So where you keep the information is up to you.

rugk commented 7 years ago

I am just collecting the data. No Java knowledge here…

westnordost commented 7 years ago

Ah, I thought you will implement the quest also.

That answers the question why you want so much feedback from me.

Well, no matter. This research and the hopefully subsequent search for suitable images will make the actual implementation very straightforward.

rugk commented 7 years ago

Yeah, and if the input gets even complexer, I can certainly not implement it. Yeah, searching for images is okay, also the translation to German, at least.

And the thing I just talk about could also make it easier for you, when we have the data ready already:

Maybe add a column "landuse=?" in the osmcrops.csv? Just to collect the information there?

So?

westnordost commented 7 years ago

Ok

rugk commented 7 years ago

done