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

WIP: Getting started #14

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
1b1b5e9
added a few necessary tools
sdahlbac Nov 1, 2016
94da525
whitespace
sdahlbac Nov 1, 2016
a2514ca
let's exit early unless an api key is provided
sdahlbac Nov 1, 2016
cdb5cf7
let's make sure we have the update_bats directory
sdahlbac Nov 1, 2016
dbbffff
[opinion] make gdal a normal dependency
sdahlbac Nov 1, 2016
293809e
whitespace
sdahlbac Nov 1, 2016
da6a6df
more prereqs and some notes
sdahlbac Nov 1, 2016
3287ff2
more findings
sdahlbac Nov 1, 2016
d055d00
wording
sdahlbac Nov 1, 2016
a11d985
make a join_osm_mtk script for bash.
sdahlbac Nov 1, 2016
7a9f850
Revert "[opinion] make gdal a normal dependency"
sdahlbac Nov 4, 2016
05d31f9
add a script for downloading the retkikartta bits
sdahlbac Nov 4, 2016
8fcc616
we want _euref
sdahlbac Nov 6, 2016
2c34899
liikennevirasto download script
sdahlbac Nov 6, 2016
1c0d2c4
ignore more stuff
sdahlbac Nov 6, 2016
1ec6a5e
more usage
sdahlbac Nov 6, 2016
7eb5315
let's ignore .idea
sdahlbac Nov 6, 2016
189212f
more shebangs to the people
sdahlbac Nov 6, 2016
c04aabf
Merge branch 'master' into getting-started
sdahlbac Nov 6, 2016
63f3833
WIP
sdahlbac Dec 3, 2016
36cb80a
Merge branch 'master' of https://github.com/pailakka/mtk2garmin into …
sdahlbac Dec 3, 2016
9558a59
Merge branch 'master' of https://github.com/pailakka/mtk2garmin into …
sdahlbac Dec 3, 2016
acf221a
Some kind of progress indication seems nice
sdahlbac Dec 3, 2016
6670d9a
platform independence
sdahlbac Dec 3, 2016
cb56211
whitespace
sdahlbac Dec 3, 2016
f1f0cd5
An attempt to improve path handling
sdahlbac Dec 3, 2016
775b142
[NOT compatible] could not get shp grid to work, also, the syvyyskayr…
sdahlbac Dec 3, 2016
f2cf97a
[NOT compatible] this also had a different name
sdahlbac Dec 3, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions USAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,18 @@
* osmconvert64 (https://wiki.openstreetmap.org/wiki/Osmconvert) and osmfilter (http://wiki.openstreetmap.org/wiki/Osmfilter) needs to be found from PATH
* mgkmap and splitter (http://www.mkgmap.org.uk/) needs to be found from PATH
* Osmosis for Mapsforge conversion (https://wiki.openstreetmap.org/wiki/Osmosis)
* wget
* Python 2 (http://www.python.org)
* requests (`pip install requests`)
* urllib3 (`pip install urllib3`)
* wfs client (?? qgis?)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WFS clientti ei varsinaisesti pakollinen, mutta helpottaa toki merkittävästi. QGis sopii oikein hyvin siihen puuhaan.

* java
* maven
* Finnish national grid dataset (only 12km x 12km grid needed)
* Can be obtained from https://tiedostopalvelu.maanmittauslaitos.fi/geoserver/ows/?service=wfs (License unknown, assumed CC 4.0 like other NLS data)
* Layer "Grid"
* National topographic database from NLS (about 9.5 GB)
* Loaded using helper script `update_data.py`. Simply running `python update_data.py <api_key>` creates necessary directory structure and creates 8 .bat files to load the whole (or just changed grid tiles) topographic database using wget (assumes wget can be found from PATH)
* Loaded using helper script `update_data.py`. Simply running `python update_data.py <api_key>` creates necessary directory structure and creates 8 .bat files to load the whole (or just changed grid tiles) topographic database using wget (assumes wget can be found from PATH).
* Requires personal API-key to ATOM-feed (http://www.maanmittauslaitos.fi/aineistot-palvelut/latauspalvelut/avoimien-aineistojen-tiedostopalvelu/muutostietopalvelu)
* Whole process is based on NLS specific GML format because it is the only format containing all of the data and attributes.
* OpenStreetMap
Expand All @@ -29,7 +36,12 @@
* pienriista (not included in styles / tag mapping)
* National/official hunting areas are not included in the maps because valid concerns about data validity and timeliness.

### OSX / Linux notes
(So far) The batch files can be run as is provided you mark them executable (e.g. `chmod u+x update_bats/loaddata_0.bat`)

## MTKtoGarminConverter
`mvn package` to build

This is the actual process doing the conversion from national topographic database GML-files to OSM PBF format and
combining most of the former datasets with the topograhic data. It does some necessary data transformations and simplifications on the way (defined in `*TagHandler`classes).
All of the work is done in ETRS-TM35FIN (3067) coordinate system and coordinates are transformed to WGS84 only for PBF output.
Expand All @@ -38,7 +50,7 @@ Because of this combination/connection process, the whole conversion process mus
Process is especially memory optimized and runs consistently well within 2 GB of memory, there is much room for more optimization and for example threaded processing is completely possible.

Process assumes that all data is located in `c:\geodata`. The process works one grid cell at a time and loads auxillary data based on grid cell bounding box and removes unnecessary data from memory after processing. Technically every OGR compatible format should be good for the auxillary data.
`C:\geodata\mtkgml\` directory is read using 2 level directory structure (`eg. C:\geodata\mtkgml\L4\L44\*.zip`). Processing of the whole topographic database is not necessary, if the directory structure matches.
`C:\geodata\mtkgml\` directory is read using 2 level directory structure (`eg. C:\geodata\mtkgml\L4\L44\*.zip`). Processing of the whole topographic database is not necessary, if the directory structure matches.

This step takes about 8 hours with a (slow) SSD, Intel Core i7 920 and 12 GB RAM (and output to HD).

Expand All @@ -58,7 +70,7 @@ Resulting gmapsupp.img is good to be transferred to GPS or it can be splitted to
## Creating Mapsforge map in AWS EC2
Consult also https://github.com/mapsforge/mapsforge/blob/master/docs/Getting-Started-Map-Writer.md

This steps requires large amounts of memory so EC2 instance is used, r3.2xlarge seems to have enough memory. Tag mapping affects memory usage significantly.
This steps requires large amounts of memory so EC2 instance is used, r3.2xlarge seems to have enough memory. Tag mapping affects memory usage significantly.

Styles should be defined at least on some level before the conversion proces because conversion includes only features defined in tag mapping.

Expand All @@ -73,4 +85,3 @@ The actual process is as follows:
2. Run Osmosis with writer plugin and tag-mapping and copyright notices with `osmosis --rbf all_osm.osm.pbf --mapfile-writer file=all.map bbox=59.4507573,19.0714057,70.1120744,31.6133108 tag-conf-file=mml_tag-mapping_tidy.xml type=hd comment="(c) NLS, Metsahallitus, Liikennevirasto, OpenStreetMap contributors 2016"`

And out comes all.map containing all of the data in Mapsforge format

8 changes: 3 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.gdal</groupId>
<artifactId>gdal</artifactId>
<version>2.1.0</version>
<systemPath>C:\Program Files\GDAL\java\gdal.jar</systemPath>
<scope>system</scope>
<groupId>org.gdal</groupId>
<artifactId>gdal</artifactId>
<version>2.1.0</version>
</dependency>
<dependency>
<groupId>com.google.protobuf</groupId>
Expand Down
12 changes: 10 additions & 2 deletions update_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import datetime
import StringIO

if len(sys.argv) < 2:
print "Usage: python update_data.py API_KEY"
sys.exit(1)
api_key = sys.argv[1]

class MMLGrid(handler.ContentHandler):
Expand All @@ -17,9 +20,14 @@ def __init__(self):
self.files = []

self.nfiles = 8

BATCH_FILE_DIR = 'update_bats'
try:
os.makedirs(BATCH_FILE_DIR)
except OSError:
if not os.path.isdir(BATCH_FILE_DIR):
raise
for i in xrange(self.nfiles):
self.files.append(open('update_bats/loaddata_%d.bat' % i,'wb'))
self.files.append(open(BATCH_FILE_DIR + '/loaddata_%d.bat' % i,'wb'))

self.gridnum = 0
self.next = None
Expand Down