Skip to content

smaclell/4k

Repository files navigation

4k API

CircleCI PRs Welcome Code of Conduct License

This is a simple service for retrieving/interacting with the 4k world map data. The data exclusively belongs to 4k world map project.

Get started

You must have Docker installed. If you are using Docker for Mac, make sure to share the repo directory.

Please also install Git LFS. Our map files are large enough to have trouble fitting in a normal repo.

To develop the application run ./start.dev

Managing the Data

To simplify the data before publishing we import and restructure it from the individual regions and maps to flat files. Update the individual files unders maps and then run either of the following:

node ./data/map.importer.js
node ./data/region.importer.js

API

GET /regions

Get the list of root regions.

# REQUEST
GET /regions

# RESPONSE
content-type: application/json

{
  "_self": "/regions",
  "roots": [
    {
      "regionKey": "ABW",
      "href": "/regions/ABW"
    }
    ...
  ]
}

GET /regions/:regionKey

Get basic data about the region.

# REQUEST
GET /regions/CAN-MAN

# RESPONSE
content-type: application/json

{
  "_self": "/regions/CAN-MAN",
  "regionKey": "CAN-MAN",
  "label": "Manitoba",
  "country": "Canada",
  "center": {
    "latitude": -97.3639242589,
    "longitude": 55.0593228371
  },
  "parentRegion": {
    "regionKey": "CAN",
    "href": "/regions/CAN"
  },
  "children": []
}

GET /geojson/:regionKey

Get the geojson defining the shape of the region.

# REQUEST
GET /geojson/CAN-MAN

# RESPONSE
content-type: application/json

{
    "type": "Feature",
    "geometry": {
        "type": "Polygon",
        "coordinates": [
            [
                [
                    -98.1205501734768,
                    54.2802499570956,
                    0
                ],
                ...
                [
                    -98.1205501734768,
                    54.2802499570956,
                    0
                ]
            ],
            ...
            [
                [
                    -100.028849917578,
                    53.0991501003509,
                    0
                ],
                ...
                [
                    -98.1927499943503,
                    57.6727498603561,
                    0
                ]
            ]
        ]
    },
    "properties": {
        "regionKey": "CAN-MAN"
    }
}

Contributing

We maintain an active backlog of new features and bugs we would love your help with.

Have a great idea or change you want to share? Awesome. We actively welcome pull requests:

  1. Fork the repo and create your branch from master.
  2. If you've added code that should be tested, add tests.
  3. If you've changed APIs, update the documentation.
  4. Ensure the test suite passes.
  5. Make sure your code lints.

We have adopted a Code of Conduct that we expect project participants to adhere to. Please read the full text so that you can understand what actions will and will not be tolerated.

Deploying

We are running the site using Zeit now.

Deploy using:

now --docker --public

Test the new site to make sure the basics work.

Then alias the new deployment to update the main site:

now alias 4k-yhgtxlebeu.now.sh 4kmaps

License

This project is Apache 2.0 Licensed. We also provide an additional patent grant.