@naivemap/maplibre-gl-image-layer 0.0.1-alpha.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Naive Map
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,65 @@
1
+ import { default as maplibregl } from 'maplibre-gl';
2
+ import { Coordinates } from './arrugator';
3
+ export type MaskProperty = {
4
+ type?: 'in' | 'out';
5
+ data: GeoJSON.Polygon | GeoJSON.MultiPolygon;
6
+ };
7
+ export type ImageOption = {
8
+ url: string;
9
+ projection: string;
10
+ coordinates: Coordinates;
11
+ resampling?: 'linear' | 'nearest';
12
+ opacity?: number;
13
+ crossOrigin?: string;
14
+ arrugatorStep?: number;
15
+ mask?: MaskProperty;
16
+ metadata?: any;
17
+ };
18
+ /**
19
+ * ImageLayer is a custom layer for MapLibre GL that renders an image
20
+ * with support for projection, coordinates, resampling, opacity, and masking.
21
+ */
22
+ export default class ImageLayer implements maplibregl.CustomLayerInterface {
23
+ id: string;
24
+ type: 'custom';
25
+ renderingMode?: '2d' | '3d' | undefined;
26
+ metadata?: any;
27
+ private option;
28
+ private map?;
29
+ private gl?;
30
+ private loaded;
31
+ private arrugado;
32
+ private programInfo?;
33
+ private bufferInfo?;
34
+ private texture?;
35
+ private maskProperty;
36
+ private maskProgramInfo?;
37
+ private maskBufferInfo?;
38
+ constructor(id: string, option: ImageOption);
39
+ onAdd(map: maplibregl.Map, gl: WebGLRenderingContext): void;
40
+ onRemove(_: maplibregl.Map, gl: WebGLRenderingContext): void;
41
+ render(gl: WebGLRenderingContext, args: any): void;
42
+ /**
43
+ * Updates the URL, the projection, the coordinates, the opacity or the resampling of the image.
44
+ * @param {Object} option Options object.
45
+ * @param {string} [option.url] Image URL.
46
+ * @param {string} [option.projection] Projection with EPSG code that points to the image..
47
+ * @param {Array<Array<number>>} [option.coordinates] Four geographical coordinates,
48
+ * @param {number} [option.opacity] opacity of the image.
49
+ * @param {string} [option.resampling] The resampling/interpolation method to use for overscaling.
50
+ */
51
+ updateImage(option: {
52
+ url?: string;
53
+ projection?: string;
54
+ coordinates?: Coordinates;
55
+ opacity?: number;
56
+ resampling?: 'linear' | 'nearest';
57
+ }): this;
58
+ /**
59
+ * Updates the mask property
60
+ * @param {MaskProperty} mask The mask property.
61
+ */
62
+ updateMask(mask: Partial<MaskProperty>): this;
63
+ private loadTexture;
64
+ private getMaskBufferInfo;
65
+ }
@@ -0,0 +1,18 @@
1
+ export default class Arrugator {
2
+ constructor(projector: any, verts: any, uv: any, trigs: any);
3
+ _segment(v1: any, v2: any, t: any, maxEpsilon?: number): any;
4
+ output(): {
5
+ unprojected: unknown[];
6
+ projected: unknown[];
7
+ uv: unknown[];
8
+ trigs: unknown[];
9
+ };
10
+ private _stepsWithSameEpsilon;
11
+ lowerEpsilon(targetEpsilon: any): void;
12
+ get epsilon(): any;
13
+ set epsilon(ep: any);
14
+ step(): void;
15
+ force(): void;
16
+ private _splitSegment;
17
+ private _splitTriangle;
18
+ }
@@ -0,0 +1,7 @@
1
+ export type Coordinates = [[number, number], [number, number], [number, number], [number, number]];
2
+ export type ArrugadoFlat = {
3
+ pos: number[];
4
+ uv: number[];
5
+ trigs: number[];
6
+ };
7
+ export declare function initArrugator(fromProj: string, coordinates: Coordinates, step?: number): ArrugadoFlat;
@@ -0,0 +1,4 @@
1
+ import { default as ImageLayer } from './ImageLayer';
2
+ export type { ImageOption, MaskProperty } from './ImageLayer';
3
+ export default ImageLayer;
4
+ export type { Coordinates } from './arrugator';