Skip to content

Commit

Permalink
Merge pull request #7 from iandees/timelapse
Browse files Browse the repository at this point in the history
Add support for timelapses with more than 2 frames
  • Loading branch information
gedankenstuecke authored Dec 22, 2024
2 parents f34fae8 + 5411e30 commit 6ebd631
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 183 deletions.
20 changes: 10 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
FROM postgis/postgis:15-3.5 AS development_build

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
RUN apt-get update --quiet \
&& apt-get install --quiet -y --no-install-recommends \
ca-certificates gnupg lsb-release locales \
wget curl \
git-core unzip \
netcat \
&& locale-gen $LANG && update-locale LANG=$LANG
&& locale-gen $LANG && update-locale LANG=$LANG


# Get packages
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
RUN apt-get update --quiet \
&& apt-get install --quiet -y --no-install-recommends \
make \
fonts-hanazono \
fonts-noto-cjk \
Expand Down Expand Up @@ -41,10 +41,10 @@ RUN apt-get update \
&& apt-get autoremove --yes \
&& rm -rf /var/lib/{apt,dpkg,cache,log}/

RUN wget https://downloads.sourceforge.net/gs-fonts/ghostscript-fonts-std-8.11.tar.gz
RUN tar xvf ghostscript-fonts-std-8.11.tar.gz
RUN mkdir -p /usr/share/fonts/type1/
RUN mv fonts/ /usr/share/fonts/type1/gsfonts
RUN wget --quiet https://downloads.sourceforge.net/gs-fonts/ghostscript-fonts-std-8.11.tar.gz \
&& tar xf ghostscript-fonts-std-8.11.tar.gz \
&& mkdir -p /usr/share/fonts/type1/ \
&& mv fonts/ /usr/share/fonts/type1/gsfonts

# Install python libraries

Expand All @@ -61,7 +61,7 @@ RUN usermod -u 1000 postgres
RUN chown -R 1000 ${HOME}
USER postgres

RUN mkdir -p ${HOME}/openstreetmap-carto/data
RUN mkdir -p ${HOME}/openstreetmap-carto/data
RUN mkdir -p ${HOME}/output
RUN mkdir -p ${HOME}/pgdata
WORKDIR ${HOME}
Expand Down
73 changes: 31 additions & 42 deletions make-images.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -11,53 +11,36 @@
"\n",
"## Getting started\n",
"\n",
"### If this is your first time using a notebook like this: \n",
"### If this is your first time using a notebook like this:\n",
"\n",
"1. You can use the up/down arrow keys of your keyboard to move between the different \"cells\" or regions of this notebook. The currently selected one will be highlighed on the left with a colour bar.\n",
"2. You can \"run\" each of these cells/regions by either pressing the \"play\" button in the menu above, or by pressing CTRL+ENTER on your keyboard.\n",
"3. If you are in the \"editing\" mode where you type into a cell, pressing ESC will take you back to the mode where the arrow keys work. \n",
"3. If you are in the \"editing\" mode where you type into a cell, pressing ESC will take you back to the mode where the arrow keys work.\n",
"\n",
"### Uploading the OSM history file\n",
"\n",
"Before we can do the rest of the steps in this notebook, you will have to upload an OSM history file that covers your region of interest. You can find the corresponding files on [Geofabrik's internal download server](https://osm-internal.download.geofabrik.de/?landing_page=true). Login with your OSM account to get to the `internal` files, and then find the page for the your region of interest. Ideally, find the smallest region that covers your area of interest to minimize the filesize you need to upload. \n",
"Before we can do the rest of the steps in this notebook, you will have to upload an OSM history file that covers your region of interest. You can find the corresponding files on [Geofabrik's internal download server](https://osm-internal.download.geofabrik.de/?landing_page=true). Login with your OSM account to get to the `internal` files, and then find the page for the your region of interest. Ideally, find the smallest region that covers your area of interest to minimize the filesize you need to upload.\n",
"\n",
"**The right file**: When you've picked your region, you will likely see two similarly named files listed: `regionname-internal.osh.pbf` and `regionname-latest-internal.osm.pbf`. The file you will want to download is the `regionname-internal.osh.pbf` (i.e. the one that includes `osh` and **no `latest`**).\n",
"\n",
"Once you have downloaded your file onto your computer, you need to upload it into your container:\n",
"\n",
"* If you've launched this notebook in _MyBinder_, you can then open up the filebrowser on the top of the left hand side (The _file_ icon, or by pressing CTRL+SHIFT+F). \n",
"* If you've launched this notebook locally, you're likely in the _notebook_ interface, switch back to the _tree_ view and upload your file there (or put it into the shared folder which is accessible by both the container and your normal operating system). \n",
"* If you've launched this notebook in _MyBinder_, you can then open up the filebrowser on the top of the left hand side (The _file_ icon, or by pressing CTRL+SHIFT+F).\n",
"* If you've launched this notebook locally, you're likely in the _notebook_ interface, switch back to the _tree_ view and upload your file there (or put it into the shared folder which is accessible by both the container and your normal operating system).\n",
"\n",
"\n",
"## Starting to make the comparison images. \n",
"## Starting to make the comparison images.\n",
"\n",
"When you run the code-cell below, it will generate some \"forms\" that will feel familiar form other web-forms, which you can use to enter all the necessary parameters to create your images. These forms allow you to add the _history file_ you have just uploaded, the two time-points you want to compare, the bounding box (i.e. the area you're interested in, which you can find e.g. [via bboxfinder](https://bboxfinder.com)) and the minimum/maximum zoom levels, if you want to create images at different zoom levels. \n",
"When you run the code-cell below, it will generate some \"forms\" that will feel familiar form other web-forms, which you can use to enter all the necessary parameters to create your images. These forms allow you to add the _history file_ you have just uploaded, the two time-points you want to compare, the bounding box (i.e. the area you're interested in, which you can find e.g. [via bboxfinder](https://bboxfinder.com)) and the minimum/maximum zoom levels, if you want to create images at different zoom levels.\n",
"\n",
"Now, run the cell below and then enter all the necessary information in the forms:"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "cf6cc023-ea39-46eb-885e-86a184dc1850",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "405e31685af24471838cd6587a52f032",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(Dropdown(description='File:', options=('external/argentina-internal.osh.pbf', 'external/argenti…"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"cell_type": "code",
"outputs": [],
"execution_count": null,
"source": [
"import ipywidgets as widgets\n",
"import glob\n",
Expand All @@ -76,7 +59,7 @@
"bbox = widgets.Text(\n",
" placeholder='-61.975228,-33.749067,-61.953167,-33.733014',\n",
" description='BBox:',\n",
" disabled=False \n",
" disabled=False\n",
")\n",
"\n",
"\n",
Expand All @@ -100,7 +83,13 @@
" disabled=False,\n",
")\n",
"\n",
"\n",
"num_frames = widgets.BoundedIntText(\n",
" min=2,\n",
" step=1,\n",
" value=2,\n",
" description='Number of frames:',\n",
" disabled=False\n",
")\n",
"\n",
"widgets.VBox([\n",
" filename,\n",
Expand All @@ -110,19 +99,22 @@
" end_date,\n",
" date_label,\n",
" min_zoom_level,\n",
" max_zoom_level])"
]
" max_zoom_level,\n",
" num_frames,\n",
"])"
],
"id": "1b57c91aa6a007a6"
},
{
"cell_type": "markdown",
"id": "0fa54f42-e3f7-428b-b604-9450f4c659d7",
"metadata": {},
"source": [
"Once you have set your parameters, you can run the cell below in the same way that you ran the cell above for creating the forms. \n",
"Once you have set your parameters, you can run the cell below in the same way that you ran the cell above for creating the forms.\n",
"\n",
"Running the cell below will take a while, in particular if it's the first time you execute it, as it needs to download some external resources first. Subsequent runs will be faster. You can re-run it as many times as you want, and change any of the parameters using the forms above. \n",
"Running the cell below will take a while, in particular if it's the first time you execute it, as it needs to download some external resources first. Subsequent runs will be faster. You can re-run it as many times as you want, and change any of the parameters using the forms above.\n",
"\n",
"Once you run the cell below, it will print a lot of output into this notebook, including some warnings. If everything works, the last things printed out will read *Generating comparison image for zoom XXX*, according to the zoom levels you picked. \n",
"Once you run the cell below, it will print a lot of output into this notebook, including some warnings. If everything works, the last things printed out will read *Generating comparison image for zoom XXX*, according to the zoom levels you picked.\n",
"\n",
"The resulting images will be saved as \"progress.filename.*parameters*.png/gif."
]
Expand Down Expand Up @@ -160,13 +152,13 @@
"}\n",
"\n",
"\n",
"\u001b[K\u001b[?25h \u001b[27m] | reify:lodash: \u001b[32;40mhttp\u001b[0m \u001b[35mfetch\u001b[0m GET 200 https://registry.npmjs.\u001b[0m\u001b[K.o\u001b[0m\u001b[K\n",
"\u001B[K\u001B[?25h \u001B[27m] | reify:lodash: \u001B[32;40mhttp\u001B[0m \u001B[35mfetch\u001B[0m GET 200 https://registry.npmjs.\u001B[0m\u001B[K.o\u001B[0m\u001B[K\n",
"added 64 packages, and audited 65 packages in 5s\n",
"\n",
"1 package is looking for funding\n",
" run `npm fund` for details\n",
"\n",
"\u001b[31m\u001b[1m5\u001b[22m\u001b[39m vulnerabilities (2 \u001b[33m\u001b[1mmoderate\u001b[22m\u001b[39m, 3 \u001b[31m\u001b[1mhigh\u001b[22m\u001b[39m)\n",
"\u001B[31m\u001B[1m5\u001B[22m\u001B[39m vulnerabilities (2 \u001B[33m\u001B[1mmoderate\u001B[22m\u001B[39m, 3 \u001B[31m\u001B[1mhigh\u001B[22m\u001B[39m)\n",
"\n",
"To address all issues, run:\n",
" npm audit fix\n",
Expand Down Expand Up @@ -1562,9 +1554,7 @@
]
}
],
"source": [
"!./make.sh {filename.value} {start_date.value.isoformat()}Z {end_date.value.isoformat()}Z {bbox.value} {min_zoom_level.value} {max_zoom_level.value}"
]
"source": "!./make.sh {filename.value} {start_date.value.isoformat()}Z {end_date.value.isoformat()}Z {bbox.value} {min_zoom_level.value} {max_zoom_level.value} {num_frames.value}"
},
{
"cell_type": "markdown",
Expand All @@ -1573,12 +1563,11 @@
"source": [
"Enjoy mapping and visualizing!\n",
"\n",
"If this all worked you should be able to see the output files in the filebrowser/file tree, named `progress.filename.parameters.png/gif.`. \n",
"If this all worked you should be able to see the output files in the filebrowser/file tree, named `progress.filename.parameters.png/gif.`.\n",
"\n",
"If you are running this in the MyBinder, you should download them to your computer to keep them permanently.\n",
"\n",
"If you are running this locally, you can do this as well or alternatively move them into the shared \"output\" folder that is accessible from your host computer. \n",
"\n"
"If you are running this locally, you can do this as well or alternatively move them into the shared \"output\" folder that is accessible from your host computer."
]
}
],
Expand Down
Loading

0 comments on commit 6ebd631

Please sign in to comment.