-
Notifications
You must be signed in to change notification settings - Fork 602
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
NIP-3166: Country code tag based on ISO-3166 #763
base: master
Are you sure you want to change the base?
NIP-3166: Country code tag based on ISO-3166 #763
Conversation
What do you expect from this country code? Language? Or current location? lat/lng can be specified? |
Simple country location. Other NIPs can take care of more granular geo-location. The direct use-case is for letting profiles show their country of origin, and allow them to be easily searched by it. |
Then, it should be just to be "Country code" not "GEO Location" ? |
Good feedback, updated the NIP and PR description. |
What about the idea to merge with #632? |
#632 is more focused on language than location. The two don't always map, and they are different concerns imo. |
Maybe this PR should be converted to an "Using Labels to Locate Events" NIP-32 section. Because if we start reserving letters for city, state and so on we may have no more letters left. How about using NIP-32 like this:
|
This was one of the use cases considered in the original NIP 32 conversation, so yeah I would go that direction. |
Just discovering NIP-32, seems to be a good fit at first sight. My main concern is that it would come at the expense of better indexing, as the That said, covering more location granularities like The reason I'm suggesting that is because a location tag might be generic/popular enough to justify its own tag. |
|
Although they would be indexed, wouldn't it be less efficient than having an index dedicated to location? I could be misunderstanding how relays index values. |
It depends, but it probably would have an impact. You could also do something like |
What's the best way forward here? Open a new PR that extends NIP-32 with a new section detailing the location use case? |
The best way forward is almost always implementing it inside your preferred use case to see if it is actually better. I am not sure if any of you coded this, but I learned a lot when implementing the geohash tag. And I am not saying that that is better than this. It's just always good to test things out. |
I think we should have a use case for this and/or an implementation before making this an official NIP. Otherwise, good idea. |
Anything a-zA-Z must be indexed |
For sure, not rushing for this to be merged, just getting feedback on the idea. The use case is displaying country/region on profiles such that they can be browsed by country/region. Client implementation will follow, still a few weeks away. |
At this point I'm starting to think that the indexing strategy needs to be discussed separately. But my take-away thus far is:
|
@mattn Why limit geocoordinates to just the country code? Why not allow developers to discern the precision of a geotag as opposed to creating a limitation from the start?
geohash is much more reliable than lat/lon since lat/lon has varying precision. From #230.
As implemented above, index-case has no conflicts and the read-case doesn't require the client to discern what the datapoint represents, since it is expressed in |
I agree with the sandwich. |
@dskvr Good idea. But imo the tag[1] should be enough to filter out (relay side) most of the things you don't want. The values are different enough from each other that it probably works withough tag[2] (except for continent code clashing with country code or state) . Also geohashes may have many entries to allow for broader filtering maybe down to 4 digits (city-level) up to 9 (building level) depending on what your app needs. So I would turn your example into this: ["g","ww8p1r"]
["g","ww8p1"],
["g","ww8p"], // city precision
["g","ww8"], // small state precision
["g","ww"], // big state precision
["g","US-LA-New Orleans"], // city; or LA-New Orleans
["g","US-LA"], // state; or just LA because country used the 3-letter code
["g","US"], // country. or USA
["g","continent>NA"], // unusual
["g","Earth"] // unusual edit: to cover city right (by using smaller pieces) when searching it probably needs higher precision than 4 digits |
@fernandolguevara why do you disagree? xD If you search for Republic of Namibia country (NA), relay would send you all North America (NA continent) entries and probably some other country entries that has NA state =P. |
I just realized https://github.com/nostr-protocol/nips/blob/master/32.md could already be used for this. |
@arthurfranca imo relays should use the component descriptor |
@fernandolguevara oh ok but right now relays can't use the tag array's third item (second value) on searches. The third item would be just something you could use to filter client-side, after receiving relay response. |
@fiatjaf That is true, may not need a new tag, but it would still be beneficial for geodata to be consistent. @arthurfranca The third key doesn't need to be filtered against. If you are filtering against |
@dskvr Ok, so if keeping the third item to account client-side for an unexpected clash you would want something like this:
Turned continent code into the full name to not clash with any state code. BUT from NIP-01 At least one of the arrays' values must match the relevant field in an event for the condition to be considered a match. so this filter So the correct would probably be something like this:
Or using three letter code for countries and codes for continents (though I prefer the previous one):
It ended up not being that simple, so @steliosrammos now indeed a NIP for Now the city filter works as expected: |
You might want to consider using colon (i.e. |
@arthurfranca I definitely overlooked the
If using subdivisions, might as well represent the key correctly.
But there is still the issue with cities, which breaks out of ISO-1366, so some alternatives...
This would be better |
@vitorpamplona Yeah @dskvr Regarding Cities: Geonames though can also be used for country and state If we use geonames just for city and other smaller subdivisions it becomes this:
So, USA-LA:New Orleans or 4335045 or both? |
I would encourage you to use NIP-32. While you may want ISO-3166, others may want some other coding system. NIP-32 handles all of them. But to clarify some of the questions about it… To put things simply (to make sure everyone is on the same page), only the first parameter after a single letter tag is indexed. AND there's (currently) no support for starts with queries in Nostr. That means both When we were coming up with NIP-32 there was some argument about how values should be structured. I was mostly thinking in terms of structured vocabularies (like ISO-3166) and wanted the namespace / vocabulary / coding system as a prefix on the value. Others wanted to query for values across multiple coding systems and wanted the value to have no prefix. As a result, most of the examples in the NIP follow the no-prefix example like this…
But to use that data you have to query on both If you notice the last paragraph of the NIP mentions…
Using that approach you can query just on
Let me know if any of that raises questions… |
missed this bit: "Publishers can self-label by adding l tags to their own non-1985 events..." |
I had to unblock myself on NIP-66 so I made this https://github.com/sandwichfarm/nostr-geotags, might be useful for someone here. |
Draft NIP for introducing a new country-code tag that can be added to any event. The tag makes use of the ISO-3166 standard country codes and would allow easier filtering and indexing of events based on their geographic location.
It differs from the current
g
tag presented in NIP-52 in that it is much less granular than a geohash, which is not ideal for indexing.The same difference is true for the proposed Geospatial Types #136.
Possibly a third parameter could be added (eg: ["g", "", "country"]), in conjunction to the existing g tag, as presented in #230 to support multiple g tag types. But I'm not sure that's preferable for indexing.(removed to focus on country code only, as per @mattn's feedback).Open to feedback!