Skip to content

Commit

Permalink
Merge pull request #298 from osmlab/country-coder
Browse files Browse the repository at this point in the history
Country coder
  • Loading branch information
bhousel authored Nov 18, 2019
2 parents 36cd4c7 + d9ea5f7 commit 4dbc77f
Show file tree
Hide file tree
Showing 704 changed files with 2,149 additions and 12,434 deletions.
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

0 comments on commit 4dbc77f

Please sign in to comment.