Skip to content

Commit

Permalink
releasing v2
Browse files Browse the repository at this point in the history
  • Loading branch information
admin committed Feb 7, 2016
1 parent 6c23ae5 commit 7d2ac0c
Show file tree
Hide file tree
Showing 26 changed files with 1,784 additions and 1,014 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.my*
*~
tmp/*
tmp/*
.idea
.DS_Store
154 changes: 88 additions & 66 deletions 42MapGenerator.sh
Original file line number Diff line number Diff line change
@@ -1,89 +1,111 @@
#!/bin/bash

####################################################################
# jgigault @ student.42.fr 06 51 15 98 82 #
####################################################################
#####################################################
# _ _ ____ __ __ ____ #
# | || ||___ \| \/ | __ _ _ __ / ___| ___ _ __ #
# | || |_ __) | |\/| |/ _` | '_ \| | _ / _ \ '_ \ #
# |__ _/ __/| | | | (_| | |_) | |_| | __/ | | | #
# |_||_____|_| |_|\__,_| .__/ \____|\___|_| |_| #
# jgigault @ student.42.fr |_| 06 51 15 98 82 #
#####################################################


function mapgen_install_dir
{
local SOURCE="${BASH_SOURCE[0]}"
local DIR
while [ -h "${SOURCE}" ]
do
DIR="$(cd -P "$(dirname "${SOURCE}")" && pwd)"
SOURCE="$(readlink "${SOURCE}")"
[[ "${SOURCE}" != /* ]] && SOURCE="${DIR}/${SOURCE}"
done
printf "%s" "$(cd -P "$(dirname "${SOURCE}")" && pwd)"
}

GLOBAL_ENTRYPATH=$(pwd)
GLOBAL_INSTALLDIR=$(mapgen_install_dir)
cd "${GLOBAL_INSTALLDIR}"

MAPGENERATOR_SH=1
RETURNPATH=$(pwd | sed 's/ /\ /g')
CVERSION=$(git log --oneline 2>/dev/null | wc -l | sed 's/ //g')
if [ "$CVERSION" == "" ]; then CVERSION="???"; fi

OPT_NO_UPDATE=0
OPT_NO_COLOR=0
OPT_NO_TIMEOUT=0

i=1
while (( i <= $# ))
do
if [ "${!i}" == "--no-update" ]
then
OPT_NO_UPDATE=1
fi
if [ "${!i}" == "--no-color" ]
then
OPT_NO_COLOR=1
fi
if [ "${!i}" == "--no-timeout" ]
then
OPT_NO_TIMEOUT=1
fi
(( i += 1 ))
case "${!i}" in
"--no-update") OPT_NO_UPDATE=1 ;;
"--no-color") OPT_NO_COLOR=1 ;;
"--no-timeout") OPT_NO_TIMEOUT=1 ;;
esac
(( i += 1 ))
done

source includes/maps.sh
source includes/data_providers.sh
source includes/utils.sh
source includes/map.sh
source includes/update.sh
source includes/credits.sh
source includes/display_menu.sh
source includes/display_header.sh
source includes/display_center.sh
source includes/display_section.sh
source includes/display_error.sh
source includes/display_success.sh
source includes/display_right.sh
source includes/display_spinner.sh
source includes/generate_map.sh
source includes/download_map.sh
source includes/google_api.sh
source includes/ign.sh
source includes/noaa.sh
source includes/mgds.sh
source includes/config.sh
source includes/custom.sh
source includes/credits.sh
source includes/update.sh


function main
{
tput civis
display_header
display_menu\
""\
gen_custom "find your own country with the Google Geocoding API"\
main_ign "preset regions: IGN's data (France and Overseas)"\
main_noaa "preset regions: NOAA's data (World)"\
display_credits "CREDITS"\
"open https://github.com/jgigault/42MapGenerator/issues/new" "REPORT A BUG"\
exit_generator "EXIT"
local RETURNFUNCTION="main" DATA_PROVIDER_ID="" MAPS_ID="" MAPS_FORMAT="" MY_EXPORT_PATH=$(utils_get_config "export_path")
if [ "${MY_EXPORT_PATH}" == "" ]
then
config_path
else
display_header
display_section
display_menu\
"" "Select a data provider:"\
main_ign "${DATA_PROVIDERS[$(utils_data_provider_id "IGN")]}"\
main_noaa "${DATA_PROVIDERS[$(utils_data_provider_id "NOAA")]}"\
main_mgds "${DATA_PROVIDERS[$(utils_data_provider_id "MGDS")]}"\
"_"\
"config_path" "Change export directory"\
"_"\
"utils_option_set OPT_NO_TIMEOUT" "$(if [ "$OPT_NO_TIMEOUT" == 0 ]; then echo "Disable timeout (--no-timeout)"; else echo "Enable timeout"; fi)"\
"utils_option_set OPT_NO_COLOR" "$(if [ "$OPT_NO_COLOR" == 0 ]; then echo "Disable color (--no-color)"; else echo "Enable color"; fi)"\
"_"\
display_credits "CREDITS"\
"open https://github.com/jgigault/42MapGenerator/issues/new" "REPORT A BUG"\
utils_exit "EXIT"
fi
}

function main_ign
{
display_header
display_menu\
""\
"gen_map 0" "France Métropolitaine"\
"gen_map 1" "DOM TOM: Guadeloupe"\
"gen_map 2" "DOM TOM: Martinique"\
"gen_map 3" "DOM TOM: Réunion"\
"gen_map 4" "DOM TOM: Guyane"\
"gen_map 5" "DOM TOM: Saint Martin - Saint Barthélémy"\
main "BACK TO MAIN MENU"
}
utils_set_env
utils_set_colors

function main_noaa
{
display_header
display_menu\
""\
"gen_map 8" "Amazonia"\
"gen_map 14" "Australia"\
"gen_map 13" "Cordillera de los Andes"\
"gen_map 16" "Ethiopia"\
"gen_map 6" "Europe"\
"gen_map 12" "Great Britain & Ireland"\
"gen_map 15" "Great Lakes (North America)"\
"gen_map 9" "India & Himalaya"\
"gen_map 11" "Italy"\
"gen_map 10" "New Zealand"\
"gen_map 7" "West Coast (North America)"\
main "BACK TO MAIN MENU"
}
#if [ "$OPT_NO_UPDATE" == "0" ]
#then
#update
#fi

if [ "$OPT_NO_UPDATE" == "0" ]
then
update
fi
main
tput civis
tput smcup
utils_update
tput rmcup
tput cnorm
cd "${GLOBAL_ENTRYPATH}"
113 changes: 86 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,99 @@
# 42MapGenerator
# 42MapGenerator (v2)

<img src="http://i.imgur.com/RLfUrZc.png" align="right" width="50%" />42 Map Generator is a tiny bash script developed at 42 school for generating maps for FdF project whose data are extracted from IGN's and NOAA's servers.
<img src="http://i.imgur.com/wnXCjUK.png" align="right" />42 Map Generator is a tiny bash script developed at 42 school for downloading and generating maps of the real world for the pedagogical project FdF.

Choose a region and an export directory and let the script generate 5 maps of different accuracies (XXL is original data, XL, L, M and S).
A map for the project FdF is a simple file based on the *ASCII Grid Format* whose headers were removed. The *ASCII Grid Format* is a good means of distributing raster image data files. It is widely supported and easy to import and export from most GIS softwares (Geographic Information System).

Horizontal accuracy of the maps according to the data source:
* IGN's data: up to 250 meters
* NOAA's data: up to 1852 meters (1 arc-minute)
The script 42 Map Generator allows you to find by name the coordinates of any country thanks to the *Google Geocoding API* and to reduce the exported file size by providing 5 different formats (XXL, XL, L, M, S).

It extracts data from 3 different providers:
* **IGN** (National Institute of Geographic and Forest Information / France), providing horizontal accuracy up to 250 meters of France and Overseas but excluding marine topography
* **NOAA** (National Oceanic and Atmospheric Administration / USA), providing horizontal accuracy up to 1852 meters (1 arc-meter) of any region of the world but with a limited capacity of exported file size
* **MGDS** (Marine Geoscience Data System / USA), providing an exceptional horizontal accuracy up to 100 meters of any region of the world, including marine topography but excluding some continental regions like Europe.

At first, you're asked to select an export directory in which to save the computed FdF maps. Then select a data provider and an available region of the world. Finally, choose a mode of export of the marine's coordinates between flatten and keep data.

## install & launch
git clone https://github.com/jgigault/42MapGenerator ~/42MapGenerator
cd ~/42MapGenerator && sh ./42MapGenerator.sh

## features
* Choose a preset region
* Find your own country with the Google Geocoding API
* Generate random maps (in progress)
```bash
git clone https://github.com/jgigault/42MapGenerator ~/42MapGenerator
cd ~/42MapGenerator && sh ./42MapGenerator.sh
```

## preset regions
* France and Overseas
* Europe, Italy, Great Britain & Ireland
* Great Lakes, West Coast (North America)
* Amazonia, Cordillera de los Andes
* Himalaya & India
* Ethiopia
* Australia, New Zealand
You may also want to set an alias to run it from everywhere, even in your project path. Add this line of code at the end of your shell initialization file (e.g.: ~/.zshrc):

```bash
alias 42MapGenerator='sh ~/42MapGenerator/42MapGenerator.sh'
```

## options
--no-update // Do not check for updates at launch
--no-color // Do not display color tags
--no-timeout // Disable time-out child process

## preview
```
--no-update // Do not check for updates at launch
--no-color // Do not display color tags
--no-timeout // Disable time-out for child processes
```

Add your options as arguments at launch:

```bash
sh ./42MapGenerator --no-update --no-timeout
```

## preset regions

<img src="http://i.imgur.com/g7dFnE9.png" align="right" height="725">
##### IGN

* France Métropolitaine
* DOM-TOM: Guadeloupe
* DOM-TOM: Martinique
* DOM-TOM: Réunion
* DOM-TOM: Guyane
* DOM-TOM: Saint Martin - Saint Barthélémy

##### NOAA / MGDS

* Whole world *(MGDS only)*
* Antarctic *(MGDS only)*
* Arctic *(MGDS only)*
* Europe *(NOAA only)*
* Alaska-Aleutians
* Cascade Range (West Coast USA)
* Central America
* East African Rift System
* Eastern North American Margin
* Gulf of California
* Amazonia
* Cordillera de los Andes
* Izu-Bonin-Marinia
* Nankai
* New Zealand
* Papua New Guinea
* Red Sea
* Himalaya
* Mid-Ocean Ridges: EPR 8-11 N
* Mid-Ocean Ridges: JdF Endeavour
* Mid-Ocean Ridges: Lau Basin

## previews

<img src="http://i.imgur.com/uO6Egii.png?1" width="50%" /><img src="http://i.imgur.com/v5uApWX.png" width="50%" /><img src="http://i.imgur.com/pkOpXLX.png" width="50%" /><img src="http://i.imgur.com/n3K2lh4.png" width="50%" />

## credits
* BD ALTI® - IGN (http://professionnels.ign.fr/bdalti)
* ETOPO1 - NGDC Grid Extraction Tool - NOAA (http://maps.ngdc.noaa.gov/viewers/wcs-client/)
* Google Geocoding API (https://developers.google.com/maps/documentation/geocoding/)

* **MNT BD Alti®**
IGN National Institute of Geographic and Forest Information / France
http://professionnels.ign.fr/bdalti

* **NGDC Grid Extraction Tool**
NOAA National Oceanic and Atmospheric Administration / USA
http://maps.ngdc.noaa.gov/viewers/wcs-client

* **GMRT Map Tool**
MGDS Marine Geoscience Data System / USA
Ryan, W.B.F., S.M. Carbotte, J.O. Coplan, S. O'Hara, A. Melkonian, R. Arko, R.A. Weissel, V. Ferrini, A. Goodwillie, F. Nitsche, J. Bonczkowski, and R. Zemsky (2009), Global Multi-Resolution Topography synthesis, Geochem. Geophys. Geosyst., 10, Q03014, doi: 10.1029/2008GC002332
http://www.marine-geo.org/tools/GMRTMapTool/

* **Google Geocoding API**
https://developers.google.com/maps/documentation/geocoding/le
Loading

0 comments on commit 7d2ac0c

Please sign in to comment.