<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jacek Czapla on Medium]]></title>
        <description><![CDATA[Stories by Jacek Czapla on Medium]]></description>
        <link>https://medium.com/@jacaczap?source=rss-176f4b63e39b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*2sF-Hx-6LQS1lBvgHysrWQ.png</url>
            <title>Stories by Jacek Czapla on Medium</title>
            <link>https://medium.com/@jacaczap?source=rss-176f4b63e39b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 12:27:29 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jacaczap/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[RTP transfer system using Blockchain, RabbitMQ, Kotlin, and Python]]></title>
            <link>https://techblog.dac.digital/rtp-transfer-system-using-blockchain-rabbitmq-kotlin-and-python-f282eb9823b7?source=rss-176f4b63e39b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f282eb9823b7</guid>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[packaging]]></category>
            <category><![CDATA[transportation]]></category>
            <category><![CDATA[logistics]]></category>
            <category><![CDATA[kotlin]]></category>
            <dc:creator><![CDATA[Jacek Czapla]]></dc:creator>
            <pubDate>Mon, 22 Mar 2021 09:01:16 GMT</pubDate>
            <atom:updated>2021-03-22T09:01:16.302Z</atom:updated>
            <content:encoded><![CDATA[<h4>BLOCKCHAIN IN LOGISTICS</h4><h4>We have designed and build Pallet Chain — a system for monitoring and transferring Reusable Transport Packages.</h4><p>In logistics, transporting cargo often requires using Reusable Transport Packages. These can include pallets, containers, carts, and many more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*4FcSfU-8uSGJWhU-wlbcqQ.png" /><figcaption>Figure 1. Examples of Reusable Transport Packages</figcaption></figure><p>In most cases, those packages are the property of a sender, and a receiver is obliged to return them upon the arrival of the cargo. But that rarely happens. More often than not the recipient wants to retain the packages (like pallets) to store the delivered goods in his own warehouse and has no substitute in return. These actions create RTP <strong>debts</strong>. To eliminate them, the receiver has to organize a new transport containing the packages alone, and send them to the owner, or compensate the debt by other means.<br>The described process leads to the following problems:</p><ul><li>transporting packages back to the sender is neither cost-effective nor eco-friendly,</li><li>storage of RTPs that are no longer used, is a <strong>waste of space</strong>,</li><li>monitoring and management of RTP debts is difficult, especially for big companies,</li><li>RTPs are often lost, forgotten, or even stolen,</li><li>it is difficult and time-consuming to collect debts and when needed, companies are forced to buy new RTP instead.</li></ul><p>In this article, you will learn about a system that addresses these pain points. But first, let’s analyze the current state-of-play and define challenges that the system has to tackle.</p><h3>Logistic process</h3><p>The current logistic process can be described in the following points:</p><ul><li>sending cargo with packages,</li><li>calculating package <strong>balance</strong> (<strong>shortage</strong> and <strong>surplus</strong>),</li><li>sending packages back to the owner,</li><li>calculating package <strong>balance</strong> and settling the debts.</li></ul><p>Let&#39;s visualize it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7N1zR1MaKEbyXWe_RBW8ow.gif" /><figcaption>Figure 2. Current logistic process</figcaption></figure><p>As you can see, two shipments with 5 packages each are sent from City A to City B, and one shipment with 10 packages from City B to City A. Then the same shipments are sent opposite way. If we look at the balances after the first transports, a very important question arises — <strong>Why don’t companies in City A and City B transfer packages among themselves?</strong> That way the second transports wouldn’t be necessary. After all, <strong>a package is a package, </strong>as long as the type is the same. The ideal situation would therefore look like that:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xh6xhilVVuk42mxQ13y3ew.gif" /><figcaption>Figure 3. An optimized logistic process</figcaption></figure><p>So why don’t companies transfer the packages that way? There are few reasons:</p><ul><li>companies don’t know about package <strong>shortage </strong>or <strong>surplus </strong>in other companies,</li><li>making information about shipments public would reveal companies’ <strong>trade secrets</strong>,</li><li>there is no <strong>guarantee</strong> that sending packages to a different company than the original owner would settle the debt,</li><li>information about the package balance of other companies (often competitive) is <strong>not</strong> <strong>trustworthy </strong>and can be easily <strong>manipulated</strong>.</li></ul><h3>System architecture</h3><p>In order to solve the problems stated in the introduction and tackle the challenges from above, a system that utilizes Blockchain technology was developed. We called it <strong>Pallet Chain</strong> as the most popular RTPs are pallets.</p><p>The Pallet Chain system is composed of:</p><ul><li>External data sources and adapters for them,</li><li>RabbitMQ,</li><li>Pallet Chain backend and frontend applications,</li><li>PostgreSQL database,</li><li>Monitoring system,</li><li>Ethereum Blockchain,</li><li>GPS Decoder,</li></ul><p>The architecture of the system is following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zdp54TOOrY9cHun_fYpv7g.jpeg" /><figcaption>Figure 4. Pallet Chain architecture</figcaption></figure><h4>Workflow</h4><p>Let&#39;s focus on each of the elements and analyze the workflow step by step.</p><p>The first component of the Pallet Chain is a variety of <strong>external systems</strong> that are used across logistic companies. They are the source of data for the system. Since each company can use a different system and provide data in a different format, for each source there is a dedicated adapter.</p><p>The<strong> adapters</strong> are responsible for reading and interpreting the data from external systems. They convert the incoming data to a unified format that contains information about <strong>RTP transfer</strong>. The RTP transfer message consists of four data fields: <strong>sender</strong>, <strong>receiver</strong>, <strong>amount,</strong> and <strong>RTP type</strong>. This message is sent to RabbitMQ to be later consumed by the Pallet Chain backend application. Each of the adapters is dedicated to a single external system and can be developed in any technology. Current adapters are written in Kotlin.</p><p><strong>RabbitMQ </strong>is used as a communication channel between the adapters and the Pallet Chain backend.</p><p><strong>Ethereum Blockchain </strong>is used to store all RTP transfers. A <strong>smart contract</strong> that was prepared stores sender and receiver DLT addresses, amount of transferred packages, and their type. To communicate with the Ethereum network, <strong>Infura</strong>, a Blockchain API service, is used. Since it is impossible to track user’s data from the DLT address, the <strong>trade secrets are protected</strong>. Also, the Blockchain is <strong>resistant to manipulation.</strong> All this allows to fulfill the requirement stated before and paves the way for solutions - like Pallet Chain, that were impossible before.</p><p><strong>PostgreSQL </strong>fulfills many roles. The first and most important is to work as a <strong>Blockchain proxy</strong>.<strong> </strong>The<strong> </strong>Ethereum network can be very slow. Especially reading all RTP transfers for all system users can be extremely painful. Therefore the database is used to <strong>store package balance</strong> for each user, and Ethereum is used for verification of that data. This is quite a common approach. Apart from the balances, information about system users, including their name, address, GPS location, and DLT address is stored in the database.</p><p><strong>Pallet Chain backend</strong> is the core of the system and is written in Python. One of its main tasks is to <strong>update balances</strong> after detecting an RTP transfer. First, the application consumes the data from the RabbitMQ. After receiving the RTP transfer event, the PostgreSQL is searched for transfer parties — sender and receiver. If they are not found, new parties are created and the DLT addresses are generated. Also, the GPS position is found using an external GPS decoding service — Mapbox. After finding or creating parties and their DLT addresses, the Ethereum transaction is sent. At the same time, the package balance for both parties is calculated and updated in the database. <br>The second task of the Pallet Chain backend is to <strong>provide REST API access </strong>for the frontend application. It gives access to the list of system users, their GPS location, and their balances.</p><p><strong>Pallet Chain frontend </strong>is responsible for displaying a map with users and their balances. This allows users to arrange a transport of the packages to pay or collect the debts in the local vicinity. Because users only see the balances and not their source, the trade secrets are not compromised.</p><p>The<strong> monitoring system </strong>consists of Prometheus and Grafana applications. Prometheus collects the data about the system and Grafana presents dashboards to display it. It is used by the system administrator to supervise the system and diagnose any problems.</p><h3>Usage</h3><p>The usage of the system is pretty straightforward. After logging into the system, the users are presented with a map. On the map, they can see companies and their balances. In the upper right corner, there is a dropdown menu that allows changing the displayed package type. With green colors and positive numbers, companies that have surplus packages are shown. They possess packages that do not belong to them and should be returned. With red colors and negative numbers, companies that have a shortage of packages are shown. They are waiting for the packages to be returned.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qsjxEsZO1meKkTRRdfZylQ.jpeg" /><figcaption>Figure 5. Pallet Chain user interface</figcaption></figure><p>With such a tool, companies no longer need to wait for the packages to be returned from other cities, they can sort out the debts in the local area.</p><h3>Summary</h3><p>The Pallet Chain is a system that greatly improves the logistic process. The users are guaranteed, that all package transfers are reflected on the map. Therefore, it is possible to return packages to a different company than the original owner. It eliminates the need to transfer Reusable Transport Packages over long distances. This is both eco-friendly and cost-effective. Users can easily get rid of surplus packages to free the storage space or collect their debts from local companies. The system also lifts the burden of debt management and monitoring from the companies. Thanks to the usage of Blockchain technology, the system is trustworthy and resistant to manipulation. Because of that, there is no need to reveal the source of the debts and compromise trade secrets alongside. Finally, the packages cannot be lost or stolen without the consequences, as the responsible user cannot get rid of the debt without paying it, nor hide it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f282eb9823b7" width="1" height="1" alt=""><hr><p><a href="https://techblog.dac.digital/rtp-transfer-system-using-blockchain-rabbitmq-kotlin-and-python-f282eb9823b7">RTP transfer system using Blockchain, RabbitMQ, Kotlin, and Python</a> was originally published in <a href="https://techblog.dac.digital/">DAC.digital Technology Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OpenStreetMap map size reduction guide]]></title>
            <link>https://techblog.dac.digital/openstreetmap-map-size-reduction-guide-43372bbf38c9?source=rss-176f4b63e39b------2</link>
            <guid isPermaLink="false">https://medium.com/p/43372bbf38c9</guid>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[osm]]></category>
            <category><![CDATA[maps]]></category>
            <category><![CDATA[guides-and-tutorials]]></category>
            <category><![CDATA[openstreetmap]]></category>
            <dc:creator><![CDATA[Jacek Czapla]]></dc:creator>
            <pubDate>Mon, 17 Aug 2020 07:01:02 GMT</pubDate>
            <atom:updated>2020-08-17T07:01:02.685Z</atom:updated>
            <content:encoded><![CDATA[<h4>OpenStreetMap</h4><h4>A step-by-step guide to boosting OSM application performance by reducing your map file size by up to 76%</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8iIZ76zKaooloCc2cci-Fg.png" /><figcaption>Official OpenStreetMap logo</figcaption></figure><p>According to <a href="https://operations.osmfoundation.org/policies/tiles/">OSM official tile usage policy</a>, one can use public OSM tile-server only under certain conditions. The main constraint is “heavy use”. One cannot use public servers in applications that are expecting high traffic. The solution to this is hosting your own tile-server. This involves fulfilling the <a href="https://switch2osm.org/serving-tiles/">hardware requirements</a> that increase proportionally to the map size. In this article, you will learn how to edit the map file and <strong>reduce its size by up to 76%</strong>. We will <strong>extract a small map fragment</strong> from the map of Germany and <strong>remove all objects that are not needed</strong> <strong>for the vehicle navigation application</strong>. This will greatly increase performance and reduce requirements.</p><p>In this guide, our goal is to make a map of the western part of Germany — regions: Hesse, Lower Saxony, North Rhine-Westphalia, and Rheinland-Palatine. Below you can see the expected result:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcdn.knightlab.com%2Flibs%2Fjuxtapose%2Flatest%2Fembed%2Findex.html%3Fuid%3Dbbee6002-d0db-11ea-bf88-a15b6c7adf9a&amp;display_name=Knight+Lab&amp;url=https%3A%2F%2Fcdn.knightlab.com%2Flibs%2Fjuxtapose%2Flatest%2Fembed%2Findex.html%3Fuid%3Dbbee6002-d0db-11ea-bf88-a15b6c7adf9a&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=knightlab" width="700" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/47f1f700ba3ae49417da2e024580b29e/href">https://medium.com/media/47f1f700ba3ae49417da2e024580b29e/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fcdn.knightlab.com%2Flibs%2Fjuxtapose%2Flatest%2Fembed%2Findex.html%3Fuid%3D00309ebe-d0dd-11ea-bf88-a15b6c7adf9a&amp;display_name=Knight+Lab&amp;url=https%3A%2F%2Fcdn.knightlab.com%2Flibs%2Fjuxtapose%2Flatest%2Fembed%2Findex.html%3Fuid%3D00309ebe-d0dd-11ea-bf88-a15b6c7adf9a&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=knightlab" width="700" height="500" frameborder="0" scrolling="no"><a href="https://medium.com/media/6e4a68eab613e6279858113e61c885df/href">https://medium.com/media/6e4a68eab613e6279858113e61c885df/href</a></iframe><p>We will achieve such results in 4 steps:</p><ol><li>Downloading base map fragment</li><li>Preparing a boundary file</li><li>Extracting map</li><li>Removing unnecessary map objects</li></ol><h4>1. Download base map fragment</h4><p>First, you need to decide what areas your map needs to cover. In this example, we will focus on western Germany. Germany’s full map will be the perfect base to extract from. There are a few possibilities to download the map. You can, for example, use <a href="https://protomaps.com/extracts">https://protomaps.com/extracts</a> (for small, user-defined fragments) or <a href="https://download.geofabrik.de/">https://download.geofabrik.de</a> (all kinds of predefined fragments). <br>In this guide, we will download a full map of Germany in <em>.pbf</em> format from Geofabrik.</p><p>If you can already find a map fragment on Geofabrik or Protomaps that is sufficient for your application, then you can skip the two following steps and go directly to step 4.</p><h4>2. Prepare a boundary file</h4><p>After getting a base map file we need to define the boundaries of our desired map fragment. The <em>.poly</em> file is exactly what we are looking for. It contains coordinates of boundary points. Since there is no single boundary file for regions Hessen, Niedersachsen, Nordrhein-Westfalen and Rheinland-Pfalz we need to create one. In order to do so, we will download .<em>poly</em> files for those regions and merge them in JOSM editor.</p><p>First, download <em>.poly</em> files from <a href="https://download.geofabrik.de/europe/germany.html">https://download.geofabrik.de/europe/germany.html</a> for each of the regions. Below is an example of downloading the North Rhein-Westphalia <em>.poly</em> file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/992/1*WrfGkyXwNHnmSGaj4XcoLA.png" /><figcaption>Downloading .poly file for Nordrhein-Westfalen</figcaption></figure><p>In order to edit <em>.poly</em> files, you need <a href="https://josm.openstreetmap.de/">JOSM</a> with the <em>poly</em> plugin. Below you can see how to install the plugin.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*V2sAYCyX-H4UI2Jri8cLNA.gif" /><figcaption>Installing the “poly” plugin</figcaption></figure><p>The next step is to open all <em>.poly</em> files and merge them. See the example below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*dX9IZhLvk4vFSNpret4bmw.gif" /><figcaption>Merge poly files and verify against map</figcaption></figure><p>Sometimes a manual adjustment is needed. For example, there can be some remaining points that should be deleted. You can verify if the selection is correct by using the background map. When everything is ready, save the new <em>.poly</em> file.</p><h4>3. Extract map</h4><p>Now that we have both <em>.poly</em> file with western Germany border and full Germany <em>.pbf </em>map, we can extract the desired fragment. In order to do so, we need the <a href="https://wiki.openstreetmap.org/wiki/Osmosis">Osmosis</a> command-line tool.</p><p>Open command line and type:</p><pre>osmosis \<br>--read-pbf file=&quot;germany-latest.osm.pbf&quot; \                 <br>--bp clipIncompleteEntities=true file=&quot;west-germany.poly&quot; \  <br>--write-pbf granularity=10000 file=&quot;west-germany.osm.pbf&quot;</pre><p>where:</p><p>--read-pbf file=&quot;germany-latest.osm.pbf&quot; — chooses base map that we will extract from</p><p>--bp — extracts map fragment using <em>.poly</em> file. (full option--bounding-polygon)</p><p>clipIncompleteEntities=true — removes objects that are exactly on the borderline and would be incomplete after extraction</p><p>--write-pbf — choose output file</p><p>granularity=10000 — reduces map precision from 1.1cm to 1.1m (enough for navigation) and reduces the size by about 10%</p><p>As a result, we’ve obtained smaller map extract — instead of 3.4GB (whole Germany at the time of writing this text), we’ve got 1.2GB. Now let’s further decrease the size by removing unnecessary map objects.</p><h4>4. Remove unnecessary map objects</h4><p>Now that we have the desired <em>.pbf</em> map fragment we can proceed to remove map objects that are not required in our application.</p><p>To do this you need to learn about <strong>elements</strong> and <strong>tags</strong> in OpenStreetMap.</p><p>In OpenSteetMap there are 3 kinds of <a href="https://wiki.openstreetmap.org/wiki/Elements"><strong>elements</strong></a>: <strong>node</strong>, <strong>way,</strong> and <strong>relation</strong>.</p><ul><li>A<strong> node</strong> is a point on a map. It can represent something by itself— for example, a monument or a bus stop, but often is a part of ways and relations.</li><li>A <strong>way </strong>is an ordered list of nodes that create a line, a curve, and even an area. For example a street, river, building, forest, etc.</li><li>A <strong>relation </strong>defines the relationship between elements. For example, a bus route consists of several ways.</li></ul><p>A definition of a <a href="https://wiki.openstreetmap.org/wiki/Tags"><strong>tag</strong></a><strong> </strong>from OSM wiki is the following:</p><blockquote>A <strong>tag</strong> consists of two items, a <em>key</em> and a <em>value</em>. Tags describe specific features of map elements”.</blockquote><p>For example, <em>highway=motorway</em> will be a tag for a particular way, and will inform that this way is a high-speed road. Tag <em>water=river</em> will inform that a way is a river. Tags determine how the tile-server should render elements on the map.</p><p>In order to remove the objects from our map, we need to learn what tags define them. For example when we look for <a href="https://wiki.openstreetmap.org/wiki/Key:highway">key:highway</a> in the wiki, we can see that it is used to define any kind of road, street, or path. <strong>Since there is a great number of tags, and they can be used together (one object can have many tags) it is very dangerous to delete all objects with certain tag. </strong>For example when we decide to delete all <a href="https://wiki.openstreetmap.org/wiki/Tag:highway%3Dcycleway">cycle-ways</a> we will also delete all highways that are a combination of cycle-way and another road. This is not the desired behavior. Therefore we will take the opposite approach. We will <strong>choose tags to preserve, and remove everything else.</strong></p><p>Now that we know all the basics, let&#39;s proceed with the map size reduction.</p><p>For the purpose of this guide we will focus on the following objects:</p><ul><li>All <a href="https://wiki.openstreetmap.org/wiki/Key:highway">highways</a></li><li>All <a href="https://wiki.openstreetmap.org/wiki/Key:building">buildings</a></li><li>Navigation-useful <a href="https://wiki.openstreetmap.org/wiki/Key:place">places</a></li></ul><p>Once again we will use Osmosis tool. We will use --tag-filter (--tf) option to remove everything BUT <strong>elements </strong>with desired<strong> tags</strong>.</p><p>First lets remove everything but <em>highways</em>. The command is split into 4 parts:</p><ul><li>Extract all<strong> nodes</strong> with tag <em>highway,</em></li><li>Extract all<strong> ways</strong> with tag <em>highway</em>, and the <strong>nodes used </strong>in these ways,</li><li>Extract all<strong> relations</strong> with tag <em>highway</em> and <strong>ways and nodes </strong>used in these relations,</li><li>Merge the result and save it</li></ul><pre>osmosis \<br>--read-pbf file=&quot;west-germany.osm.pbf&quot; \<br>--tf accept-nodes &quot;highway=*&quot; \<br>--tf reject-ways \<br>--tf reject-relations \<br>--sort \<br>\<br>--read-pbf file=&quot;west-germany.osm.pbf&quot; \<br>--tf accept-ways &quot;highway=*&quot; \<br>--tf reject-relations \<br>--used-node \<br>--sort \<br>\<br>--read-pbf file=&quot;west-germany.osm.pbf&quot; \<br>--tf accept-relations &quot;highway=*&quot; \<br>--used-way \<br>--used-node \<br>--sort \<br>\<br>--merge --merge \<br>--write-pbf granularity=10000 &quot;west-germany-highway.osm.pbf&quot;</pre><p>Let’s look at this in details:</p><p>--read-pbf file=&quot;west-germany.osm.pbf” — load the map file</p><p>--tf accept-nodes highway=* — accept only <strong>nodes</strong> with any <em>highway</em> tag</p><p>--tf reject-ways — remove all <strong>ways</strong></p><p>--tf reject-relations — remove all <strong>relations</strong></p><p>--sort — sort the data before merging</p><p>--tf accept-ways highway=* — accept only <strong>ways</strong> with any <em>highway</em> tag</p><p>--used-node — keep only <strong>nodes</strong> that are used in <strong>relations</strong> or <strong>ways</strong></p><p>--tf accept-relations highway=* — accept only <strong>relations</strong> with any <em>highway</em> tag</p><p>--used-way — keep only <strong>ways</strong> that are used in <strong>relations</strong></p><p>--merge --merge — merge 3 sources into one</p><p>--write-pbf granularity=10000 &quot;west-germany-highway.osm.pbf&quot; — save the result to a file with granularity 10000</p><p>Now we can do the same for every element with any <em>building </em>tag:</p><pre>osmosis \<br>--read-pbf file=&quot;west-germany.osm.pbf&quot; \<br>--tf accept-nodes &quot;building=*&quot; \<br>--tf reject-ways \<br>--tf reject-relations \<br>--sort \<br>\<br>--read-pbf file=&quot;west-germany.osm.pbf&quot; \<br>--tf accept-ways &quot;building=*&quot; \<br>--tf reject-relations \<br>--used-node \<br>--sort \<br>\<br>--read-pbf file=&quot;west-germany.osm.pbf&quot; \<br>--tf accept-relations &quot;building=*&quot; \<br>--used-way \<br>--used-node \<br>--sort \<br>\<br>--merge --merge \<br>--write-pbf granularity=10000 &quot;west-germany-building.osm.pbf&quot;</pre><p>And finally, the <em>place </em>tag. The goal is to extract all cities and their names. Without it, the map is very hard to use. The values of tag <em>place</em> that represent those elements would be: c<em>ountry, state, region, province, district, county, municipality, city, town, village, hamlet, isolated_dwelling, farm, allotments. </em>The command below will remove any object that is not one of the above.</p><pre>osmosis \<br>--read-pbf file=&quot;west-germany.osm.pbf&quot; \<br>--tf accept-nodes &quot;place=country,state,region,province,district,county,municipality,city,town,village,hamlet,isolated_dwelling,farm,allotments&quot; \<br>--tf reject-ways \<br>--tf reject-relations \<br>--sort \<br>\<br>--read-pbf file=&quot;west-germany.osm.pbf&quot; \<br>--tf accept-ways &quot;place=country,state,region,province,district,county,municipality,city,town,village,hamlet,isolated_dwelling,farm,allotments&quot; \<br>--tf reject-relations \<br>--used-node \<br>--sort \<br>\<br>--read-pbf file=&quot;west-germany.osm.pbf&quot; \<br>--tf accept-relations &quot;place=country,state,region,province,district,county,municipality,city,town,village,hamlet,isolated_dwelling,farm,allotments&quot; \<br>--used-way \<br>--used-node \<br>--sort \<br>\<br>--merge --merge \<br>--write-pbf granularity=10000 &quot;west-germany-place.osm.pbf&quot;</pre><p>In order to verify that all unnecessary elements were deleted and all others were left intact, you can use JOSM. Please note that a big map will fail to load so you have to use a very small map fragment for test purposes only. For our example, I downloaded a fragment of the map of Dortmund city and performed the commands from above once again.</p><p>To open the created files you need to add <em>pbf </em>plugin. Now you can verify the results. You can also select any element on the map and check its details. That way you can learn what tags are used in the selected element. You can then experiment with the scripts above to find an optimal solution for your application. Below you can see how to preview the results.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*giOomacn-xq5WF6I50_quA.gif" /><figcaption>Object deletion inspection for Dortmund map</figcaption></figure><p>Finally, let&#39;s merge <strong>highways</strong>,<strong> buildings, </strong>and <strong>places</strong>. The command to do so is pretty straightforward:</p><pre>osmosis \<br>--read-pbf file=&quot;west-germany-highway.osm.pbf&quot; \<br>--sort \<br>--read-pbf file=&quot;west-germany-building.osm.pbf&quot; \<br>--sort \<br>--merge \<br>--read-pbf file=&quot;west-germany-place.osm.pbf&quot; \<br>--sort \<br>--merge \<br>--write-pbf granularity=10000 &quot;west-germany-final.osm.pbf&quot;</pre><p>The final output file is only 800MB!</p><h3>Summary</h3><p>In this article you have learned how to:</p><ul><li>get a map file,</li><li>prepare a boundary file,</li><li>extract desired map fragment,</li><li>remove unnecessary map objects.</li></ul><p>By extracting the map fragment, we have reduced its size from 3.4GB to 1.2GB which is <strong>by 64%</strong>.<strong> </strong>This, of course, depends on the map fragment that you need, but using only an extract of the map instead of, for example, the whole country is the easiest and the most efficient way of reducing map size.</p><p>By removing map objects and leaving only roads, buildings, and certain places we have further reduced map size from 1.2GB to 800MB which is <strong>by an additional 30%</strong>.</p><p>Generally speaking instead of using the whole Germany map — 3.4GB we have modified it and obtained 800MB fragment. This is a <strong>76% size reduction</strong> that directly increases performance!</p><p>Thanks to the learned tools you can adjust map according to the application and greatly reduce its size!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=43372bbf38c9" width="1" height="1" alt=""><hr><p><a href="https://techblog.dac.digital/openstreetmap-map-size-reduction-guide-43372bbf38c9">OpenStreetMap map size reduction guide</a> was originally published in <a href="https://techblog.dac.digital/">DAC.digital Technology Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>