Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

consequently use conversion functions instead of hardcoded formulas #3

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ocitysmap/indexlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
from indexer import StreetIndex
from renderer import StreetIndexRenderer
from commons import IndexCategory, IndexItem

import ocitysmap.layoutlib.commons as UTILS

logging.basicConfig(level=logging.DEBUG)
random.seed(42)
Expand Down Expand Up @@ -67,8 +67,8 @@ def __init__(self, rtl):
def isrtl(self):
return self.rtl

width = 2.5*(20 / 2.54) * 72
height = 2.5*(29 / 2.54) * 72
width = 2.5 * contert_mm_to_pt(210)
height = 2.5 * contert_mm_to_pt(297)

surface = cairo.PDFSurface('/tmp/myindex.pdf', width, height)

Expand Down
4 changes: 2 additions & 2 deletions ocitysmap/indexlib/multi_page_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ def render(self, dpi = UTILS.PT_PER_INCH):
import commons
import coords

width = 72*21./2.54
height = 72*29.7/2.54
width = UTILS.convert_mm_to_pt(210)
height = UTILS.convert_mm_to_pt(297)

surface = cairo.PDFSurface('/tmp/myindex_render.pdf', width, height)

Expand Down
4 changes: 2 additions & 2 deletions ocitysmap/indexlib/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,8 +499,8 @@ def _compute_columns_split(self, pc, rendering_style,

logging.basicConfig(level=logging.DEBUG)

width = 72*21./2.54
height = .75 * 72*29.7/2.54
width = UTILS.convert_mm_to_pt(210)
height = .75 * UTILS.convert_mm_to_pt(294)

random.seed(42)

Expand Down
5 changes: 3 additions & 2 deletions ocitysmap/layoutlib/commons.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,13 @@

# PT/metrics conversion routines
PT_PER_INCH = 72.0
MM_PER_INCH = 25.4

def convert_pt_to_dots(pt, dpi = PT_PER_INCH):
return float(pt * dpi) / PT_PER_INCH

def convert_mm_to_pt(mm):
return ((mm/10.0) / 2.54) * 72
return float(mm) / MM_PER_INCH * PT_PER_INCH

def convert_pt_to_mm(pt):
return (float(pt) * 10.0 * 2.54) / 72
return float(pt) * MM_PER_INCH / PT_PER_INCH