Split GPX file

GPX-files are used to store planned and done routes, for example for cycling.
A lot of web sites and applications allow creating and editing such routes.

In practice it matters for a trip from A to B if there is one long route that covers the whole distance or many shorter routes. Long routes get hard to handle, because of the software gets slow or crashes when the data set is too big. And small routes are more difficult to use when wanting to have an overview and they require switching to another route during the day, which can be inconvenient.

In theory it is possible to just copy a long route and to delete parts of it to obtain shorter routes, but that does not work too well, if the route is already very long.

So one way to go is to make a long route with only rough planning, to have an overview and then split it into shorter routes that can then be modified to obtain a more accurate planning.
So the following program (written in Perl for Linux) will split a GPX file into n about equally long parts. It is quite simple, but I hope it will help to make this task a little bit easier.

License is GPL v3.


#!/usr/bin/perl -w

# (C) Karl Brodowsky 2024-06-09
# Licence GPS v3.0
# (see https://www.gnu.org/licenses/gpl-3.0.de.html )

use strict;
use utf8;
use Encode qw(decode encode);

binmode STDOUT, ":utf8";
binmode STDIN, ":utf8";

my $header =<<'EOH';
<?xml version='1.0' encoding='UTF-8'?>
<gpx version="1.1" creator="https://www.komoot.de" xmlns="http://www.topografix.com/GPX/1/1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd">
      <link href="https://www.komoot.de">
my $footer =<<'EOF';

sub usage($) {
    my $msg = $_[0];
    if ($msg) {
        chomp $msg;
        print $msg, "\n\n";
    print <<"EOU";


    if ($msg) {
        exit 1;
    } else {
        exit 0;

if (scalar(@ARGV) == 0 || $ARGV[0] =~ m/^-{0,2}help/) {
if (scalar(@ARGV) != 3) {
    usage("wrong number of arguments");
my $file = $ARGV[0];
my $file_u = decode("utf-8", $file);
unless (-f $file && -r $file) {
    usage("$file_u is not a readable file");
unless ($file =~ m/.+\.gpx$/) {
    usage("$file_u is not a gpx-file");
my $name = decode("utf-8", $ARGV[1]);
$name =~ s/^\s+//;
$name =~ s/\s+$//;
$name =~ s/\r//g;

unless (length($name) > 0) {
    usage("$name must be at least 1 character");
if ($name =~ m/[<>"']/) {
    usage("$name contains illegal characters");
print "name=$name\n";

my $number_of_parts = $ARGV[2];
if ($number_of_parts < 2) {
    usage("at least 2 parts are required");

open INPUT, "<:utf8", $file || usage("cannot open $file_u");
my @points = ();
my $point = "";
while (<INPUT>) {
    if (m/^\s*<trkpt/) {
        $point = $_;
    } elsif (m/^\s*<(ele|time)>/) {
        $point .= $_;
    } elsif (m/^\s*<\/trkpt>/) {
        $point .= $_;
        push @points, $point;
        $point = "";
    } else {
close INPUT;
print "\n";

my $length = scalar(@points);

sub part_length($$) {
    my ($remaining_length, $remaining_number_of_parts) = @_;
    ($remaining_length - 1) / $remaining_number_of_parts + 1;

my $part_length = part_length($length, $number_of_parts);
print "length = $length part_length = $part_length number_of_parts = $number_of_parts\n";

if ($part_length < 2) {
    usage("too many parts part_length=$part_length");
my $remaining_length;
my $remaining_number_of_parts = $number_of_parts;
my $i = 0;
while ($remaining_number_of_parts > 0) {
    $part_length = int(part_length($remaining_length, $remaining_number_of_parts) + 0.5);
    my $header_i = $header;
    my $title_i = sprintf("%s (%d)", $name, $i);
    $header_i =~ s/<<TITLE>>/$title_i/g;
    my $file_i = $file;
    my $file_u_i = decode("utf-8", $file);
    $file_i =~ s/\.gpx$/_$i.gpx/;
    print "i=$i remaining_number_of_parts=$remaining_number_of_parts remaining_length=$remaining_length\n";
    print "i=$i file_i=$file_u_i title_i=$title_i\n";
    open OUTPUT, ">:utf8", $file_i;
    print OUTPUT $header_i;
    for (my $j = 0; $j < $part_length; $j++) {
        my $point = $points[0];
        if ($j < $part_length -1) {
            shift @points;
        print OUTPUT $point;
    print OUTPUT $footer;
    close OUTPUT;

P.S. I plan to return to regular posts in this blog during this year.

Share Button

New Numeric Type

Russian Informatics scientists have invented a new numeric type for computers. Russian made computer chips have it already implemented in hardware.

The numbers are expressed in the form

    \[a_0 + 17 \cdot a_1 + 17 \cdot 19 \cdot a_2 + 17 \cdot 19 \cdot 21  \cdot  a_3 + 17 \cdot 19 \cdot 21 \cdot 23 \cdot a_4 + 17 \cdot 19 \cdot 21 \cdot 23 \cdot 25  \cdot  a_5 + 17 \cdot 19 \cdot 21 \cdot 23 \cdot 25  \cdot  27 \cdot  a_6 + 17 \cdot 19 \cdot 21 \cdot 23 \cdot 25  \cdot  27 \cdot  29 \cdot   a_7 + 17 \cdot 19 \cdot 21 \cdot 23 \cdot 25  \cdot  27 \cdot  29 \cdot 31 \cdot  a_8\]

a_0, a_1, \ldots are each expressed by 6 bits. The exact encoding, which combination of bits have which meaning is a state secret, so it will be necessary to get the hardware and the software only from Russian quality suppliers, that are absolutely not assosicated with FSB or the fascist regime.

This will revolutionize computing world wide through higher efficiency and greener IT.

Share Button

New Year 2024

Sala we ya nû pîroz be! — Srechno novo leto! — السنة الجديدة المبتهجة — Un an nou fericit! — Bun di bun an! — Happy New Year! — Gott nytt år! — Среќна нова година! — Sugeng warsa enggal! — ¡Próspero año nuevo! — Весёлого нового года! — Bonne année! — Щасливого нового року! — Καλή Χρονια! — Een gelukkig nieuwjaar! — Feliĉan novan jaron! — Sretna nova godina! — Cung chúc tân xuân! — Gelukkig nieuwjaar! — Boldog új évet! — Naya barsa ko hardik shuvakamana! — 새해 복 많이 받으세요 — Ath bhliain faoi mhaise! — Laimīgu Jauno gadu! — Nav varsh ki subhkamna! — うれしい新しい年 — Onnellista uutta vuotta! — Lokkich nijjier! — FELIX SIT ANNUS NOVUS! — Akemashite omedetô! — Frohes neues Jahr! — Felice Anno Nuovo! — Feliz año nuevo! — Shnorhavor nor tari! — Hääd uut aastat! — Срећна нова година! — Laimīgu jauno gadu! — عام سعيد — สวัสดีปีใหม่ — Godt Nyttår! — Gott nýggjár! — سال نو مبارک — Feliz ano novo! — Yeni yılınız kutlu olsun! — Šťastný nový rok! — Subho nababarsho! — Próspero ano novo! — Selamat tahun baru! — 新年好 — Честита нова година! — Szczęśliwego nowego roku! — Gleðilegt nýtt ár! — Godt nytår! — Laimingų naujųjų metų!

Share Button

Christmas 2023

Bon nadal — Bella Festas daz Nadal — Fröhliche Weihnachten — Prettige Kerstdagen — کريسمس مبارک — Mutlu Noeller — 즐거운 성탄, 성탄 축하 — Sretan božić — Kellemes Karácsonyi Ünnepeket — God Jul! — Nollaig Shona Dhuit! — Vesele Vianoce — Buon Natale — Häid jõule — Priecîgus Ziemassvçtkus — Vesele bozicne praznike — Su Šventom Kalėdom — Veselé Vánoce — God Jul — Natale hilare — καλά Χριστούγεννα — Merry Christmas — Hyvää Joulua — クリスマスおめでとう ; メリークリスマス — Crăciun fericit — Joyeux Noël — Срећан Божић — Gëzuar Krishtlindjet — Feliĉan Kristnaskon — ميلاد مجيد — Zalig Kerstfeest — Selamat Hari Natal — 圣诞快乐 — Gleðileg jól — क्रिसमस मंगलमय हो — Feliz Navidad — Wesołych Świąt Bożego Narodzenia — Gledhilig jól — Glædelig Jul — Честита Коледа — Feliz Natal — З Рiздвом Христовим

Generated by the following Kotin program:

package net.itsky.xmas

data class Element(val key: Long, val text: String) {
    override fun hashCode(): Int {
        return key.hashCode();

    override fun equals(other: Any?): Boolean {
        if (other is Element) {
            return this.key == other.key;
        } else {
            return false;

    override fun toString(): String {
        return text

package net.itsky.xmas

import java.security.SecureRandom

fun main() {
    val texts: List = listOf(
        "Bella Festas daz Nadal", "Bon nadal", "Buon Natale", "Crăciun fericit",
        "Feliz Natal", "Feliz Navidad", "Feliĉan Kristnaskon", "Fröhliche Weihnachten", "Gledhilig jól",
        "Gleðileg jól", "Glædelig Jul", "God Jul!", "God Jul", "Gëzuar Krishtlindjet", "Hyvää Joulua", "Häid jõule",
        "Joyeux Noël", "Kellemes Karácsonyi Ünnepeket", "Merry Christmas", "Mutlu Noeller", "Natale hilare",
        "Nollaig Shona Dhuit!", "Prettige Kerstdagen", "Priecîgus Ziemassvçtkus", "Selamat Hari Natal", "Sretan božić",
        "Su Šventom Kalėdom", "Vesele Vianoce", "Vesele bozicne praznike", "Veselé Vánoce",
        "Wesołych Świąt Bożego Narodzenia", "Zalig Kerstfeest", "καλά Χριστούγεννα", "З Рiздвом Христовим",
        "Срећан Божић", "Честита Коледа", "ميلاد مجيد", "کريسمس مبارک", "क्रिसमस मंगलमय हो",
        "クリスマスおめでとう ; メリークリスマス", "圣诞快乐", "즐거운 성탄, 성탄 축하"
    val random: SecureRandom = SecureRandom();
    val elementsList: List = texts.map { Element(random.nextLong(), it) }
    val elements: Set = HashSet(elementsList);

    var first = true
    for (e in elements) {
        if (first) {
            first = false
        } else {
            print(" — ")


Share Button

Russia introduces new character encoding to replace Unicode

Russian computer scientists have created a new character encoding that will replace Unicode.

The encoding looks like this:

2.SPC! «»%ZV()*+-,./

For Chinese letter, a three-byte-sequence starting with PREFIX-CN can be used. For all other letters, that are not in the base set, an eight byte long sequence starting with PREFIX-OTHER can be used.

This encoding will be mandatory in Russia and all areas annexed by Russia after a transition period.

Programming langauges, internet protocols, databases, operating systems,… everything will be replaced or adapted to work with this new revolutionary encoding.

Share Button


Щасливого нового року! — Frohes neues Jahr! — Happy new year!

Share Button

Christmas 2022

З Рiздвом Христовим − Merry Christmas − Frohe Weihnachten

Weihnachtsbaum in New York 1981
(C) Karl Brodowsky 1981-2022
Share Button

Available for new Projects in 2023

I am available for new projects starting April 2023.

I can support you for SW-architecture, SW-development, Linux, databases and security.

See IT Sky Consulting to see for more details on what I can offer.

Share Button


Just a reminder:
Articles that are published on April 1st in this blog are always April-jokes.

Share Button

Goodware: Russian BOT-Networks

The FSB in Russia has an increasing demand for computing power and storage. On the other hand it is getting more difficult to import computers or parts into Russia due to the sanctions.

So now an innovative Russian IT work group has developed a software stack, that allows reliable storage and computing on bot nets.

Some challenges:

  • It is possible that a whole bot net is taken down and all the data is lost
  • Since the confidential data is distributed across millions or billions of nodes all over the world, good encryption is needed all the way
  • Transfer of data needs to be obfuscated

The work group came up with solutions. They develop malware, which is actually called „goodware“, because it serves a good purpose, that installs the software on millions of computers all over the world. This malware is constantly changed and updated, in order to create multiple independent botnets.

The crucial data is encrypted. Advanced Russian technology allows to perform the calculations on encrypted data, so the real content is never revealed on the node.

The FSB-IT-team creates virtual networks, again based on botnets of goodware, with many hops that change rapidly to transfer data and goodware to and from the nodes and to control them.

Data is stored and processed redundantly. Since there is a huge surplus of computing power and storage volume, it is possible to store data with such high multiplicity that recovery is possible even if multiple complete goodware-botnets are taken down.

A positive side effect is that the FSB learns what is going on on the devices where they have positioned their goodware.

So let’s buy more and better computers and help the FSB to get more computing power.

Share Button