-
Notifications
You must be signed in to change notification settings - Fork 13
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
Add hierarchical placetype "rank" property #12
Comments
I had a crack at this today, it's a fairly simple algorithm: // assign ranks
while (!placetypes.every(pt => pt.hasOwnProperty('rank'))) {
placetypes.forEach(pt => {
// already ranked
if (pt.hasOwnProperty('rank')) { return }
// pt has 0 parents
if (!pt.parent.length) {
pt.rank = 0
return
}
// not all parents have been ranked yet
if (!pt.parent.every(pid => ids.get(pid).hasOwnProperty('rank'))) { return }
// find the highest parent rank
let parentRanks = pt.parent.map(pid => ids.get(pid).rank)
let maxParentRank = Math.max.apply(null, parentRanks)
// assign rank one higher than highest parent
pt.rank = maxParentRank + 1
})
} |
Although with this ranking algo there are some duplicate ranks:
|
I was looking at this again today and I think that while the algorithm isn't perfect, it might highlight some errors in the existing spec:
It also illustrates some interesting things: Here's the full list using this algo: 00 metroarea [optional]
00 constituency [common_optional]
00 planet [common_optional]
01 ocean [common_optional]
01 continent [common]
02 empire [common_optional]
03 country [common]
03 dependency [common_optional]
04 marketarea [optional]
04 marinearea [common_optional]
04 timezone [common_optional]
04 disputed [common_optional]
05 macroregion [optional]
06 region [common]
07 macrocounty [optional]
08 county [common_optional]
09 localadmin [common_optional]
10 locality [common]
11 postalcode [common_optional]
11 borough [common_optional]
12 macrohood [optional]
13 neighbourhood [common]
14 microhood [optional]
15 campus [common_optional]
16 intersection [optional]
17 address [common_optional]
18 building [common_optional]
19 wing [optional]
20 concourse [optional]
21 arcade [optional]
22 venue [common_optional]
23 enclosure [optional]
24 installation [optional] cc @thisisaaronland @nvkelso do you think points |
I think on a practical level it probably makes sense to assume metro areas are parented by On a more think-y think-y level in these examples you are seeing the messy intersection of the liberal-economic nation state and late-capitalist globalized capitalism... Also, I'm not sure if the numbering scheme above is just for example but we should make sure the rank have a > 1 separator to allow for flexibility in the future. |
A numeric property that can be to sort place(type)s, typically in a database setting.
The text was updated successfully, but these errors were encountered: