Skip to content

Commit bbc71b7

Browse files
committed
v0.7.14
1 parent edfb0ce commit bbc71b7

7 files changed

Lines changed: 40 additions & 11 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
v0.7.14
2+
* Added support for importing GeoTIFFs and also PNGs and JPEGs with world file and .prj sidecar files.
3+
* Rasters can only be exported as layers in an SVG.
4+
* The only supported raster editing operation is clipping to a rectangle.
5+
* Raster reprojection is not yet supported.
6+
17
v0.7.13
28
* Moved the layers panel in the web UI to the left sidebar, which it now shares with the console.
39
* Added options to the `-style` command: `icon`, `icon-size` and `icon-color`. This lets you add a variety of icons to a label layer.

docs/reference.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ mapshaper -i 'lat,lon,label\n48.86,2.35,Paris\n51.51,-0.13,London' \
197197

198198
`percentile-range=` [Raster] Input percentile range used with `scaling=percentile`. The default is `2,98`.
199199

200-
`rendition=` [GeoTIFF] Import a specific GeoTIFF rendition, such as `full` or `overview-1`. By default, large GeoTIFFs are imported from the best available reduced-resolution rendition under Mapshaper's import size limit. Use `rendition=full` to force full-resolution import.
200+
`rendition=` [GeoTIFF] Import a specific GeoTIFF rendition, using a slug such as `full` or `overview-1`. When a GeoTIFF has internal overviews, Mapshaper lists the available slugs during import. By default, large GeoTIFFs are imported from the best available reduced-resolution overview under Mapshaper's import size limit, or resampled during import if no suitable overview is available. Use `rendition=full` to force full-resolution import.
201201

202202
`name=` Rename the imported layer (or layers).
203203

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "mapshaper",
3-
"version": "0.7.13",
3+
"version": "0.7.14",
44
"description": "A tool for editing vector datasets for mapping and GIS.",
55
"keywords": [
66
"shapefile",

src/gui/gui-export-control.mjs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -120,18 +120,19 @@ export var ExportControl = function(gui) {
120120
} else {
121121
// stack seems to change if Error is logged directly
122122
console.error(err.stack);
123-
var msg = 'Export failed for an unknown reason';
124-
if (err.name == 'UserError') {
125-
msg = err.message;
126-
}
127-
gui.alert(msg, 'Export failed');
123+
gui.alert(getExportErrorMessage(err), 'Export failed');
128124
}
129125
}).finally(function() {
130126
gui.clearProgressMessage();
131127
});
132128
}, 20);
133129
}
134130

131+
function getExportErrorMessage(err) {
132+
if (err && err.message) return err.message;
133+
return 'Export failed for an unknown reason';
134+
}
135+
135136
function getExportOpts() {
136137
return GUI.parseFreeformOptions(getExportOptsAsString(), 'o');
137138
}
@@ -287,9 +288,11 @@ export var ExportControl = function(gui) {
287288
}
288289

289290
function getDefaultExportFormat() {
290-
var dataset = model.getActiveLayer().dataset;
291+
var active = model.getActiveLayer();
292+
var dataset = active.dataset;
291293
var inputFmt = dataset.info && dataset.info.input_formats &&
292294
dataset.info.input_formats[0];
295+
if (active.layer && internal.layerHasRaster(active.layer)) return 'svg';
293296
return getExportFormats().includes(inputFmt) ? inputFmt : 'geojson';
294297
}
295298

src/io/mapshaper-export.mjs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { copyDatasetForExport, copyDatasetForRenaming } from '../dataset/mapshap
1616
import { mergeDatasetsForExport } from '../dataset/mapshaper-merging';
1717
import { getOutputFormat } from '../io/mapshaper-output-format';
1818
import utils from '../utils/mapshaper-utils';
19-
import { error } from '../utils/mapshaper-logging';
19+
import { error, stop } from '../utils/mapshaper-logging';
2020
import { buildTopology } from '../topology/mapshaper-topology';
2121
import { runningInBrowser } from '../mapshaper-env';
2222
import { getFileBase } from '../utils/mapshaper-filename-utils';
@@ -56,6 +56,7 @@ export async function exportTargetLayers(catalog, targets, opts) {
5656
async function exportDatasets(datasets, opts) {
5757
var format = getOutputFormat(datasets[0], opts);
5858
var files;
59+
validateRasterExportFormat(datasets, format);
5960
if (format != 'geoparquet' && (opts.compression || opts.level !== undefined)) {
6061
error('The compression= and level= options only apply to GeoParquet output');
6162
}
@@ -125,6 +126,18 @@ async function exportDatasets(datasets, opts) {
125126
return files;
126127
}
127128

129+
function validateRasterExportFormat(datasets, format) {
130+
if (!datasetsHaveRasterLayers(datasets)) return;
131+
if (format == 'svg' || format == PACKAGE_EXT) return;
132+
stop('Raster layers can only be exported as SVG or ' + PACKAGE_EXT + ' files');
133+
}
134+
135+
function datasetsHaveRasterLayers(datasets) {
136+
return datasets.some(function(dataset) {
137+
return dataset.layers && dataset.layers.some(layerHasRaster);
138+
});
139+
}
140+
128141
// Return an array of objects with 'filename' and 'content' members.
129142
//
130143
export function exportFileContent(dataset, opts) {
@@ -137,6 +150,7 @@ export function exportFileContent(dataset, opts) {
137150
} else if (!exporter) {
138151
error('Unknown output format:', outFmt);
139152
}
153+
validateRasterExportFormat([dataset], outFmt);
140154

141155
// shallow-copy dataset and layers, so layers can be renamed for export
142156
dataset = utils.defaults({

test/raster-test.mjs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ describe('raster layers', function () {
2323
assert(file.content.includes('preserveAspectRatio="none"'));
2424
});
2525

26+
it('rejects raster export to vector and table formats', function () {
27+
assert.throws(function() {
28+
api.internal.exportFileContent(getRasterDataset(), {format: 'geojson'});
29+
}, /Raster layers can only be exported as SVG or/);
30+
});
31+
2632
it('clips embedded SVG raster images to a frame layer', function () {
2733
var dataset = getRasterDataset();
2834
var frameDataset = getFrameDataset();

0 commit comments

Comments
 (0)