Skip to content
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

Country coder #298

Merged
merged 35 commits into from
Nov 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c9e863a
Add Country Coder dependency
bhousel Nov 13, 2019
ada8f0a
Add include/excludeLocations properties to resources schema
bhousel Nov 13, 2019
11ee9ea
Add includeResources M49 codes for world and latam resources
bhousel Nov 13, 2019
01ba153
Tests for valid includeLocations strings against country coder
bhousel Nov 13, 2019
5e31630
Upgrade to country-coder 2.1.0, which supports 'world'
bhousel Nov 14, 2019
d30a233
Validate `includeLocation` and `excludeLocation` values
bhousel Nov 14, 2019
4427f1a
From now on, set feature ids to match the feature filename
bhousel Nov 14, 2019
b9045f5
Swap `featureId` for `includeLocations`, remove `featureId`
bhousel Nov 14, 2019
cecff19
Replace YouthMappers geojson features with centroid locations
bhousel Nov 14, 2019
f615541
Round youthmappers centroids to 5 decimals, remove conversion code
bhousel Nov 14, 2019
16c218e
Replace a few Philippines YouthMappers geojsons with centroid points
bhousel Nov 14, 2019
5eaa8ab
pacify eslint
bhousel Nov 14, 2019
21a57f8
Perform trivial geojson -> country-coder replacements
bhousel Nov 15, 2019
29075e9
Remove conversion code
bhousel Nov 15, 2019
fe2726e
Remove korean, latam geojsons, use country coder for these too
bhousel Nov 15, 2019
fe73b97
Adjust Northern Scotland boundary to exclude Faroe Islands
bhousel Nov 15, 2019
8ef74bf
Remove antarctia folder
bhousel Nov 15, 2019
73085c5
Resource `includeLocations` can now be required
bhousel Nov 15, 2019
5216b57
Update documentation
bhousel Nov 15, 2019
4f6a953
Warn if a geojson file has such small area it should instead be a point
bhousel Nov 15, 2019
637a029
Rename `df` -> `brasilia_df`
bhousel Nov 15, 2019
b3dd156
Add totals to `npm run stats`
bhousel Nov 15, 2019
16d3435
Drop the single-quote eslint rule
bhousel Nov 15, 2019
6f525e4
Markdown formatting
bhousel Nov 15, 2019
5e16dfe
Use console.warn for warning
bhousel Nov 15, 2019
2afc0af
Add locationToFeature function
bhousel Nov 16, 2019
9eb21ae
Use locationToFeature in build script
bhousel Nov 17, 2019
2d01c0a
Split `locationToFeature` and `isValidLocation`
bhousel Nov 17, 2019
5527f76
Get combined.geojson working again, now with country coder data
bhousel Nov 17, 2019
9af5aed
Export isValidLocation and locationToFeature
bhousel Nov 18, 2019
0dadd39
Add tests for locationToFeature and isValidLocation
bhousel Nov 18, 2019
f843698
Drop precision on generated 25km point-circle features
bhousel Nov 18, 2019
2b82144
Make sure all features contain an area property
bhousel Nov 18, 2019
9752916
Remove area properties from geojsons - do this with code instead
bhousel Nov 18, 2019
d9ea5f7
Test that returned features have a numeric `area` property
bhousel Nov 18, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
122 changes: 60 additions & 62 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,64 +1,62 @@
{
"env": {
"node": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"extends": [
"eslint:recommended"
],
"rules": {
"dot-notation": "error",
"eqeqeq": ["error", "smart"],
"indent": ["off", 4],
"keyword-spacing": "error",
"linebreak-style": ["error", "unix"],
"no-caller": "error",
"no-catch-shadow": "error",
"no-console": "warn",
"no-div-regex": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-floating-decimal": "error",
"no-implied-eval": "error",
"no-invalid-this": "error",
"no-iterator": "error",
"no-labels": "error",
"no-label-var": "error",
"no-lone-blocks": "error",
"no-loop-func": "error",
"no-multi-str": "error",
"no-native-reassign": "error",
"no-new": "error",
"no-new-func": "error",
"no-new-wrappers": "error",
"no-octal": "error",
"no-octal-escape": "error",
"no-process-env": "error",
"no-proto": "error",
"no-prototype-builtins": "off",
"no-return-assign": "off",
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow": "off",
"no-shadow-restricted-names": "error",
"no-throw-literal": "error",
"no-unneeded-ternary": "error",
"no-unused-expressions": "error",
"no-unexpected-multiline": "error",
"no-unused-vars": "warn",
"no-void": "error",
"no-warning-comments": "warn",
"no-with": "error",
"no-use-before-define": ["off", "nofunc"],
"semi": ["error", "always"],
"semi-spacing": "error",
"space-unary-ops": "error",
"wrap-regex": "off",
"quotes": ["error", "single"]
}
"env": {
"node": true,
"es6": true
},
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module"
},
"extends": [
"eslint:recommended"
],
"rules": {
"dot-notation": "error",
"eqeqeq": ["error", "smart"],
"keyword-spacing": "error",
"linebreak-style": ["error", "unix"],
"no-caller": "error",
"no-catch-shadow": "error",
"no-console": "warn",
"no-div-regex": "error",
"no-extend-native": "error",
"no-extra-bind": "error",
"no-floating-decimal": "error",
"no-implied-eval": "error",
"no-invalid-this": "error",
"no-iterator": "error",
"no-labels": "error",
"no-label-var": "error",
"no-lone-blocks": "error",
"no-loop-func": "error",
"no-multi-str": "error",
"no-native-reassign": "error",
"no-new": "error",
"no-new-func": "error",
"no-new-wrappers": "error",
"no-octal": "error",
"no-octal-escape": "error",
"no-process-env": "error",
"no-proto": "error",
"no-prototype-builtins": "off",
"no-return-assign": "off",
"no-script-url": "error",
"no-self-compare": "error",
"no-sequences": "error",
"no-shadow": "off",
"no-shadow-restricted-names": "error",
"no-throw-literal": "error",
"no-unneeded-ternary": "error",
"no-unused-expressions": "error",
"no-unexpected-multiline": "error",
"no-unused-vars": "warn",
"no-void": "error",
"no-warning-comments": "warn",
"no-with": "error",
"no-use-before-define": ["off", "nofunc"],
"semi": ["error", "always"],
"semi-spacing": "error",
"space-unary-ops": "error",
"wrap-regex": "off"
}
}
96 changes: 48 additions & 48 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@

There are 2 kinds of files in this project:

* Under `features/` there are `.geojson` files to describe the areas where the communities are active
* Under `resources/` there are `.json` files to describe the community resources
* Under `features/` there are `.geojson` files to describe the areas where the communities are active

##### tl;dr

To add your community resource:

* Add a **feature** `.geojson` file under `features/` folder
* This is a boundary around where the resource is active
* You can use [geojson.io](http://geojson.io) or other tools to create these.
* Add a **resource** `.json` file under `resources/` folder
* (required) Add a **resource** `.json` file under `resources/` folder
* This contains info about what the resource is (slack, forum, mailinglist, facebook, etc.)
* You can just copy and change an existing one
* Several resources can share the same `.geojson` feature
* Each resource needs an `includeLocations` property to say where it is active.
* (optional) Add a **feature** `.geojson` file under `features/` folder
* This is a boundary around where the resource is active
* You can use [geojson.io](http://geojson.io) or other tools to create these.
* `npm run test`
* This will build and check for errors and make the files pretty

Expand All @@ -30,56 +30,18 @@ To add your community resource:
* Run `npm install` to install libraries


### Features

These are `*.geojson` files found under the `features/` folder. Each feature file contains a single GeoJSON `Feature` for a region where a community resource is active.

Feature files look like this:

```js
{
"type": "Feature",
"id": "usa_full",
"properties": { "area": 11645277.77 },
"geometry": {
"type": "MultiPolygon",
"coordinates": [
...
]
}
}
```

Note: A `FeatureCollection` containing a single `Feature` is ok too - the build script can handle this.

There are many online tools to create or modify these `.geojson` files. A workflow could be:

1. Create the shape with [geojson.io](http://geojson.io) from scratch.

or

1. Generate a precise file with the [Polygon creation](http://polygons.openstreetmap.fr/) from an OSM Relation.
1. Simplify the file with [Mapshaper](http://mapshaper.org/). Beware that the simplification probably cuts some border areas.
1. So load the file in [geojson.io](http://geojson.io) and include the border areas again and perhaps reduce the point count further. It is probably better to have the feature a bit larger than missing an area.

Each feature must have a unique `id` property, for example `usa_full`.

You do not need to supply an `area` property. The `npm run build` script will calculate the `area` property automatically.


### Resources

These are `*.json` files found under the `resources/` folder.
Each resource file contains a single JSON object with information about
the community resource.
Each resource file contains a single JSON object with information about the community resource.

Resource files look like this:

```js
{
"id": "OSM-US-slack",
"featureId": "usa_full",
"type": "slack",
"includeLocations": ["us"],
"countryCodes": ["us"],
"languageCodes": ["en"],
"name": "OpenStreetMap US Slack",
Expand Down Expand Up @@ -111,14 +73,21 @@ Resource files look like this:
Here are the properties that a resource file can contain:

* __`id`__ - (required) A unique identifier for the resource.
* __`featureId`__ - (optional) A unique identifier for the feature. This `featureId` matches the resource to a .geojson feature. If null, this is a global resource.
* __`type`__ - (required) Type of community resource (see below for list).
* __`includeLocations`__ - (required) Array of locations where the resource is active. May contain any of these:
* Strings recognized by the [country-coder library](https://github.com/ideditor/country-coder#readme). These should be [ISO 3166-1 2 or 3 letter country codes or UN M.49 numeric codes](https://en.wikipedia.org/wiki/List_of_countries_by_United_Nations_geoscheme).<br/>_Example: `"de"`_
* Filenames for `.geojson` files saved under the `/features` folder<br/>_Example: `"de-hamburg.geojson"`_
* Points as `[longitude, latitude]` coordinate pairs. A 25km radius circle will be computed around the point.<br/>_Example: `[8.67039, 49.41882]`_
* __`excludeLocations`__ - (optional) Array of locations to exclude from `includeLocations` (specified in the same format):
* __`name`__ - (required) Display name for this community resource
(in English, will be sent to Transifex for translation to other languages)
* __`description`__ - (required) One line description of the community resource
(in English, will be sent to Transifex for translation to other languages)
* __`extendedDescription`__ - (optional) Longer description of the community resource
(in English, will be sent to Transifex for translation to other languages)
* __`url`__ - (required) A url link to visit the community resource
* __`signupUrl`__ - (optional) A url link to sign up for the community resource
* __`countryCodes`__ - (optional) Array of [two letter country codes](https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes) where the community is active
* __`countryCodes`__ - (optional) Array of [two letter country codes](https://en.wikipedia.org/wiki/List_of_countries_by_United_Nations_geoscheme) where the community is active
* __`languageCodes`__ - (optional) Array of [two letter](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) or [three letter](https://en.wikipedia.org/wiki/List_of_ISO_639-3_codes) spoken by this community
* __`order`__ - (optional) When several resources with same geography are present, this adjusts the display order (default = 0, higher numbers display more prominently)

Expand Down Expand Up @@ -165,6 +134,37 @@ Resources may have events. These are optional.
* __`url`__ - (optional) A url link for the event


### Features

These are `*.geojson` files found under the `features/` folder. Each feature file contains a single GeoJSON `Feature` for a region where a community resource is active.

Feature files look like this:

```js
{
"type": "Feature",
"id": "boston_metro",
"properties": {},
"geometry": {
"type": "Polygon",
"coordinates": [...]
}
}
```

Note: A `FeatureCollection` containing a single `Feature` is ok too - the build script can handle this.

There are many online tools to create or modify these `.geojson` files. A workflow could be:

1. Create the shape with [geojson.io](http://geojson.io) from scratch.

or

1. Generate a precise file with the [Polygon creation](http://polygons.openstreetmap.fr/) from an OSM Relation.
1. Simplify the file with [Mapshaper](http://mapshaper.org/). Beware that the simplification probably cuts some border areas.
1. So load the file in [geojson.io](http://geojson.io) and include the border areas again and perhaps reduce the point count further. It is probably better to have the feature a bit larger than missing an area.


### Building

* Just `npm run test`
Expand Down
16 changes: 10 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ might find interesting or helpful.
#### Source files
The source files for this index are stored in two kinds of files:

* Under `features/` there are `.geojson` files to describe the areas where the communities are active
* Under `resources/` there are `.json` files to describe the community resources
* Under `features/` there are `.geojson` files to describe the areas where the communities are active

:point_right: See [CONTRIBUTING.md](CONTRIBUTING.md) for info about how to add your
community resource to this index.
Expand All @@ -43,33 +43,37 @@ Several files are published under `dist/`

##### tl;dr

* Add a **feature** `.geojson` file under `features/` folder
* This is a boundary around where the resource is active
* You can use [geojson.io](http://geojson.io) to create these
* Add a **resource** `.json` file under `resources/` folder
* (required) Add a **resource** `.json` file under `resources/` folder
* This contains info about what the resource is (slack, forum, mailinglist, facebook, etc.)
* You can just copy and change an existing one
* Several resources can share the same `.geojson` feature
* Each resource needs an `includeLocations` property to define where it is active.
* (optional) Add a **feature** `.geojson` file under `features/` folder
* This is a boundary around where the resource is active
* You can use [geojson.io](http://geojson.io) or other tools to create these.
* `npm run test`
* This will build and check for errors and make the files pretty


#### Prerequisites

* [Node.js](https://nodejs.org/) version 8 or newer
* [`git`](https://www.atlassian.com/git/tutorials/install-git/) for your platform


#### Installing

* Clone this project, for example:
`git clone [email protected]:osmlab/osm-community-index.git`
* `cd` into the project folder,
* Run `npm install` to install libraries


#### Building

* Just `npm run test`
* This will check the files for errors and make them pretty.


### License

osm-community-index is available under the [ISC License](https://opensource.org/licenses/ISC).
Expand Down
Loading