Ox.API: better workaround for area

This commit is contained in:
rolux 2012-06-19 17:57:21 +02:00
parent 0d802a16c9
commit 76a540e399

View file

@ -224,12 +224,24 @@ Ox.api = function(items, options) {
east: data.area.ne.lng
};
*/
data.area = {
south: Ox.MIN_LATITUDE,
data.area = items.length == 0 ? {
south: -Ox.MAX_LATITUDE,
west: -180,
north: Ox.MAX_LATITUDE,
east: 180
}
} : items.reduce(function(prev, curr) {
return {
south: Ox.min(prev.south, curr.south),
west: Ox.min(prev.west, curr.west),
north: Ox.max(prev.north, curr.north),
east: Ox.max(prev.east. curr.east)
};
}, {
south: Ox.MAX_LATITUDE,
west: 180,
north: -Ox.MAX_LATITUDE,
east: -180
});
}
result.data = data;
} else {