6

Not sure if something exists for such a specific need, but I'll try anyway. I've got some PDF maps, and I was wondering if there's any PDF-viewer or similar software that allows me to measure distances, and use a compass to figure out headings.

The only thing I can think of is to import the maps into image editing software and use a line matching the scale to measure distances, but this would be highly impractical and potentially time consuming, and there would still be no way for me to measure headings.

EDIT: screenruler and kruler are unfortunately too basic, as they lack protractors, as well as the ability to make precision rotations.

What about something that would allow me to overlay, move, and rotate a transparent image of my choosing? That would allow me to create or find my own images of measurement tools.

EDIT2: Running Ubuntu 18.10 on a tablet

2
  • How about using a screen ruler? There are some here: askubuntu.com/questions/5324/…
    – Parto
    Commented Apr 8, 2019 at 12:27
  • 1
    @Parto: Gave screenruler and kruler a try. Both are too basic, unfortunately. Unable to make precise rotations (90 degrees is the only option), and lack of protractor. Will edit post.
    – hiigaran
    Commented Apr 8, 2019 at 13:11

2 Answers 2

1

Get geometry info on screen

Although the solution below should quickly give you all the info you ask for, not sure if the way the info is presented will fully satisfy your description.

It is an edited version of this answer, now extended with a few extra calculations, now including the angle to an imaginary horizontal line, as well as the length of the line you draw, in (equivalents of) px:

enter image description here

The script

#!/usr/bin/env python3
import subprocess
import os
import math

home = os.environ["HOME"]
area = home+"/"+".measure_area.txt"

def get_pos():
    pos_data = subprocess.check_output(["xdotool", "getmouselocation"]).decode("utf-8")
    return [m[2:] for m in pos_data.split()[:2]]

def confirm():
    get = subprocess.check_output(["xrandr", "--verbose"]).decode("utf-8").split()
    for s in [get[i-1] for i in range(len(get)) if get[i] == "connected"]:
        br_data = float(get[get.index("Brightness:")+1])
        brightness = lambda br: ["xrandr", "--output", s, "--brightness", br]
        flash = ["sleep", "0.1"]
        for cmd in [brightness(str(br_data-0.1)), flash, brightness(str(br_data))]:
            subprocess.call(cmd)

if not os.path.exists(area):
    with open(area, "wt") as measure:
        measure.write(str(get_pos()))
    confirm()
else:
    second = get_pos()
    with open(area) as first_m:
        try:
            first = eval(first_m.read())
            w = int(math.fabs(int(second[0]) - int(first[0])))
            h = int(math.fabs(int(second[1]) - int(first[1])))
            l = str(round(math.sqrt(pow(w, 2) + pow(h, 2))))
            arc = math.degrees(math.atan(w/h))
            angle = str(round(90-arc))
            command = [
                'zenity', '--info', '--title', 'Area Size', '--width', '200',
                '--text', "rectangle: " + str(w) + 'px x ' + str(h) + "px"
                "\nline length: " + l + "px\nangle: " + str(angle) + "°",
            ]
            #---
            confirm()
        except SyntaxError:
            text = "Please try again, there was an error in the data"
            command = ['zenity', '--info', '--title', 'Please try again', '--text', text]
        subprocess.Popen(command)
    os.remove(area)

How it works

The script calculates the angle to an imaginary horizontal line, the length and the area size, between two locations of the mouse pointer.

It works as followes:

  1. Place the mouse pointer in the first position (without clicking)
  2. Press the key combination of your choice (see further below)
  3. Place the mouse in the second position (again without clicking)
  4. Press your key combination again. A Zenity window will show you the result as in the image above.

How to set up

  1. The script uses xdotool:

    sudo apt-get install xdotool
    
  2. Copy the script below into an empty file, save it in ~/bin (you will probably have to create the directory) as measure_area (no extension) and make it executable.

  3. Add a key combination of your choice to run the script: Choose: System Settings > "Keyboard" > "Shortcuts" > "Custom Shortcuts". Click the "+" and add the command:

    measure_area
    

Notes

  • You will have to log out / in first
  • It does not make a difference what you take as first/second position; the script measures absolute values.
4
  • Looks promising, but I'm guessing a keyboard and mouse are mandatory here, right? I'm working with a tablet.
    – hiigaran
    Commented Apr 8, 2019 at 19:18
  • @hiigaran please add that to your Q, it is essential information. I am guessing that will rule out about all the allready scarce options. What is your distro? Commented Apr 8, 2019 at 19:25
  • Will do. And it's running Ubuntu 18.10
    – hiigaran
    Commented Apr 8, 2019 at 21:18
  • Works like a charme... Thanx Jacob
    – rcspam
    Commented Jun 14, 2022 at 11:35
0

Assuming that the PDF map that you have is a geospatial PDF, you can use Adobe Acrobat and teh built-in analysis tools or you can use the Avenza Maps mobile app on your phone or tablet.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .