open-index/open-npm huggingface dataset:
npm package: @gisatcz/ptr-core
Description: Panther FE core package.
Latest version: 1.8.1

# ptr-core

## ssr

### Api

```js
/**
 * Returns function that repeats creating element until there are no more requests pending or if
 * `maxRetries` was exceeded.
 *
 * @param {Object} options
 * @param {number=} options.maxRetries - If number of retries is reached, current element is retrieved even if there are requests pending.
 * @param {Function=} options.createDataFn - Create data returned by render fn using react element returned by `createElFn`.
 * @param {Function} options.createElFn - Creates react element.
 * @param {Object} options.requestCounter
 *
 * @returns Function that returns `Promise` resolving to data returned by `createDataFn`.
 */
createRenderFn({
	maxRetries,
	createDataFn,
	createElFn,
	requestCounter,
});

/**
 * Returns counter of async requests.
 *
 * When request is fired, `onRequest()` should be called.
 * When request finishes, `onResponse()` should be called.
 *
 * `pendingRequests()` returns number of pending requests.
 *
 * `createReadyP()` returns promise that resolves once there are no pending requests or rejects on timeout.
 *
 * @param {Object} object
 * @param {number=} object.timeout Waiting for promise to resolve
 *
 * @returns {Object}
 */
createRequestCounter(options);

/**
 * Redux middleware that counts number of pending requests
 * by incrementing counter in `requestCounter` when such request
 * is encountered and decrementing it once it finishes.
 *
 * This can be used e.g. for SSR to know if we're done rendering
 * or we have to wait for some data.
 */
createAsyncMiddleware(requestCounter);
```

### Demo

```js
import {createStore} from 'redux';
import {
	createRenderFn,
	createRequestCounter,
	createAsyncMiddleware,
} from '@gisatcz/ptr-core';

function createStore() {
	const requestCounter = createRequestCounter();

	const store = createStore(reducer, {}, createAsyncMiddleware(requestCounter));

	return {
		store,
		requestCounter,
	};
}

function handler(req, res) {
	const {store, requestCounter} = createStore();

	const createEl = () => {
		/* Element returned for further processing.
		 * If in react we fire some requests, this `createEl` function will be called again
		 * thanks to `createAsyncMiddleware` that tracks requests using `requestCounter`.
		 */
		const appEl = (
			<UIDReset>
				<Provider store={store}>
					<App />
				</Provider>
			</UIDReset>
		);

		if (shouldRedirect) {
			/* If we decide somewhere in react that we want to redirect user, we can
			 * just do that and return `nil` instead of the element.
			 */
			res.redirect(301, requiredUrl);
			return;
		}

		return appEl;
	};

	const renderFn = createRenderFn({requestCounter, createEl});

	/* Here we just return promise of data that's gonna be send to client
	 * using `cra-universal` npm package (unless `createEl` returns `nil` in which case we
	 * handled sending data to client already)
	 */
	return requestCounter.createReadyP().then(() => renderFn());
}
```
npm package: @gisatcz/ptr-state
Description: Panther FE state package
Latest version: 3.0.1

# ptr-state package

# New BE update notes

- ADD BE support for notin filter like it was in ensureIndexed
- if new BE will always return Array of items, then fix request.js
- variable categoryPath is usually be-metadata is it correct?
- apiDelete can delete only one item
- apiUpdate expect in result.body array, but it takes only first as a updated
- saveEdited prepare specific structure
- add tests for ensureKey
- remove processPatchResponse
- remove processResponse
- BE should always return correct total length
- test pagination for requests
- fix request method -> handling response object vs. array and checking dataType
npm package: @gisatcz/ptr-tile-grid
Description: Panther globe tile set in WGS84.
Latest version: 0.2.0

# ptr-tile-grid

Tile grid for globe.

Tile grid covers the whole globe. Extent of grid is [bottomLeft, topRight] [[-180,-90], [180, 90]].

It is possible to generate all tiles for a certain level. Zero lavel has two tiles. Tiles count rise quadratic with each level.

Function getGridForLevelAndExtent(level, extent) creates grid for asked level and extent. Extent parameter is optional and use whole globe as default.

```js
import {getSizeForLevel} from './src/grid';

const grid0 = getGridForLevelAndExtent(0);
//[
//    [[-180,-90], [0,-90]]
//]
const grid1 = getGridForLevelAndExtent(1);
//[
//    [[-180,0], [-90,0], [0,0], [90,0]],
//    [[-180,-90], [-90,-90], [0,-90], [90,-90]]
//]
const grid2 = getGridForLevelAndExtent(2);
//[
//    [[-180,45], [-135,45], [-90,45], [-45,45], [0,45], [45,45], [90,45], [135,45]],
//    [[-180,0], [-135,0], [-90,0], [-45,0], [0,0], [45,0], [90,0], [135,0]],
//    [[-180,-45], [-135,-45], [-90,-45], [-45,-45], [0,-45], [45,-45], [90,-45], [135,-45]],
//    [[-180,-90], [-135,-90], [-90,-90], [-45,-90], [0,-90], [45,-90], [90,-90], [135,-90]]
// ]
```

### Tiles for extent

```js
import {getSizeForLevel} from './src/grid';

const grid2 = utils.getGridForLevelAndExtent(2, [
	[-10, -10],
	[10, 10],
]);
// [
//   [[-45,0], [0,0]],
//   [[-45,-45], [0,-45]
// ]
```

## Tile

Tile is spherical square with same side size in degrees. Side size is same for all tiles in same level. Each tile is defined by left bottom (south west) corner longitude latitude.

```js
import {getSizeForLevel} from './src/grid';

const level0 = getSizeForLevel(0); //180
const level1 = getSizeForLevel(1); //90
const level2 = getSizeForLevel(2); //45
const level3 = getSizeForLevel(3); //22.5
const level4 = getSizeForLevel(4); //11.25
const level5 = getSizeForLevel(5); //5.625
const level6 = getSizeForLevel(6); //2.8125
const level7 = getSizeForLevel(7); //1.40625
const level8 = getSizeForLevel(8); //0.703125
const level9 = getSizeForLevel(9); //0.3515625
const level10 = getSizeForLevel(10); //0.17578125
```

## Level

Tile set is defined by pyramid of levels, where each next level has quadratically more tile than level before.

Base level is level 0 with two tiles and side size 180°.

Level is required parameter for function `getGridForLevelAndExtent`. Usual usecase how determinate right level is by `getLevelByViewport(boxRange, viewportRange)` , where boxrange is smaller size of visible map in meters and viewportRange is smaller size of viewport in pixels.

```js
import {getLevelByViewport} from './src/grid';

const boxRange = 240; //meters
const viewport = 240; //pixels

const level0 = grid.getLevelByViewport(boxRange, viewport);
// level0 = 17

const level1 = grid.getLevelByViewport(50000000, 250);
// level1 = 0
```