@vectoriahq/quac 0.18.0-next.1 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export { STAC_VERSION } from './model/Stac.ts';
|
|
|
8
8
|
export { isIconLibraryAddress, resolveFieldIconAddress } from './model/fieldIconAddress.ts';
|
|
9
9
|
export { collectCollectionStyles, getDefaultStyle, styleAssetKey, GL_STYLE_MEDIA_TYPE } from './model/stacStyles.ts';
|
|
10
10
|
export type { StacStyle, StyleOverrideReference } from './model/stacStyles.ts';
|
|
11
|
+
export { readCollectionColourAdjustment } from './model/colourAdjustment.ts';
|
|
12
|
+
export type { ColourAdjustment } from './model/colourAdjustment.ts';
|
|
11
13
|
export { parseQgsXml } from './parse/parseQgsXml.ts';
|
|
12
14
|
export { measureFactorsOf } from './parse/parseMeasurement.ts';
|
|
13
15
|
export type { MeasureFactors } from './parse/parseMeasurement.ts';
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
export { STAC_VERSION } from "./model/Stac.js";
|
|
6
6
|
export { isIconLibraryAddress, resolveFieldIconAddress } from "./model/fieldIconAddress.js";
|
|
7
7
|
export { collectCollectionStyles, getDefaultStyle, styleAssetKey, GL_STYLE_MEDIA_TYPE } from "./model/stacStyles.js";
|
|
8
|
+
export { readCollectionColourAdjustment } from "./model/colourAdjustment.js";
|
|
8
9
|
export { parseQgsXml } from "./parse/parseQgsXml.js";
|
|
9
10
|
export { measureFactorsOf } from "./parse/parseMeasurement.js";
|
|
10
11
|
export { readProjectXml } from "./parse/readProjectFile.js";
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { StacCollection } from './Stac.ts';
|
|
2
|
+
/**
|
|
3
|
+
* The colour adjustments a Collection declares for its layer, each as its
|
|
4
|
+
* `quac:` field states it. A reader applies them to every pixel's red, green
|
|
5
|
+
* and blue values in QGIS's order: contrast, brightness, gamma, saturation.
|
|
6
|
+
*/
|
|
7
|
+
export interface ColourAdjustment {
|
|
8
|
+
/** `quac:contrast`, from -1 to 1; 0 leaves the layer unchanged. */
|
|
9
|
+
contrast: number;
|
|
10
|
+
/** `quac:brightness`, from -1 to 1; 0 leaves the layer unchanged. */
|
|
11
|
+
brightness: number;
|
|
12
|
+
/** `quac:gamma`, from 0.1 to 10; 1 leaves the layer unchanged. */
|
|
13
|
+
gamma: number;
|
|
14
|
+
/** `quac:saturation`, from -1 to 1; 0 leaves the layer unchanged. */
|
|
15
|
+
saturation: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* The colour adjustments a Collection declares, or null where every one of
|
|
19
|
+
* them leaves the layer unchanged, so a caller draws the layer as it is.
|
|
20
|
+
*
|
|
21
|
+
* A value that is not a finite number is read as stating nothing, as is a
|
|
22
|
+
* gamma of 0 or below, which has no meaning. A value outside its field's range
|
|
23
|
+
* is brought to the nearer end of it.
|
|
24
|
+
*/
|
|
25
|
+
export declare function readCollectionColourAdjustment(collection: StacCollection): ColourAdjustment | null;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/** What each field reads as when the Collection states nothing, and the range a value is brought into. */
|
|
2
|
+
const FIELDS = {
|
|
3
|
+
contrast: { key: 'quac:contrast', unchanged: 0, min: -1, max: 1 },
|
|
4
|
+
brightness: { key: 'quac:brightness', unchanged: 0, min: -1, max: 1 },
|
|
5
|
+
gamma: { key: 'quac:gamma', unchanged: 1, min: 0.1, max: 10 },
|
|
6
|
+
saturation: { key: 'quac:saturation', unchanged: 0, min: -1, max: 1 }
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* The colour adjustments a Collection declares, or null where every one of
|
|
10
|
+
* them leaves the layer unchanged, so a caller draws the layer as it is.
|
|
11
|
+
*
|
|
12
|
+
* A value that is not a finite number is read as stating nothing, as is a
|
|
13
|
+
* gamma of 0 or below, which has no meaning. A value outside its field's range
|
|
14
|
+
* is brought to the nearer end of it.
|
|
15
|
+
*/
|
|
16
|
+
export function readCollectionColourAdjustment(collection) {
|
|
17
|
+
const adjustment = {};
|
|
18
|
+
let changes = false;
|
|
19
|
+
for (const [name, field] of Object.entries(FIELDS)) {
|
|
20
|
+
const value = collection[field.key];
|
|
21
|
+
const stated = typeof value === 'number' && Number.isFinite(value) && !(name === 'gamma' && value <= 0);
|
|
22
|
+
adjustment[name] = stated ? Math.min(field.max, Math.max(field.min, value)) : field.unchanged;
|
|
23
|
+
if (adjustment[name] !== field.unchanged)
|
|
24
|
+
changes = true;
|
|
25
|
+
}
|
|
26
|
+
return changes ? adjustment : null;
|
|
27
|
+
}
|
package/package.json
CHANGED
|
@@ -217,6 +217,30 @@
|
|
|
217
217
|
"minimum": 0,
|
|
218
218
|
"maximum": 1
|
|
219
219
|
},
|
|
220
|
+
"quac:contrast": {
|
|
221
|
+
"description": "The contrast adjustment applied to the layer as drawn, from -1 to 1: each red, green and blue value's distance from mid-grey is multiplied by (1 + contrast) squared, so -1 draws flat mid-grey. It applies to any kind of layer. A layer with no value is unchanged.",
|
|
222
|
+
"type": "number",
|
|
223
|
+
"minimum": -1,
|
|
224
|
+
"maximum": 1
|
|
225
|
+
},
|
|
226
|
+
"quac:brightness": {
|
|
227
|
+
"description": "The brightness adjustment applied to the layer as drawn, from -1 to 1: added to each red, green and blue value, on a scale where each runs from 0 to 1. It applies to any kind of layer. A layer with no value is unchanged.",
|
|
228
|
+
"type": "number",
|
|
229
|
+
"minimum": -1,
|
|
230
|
+
"maximum": 1
|
|
231
|
+
},
|
|
232
|
+
"quac:gamma": {
|
|
233
|
+
"description": "The gamma correction applied to the layer as drawn, from 0.1 to 10: each red, green and blue value, from 0 to 1, is raised to the power 1 / gamma, so a gamma above 1 lightens the mid-tones. It applies to any kind of layer. A layer with no value, or with 1, is unchanged.",
|
|
234
|
+
"type": "number",
|
|
235
|
+
"minimum": 0.1,
|
|
236
|
+
"maximum": 10
|
|
237
|
+
},
|
|
238
|
+
"quac:saturation": {
|
|
239
|
+
"description": "The saturation adjustment applied to the layer as drawn, from -1 to 1: the saturation of each colour is multiplied by 1 + saturation, so -1 draws the layer in greys. It applies to any kind of layer. A layer with no value is unchanged.",
|
|
240
|
+
"type": "number",
|
|
241
|
+
"minimum": -1,
|
|
242
|
+
"maximum": 1
|
|
243
|
+
},
|
|
220
244
|
"quac:related_to": {
|
|
221
245
|
"description": "The relations this Collection is the child side of, so its records hang off another Collection's features rather than being a map layer of their own. Written from a QGIS project's Relations.",
|
|
222
246
|
"type": "array",
|