Skip to content

Commit

Permalink
reduce memory allocation in label build
Browse files Browse the repository at this point in the history
  • Loading branch information
bcamper committed Mar 6, 2019
1 parent 4bd959c commit 9d772cd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
8 changes: 2 additions & 6 deletions src/labels/label.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import PointAnchor from './point_anchor';
import {boxIntersectsList} from './intersect';
import Utils from '../utils/utils';
import OBB from '../utils/obb';
import Geo from '../utils/geo';
// import log from '../utils/log';
Expand Down Expand Up @@ -79,13 +78,10 @@ export default class Label {

// checks whether the label is within the tile boundaries
inTileBounds () {
let min = [ this.aabb[0], this.aabb[1] ];
let max = [ this.aabb[2], this.aabb[3] ];

if (!Utils.pointInTile(min) || !Utils.pointInTile(max)) {
if ((this.aabb[0] >= 0 && this.aabb[1] > -Geo.tile_scale && this.aabb[0] < Geo.tile_scale && this.aabb[1] <= 0) ||
(this.aabb[2] >= 0 && this.aabb[3] > -Geo.tile_scale && this.aabb[2] < Geo.tile_scale && this.aabb[3] <= 0)) {
return false;
}

return true;
}

Expand Down
5 changes: 0 additions & 5 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import log from './log';
import Thread from './thread';
import WorkerBroker from './worker_broker';
import Geo from './geo';

export default Utils;

Expand Down Expand Up @@ -237,7 +236,3 @@ Utils.toCSSColor = function (color) {
// RGB is between [0, 255] opacity is between [0, 1]
return `rgba(${color.map((c, i) => (i < 3 && Math.round(c * 255)) || c).join(', ')})`;
};

Utils.pointInTile = function (point) {
return point[0] >= 0 && point[1] > -Geo.tile_scale && point[0] < Geo.tile_scale && point[1] <= 0;
};

0 comments on commit 9d772cd

Please sign in to comment.