OpenMapTiles: Generate boundary admin_level 6 at lower zoom levels - openstreetmap

I am wanting to show admin_level 6 boundaries at lower zoom levels (8, 7, 6), currently they start showing at zoom level 9.
I realize that I need to modify the import script so that this data is saved into the .mbtiles file. I have edited the boundary.sql file to change WHERE admin_level <= 4 to WHERE admin_level <= 6 for boundary_z6, boundary_z7 and boundary_z8.
I see the .sh file at /var/lib/docker/overlay/d9c758ee5fef79d79f0412880332a2efe66fd5c3d9614d6a710211c87e7bc04c/root/usr/src/app/import_osmborder_lines.sh, however I don't know if that will be overwritten at some point?
However, after a new import boundaries are still not shown at levels 8, 7, 6.
Looking deeper, it appears that I need to also modify the import_osmborder_lines.sh script so those lines get imported, but that is in its own docker file that I don't know how to edit so the quickstart.sh will use it.
How can I edit the import-osmborder docker file and have my quickstart.sh script use this for import? Or, am I going about this completely wrong?

I ended up editing the import_osmborder_lines.sh that is in the /var/lib/docker/ directory. This worked, but I still am not sure this is the ideal method.

Related

ImageMagick: How to batch append 4 parts of images into one (2 rows, 2 columns) (I have 500+ images that need to be combined like this)

everyone!
I am using ImageMagick-7.0.10-Q16 on Windows 10. I’ve tried Googling for answers, but I’m still left very confused about how to do this. Most of the answers have been for UNIX and not Windows, I have no idea what it means, or given me errors. I don’t have any experience with coding or Windows PowerShell, so forgive my slowness
I have scanned pages of books that have been split into four pieces of jpg files. The images are named after the page number and the orientation of the corresponding piece. BL=Bottom left. BR=Bottom right. TR=Top right. TL=Top left. (BM=Bottom pieces merged. TB=Top pieces merged). So “BL0001.jpg" is the bottomleft piece of page 1. I’m not mentioning their sizes because I don’t want them to be resized or whatever. I just want them to be combined via append like a puzzle like this:
Combined jpg pieces.
The borders and the text-boxes there are just to demonstrate, and are not to be included
So the files are for example like this:
BL0001.jpg
BR0001.jpg
TL0001.jpg
BR0001.jpg
BL0002.jpg
BR0002.jpg
TL0002.jpg
BR0002.jpg
And so on...
This was the last thing I’ve tried in Windows PowerShell:
magick convert B*0001.jpg +append 0001BM.jpg
magick convert T*0001.jpg +append 0001TM.jpg
magick convert 0001*.jpg +swap -append 0001merged.jpg
This combines 4 parts into one image just like I want it to. I found out adding * works like a wildcard and merges all the images like BR and TR together in one go. But I can’t do that for the page number (in this case ‘0001’ in ‘B*0001.jpg’), because that would merge all the files in the folder into the same image, something I don’t want. So what I want to figure out is to how to “batch” run this command for with a sequential numbering system for the different pages. In other words, use a command to batch combine pieces of an image into one image, but with all the scanned pages in jpg in the folder. I know the commands above create addition files with the merged top and bottom parts before the final merge, but I don’t know how to make this command otherwise. I'm willing to try other commands/things too
Using ImageMagick v7 in a simple Windows BAT script you could do something like this...
#echo off
setlocal EnableDelayedExpansion
for /l %%n in ( 1 1 9999 ) do (
set V1=000%%n
set V1=!V1:~-4!
magick *!V1!.jpg +append -crop 2x1# +swap -append +repage !V1!merged.jpg
)
exit /b
That uses a "for" loop to read all four "*0001.jpg" images at a time into an ImageMagick command. The "set V1=" lines are to make sure the variables have the correct number of leading zeros.
The IM command appends, crops, and appends the four images into the properly ordered output, and writes the image as "0001merged.jpg". Then it moves on to process "*0002.jpg" and so on.
I put a top limit on the number of image sets to process with that "9999" in the "for" command to work with the number of leading zeros. Make sure that number is the same or more than the number of image sets you have. It will just print an error for each loop after it goes over the number of image sets, but no harm done.
Note: Using ImageMagick v7 you should just use "magick" because when you use "magick convert" it emulates IMv6 behavior. You probably won't usually want that.

Use older MATLAB save formats

I'm running a model that has a bunch of DLLs which read some .mat files.
When I use an old version of MATLAB (I think 2011a) to generate the files I get files that work okay, but when I create them with 2017a the files seem not to work with the same script.
I've used 2017 to read in the working 2011 file and then saved it, and these files also don't work.
I've also tried the above with the '-vXX' settings at all available values according to the help, with no success.
Example:
clear; load('v2011file.mat'); save('v2017copy.mat', '-v6', 'var1', 'var2', 'var3');
One thing that I have noticed between the two is that when they're selected in the "Current folder" browser, the preview always shows the 2017 files with the variable names in alphabetical order, regardless of the order that I saved them in, while the older 2011 file seems to maintain the order that they were saved. I can only assume that this is something related to a change in the way that files are saved - it might not be the problem but it does hint toward a change (it does this whether or not I include '-vXX' to use older formats).
It's probably worth noting that the 2011 files are created on XP, while the 2017 files are made on Windows 7.
Essentially I'm looking for anyone who might know whether it's possible for me to change the way the file is put together by MATLAB, rather than having to change the DLLs to accept a newer file.
It looks like I can work around the save order issue and have something that works by doing:
save('new2017file.mat', 'var1');
save('new2017file.mat', 'var3'. '-append');
save('new2017file.mat', 'var2', '-append');
Meaning I can put them in a specific order - I have to have the default save set to -v7 in preferences>general>.mat files too.
I wouldn't say no to a more elegant answer if there's one available though!

Defining what is a line in Tesseract

I'm working on document recognition for scanned bank statement. The statements that I have are organized by lines, such as the one attached. Because Tesseract does such a good job at detecting the areas of text, it breaks the lines in the middle (I'm assuming this is because of the large white space between the first block in the line (blurred for privacy reason), and the next one ('EUR', or 'COURS').
In the hocr file, the bbox of all the elements in the line are within 2px or so, so I could potentially rebuild a line myself. However, this seems more like a hack. Is there a way to tell Tesseract that lines should be as wide as the document itself? Or would there be another way to go about it? I've tried playing with the psm option, but with no luck.
-psm 6 -- Assume a single uniform block of text -- should work. If not, you may want to use the older version 2.0x, which does not perform page layout analysis.

Can I force visdiff to display more than the first 2000 bytes?

I have two binary files that I'm trying to compare using Matlab's built-in function visdiff, but it only displays the first 2000 bytes as a default. Is there any way to force the comparison tool to display the entire contents of both files side by side?
Edit the file matlabroot\toolbox\shared\comparisons\private\bindiff.m, where matlabroot is your MATLAB installation directory. On line 149, you'll see it sets the variable MAXLEN to 2000. Change this to something bigger (even Inf seems to work).
You may need to type rehash toolboxcache after making this change, in order to get MATLAB to notice.
Please note:
As you're making a change to the MATLAB source, this is at your own risk (it seems fine to me though). Keep a backup of the file you've edited.
That truncation at 2000 bytes is there for a reason - comparing the whole of larger binary files does seem to take quite a while, so be patient. Maybe try gradually increasing MAXLEN, rather than going straight to Inf.
I only have R2011b available to me right now, so if you're on a newer version the file path and line number I mentioned above may have changed. It was very easy to trace through the code from visdiff to comparisons_private to bindiff though, so unless they've changed the deeper structure of the Comparisons Tool between 11b and now, it will probably be very similar.

Editing a Text File from Matlab

I'm still getting used to Matlab, and not sure if this is possible using Matlab or not, but it's just something that popped into my head that I thought could be interesting.
Is there any way to edit the contents of a text file in Matlab?
Moreover, is there any way to edit specific parts of the text file without altering the rest?
To elaborate, let's say I had a text file that was several lines long. For instance:
This is a hypothetical text file.
The cat chased a mouse.
The mouse ran into a hole.
The cat tried to paw at the mouse.
The mouse waited in the hole until the cat got bored.
The mouse came back out when the cat left.
Is there any way to use Matlab to exclusively edit, say, line 6 and change it from "The mouse waited in the hole until the cat got bored" to "The mouse fell asleep and the cat got bored", without having to change the rest of the file?
I know of several methods to read and display contents of text files using Matlab, but I'm not sure if there's any way to actually edit the text files in Matlab.
Thanks!
As far as I know, you will always have to read the file line by line (for instance into a cell-array) and edit it as you need. After that, you write a new file or overwrite the old one.
Of course, you can encapsulate this procedure and then call you own function like
manipulateFile(lineNumber, newLineText)
Some commands that may come in handy are fopen, fscanf, textread, fprintf, and fclose.