Skip to content

Commit 2d48c0b

Browse files
committed
Add options and methods to README
1 parent d6e2b0e commit 2d48c0b

File tree

2 files changed

+41
-8
lines changed

2 files changed

+41
-8
lines changed

README.md

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ new GeoRasterLayer({ georaster }).addTo(map);
5151
5252
## The GeoRasterLayer Class
5353
54-
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.
54+
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.
5555
5656
### Usage Example
5757
@@ -61,6 +61,7 @@ Source Code: <https://github.com/GeoTIFF/georaster-layer-for-leaflet-example/blo
6161
var parse_georaster = require("georaster");
6262
6363
var GeoRasterLayer = require("georaster-layer-for-leaflet");
64+
// or: import GeoRasterLayer from "georaster-layer-for-leaflet";
6465
6566
// initalize leaflet map
6667
var map = L.map('map').setView([0, 0], 5);
@@ -87,7 +88,7 @@ fetch(url_to_geotiff_file)
8788
Optionally set the pixelValuesToColorFn function option to customize
8889
how values for a pixel are translated to a color.
8990
90-
http://leafletjs.com/reference-1.2.0.html#gridlayer
91+
https://leafletjs.com/reference.html#gridlayer
9192
*/
9293
var layer = new GeoRasterLayer({
9394
georaster: georaster,
@@ -103,14 +104,46 @@ fetch(url_to_geotiff_file)
103104
});
104105
```
105106
107+
### Options for GeoRasterLayer
108+
109+
> The layer extends L.GridLayer, see the [docs](https://leafletjs.com/reference.html#gridlayer) for inherited options and methods.
110+
111+
| Option | Type | Default | Description |
112+
|----------------------|-------------------------------------------------------------------|---------|------------------------------------------------------------------|
113+
| georaster | GeoRaster | | Use `georaster` from georaster-library. `georaster` or `georasters` is required. |
114+
| georasters | GeoRaster[] | | Use different `georasters` from georaster-library. `georaster` or `georasters` is required. |
115+
| 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. |
116+
| debugLevel | number | 0 | Available debug levels: 0 - 5 |
117+
| pixelValuesToColorFn | (values: number[]) => string | null | Customize how values for a pixel are translated to a color. |
118+
| bounds | LatLngBounds | null | https://leafletjs.com/reference.html#latlngbounds |
119+
| proj4 | Function | | https://github.com/proj4js/proj4js |
120+
| resampleMethod | string | nearest | bilinear \| nearest |
121+
| 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. |
122+
| mask_srs | string \| number | "EPSG:4326" | Default mask srs is the EPSG:4326 projection used by GeoJSON |
123+
| mask_strategy | string | outside | inside \| outside |
124+
| updateWhenIdle | boolean | true | https://leafletjs.com/reference.html#gridlayer-updatewhenidle |
125+
| updateWhenZooming | boolean | false | https://leafletjs.com/reference.html#gridlayer-updatewhenzooming |
126+
| keepBuffer | number | 25 | https://leafletjs.com/reference.html#gridlayer-keepbuffer |
127+
128+
129+
106130
<!-- ## Options -->
107131
<!-- todo: add a table of options for GeoRasterLayer -->
108132
109133
### Methods
110134
111-
| Method | Returns | Description |
112-
| ------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
113-
| 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`). |
135+
| Method | Returns | Description |
136+
|------------------------------------------------------------------|---------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
137+
| getBounds() | LatLngBounds | Returns the bounds of the layer |
138+
| getMap() | Map | Returns the map which contains the layer |
139+
| getMapCRS() | CRS | Returns map CRS if available else EPSG3857 |
140+
| getColor(values: number[]) | string \| undefined | Returns the colors of the values |
141+
| 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`). |
142+
| getTiles() | Tile[] | Returns tiles as array |
143+
| getActiveTiles() | Tile[] | Returns active / visible tiles as array |
144+
| isSupportedProjection() | boolean | Returns if the projection is supported |
145+
| getProjectionString(projection: number) | string | Returns the projection string for example "EPSG:3857" |
146+
| getProjector() | Projection | Returns the current projection |
114147
115148
## Advanced Capabilities
116149

src/types/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,14 @@ export type PixelValuesToColorFn = (values: number[]) => string;
88

99
export type DebugLevel = 0 | 1 | 2 | 3 | 4 | 5;
1010

11-
export type ResampleMethod = "bilinear" | "near";
11+
export type ResampleMethod = "bilinear" | "nearest";
1212

1313
export type SimplePoint = {
1414
x: number;
1515
y: number;
1616
};
1717

18-
export type Mask = Feature | FeatureCollection | Polygon | MultiPolygon;
18+
export type Mask = string | Feature | FeatureCollection | Polygon | MultiPolygon;
1919

2020
interface GeoRasterLayerOptions_CommonOptions extends GridLayerOptions {
2121
resolution?: number;
@@ -77,7 +77,7 @@ export type GetValuesOptions = {
7777
right?: number;
7878
top?: number;
7979
width: number;
80-
resampleMethod?: string
80+
resampleMethod?: ResampleMethod
8181
};
8282

8383
export type GeoRasterValues = number[][][];

0 commit comments

Comments
 (0)