Skip to content

Commit

Permalink
Update website
Browse files Browse the repository at this point in the history
  • Loading branch information
mbloch committed May 17, 2024
1 parent ddb4716 commit 1c04169
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 38 deletions.
48 changes: 38 additions & 10 deletions mapshaper-gui.js
Original file line number Diff line number Diff line change
Expand Up @@ -3707,7 +3707,13 @@
// init simplify button and mode
gui.addMode('simplify', turnOn, turnOff, menuBtn);

model.on('update', function() {
model.on('update', function(e) {
// exit simplify mode if data has been changed from outside the simplify
// tool
// (TODO: try to only respond to changes that might affect simplification)
if (e.flags.simplify_method || e.flags.simplify_amount) {
return;
}
menuBtn.classed('disabled', !model.getActiveLayer());
if (gui.getMode() == 'simplify') gui.clearMode();
});
Expand Down Expand Up @@ -5890,7 +5896,7 @@

var menus = {
standard: ['info', 'selection', 'box'],
empty: ['edit_points', 'edit_lines', 'edit_polygons', 'box'],
empty: ['edit_polygons', 'edit_lines', 'edit_points', 'box'],
polygons: ['info', 'selection', 'box', 'edit_polygons'],
rectangles: ['info', 'selection', 'box', 'rectangles', 'edit_polygons'],
lines: ['info', 'selection', 'box' , 'edit_lines'],
Expand All @@ -5908,11 +5914,11 @@
// mode name -> menu text lookup
var labels = {
info: 'inspect features',
box: 'shift-drag box tool',
box: 'rectangle tool',
data: 'edit attributes',
labels: 'position labels',
edit_points: 'draw/edit points',
edit_lines: 'draw/edit lines',
edit_points: 'add/edit points',
edit_lines: 'draw/edit polylines',
edit_polygons: 'draw/edit polygons',
vertices: 'edit vertices',
selection: 'selection tool',
Expand Down Expand Up @@ -6531,8 +6537,7 @@
if (!obj) return false;
if (isArray(obj)) return true;
if (isString(obj)) return false;
if (obj.length === 0) return true;
if (obj.length > 0) return true;
if (obj.length === 0 || obj.length > 0) return true;
return false;
}

Expand Down Expand Up @@ -8830,12 +8835,12 @@
element.addEventListener('mousedown', onAreaDown);
element.addEventListener('dblclick', onAreaDblClick);
document.addEventListener('contextmenu', function(e) {
if (!e.ctrlKey) {
if (!(e.ctrlKey && e.altKey)) {
e.preventDefault();
}
});
element.addEventListener('contextmenu', function(e) {
if (!e.ctrlKey) {
if (!(e.ctrlKey && e.altKey)) {
_self.dispatchEvent('contextmenu', procMouseEvent(e));
}
});
Expand Down Expand Up @@ -12142,6 +12147,8 @@
var popup = gui.container.findChild('.box-tool-options');
var coords = popup.findChild('.box-coords');
var _on = false;
var instructionsShown = false;
var alert;

var infoBtn = new SimpleButton(popup.findChild('.info-btn')).on('click', function() {
if (coords.visible()) hideCoords(); else showCoords();
Expand Down Expand Up @@ -12188,6 +12195,10 @@
gui.on('interaction_mode_change', function(e) {
if (e.mode === 'box') {
gui.enterMode('box_tool');
if (!instructionsShown) {
instructionsShown = true;
showInstructions();
}
} else if (_on) {
turnOff();
}
Expand All @@ -12198,7 +12209,10 @@
});

box.on('dragend', function(e) {
if (_on) popup.show();
if (_on) {
hideInstructions();
popup.show();
}
});

box.on('handle_drag', function() {
Expand All @@ -12207,6 +12221,19 @@
}
});

function showInstructions() {
var isMac = navigator.userAgent.includes('Mac');
var symbol = isMac ? '⌘' : '^';
var msg = `Instructions: Shift-drag to draw a rectangle. Drag handles to resize. Shift-drag handles to resize symmetrically.`;
alert = showPopupAlert(msg, null, { non_blocking: true, max_width: '360px'});
}

function hideInstructions() {
if (!alert) return;
alert.close('fade');
alert = null;
}

function inZoomMode() {
return !_on && gui.getMode() != 'selection_tool';
}
Expand Down Expand Up @@ -12242,6 +12269,7 @@

function turnOff() {
box.turnOff();
hideInstructions();
if (gui.interaction.getMode() == 'box') {
// mode change was not initiated by interactive menu -- turn off interactivity
gui.interaction.turnOff();
Expand Down
49 changes: 21 additions & 28 deletions mapshaper.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,7 @@
if (!obj) return false;
if (isArray(obj)) return true;
if (isString(obj)) return false;
if (obj.length === 0) return true;
if (obj.length > 0) return true;
if (obj.length === 0 || obj.length > 0) return true;
return false;
}

Expand Down Expand Up @@ -28103,9 +28102,9 @@ ${svg}
var BUFLEN = 1e7; // buffer chunk size
var MAX_STRLEN = 5e6; // max byte len of a value string (object keys are shorter)

// Parse from a Buffer -- similar to JSON.parse(), used for testing
function parse(buf) {
var reader = new BufferReader(buf);
// Parse from a Buffer or FileReader
function parseJSON(arg) {
var reader = isArrayLike(arg) ? new BufferReader(arg) : arg;
var src = ByteReader(reader, 0);
skipWS(src);
var val = readValue(src);
Expand All @@ -28116,11 +28115,18 @@ ${svg}
return val;
}

// parse data from:
// * FeatureCollection
// * GeometryCollection
// * Single Feature or Geometry
// * WS-delimited sequence of Features or geometries
// Parse data from:
// * FeatureCollection
// * GeometryCollection
// * Single Feature or Geometry
// * WS-delimited sequence of Features or geometries
//
// reader: FileReader or compatible reader
// cb: callback function, called once for each parsed Feature or bare geometry
//
// Returns:
// * collections - top-level object with features/geometries array set to null
// * others - null
//
function parseGeoJSON(reader, cb) {
var src = ByteReader(reader, 0);
Expand All @@ -28145,6 +28151,7 @@ ${svg}
return null;
}


function parseError(msg, i) {
if (i >= 0) {
msg += ' at position ' + i;
Expand Down Expand Up @@ -28596,19 +28603,6 @@ ${svg}
}
}

// Read GeoJSON Features or geometry objects from a file
// @reader: a FileReader
function GeoJSONReader(reader) {

this.readObjects = function(onObject) {
T$1.start();
var val = parseGeoJSON(reader, onObject);
// var val = parseGeoJSON_native(reader, onObject);
debug('Parse GeoJSON', T$1.stop());
return val;
};
}

// Identify JSON type from the initial subset of a JSON string
function identifyJSONString(str, opts) {
var maxChars = 1000;
Expand Down Expand Up @@ -28642,7 +28636,7 @@ ${svg}

function importGeoJSONFile(fileReader, opts) {
var importer = new GeoJSONParser(opts);
new GeoJSONReader(fileReader).readObjects(importer.parseObject);
parseGeoJSON(fileReader, importer.parseObject);
// TODO: examine top-level objects, like crs
return importer.done();
}
Expand Down Expand Up @@ -45678,7 +45672,7 @@ ${svg}
});
}

var version = "0.6.94";
var version = "0.6.95";

// Parse command line args into commands and run them
// Function takes an optional Node-style callback. A Promise is returned if no callback is given.
Expand Down Expand Up @@ -46310,8 +46304,8 @@ ${svg}
Dbf,
DbfReader,
DouglasPeucker,
geojson: GeoJSON,
json: { parse: parse },
parseGeoJSON,
json: { parse: parseJSON },
ShpType,
topojson: TopoJSON,
Visvalingam,
Expand All @@ -46321,7 +46315,6 @@ ${svg}
CommandParser,
DataTable,
editArcs,
GeoJSONReader,
Heap,
IdLookupIndex,
NodeCollection,
Expand Down

0 comments on commit 1c04169

Please sign in to comment.