Showing posts with label OSMAND. Show all posts
Showing posts with label OSMAND. Show all posts

Sunday, January 11, 2026

Note to Self, Mainly, on Shrinking Map Colors

 I am helping a theatre redo their website, from a post-Y2K relic to one that promises responsiveness (their phrase). They make a big deal about putting warning flags on images over 1MB, or a certain pixel size (like 800x1340). On the "directions and parking" section the old site had text directions, probably copied from Mapquest in 2002 or so. I kept the narrative and added static maps, since I didn't want to try a "live" google map image, figuring most folks would put the address in the own GPS/map app.

  The OSMAND app works great, so I figured I'd do screenshots and show the suggested routes, whether they lined up with the old text or not. They looked good, full screen PNG files with nice colors. Only they ended up way too big for a quick page load.

-rw-rw-rw-  1 user  users  1586661 Dec 14 22:19 map_from_westminster.png

When I saved them as JPEG, they didn't shrink much, just got a little fuzzier. Smaller size images didn't look great either. So I turned to the old standby library of graphics fixer-uppers, NetPBM [ netpbm.sourceforge.net/doc/ ]

The classic set of 216 colors (AKA "Web Safe") made sense as a target palette, as long as the altered image looked decent. I recall doing color reduction in the past and making some pictures that didn't. The docs said create a palette file, like so:

pamseq 3 5 >websafe.pam

Now, I had a 3 color band file, 5 values deep, just like Netscape likes. Applying that to a large image took almost no time:

pnmremap -map=websafe.pam map_from_westminster.pnm >websafe_west.ppm

Note this skips the PNG to PNM and PPM to PNG steps, which I added in a shell script that rotated through the 8 compass points of map/directions I wanted (N, NE, E, etc.)

#!/bin/sh

for img in \

 img1 \

 img2 \


do

  pngtopnm $img.png >$img.pnm

  pnmremap -map=websafe.pam $img.pnm | pnmtopng > ${img}_c216.png

done


Even on a slow drive, this is quick.

$ time pngtopnm map_from_westminster.png | pnmremap -map=websafe.pam - | pnmtopng >west_c26.png
pnmremap: 216 colors found in colormap

real    0m0.246s
user    0m0.260s
sys     0m0.017s

$ ls -l west_c26.png
-rw-r--r--  1 user  users  282243 Jan 12 00:01 west_c26.png


From 1.5 MB to 276 KB: good shrink!


$ perl $EXIFTOOL *west* | egrep "File Size|Image Size|Color Type"
File Size                       : 1549 KiB
Color Type                      : RGB
Image Size                      : 800x1340
File Size                       : 276 KiB
Color Type                      : Palette
Image Size                      : 800x1340

Afterward, I reapplied metadata such as Author and Copyright to the PNG file with the awesome exiftool.

Yet to do: add an overlay showing the OpenStreetMap sources used.




Saturday, May 31, 2025

Geotagging Charger Stations to see on Android Auto OsmAnd

 Searching for EV charging stations seems as much an art than a science so far. My flexible vehicle display provides searches from the manufacturer, and through Android Auto Google Maps and my installed OSMAND Android app.

What I'd like to see at a minimum I have through my own favorites shared as a KML file over Dropbox. Bit of work, and worth it so far for me.


I found when OsmAnd shows favorites, they are in alphabetical order, and no more than 10 are shown no matter how many are in the KML file. I've split my chargers list by brand in order to view all of them, even in the fractured level way. This example shows only Shell EV stations.

The map is useless, going from Hudson Bay to Venezuela, and there is no way to sort by distance, only name. Clicking on one item gets to navigation, with no map view in between.

Multiple chargers in one spot gets the worst result with OsmAnd Points of Interest for chargers.


You can see 10, but only 4 at once...

Some useful places to avoid, though, in later content.


At least on the POI view a map can appear. Not that you can zoom, pan, or otherwise affect that landscape shown behind the list while in motion. Or stopped at a light, as all of these shots were.

Only one field in the OpenStreetMap data is shown on the favorites list; thus I have refined what that should include, given space, mnemonic devices, and community standards. After I finish "just a couple more" on OSM edits I will reload my local phone map store and see what I've sown.