How to create a free Mapbox access token

Mapbox provides mapping services, and for private individuals many of those services are free. They ask for a credit card number to create a free access token, but they only charge it if the usage is very high, which usually only happens when the token is used for commercial purposes. To avoid credit card charges, keep your Mapbox token safe without publishing it on-line.

To create a free Mapbox access token

Create a Mapbox account

  • Navigate to https://www.mapbox.com/
  • Click the Get started for free button
  • Create an individual account
  • Follow the prompts and provide a credit card information. Mapbox will only charge it if the usage is very high, this usually never happens with private usage.

Create a Mapbox token

  • On the Tokens page click the Create a token button
  • Enter a name for the token, and keep the Public scopes selected
  • Click the Create token button
  • Save the token on your computer, never share it on the internet, as your credit card will be charged if the usage will reach the commercial level.

Migrating from conda to conda-forge for Python package management

Anaconda changed its Term of Use to require payment from companies larger than 200 employees. Many companies are not willing to pay the subscription fees for a software they can substitute.

conda-forge is the free, really open source alternative for the conda Python package manager.

To migrate your development environment from conda to conda-forge

Install conda-forge

To install conda-forge

  1. Navigate to https://conda-forge.org/download/,
  2. Download the installer for you operating system,

On macOS

  1. Open a terminal
  2. Execte the command
    bash ~/Downloads/Miniforge3-MacOSX-x86_64.sh
    • Answer yes when asked to accept the license terms
    • Press ENTER to allow the installation into your user directory

On Windows

  1. Execute the Windows installer

Configuration

Check the version of conda on your workstation, it should be higher than 4.9

conda --version

To not to active the conda base environment at startup execute the command

conda config --set auto_activate_base false

Usage

To activate the conda base environment in the terminal execute
eval “$(~/miniforge3/bin/conda shell.YOUR_SHELL_NAME hook)”

For iTerm the command is

eval "$(~/miniforge3/bin/conda shell.bash hook)"

To install conda’s shell functions for easier access, first activate, then:

conda init

For changes to take effect, close and re-open your current shell.

Type ‘unknown’ is not assignable to type …

TypeScript tries to make sure the variables are always populated with data of the type specified during the variable definition.

Issue

When the TypeScript compiler thinks a function can return another data type, or “unknown”, “undefined”, “null”, Visual Studio Code displays a warning:

type ‘unknown’ is not assignable to type …

Solution

The solution is to explicitly convert the return type to the expected one:

let soObject: SsoObject = <SsoObject> decodeJWT(ssoCookie);

Generating height maps with skydark.pl

To generate the height map of an area of the Earth

  • Navigate to https://heightmap.skydark.pl
  • Enter the name of the city in the search box
  • Set the Map size to 14.336 km
  • To move the selected area on the map, click and drag the central blue square.
  • To move the map closer to the sea level, click the Base level calculator button
  • Select Draw water streams to create the correct river and lake beds on the height map.
  • To display the elevation contour lines on the map image enable the Show height contours button
  • To display the edge of the water on the map image enable the Show water contours button
  • Click the Download PNG height hap button to download the height map.
  • Click the Download map image button to download the map for the overlay image.

Host the Cities: Skylines map generator locally

There are times when the Cities: Skylines Map Generator at https://heightmap.skydark.pl is not available. The free MapBox token expires because of the number of requests it serves.

We can host the site ourselves on our workstation and use it any time.

Install XAMPP

XAMPP is a free web server created by Apache Friends.

  • Download the installer for your workstation’s operating system at https://www.apachefriends.org/download.html
  • Install the application. As the popup will warn you, do not install it in the Program Files directory, as Windows restricts the access there.

Download the Cities: Skylines Map Generator application

The source code of the application is available on GitHub.

Place the application in the XAMPP directory

XAMPP contains the Apache web server which can host our JavaScript web application.

  • Create a directory called map in the htdocs folder of XAMPP. If you installed XAMPP to the default location, it is at C:\xampp\htdocs
  • Move the images and src directories of the map generator application into the map folder

Start XMAPP

  • Start the XAMPP Control Panel from the Start Menu
  • Start the Apache web server
  • Open your web browser and navigate to http://localhost/map/src/

Changing the MapBox access token

If the MapBox access token expires

  • Create a free access token for yourself at https://www.mapbox.com/
  • Update the value of mapboxgl.accessToken in the src/app.js file in line 47

To host the app from another directory

With the default configuration, XAMPP is looking for the web application in the htdocs directory within the XAMPP installation folder.

If you want to keep the Map Generator in another directory and host it from there with XAMPP:

  • Open the XAMPP control panel
  • Stop the Apache server
  • Click the Config button and select Apache (httpd.conf)
  • Place the project location into the DocumentRoot and Directory lines
  • Start the Apache server
  • Open your web browser and navigate to http://localhost/src/

Create a high resolution overlay image for Cities: Skylines II

The Image Overlay mod for Cities: Skylines 2 allows us to build a city based on real world locations. See Image overlay in Cities: Skylines 2 on how to install and use it.

To generate a high resolution overlay image

Create the standard resolution overlay image

Create a 2560×2560 pixel overlay image matching the height map. See Using the Map Editor in Cities:Skylines 2

Update the overlay image to high resolution

We can update the resolution to 16,384×16,384 pixels with some editing work using GIMP, the free graphics editor.

  • With your web browser navigate to Cities: Skylines map generator
  • Use the same location you used for the height map and the standard resolution overlay image
  • Set the Map size to 2.24 km

Signature verification failed, repository.json is not valid

When the Cities: Skylines II mod publishing fails with

Syncing WIP mod “…”
[L3Error_][6574][4B66][EFB4][0181] Error getting repository metadata for repository mods/cities_skylines_2/…/repo/Windows__Any, got exception: Signature verification failed, repository.json is not valid
Could not sync WIP mod: Signature verification failed, repository.json is not valid

Check the state of your mod

  • With your web browser, open the My Uploaded Mods page on the Paradox Plaza,
  • Click the mod to open the details page.

The Mod ID

The Mod ID is in the URL

It is the number you saved in the PublishConfiguration.xml file at

If the mod is corrupted on the Paradox Plaza

If the mod is corrupted on the Paradox servers, and you cannot update it anymore with the regular publishing process, you may need to delete the corrupted copy.

Warning!!!

If you delete a mod, all users who have subscribed to it, will get the “This mod has been banned” message when they open their playsets. They have to delete it from their playsets, and add it again to their active playset.

Delete a mod from Paradox Plaza

  • Hover above the pencil on the mod’s thumbnail and select Delete mod

Upload the mod again

If a mod has been deleted from Paradox Plaza, we can no longer publish updates to it to keep the same Mod ID. If we try, we get the error message: Could not publish new version of the mod: Updates are disabled for this mod.

To upload the mod again, we need to publish the mod as new.

  • Right-click the project and select Publish
  • On the Publish page select PublishNewMod
  • When the publishing process completed, copy the new Mod ID to the clipboard
  • Update the ModId value with it in the PublishConfiguration.xml file.