kopia lustrzana https://github.com/hholzgra/maposmatic/
Porównaj commity
6 Commity
fa64be0525
...
c032057703
Autor | SHA1 | Data |
---|---|---|
Hartmut Holzgraefe | c032057703 | |
Hartmut Holzgraefe | 5b17fcfc60 | |
Hartmut Holzgraefe | acdbc511a9 | |
Hartmut Holzgraefe | cb557cd586 | |
Hartmut Holzgraefe | 5500f95b21 | |
Hartmut Holzgraefe | b97c9f284b |
|
@ -23,6 +23,12 @@ function choose_paper_buttons(layout)
|
|||
}
|
||||
}
|
||||
|
||||
function myParseInt(val)
|
||||
{
|
||||
var parsed = parseInt(val);
|
||||
if (isNaN(parsed)) return 0;
|
||||
return parsed;
|
||||
}
|
||||
|
||||
|
||||
var best_fit_width = 0;
|
||||
|
@ -96,16 +102,16 @@ function preparePaperSize() {
|
|||
$('#id_paper_width_mm').attr("min", w);
|
||||
$('#id_paper_height_mm').attr("min", h);
|
||||
|
||||
best_fit_width = parseInt(w);
|
||||
best_fit_height = parseInt(h);
|
||||
best_fit_scale = parseInt( data[i][(data[i]['portrait_ok']) ? 'portrait_scale' : 'landscape_scale']);
|
||||
best_fit_width = myParseInt(w);
|
||||
best_fit_height = myParseInt(h);
|
||||
best_fit_scale = myParseInt( data[i][(data[i]['portrait_ok']) ? 'portrait_scale' : 'landscape_scale']);
|
||||
|
||||
$("#best_width").text(w);
|
||||
$("#best_height").text(h);
|
||||
|
||||
// if current values are below limits -> enforce min size
|
||||
if (w > parseInt($('#id_paper_width_mm').val())
|
||||
|| h > parseInt($('#id_paper_height_mm').val())) {
|
||||
if (w > myParseInt($('#id_paper_width_mm').val())
|
||||
|| h > myParseInt($('#id_paper_height_mm').val())) {
|
||||
$('#id_paper_width_mm').val(w);
|
||||
$('#id_paper_height_mm').val(h);
|
||||
}
|
||||
|
@ -114,7 +120,7 @@ function preparePaperSize() {
|
|||
}
|
||||
|
||||
if (data[i]['portrait_ok']) {
|
||||
var scale = Math.round(parseInt(data[i]['portrait_scale']));
|
||||
var scale = Math.round(myParseInt(data[i]['portrait_scale']));
|
||||
var scale_txt = "";
|
||||
if (scale) {
|
||||
scale_txt = "Scale ca. 1:" + scale + "; zoom factor " + data[i]['portrait_zoom'];
|
||||
|
@ -122,7 +128,7 @@ function preparePaperSize() {
|
|||
enable_papersize(w, h, scale_txt);
|
||||
}
|
||||
if (data[i]['landscape_ok']) {
|
||||
var scale = Math.round(parseInt(data[i]['landscape_scale']));
|
||||
var scale = Math.round(myParseInt(data[i]['landscape_scale']));
|
||||
var scale_txt = "";
|
||||
if (scale) {
|
||||
scale_txt = "Scale ca. 1:" + scale + "; zoom factor " + data[i]['landscape_zoom'];
|
||||
|
@ -142,11 +148,11 @@ function preparePaperSize() {
|
|||
|
||||
function change_papersize()
|
||||
{
|
||||
w = parseInt($('#id_paper_width_mm').val());
|
||||
h = parseInt($('#id_paper_height_mm').val());
|
||||
w = myParseInt($('#id_paper_width_mm').val());
|
||||
h = myParseInt($('#id_paper_height_mm').val());
|
||||
|
||||
wmin = parseInt($('#id_paper_width_mm').attr('min'));
|
||||
hmin = parseInt($('#id_paper_height_mm').attr('min'));
|
||||
wmin = myParseInt($('#id_paper_width_mm').attr('min'));
|
||||
hmin = myParseInt($('#id_paper_height_mm').attr('min'));
|
||||
|
||||
if (w < wmin) {
|
||||
w = wmin;
|
||||
|
@ -171,10 +177,10 @@ function set_papersize(paper_width, paper_height)
|
|||
|
||||
if (paper_width == 0 && paper_height == 0) {
|
||||
id = ".papersize_best_fit";
|
||||
paper_width = parseInt($("#best_width").text());
|
||||
paper_height = parseInt($("#best_height").text());
|
||||
} else if (paper_width == parseInt($("#best_width").text())
|
||||
&& paper_height == parseInt($("#best_height").text())) {
|
||||
paper_width = myParseInt($("#best_width").text());
|
||||
paper_height = myParseInt($("#best_height").text());
|
||||
} else if (paper_width == myParseInt($("#best_width").text())
|
||||
&& paper_height == myParseInt($("#best_height").text())) {
|
||||
id = ".papersize_best_fit";
|
||||
} else {
|
||||
id = ".papersize_" + paper_width + "_" + paper_height;
|
||||
|
@ -207,8 +213,8 @@ function show_paper_preview(canvas_name, w, h, scale)
|
|||
var cw = canvas.width-1;
|
||||
var ch = canvas.height-1;
|
||||
|
||||
w = parseInt(w);
|
||||
h = parseInt(h);
|
||||
w = myParseInt(w);
|
||||
h = myParseInt(h);
|
||||
|
||||
if (w > h) {
|
||||
tw = (cw - 20)
|
||||
|
@ -454,8 +460,8 @@ function enable_papersize(w, h, txt)
|
|||
id = ".papersize_" + w + "_" + h;
|
||||
} else {
|
||||
id = ".papersize_best_fit";
|
||||
w = parseInt($("#best_width").text());
|
||||
h = parseInt($("#best_height").text());
|
||||
w = myParseInt($("#best_width").text());
|
||||
h = myParseInt($("#best_height").text());
|
||||
}
|
||||
|
||||
var buttons = $(id);
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
{% load extratags %}
|
||||
|
||||
function wizardmap(elt, bounds=false) {
|
||||
/**
|
||||
/**
|
||||
* Update the 4 text fields with the area coordinates.
|
||||
*
|
||||
* If a feature has been drawned (bbox != null), the bounding box of the
|
||||
|
@ -106,7 +106,7 @@ function wizardmap(elt, bounds=false) {
|
|||
strokeWidth: 2
|
||||
};
|
||||
var countryquery = null;
|
||||
locationFilter = new L.LocationFilter({
|
||||
var filterParams = {
|
||||
enableButton: {
|
||||
enableText: '{% trans "Select area" %}',
|
||||
disableText: '{% trans "Remove selection" %}'
|
||||
|
@ -115,7 +115,14 @@ function wizardmap(elt, bounds=false) {
|
|||
text: '{% trans "Select area within current zoom" %}'
|
||||
},
|
||||
buttonPosition: 'topright'
|
||||
});
|
||||
};
|
||||
if (bounds) {
|
||||
filterParams["bounds"] = bounds;
|
||||
filterParams["enable"] = true;
|
||||
map.fitBounds(bounds);
|
||||
}
|
||||
|
||||
locationFilter = new L.LocationFilter(filterParams);
|
||||
locationFilter.on("change", function (e) {
|
||||
bbox = e.target.getBounds();
|
||||
map.fitBounds(bbox);
|
||||
|
@ -131,10 +138,6 @@ function wizardmap(elt, bounds=false) {
|
|||
update_fields();
|
||||
});
|
||||
locationFilter.addTo(map);
|
||||
if (bounds) {
|
||||
locationFilter.setBounds(bounds);
|
||||
locationFilter.enable();
|
||||
}
|
||||
|
||||
// locate client position
|
||||
L.control.locate().addTo(map);
|
||||
|
|
|
@ -47,6 +47,7 @@ from django.utils.safestring import mark_safe
|
|||
import ocitysmap
|
||||
from www.maposmatic import helpers, forms, nominatim, models
|
||||
import www.settings
|
||||
from www.maposmatic.apis import get_paper_from_size
|
||||
|
||||
import psycopg2
|
||||
|
||||
|
@ -144,19 +145,30 @@ def create_upload_file(job, file, keep_until = None):
|
|||
file_instance.save()
|
||||
file_instance.job.add(job)
|
||||
|
||||
def _papersize_buttons(basename, width=None, height=None):
|
||||
format = "<button id='{0}_{1}_{2}' type='button' class='btn btn-primary papersize papersize_{1}_{2}' onclick='set_papersize({1}, {2});'><i class='fas fa-{3} fa-2x'></i></button> "
|
||||
|
||||
if width is None or height is None: # no values -> "best fit"
|
||||
return format.format(basename, "best", "fit", 'square')
|
||||
|
||||
if width == height: # square format, just one button
|
||||
return format.format(basename, width, height, 'square')
|
||||
|
||||
# individual buttons for landscape and portrait
|
||||
return format.format(basename, height, width, 'image') + format.format(basename, width, height, 'portrait')
|
||||
|
||||
def new(request):
|
||||
"""The map creation page and form."""
|
||||
|
||||
papersize_buttons = ''
|
||||
|
||||
if request.method == 'POST':
|
||||
form = forms.MapRenderingJobForm(request.POST, request.FILES)
|
||||
if form.is_valid():
|
||||
request.session['new_layout'] = form.cleaned_data.get('layout')
|
||||
request.session['new_indexer'] = form.cleaned_data.get('indexer')
|
||||
request.session['new_stylesheet'] = form.cleaned_data.get('stylesheet')
|
||||
request.session['new_overlay'] = form.cleaned_data.get('overlay')
|
||||
request.session['new_paper_width_mm'] = form.cleaned_data.get('paper_width_mm')
|
||||
# remember some settings as future defaults
|
||||
request.session['new_layout'] = form.cleaned_data.get('layout')
|
||||
request.session['new_indexer'] = form.cleaned_data.get('indexer')
|
||||
request.session['new_stylesheet'] = form.cleaned_data.get('stylesheet')
|
||||
request.session['new_overlay'] = form.cleaned_data.get('overlay')
|
||||
request.session['new_paper_width_mm'] = form.cleaned_data.get('paper_width_mm')
|
||||
request.session['new_paper_height_mm'] = form.cleaned_data.get('paper_height_mm')
|
||||
|
||||
job = form.save(commit=False)
|
||||
|
@ -239,29 +251,20 @@ def new(request):
|
|||
|
||||
_ocitysmap = ocitysmap.OCitySMap(www.settings.OCITYSMAP_CFG_PATH)
|
||||
|
||||
# TODO: create tempates for these button lines ...
|
||||
best_fit = _("Best fit")
|
||||
papersize_buttons += "<p><button id='paper_best_fit' type='button' class='btn btn-primary papersize papersize_best_fit' onclick='set_papersize(0,0);'><i class='fas fa-square fa-2x'></i></button> <b>%s</b> (<span id='best_width'>?</span>×<span id='best_height'>?</span>mm²)</p>" % best_fit
|
||||
papersize_buttons = '<p>'
|
||||
papersize_buttons += _papersize_buttons('paper')
|
||||
papersize_buttons += "<b>%s</b> (<span id='best_width'>?</span>×<span id='best_height'>?</span>mm²)</p>" % _("Best fit")
|
||||
for p in _ocitysmap.get_all_paper_sizes():
|
||||
if p[1] is not None:
|
||||
papersize_buttons += "<p>"
|
||||
if p[1] != p[2]:
|
||||
papersize_buttons += "<button id='paper_{0}_{1}' type='button' class='btn btn-primary papersize papersize_{0}_{1}' onclick='set_papersize({0}, {1});'><i class='fas fa-portrait fa-2x'></i></button> ".format(p[1], p[2])
|
||||
papersize_buttons += "<button id='paper_{0}_{1}' type='button' class='btn btn-primary papersize papersize_{0}_{1}' onclick='set_papersize({0}, {1});'><i class='fas fa-image fa-2x'></i></button> ".format(p[2], p[1])
|
||||
else:
|
||||
papersize_buttons += "<button id='paper_{0}_{1}' disabled type='button' class='btn btn-primary papersize papersize_{0}_{1}' onclick='set_papersize({0}, {1});'><i class='fas fa-square fa-2x'></i></button> ".format(p[1], p[2])
|
||||
|
||||
papersize_buttons += _papersize_buttons('paper', p[1], p[2])
|
||||
papersize_buttons += "<b>%s</b> (%s×%smm²)</p>" % (p[0], repr(p[1]), repr(p[2]))
|
||||
|
||||
multisize_buttons = ''
|
||||
for p in _ocitysmap.get_all_paper_sizes('multipage'):
|
||||
if p[1] is not None:
|
||||
multisize_buttons += "<p>"
|
||||
if p[1] != p[2]:
|
||||
multisize_buttons += "<button id='multipaper_{0}_{1}' type='button' class='btn btn-primary papersize papersize_{0}_{1}' onclick='set_papersize({0}, {1});'><i class='fas fa-portrait fa-2x'></i></button> ".format(p[1], p[2])
|
||||
multisize_buttons += "<button id='multipaper_{0}_{1}' type='button' class='btn btn-primary papersize papersize_{0}_{1}' onclick='set_papersize({0}, {1});'><i class='fas fa-image fa-2x'></i></button> ".format(p[2], p[1])
|
||||
else:
|
||||
multisize_buttons += "<button id='multipaper_{0}_{1}' disabled type='button' class='btn btn-primary papersize papersize_{0}_{1}' onclick='set_papersize({0}, {1});'><i class='fas fa-square fa-2x'></i></button> ".format(p[1], p[2])
|
||||
multisize_buttons += _papersize_buttons('multipaper', p[1], p[2])
|
||||
multisize_buttons += "<b>%s</b> (%s×%smm²)</p>" % (p[0], repr(p[1]), repr(p[2]))
|
||||
|
||||
return render(request, 'maposmatic/new.html',
|
||||
|
@ -408,6 +411,7 @@ def reedit(request):
|
|||
|
||||
init_vals = {
|
||||
'layout': job.layout,
|
||||
'indexer': job.indexer,
|
||||
'stylesheet': job.stylesheet,
|
||||
'overlay': job.overlay.split(","),
|
||||
'maptitle': job.maptitle,
|
||||
|
@ -417,6 +421,7 @@ def reedit(request):
|
|||
}
|
||||
|
||||
request.session['new_layout'] = job.layout
|
||||
request.session['new_indexer'] = job.indexer
|
||||
request.session['new_stylesheet'] = job.stylesheet
|
||||
request.session['new_overlay'] = job.overlay.split(",")
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue