diff --git a/README.md b/README.md index f2be9ae..9b12bd5 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ new GeoRasterLayer({ georaster }).addTo(map); ## The GeoRasterLayer Class -A custom class for rendering GeoTIFF's (including COG's) on a leaflet map. The layer extends L.GridLayer, see the [docs](https://leafletjs.com/reference-1.7.1.html#gridlayer) for inherited options and methods. +A custom class for rendering GeoTIFF's (including COG's) on a leaflet map. The layer extends L.GridLayer, see the [docs](https://leafletjs.com/reference.html#gridlayer) for inherited options and methods. ### Usage Example @@ -61,6 +61,7 @@ Source Code: The layer extends L.GridLayer, see the [docs](https://leafletjs.com/reference.html#gridlayer) for inherited options and methods. + +| Option | Type | Default | Description | +|----------------------|-------------------------------------------------------------------|---------|------------------------------------------------------------------| +| georaster | GeoRaster | | Use `georaster` from georaster-library. `georaster` or `georasters` is required. | +| georasters | GeoRaster[] | | Use different `georasters` from georaster-library. `georaster` or `georasters` is required. | +| resolution | number | 32 | The resolution parameter is how many samples to take across and down from a dataset for each map tile. Typical tiles are 256 x 256 pixels (higher resolution are 512 x 512) which would be a optimal resolution of 256. It's not recommended to set the resolution higher then 512. | +| debugLevel | number | 0 | Available debug levels: 0 - 5 | +| pixelValuesToColorFn | (values: number[]) => string | null | Customize how values for a pixel are translated to a color. | +| bounds | LatLngBounds | null | https://leafletjs.com/reference.html#latlngbounds | +| proj4 | Function | | https://github.com/proj4js/proj4js | +| resampleMethod | string | nearest | bilinear \| nearest | +| mask | string \| Feature \| FeatureCollection \| Polygon \| MultiPolygon | null | You can hide all the pixels either inside or outside a given mask geometry. You can provide a JSON object as a mask geometry or a URL to a GeoJSON. | +| mask_srs | string \| number | "EPSG:4326" | Default mask srs is the EPSG:4326 projection used by GeoJSON | +| mask_strategy | string | outside | inside \| outside | +| updateWhenIdle | boolean | true | https://leafletjs.com/reference.html#gridlayer-updatewhenidle | +| updateWhenZooming | boolean | false | https://leafletjs.com/reference.html#gridlayer-updatewhenzooming | +| keepBuffer | number | 25 | https://leafletjs.com/reference.html#gridlayer-keepbuffer | + + + ### Methods -| Method | Returns | Description | -| ------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -| updateColors(pixelValuesToColorFn, options) | this | Causes the tiles to redraw without clearing them first. It uses the updated `pixelValuesToColorFn` function. You can set a debugLevel specific to this function by passing in an options object with a debugLevel property. For example, you can turn on the console debugs for this method by setting `debugLevel = 1` in the options (even if you created the layer with `debugLevel = 0`). | +| Method | Returns | Description | +|------------------------------------------------------------------|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| getBounds() | LatLngBounds | Returns the bounds of the layer | +| getMap() | Map | Returns the map which contains the layer | +| getMapCRS() | CRS | Returns map CRS if available else EPSG3857 | +| getColor(values: number[]) | string \| undefined | Returns the colors of the values | +| updateColors(pixelValuesToColorFn, options = { debugLevel: -1 }) | this | Causes the tiles to redraw without clearing them first. It uses the updated `pixelValuesToColorFn` function. You can set a debugLevel specific to this function by passing in an options object with a debugLevel property. For example, you can turn on the console debugs for this method by setting `debugLevel = 1` in the options (even if you created the layer with `debugLevel = 0`). | +| getTiles() | Tile[] | Returns tiles as array | +| getActiveTiles() | Tile[] | Returns active / visible tiles as array | +| isSupportedProjection() | boolean | Returns if the projection is supported | +| getProjectionString(projection: number) | string | Returns the projection string for example "EPSG:3857" | +| getProjector() | Projection | Returns the current projection | ## Advanced Capabilities diff --git a/src/types/index.ts b/src/types/index.ts index 990194f..8c5371c 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -8,14 +8,14 @@ export type PixelValuesToColorFn = (values: number[]) => string; export type DebugLevel = 0 | 1 | 2 | 3 | 4 | 5; -export type ResampleMethod = "bilinear" | "near"; +export type ResampleMethod = "bilinear" | "nearest"; export type SimplePoint = { x: number; y: number; }; -export type Mask = Feature | FeatureCollection | Polygon | MultiPolygon; +export type Mask = string | Feature | FeatureCollection | Polygon | MultiPolygon; interface GeoRasterLayerOptions_CommonOptions extends GridLayerOptions { resolution?: number; @@ -77,7 +77,7 @@ export type GetValuesOptions = { right?: number; top?: number; width: number; - resampleMethod?: string + resampleMethod?: ResampleMethod }; export type GeoRasterValues = number[][][];