Skip to content

Commit 43cfe64

Browse files
committed
rebuilt build system and updated default resampling to nearest
1 parent 6e8bec3 commit 43cfe64

File tree

3 files changed

+45
-33
lines changed

3 files changed

+45
-33
lines changed

package.json

+30-27
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,35 @@
33
"version": "3.8.0",
44
"description": "Display GeoTIFFs and soon other types of raster on your Leaflet Map",
55
"type": "module",
6-
"main": "dist/webpack/bundle/georaster-layer-for-leaflet.min.js",
7-
"module": "dist/babel/esm/georaster-layer-for-leaflet.js",
6+
"main": "dist/v3/webpack/bundle/georaster-layer-for-leaflet.min.js",
7+
"module": "dist/v3/babel/esm/georaster-layer-for-leaflet.js",
88
"exports": {
99
"./package.json": "./package.json",
1010
".": {
11-
"import": "./dist/babel/esm/georaster-layer-for-leaflet.js",
12-
"require": "./dist/babel/cjs/georaster-layer-for-leaflet.js"
11+
"import": "./dist/v3/babel/esm/georaster-layer-for-leaflet.js",
12+
"require": "./dist/v3/babel/cjs/georaster-layer-for-leaflet.js"
1313
}
1414
},
15-
"browser": "dist/webpack/bundle/georaster-layer-for-leaflet.min.js",
16-
"types": "dist/ts/types/georaster-layer-for-leaflet.d.ts",
17-
"unpkg": "dist/webpack/bundle/georaster-layer-for-leaflet.min.js",
18-
"jsdelivr": "dist/webpack/bundle/georaster-layer-for-leaflet.min.js",
15+
"browser": "dist/v3/webpack/bundle/georaster-layer-for-leaflet.min.js",
16+
"types": "dist/v3/ts/types/georaster-layer-for-leaflet.d.ts",
17+
"unpkg": "dist/v3/webpack/bundle/georaster-layer-for-leaflet.min.js",
18+
"jsdelivr": "dist/v3/webpack/bundle/georaster-layer-for-leaflet.min.js",
1919
"scripts": {
2020
"clean": "rimraf dist",
21-
"build:ts:source": "npx mkdirp ./dist/ts/source/. && cp -r ./src/* ./dist/ts/source/.",
21+
"b": "npm run build",
22+
"build:ts:source": "npx mkdirp ./dist/v3/ts/source/. && cp -r ./src/* ./dist/v3/ts/source/.",
2223
"build:ts:types": "tsc --emitDeclarationOnly",
2324
"build:babel": "npm run build:babel:esm && npm run build:babel:cjs",
24-
"build:babel:esm": "npx babel --extensions \".ts\" --plugins @babel/plugin-proposal-export-namespace-from --plugins @babel/plugin-proposal-optional-chaining --presets @babel/preset-typescript ./src/georaster-layer-for-leaflet.ts --out-dir ./dist/babel/esm",
25-
"build:babel:cjs": "npx babel --extensions \".ts\" --plugins @babel/plugin-transform-modules-commonjs --plugins @babel/plugin-proposal-optional-chaining --plugins @babel/plugin-proposal-export-namespace-from --presets @babel/preset-typescript ./src/georaster-layer-for-leaflet.ts --out-dir dist/babel/cjs",
26-
"build:webpack:bundle": "WEBPACK_OUTPUT_PATH=\"$PWD/dist/webpack/bundle/\" webpack",
27-
"build:webpack:lite": "LITE=true WEBPACK_OUTPUT_PATH=\"$PWD/dist/webpack/lite/\" webpack",
25+
"build:babel:esm": "npx babel --extensions \".ts\" --plugins @babel/plugin-proposal-export-namespace-from --plugins @babel/plugin-proposal-optional-chaining --presets @babel/preset-typescript ./src/georaster-layer-for-leaflet.ts --out-dir ./dist/v3/babel/esm",
26+
"build:babel:cjs": "npx babel --extensions \".ts\" --plugins @babel/plugin-transform-modules-commonjs --plugins @babel/plugin-proposal-optional-chaining --plugins @babel/plugin-proposal-export-namespace-from --presets @babel/preset-typescript ./src/georaster-layer-for-leaflet.ts --out-dir dist/v3/babel/cjs",
27+
"build:webpack:bundle": "WEBPACK_OUTPUT_PATH=\"$PWD/dist/v3/webpack/bundle/\" webpack",
28+
"build:webpack:lite": "LITE=true WEBPACK_OUTPUT_PATH=\"$PWD/dist/v3/webpack/lite/\" webpack",
2829
"copy:legacy": "npm run copy:legacy:min && npm run copy:legacy:lite && npm run copy:legacy:cjs && npm run copy:legacy:esm && npm run copy:legacy:types",
29-
"copy:legacy:min": "cp ./dist/webpack/bundle/* ./dist/.",
30-
"copy:legacy:lite": "cp ./dist/webpack/lite/* ./dist/.",
31-
"copy:legacy:cjs": "cp ./dist/babel/cjs/georaster-layer-for-leaflet.js ./dist/georaster-layer-for-leaflet.bundle.js",
32-
"copy:legacy:esm": "cp ./dist/babel/esm/georaster-layer-for-leaflet.js ./dist/georaster-layer-for-leaflet.js",
33-
"copy:legacy:types": "cp -r ./dist/ts/types/* ./dist/.",
30+
"copy:legacy:min": "cp ./dist/v3/webpack/bundle/* ./dist/.",
31+
"copy:legacy:lite": "cp ./dist/v3/webpack/lite/* ./dist/.",
32+
"copy:legacy:cjs": "cp ./dist/v3/babel/cjs/georaster-layer-for-leaflet.js ./dist/georaster-layer-for-leaflet.bundle.js",
33+
"copy:legacy:esm": "cp ./dist/v3/babel/esm/georaster-layer-for-leaflet.js ./dist/georaster-layer-for-leaflet.js",
34+
"copy:legacy:types": "cp -r ./dist/v3/ts/types/* ./dist/.",
3435
"build": "npm run clean && npm run build:ts:source && npm run build:ts:types && npm run build:babel:esm && npm run build:babel:cjs && npm run build:webpack:bundle && npm run build:webpack:lite && npm run copy:legacy",
3536
"dev": "concurrently \"npm run serve\" \"npm run build:webpack:bundle:old -- --watch\" ",
3637
"f": "npm run format",
@@ -40,7 +41,7 @@
4041
"prep-legacy": "./prep-legacy.sh",
4142
"test": "echo 'to set library, run dev and serve and open the html files in test folder on localhost'",
4243
"validate": "npm run lint && npm run format && npm run check-types",
43-
"serve": "HOST=0.0.0.0 http-server --cors"
44+
"serve": "HOST=0.0.0.0 npx http-server --cors"
4445
},
4546
"repository": {
4647
"type": "git",
@@ -65,24 +66,26 @@
6566
},
6667
"homepage": "https://github.com/GeoTIFF/georaster-layer-for-leaflet#readme",
6768
"dependencies": {
69+
"@types/geojson": "^7946.0.10",
70+
"@types/node": "^18.6.4",
6871
"chroma-js": "^1.4.1",
69-
"geo-extent": "^0.9.0",
72+
"geo-extent": "^0.10.0",
7073
"geocanvas": "^0.3.1",
71-
"pixel-utils": "^0.4.0",
72-
"proj4-fully-loaded": "^0.0.4",
74+
"pixel-utils": "^0.7.0",
75+
"proj4-fully-loaded": "^0.1.0",
7376
"regenerator-runtime": "^0.13.9",
77+
"reproject-bbox": "^0.4.0",
7478
"snap-bbox": "^0.2.0",
7579
"utm-utils": "^0.1.0"
7680
},
7781
"devDependencies": {
78-
"@babel/cli": "^7.18.9",
79-
"@babel/core": "^7.18.9",
82+
"@babel/cli": "^7.18.10",
83+
"@babel/core": "^7.18.10",
8084
"@babel/plugin-transform-template-literals": "^7.18.9",
81-
"@babel/preset-env": "^7.18.9",
85+
"@babel/preset-env": "^7.18.10",
8286
"@babel/preset-typescript": "^7.18.6",
8387
"@types/chroma-js": "^2.1.4",
8488
"@types/leaflet": "^1.7.11",
85-
"@types/node": "^14.18.22",
8689
"@typescript-eslint/eslint-plugin": "^4.33.0",
8790
"@typescript-eslint/parser": "^4.33.0",
8891
"babel-loader": "^8.2.5",
@@ -91,7 +94,7 @@
9194
"eslint": "^7.32.0",
9295
"eslint-config-prettier": "^7.2.0",
9396
"eslint-plugin-prettier": "^3.4.1",
94-
"http-server": "^0.12.3",
97+
"geojson": "^0.5.0",
9598
"null-loader": "^4.0.1",
9699
"prettier": "^2.7.1",
97100
"rimraf": "^3.0.2",

src/georaster-layer-for-leaflet.ts

+13-4
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ const GeoRasterLayer: (new (options: GeoRasterLayerOptions) => any) & typeof L.C
295295
// !note: The types need confirmation - SFR 2021-01-20
296296
return Promise.all(
297297
this.georasters.map((georaster: GeoRaster) =>
298-
georaster.getValues({ ...getValuesOptions, resampleMethod: this.resampleMethod || "bilinear" })
298+
georaster.getValues({ ...getValuesOptions, resampleMethod: this.resampleMethod || "nearest" })
299299
)
300300
).then(valuesByGeoRaster =>
301301
valuesByGeoRaster.reduce((result: number[][][], values) => {
@@ -317,10 +317,13 @@ const GeoRasterLayer: (new (options: GeoRasterLayerOptions) => any) & typeof L.C
317317
tile.style.visibility = "hidden";
318318

319319
const context = tile.getContext("2d");
320+
320321
// note that we aren't setting the tile height or width here
321322
// drawTile dynamically sets the width and padding based on
322323
// how much the georaster takes up the tile area
323-
return this.drawTile({ tile, coords, context, done });
324+
this.drawTile({ tile, coords, context, done });
325+
326+
return tile;
324327
},
325328

326329
drawTile: function ({ tile, coords, context, done }: DrawTileOptions) {
@@ -591,8 +594,12 @@ const GeoRasterLayer: (new (options: GeoRasterLayerOptions) => any) & typeof L.C
591594
for (let columnIndex = 0; columnIndex < row.length; columnIndex++) {
592595
const value = row[columnIndex];
593596
if (value !== noDataValue) {
594-
if (min === undefined || value < min) min = value;
595-
if (max === undefined || value > max) max = value;
597+
if (min === undefined || value < min) {
598+
min = value;
599+
}
600+
if (max === undefined || value > max) {
601+
max = value;
602+
}
596603
}
597604
}
598605
}
@@ -722,6 +729,7 @@ const GeoRasterLayer: (new (options: GeoRasterLayerOptions) => any) & typeof L.C
722729

723730
tile.style.visibility = "visible"; // set to default
724731
} catch (e: any) {
732+
console.error(e);
725733
error = e;
726734
}
727735
done && done(error, tile);
@@ -730,6 +738,7 @@ const GeoRasterLayer: (new (options: GeoRasterLayerOptions) => any) & typeof L.C
730738
// return the tile so it can be rendered on screen
731739
return tile;
732740
} catch (error: any) {
741+
console.error(error);
733742
done && done(error, tile);
734743
}
735744
},

tsconfig.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
// "checkJs": true, /* Report errors in .js files. */
1212
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
1313
"declaration": true /* Generates corresponding '.d.ts' file. */,
14-
"declarationDir": "dist/ts/types",
14+
"declarationDir": "dist/v3/ts/types",
1515
"declarationMap": true /* Generates a sourcemap for each corresponding '.d.ts' file. */,
1616
"sourceMap": true /* Generates corresponding '.map' file. */,
1717
// "outFile": "./index.d.ts" /* Concatenate and emit output to single file. */,
18-
"outDir": "./dist/ts/source" /* Redirect output structure to the directory. */,
18+
"outDir": "./dist/v3/ts/source" /* Redirect output structure to the directory. */,
1919
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
2020
// "composite": true, /* Enable project compilation */
2121
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */

0 commit comments

Comments
 (0)