Updated min bounds algorithm
This commit is contained in:
parent
9bf489a0b9
commit
cf896fa0a7
1 changed files with 16 additions and 7 deletions
|
@ -97,17 +97,26 @@ OSM.History = function(map) {
|
||||||
$("[data-changeset]").each(function () {
|
$("[data-changeset]").each(function () {
|
||||||
var changeset = $(this).data('changeset');
|
var changeset = $(this).data('changeset');
|
||||||
if (changeset.bbox) {
|
if (changeset.bbox) {
|
||||||
var latModifier = 0;
|
var latWidth = changeset.bbox.maxlat - changeset.bbox.minlat;
|
||||||
var lonModifier = 0;
|
var lonWidth = changeset.bbox.maxlon - changeset.bbox.minlon;
|
||||||
|
var minLatWidth = 0.0004;
|
||||||
|
var minLonWidth = 0.0008;
|
||||||
|
|
||||||
if (changeset.bbox.minlat === changeset.bbox.maxlat || changeset.bbox.minlon === changeset.bbox.maxlon) {
|
var bounds = [[changeset.bbox.minlat, changeset.bbox.minlon],
|
||||||
latModifier = 0.0001;
|
[changeset.bbox.maxlat, changeset.bbox.maxlon]];
|
||||||
lonModifier = 0.0002;
|
|
||||||
|
if (latWidth < minLatWidth) {
|
||||||
|
bounds[0][0] -= ((minLatWidth - latWidth) / 2);
|
||||||
|
bounds[1][0] += ((minLatWidth - latWidth) / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lonWidth < minLonWidth) {
|
||||||
|
bounds[0][1] -= ((minLonWidth - lonWidth) / 2);
|
||||||
|
bounds[1][1] += ((minLonWidth - lonWidth) / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
changeset.bounds = L.latLngBounds(
|
changeset.bounds = L.latLngBounds(
|
||||||
[changeset.bbox.minlat - latModifier, changeset.bbox.minlon - lonModifier],
|
bounds);
|
||||||
[changeset.bbox.maxlat + latModifier, changeset.bbox.maxlon + lonModifier]);
|
|
||||||
changesets.push(changeset);
|
changesets.push(changeset);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue