Skip to content

Commit

Permalink
Major updates, merging private and public versions of the repo.
Browse files Browse the repository at this point in the history
  • Loading branch information
tschoffelen committed Jun 19, 2021
1 parent ec347d9 commit 1e9a149
Show file tree
Hide file tree
Showing 207 changed files with 118,033 additions and 19,215 deletions.
32 changes: 3 additions & 29 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ orbs:
aws-s3: circleci/[email protected]

jobs:
build_backend:
build:
docker:
- image: circleci/node:12
working_directory: /home/circleci/app
Expand All @@ -16,39 +16,13 @@ jobs:
command: yarn
- run:
name: Deploy application
command: yarn deploy

build_frontend:
working_directory: /home/circleci/app/web
docker:
- image: circleci/node:8.15.0
steps:
- checkout:
path: /home/circleci/app
- run: sudo apt-get install python-dev
- run:
name: Install dependencies
command: yarn
- run:
name: Build React app
command: yarn build
- aws-s3/sync:
from: build
to: 's3://mapitout.iamsterdam.com'
arguments: --acl public-read --cache-control "max-age=86400"
overwrite: true
- run: aws cloudfront create-invalidation --distribution-id E5M144WQ6D3CE --paths /\*
command: yarn deploy --stage production

workflows:
version: 2
workflow:
jobs:
- build_backend:
context: includable-ecs
filters:
branches:
only: master
- build_frontend:
- build:
context: includable-ecs
filters:
branches:
Expand Down
10 changes: 10 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
TRAVELTIME_APP_ID=""
TRAVELTIME_APP_KEY=""

CLOUDFRONT_DISTRIBUTION_ID=""
S3_BUCKET=""

REACT_APP_API_BASE_URL=""
REACT_APP_GOOGLE_MAPS_TOKEN=""
REACT_APP_GOOGLE_ANATLYTICS_TAGS=""
REACT_APP_SENTRY_DSN=""
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,22 @@ dist/

# Serverless directories
.serverless
.webpack

# Editor configs
.vscode
.idea
.husky

# Packaging
node_modules
*.log
package-lock.json

# Lingui
src/locales/_build
src/locales/*/*.js

# Importer
import/**/*.json
import/yarn.lock
File renamed without changes.
1 change: 1 addition & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
165 changes: 165 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007

Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.


This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.

0. Additional Definitions.

As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.

"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.

An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.

A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".

The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.

The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.

1. Exception to Section 3 of the GNU GPL.

You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.

2. Conveying Modified Versions.

If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:

a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or

b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.

3. Object Code Incorporating Material from Library Header Files.

The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:

a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.

b) Accompany the object code with a copy of the GNU GPL and this license
document.

4. Combined Works.

You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:

a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.

b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.

c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.

d) Do one of the following:

0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.

1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.

e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)

5. Combined Libraries.

You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:

a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.

b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.

6. Revised Versions of the GNU Lesser General Public License.

The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.

Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.

If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
99 changes: 56 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,65 +1,78 @@
![MapItOut logo](/docs/logo.png)
# MapItOut

MapItOut is a tool to calculate how far you can travel with certain types of transport within Amsterdam and its surrounding cities/municipalities. It also shows POIs such as educational institutes.

The current tech stack provides coverage within The Netherlands but contains some "bias" towards the Amsterdam region. Such as the starting coordinates on launch, and the Google Places search being targeted towards the Amsterdam region.
MapitOut is a tool to calculate how far you can travel with certain types of transport within Amsterdam and its
surrounding cities/municipalities. It also shows POIs such as educational institutes.

---

**This is a public copy of the [MapitOut web application](https://mapitout.iamsterdam.com).**

This repository can be cloned and used by other parties, under the conditions of the GNU Lesser General Public License
3.0. The following conditions apply:

- Do not utilize the name MapItOut or the logo, or any of the related assets (branding, videos, FAQs, blog)
- Provide references to the original source material (this repository and URL), with the text: "Based on the open-source
MapItOut application"

---

The current tech stack provides coverage within The Netherlands but contains some "bias" towards the Amsterdam region.
Such as the starting coordinates on launch, and the Google Places search targeted towards the Amsterdam region.

![Screenshot of the application in a browser window](/docs/preview.png)

# Gettings started
## Getting started

This app uses a few services in order to run:

- [TravelTime Platform's Search](https://www.traveltimeplatform.com/search) API key
- [Google Maps](https://developers.google.com/maps/documentation/javascript/get-api-key) API key, this key needs to have access to the `geometry`, `drawing` and `places` features
- [Google Maps](https://developers.google.com/maps/documentation/javascript/get-api-key) API key, this key needs to have
access to the `geometry`, `drawing` and `places` features

Both API keys can be requested by following the guides provided by said provider (check the links).

## Tech
## Tech stack

## Backend
The only backend component to this application is a simple AWS Lambda (written in JavaScript) to proxy the [Travel Time Platform's API](https://www.traveltimeplatform.com/). By proxying this request the API token can be injected into the request and remain hidden from the user.
### Back-end

It is deployed via [Serverless](https://serverless.com/).
The only backend component to this application is a simple AWS Lambda (written in JavaScript) to proxy
the [Travel Time Platform's API](https://www.traveltimeplatform.com/). By proxying this request the API token can be
injected into the request and remain hidden from the user.

## Frontend
The frontend is a React application generated with the [Create React App](https://github.com/facebook/create-react-app) project. It's written in [TypeScript](https://www.typescriptlang.org/), TypeScript is a typed superset of JavaScript that compiles to plain JavaScript.
It is deployed via [Serverless](https://serverless.com/).

The frontend specific documentation can be found inside the `web` directory, nearly all the code is self explanatory when your are familiar with React.
### Front-end

# Import
The frontend requires a `schools.json` file (`web/src/assets/schools.json`) which contains the addresses of all schools (depending on configuration), it can be generated using the import scripts and appropriate CSV files.
The frontend is a React application generated with the [Create React App](https://github.com/facebook/create-react-app)
project. It's written in [TypeScript](https://www.typescriptlang.org/), TypeScript is a typed superset of JavaScript
that compiles to plain JavaScript.

The generation of this file is done as follows:
1. Entering the root directory of the scripts (`cd import`)
2. Running `node src/main.js --primary <path> --secondary <path> --international <path>`
3. Running `node src/trim.js`
The frontend specific documentation can be found inside the `web` directory, nearly all the code is self explanatory
when your are familiar with React.

The main script merges the data from three CSV files, geocodes the addresses and saves the data as a JSON file. The script requires thee arguments as described below.
### Importer tool

| argument | description |
|-----|-----|
| primary | path to the primary schools file<sup>1</sup> |
| secondary | path to the secondary schools file<sup>2</sup> |
| international | path to the international schools file |
The frontend requires a `schools.json` file (`src/assets/schools.json`) which contains the addresses of all
schools (depending on configuration), it can be generated using the import scripts and appropriate CSV files.

<sup>1</sup> Can be downloaded from the [DUO website (primary education)](https://duo.nl/open_onderwijsdata/databestanden/po/adressen/)
<sup>2</sup> Can be downloaded from the [DUO website (secondary education)](https://duo.nl/open_onderwijsdata/databestanden/vo/adressen/)
The generation of this file can be done using this command:

All three CSV files will be used to determine certain properties and must therefor adhere to certain standards, mainly the column names and the fact that the application assumes all required fields to be filled in correctly. The naming convention used in the process are based on the default column names as presented in the documents provided by DUO.
```shell
cd import && yarn start
```

| column name | description | required in |
|-----|-----|-----|
| `VESTIGINGSNAAM` or `INSTELLINGSNAAM` | title | all |
| `INTERNETADRES` | URL | all |
| `STRAATNAAM` | street | all |
| `HUISNUMMER-TOEVOEGING` | house number | all |
| `POSTCODE` | postal code | all |
| `PLAATSNAAM` | city | all |
| `TYPE` | _"primary"_, _"secondary"_ or _"mixed"_ | international |
The main script merges the data from three CSV files, geocodes the addresses and saves the data as a JSON file.

The trim script removes invalid entries and is able to filter the previously generated JSON file based on distance from provided center coordinates. The arguments mentioned in the table below are optional, you can either use all off them, or none.
All three CSV files will be used to determine certain properties and must therefore adhere to certain standards, mainly
the column names and the fact that the application assumes all required fields to be filled in correctly. The naming
convention used in the process are based on the default column names as presented in the documents provided by DUO.

| argument | description |
|----|-----|
| lat | latitude of the center |
| lng | longitude of the center |
| radius | inclusion radius, provided in kilometers |
| column name | description | required in |
| ------------------------------------- | --------------------------------------- | ------------- |
| `VESTIGINGSNAAM` or `INSTELLINGSNAAM` | title | all |
| `INTERNETADRES` | URL | all |
| `STRAATNAAM` | street | all |
| `HUISNUMMER-TOEVOEGING` | house number | all |
| `POSTCODE` | postal code | all |
| `PLAATSNAAM` | city | all |
| `TYPE` | _"primary"_, _"secondary"_ or _"mixed"_ | international |
Binary file removed docs/logo.png
Binary file not shown.
Loading

0 comments on commit 1e9a149

Please sign in to comment.