Skip to content

Commit

Permalink
Update website
Browse files Browse the repository at this point in the history
  • Loading branch information
mbloch committed Sep 28, 2023
1 parent 66f5ca1 commit 7fbb2d8
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 29 deletions.
2 changes: 1 addition & 1 deletion mapshaper-gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -8112,7 +8112,7 @@
el.addClass('option-menu');
var html = `<input type="text" class="field-name text-input" placeholder="field name"><br>
<input type="text" class="field-value text-input" placeholder="value"><br>
<div class="btn dialog-btn">Apply</div> <span class="inline-checkbox"><input type="checkbox" class="all" />assign value to all records</span>`;
<div tabindex="0" class="btn dialog-btn">Apply</div> <span class="inline-checkbox"><input type="checkbox" class="all" />assign value to all records</span>`;
el.html(html);

var name = el.findChild('.field-name');
Expand Down
90 changes: 62 additions & 28 deletions mapshaper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(function () {

var VERSION = "0.6.42";
var VERSION = "0.6.43";


var utils = /*#__PURE__*/Object.freeze({
Expand Down Expand Up @@ -16438,45 +16438,49 @@
buildPolygonMosaic: buildPolygonMosaic
});

// Map non-negative integers to non-negative integer ids
function IdLookupIndex(n) {
var index = new Uint32Array(n);

this.setId = function(id, val) {
if (id >= 0 && val >= 0 && val < n - 1) {
index[id] = val + 1;
} else {
error('Invalid value');
}
};

this.hasId = function(id) {
return this.getId(id) > -1;
};

this.getId = function(id) {
if (id >= 0 && id < n) {
return index[id] - 1;
} else {
error('Invalid index');
}
};
}


// Map positive or negative integer ids to non-negative integer ids
function IdLookupIndex(n, clearable) {
function ArcLookupIndex(n) {
var fwdIndex = new Int32Array(n);
var revIndex = new Int32Array(n);
var index = this;
var setList = [];
utils.initializeArray(fwdIndex, -1);
utils.initializeArray(revIndex, -1);

this.setId = function(id, val) {
if (clearable && !index.hasId(id)) {
setList.push(id);
}
if (id < 0) {
revIndex[~id] = val;
} else {
fwdIndex[id] = val;
}
};

this.clear = function() {
if (!clearable) {
error('Index is not clearable');
}
setList.forEach(function(id) {
index.setId(id, -1);
});
setList = [];
};

this.clearId = function(id) {
if (!index.hasId(id)) {
error('Tried to clear an unset id');
}
index.setId(id, -1);
};

this.hasId = function(id) {
var val = index.getId(id);
var val = this.getId(id);
return val > -1;
};

Expand All @@ -16489,6 +16493,36 @@
};
}

// Support clearing the index (for efficient reuse)
function ClearableArcLookupIndex(n) {
var setList = [];
var idx = new ArcLookupIndex(n);
var _setId = idx.setId;

idx.setId = function(id, val) {
if (!idx.hasId(id)) {
setList.push(id);
}
_setId(id, val);
};

idx.clear = function() {
setList.forEach(function(id) {
_setId(id, -1);
});
setList = [];
};

this.clearId = function(id) {
if (!idx.hasId(id)) {
error('Tried to clear an unset id');
}
_setId(id, -1);
};

return idx;
}

// Associate mosaic tiles with shapes (i.e. identify the groups of tiles that
// belong to each shape)
//
Expand Down Expand Up @@ -16740,7 +16774,7 @@
// Supports looking up a shape id using an arc id.
function ShapeArcIndex(shapes, arcs) {
var n = arcs.size();
var index = new IdLookupIndex(n);
var index = new ArcLookupIndex(n);
var shapeId;
shapes.forEach(onShape);

Expand Down Expand Up @@ -16892,7 +16926,7 @@
var arcs = dataset.arcs;
var filter = getArcPresenceTest(lyr.shapes, arcs);
var nodes = new NodeCollection(arcs, filter);
var arcIndex = new IdLookupIndex(arcs.size(), true);
var arcIndex = new ClearableArcLookupIndex(arcs.size());
lyr.shapes = lyr.shapes.map(function(shp, i) {
if (!shp) return null;
// split parts at nodes (where multiple arcs intersect)
Expand Down Expand Up @@ -38262,7 +38296,7 @@ ${svg}
// polygon layer, @clipData). This avoids performing unnecessary intersection
// tests on each line segment.
var layers = dataset.layers.filter(function(lyr) {
return !layerIsFullyEnclosed(lyr, dataset, clipData);
return layerHasGeometry(lyr) && !layerIsFullyEnclosed(lyr, dataset, clipData);
});
if (layers.length > 0) {
clipLayersInPlace(layers, clipData, dataset, 'clip');
Expand Down

0 comments on commit 7fbb2d8

Please sign in to comment.