@geospatial-sdk/maplibre 0.0.5-dev.54 → 0.0.5-dev.56

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.
@@ -1 +1 @@
1
- {"version":3,"file":"map.helpers.d.ts","sourceRoot":"","sources":["../../lib/helpers/map.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,GAAG,EAAsB,MAAM,aAAa,CAAC;AAC/E,OAAO,EACL,OAAO,EACP,qBAAqB,EACrB,0BAA0B,EAC1B,4BAA4B,EAC7B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAGtD,OAAO,EAAuB,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAW5E;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,qBAAqB,EACjC,OAAO,EAAE,iBAAiB,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,MAAM,EACpD,QAAQ,EAAE,0BAA0B,GACnC,OAAO,CA+BT;AAED,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,eAAe,GAC1B,4BAA4B,EAAE,CAkBhC;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,MAAM,GACf,4BAA4B,EAAE,CAoBhC;AAED;;;;;GAKG;AACH,wBAAgB,yBAAyB,CACvC,GAAG,EAAE,GAAG,EACR,QAAQ,EAAE,MAAM,GACf,MAAM,GAAG,SAAS,CAoBpB;AAYD;;;GAGG;AACH,wBAAgB,sCAAsC,CACpD,UAAU,EAAE,eAAe,UAG5B;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,eAAe,EACzB,QAAQ,EAAE,eAAe,GACxB,OAAO,CAKT;AAED;;GAEG;AACH,wBAAgB,eAAe,WAE9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AAe,WAE9B;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,GAAG,EAAE,GAAG,EACR,KAAK,EAAE,kBAAkB,EACzB,UAAU,EAAE,eAAe,EAC3B,kBAAkB,EAAE,eAAe,QA+BpC"}
@@ -1,5 +1,5 @@
1
1
  import { contextStyleToMaplibreLayers } from "./style.helpers.js";
2
- import { getHash } from "@geospatial-sdk/core/dist/utils/hash.js";
2
+ import { getHash, } from "@geospatial-sdk/core";
3
3
  function getOpacityPaintPropNames(layerType) {
4
4
  switch (layerType) {
5
5
  case "circle":
@@ -1,4 +1,4 @@
1
- import { VectorStyle } from "@geospatial-sdk/core/dist/model/style.js";
1
+ import { VectorStyle } from "@geospatial-sdk/core";
2
2
  import { LayerSpecification } from "maplibre-gl";
3
3
  export declare function contextStyleToMaplibreLayers(style?: VectorStyle): Partial<LayerSpecification>[];
4
4
  //# sourceMappingURL=style.helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"style.helpers.d.ts","sourceRoot":"","sources":["../../lib/helpers/style.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,0CAA0C,CAAC;AACvE,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAajD,wBAAgB,4BAA4B,CAC1C,KAAK,GAAE,WAAgB,GACtB,OAAO,CAAC,kBAAkB,CAAC,EAAE,CAmD/B"}
1
+ {"version":3,"file":"style.helpers.d.ts","sourceRoot":"","sources":["../../lib/helpers/style.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAajD,wBAAgB,4BAA4B,CAC1C,KAAK,GAAE,WAAgB,GACtB,OAAO,CAAC,kBAAkB,CAAC,EAAE,CAmD/B"}
@@ -7,8 +7,11 @@ import {
7
7
  } from "../maplibre.models.js";
8
8
  import { FeatureCollection, Geometry } from "geojson";
9
9
  import { contextStyleToMaplibreLayers } from "./style.helpers.js";
10
- import { getHash } from "@geospatial-sdk/core/dist/utils/hash.js";
11
- import { MapContextBaseLayer, MapContextLayer } from "@geospatial-sdk/core";
10
+ import {
11
+ getHash,
12
+ MapContextBaseLayer,
13
+ MapContextLayer,
14
+ } from "@geospatial-sdk/core";
12
15
 
13
16
  function getOpacityPaintPropNames(layerType: string): string[] {
14
17
  switch (layerType) {
@@ -1,4 +1,4 @@
1
- import { VectorStyle } from "@geospatial-sdk/core/dist/model/style.js";
1
+ import { VectorStyle } from "@geospatial-sdk/core";
2
2
  import { LayerSpecification } from "maplibre-gl";
3
3
  import { FlatFill, FlatStyle, Rule } from "ol/style/flat.js";
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@geospatial-sdk/maplibre",
3
- "version": "0.0.5-dev.54+352b554",
3
+ "version": "0.0.5-dev.56+eae591c",
4
4
  "description": "Maplibre-related utilities",
5
5
  "keywords": [
6
6
  "maplibre",
@@ -33,7 +33,7 @@
33
33
  "maplibre-gl": "^5.7.3"
34
34
  },
35
35
  "dependencies": {
36
- "@geospatial-sdk/core": "^0.0.5-dev.54+352b554"
36
+ "@geospatial-sdk/core": "^0.0.5-dev.56+eae591c"
37
37
  },
38
- "gitHead": "352b554ec0ca6a27dee923a28b4b1bb4e3f12973"
38
+ "gitHead": "eae591cfcca0346c3cac6fe7d5dcddf88fe408f4"
39
39
  }
@@ -1,9 +0,0 @@
1
- import { ColorExpression } from "ol/style/flat";
2
- export interface ColorProps {
3
- color?: string;
4
- opacity?: number;
5
- expression?: any[];
6
- }
7
- export declare const DEFAULT_COLOR = "black";
8
- export declare function createColor(input: ColorExpression): ColorProps;
9
- //# sourceMappingURL=color.helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"color.helpers.d.ts","sourceRoot":"","sources":["../../lib/helpers/color.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;CACpB;AAED,eAAO,MAAM,aAAa,UAAU,CAAC;AAErC,wBAAgB,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG,UAAU,CA6B9D"}
@@ -1,28 +0,0 @@
1
- export const DEFAULT_COLOR = "black";
2
- export function createColor(input) {
3
- // Expression
4
- if (Array.isArray(input) && typeof input[0] === "string") {
5
- console.warn("Color expressions are not fully supported yet.");
6
- return { expression: input };
7
- }
8
- // Color as Array [red, green, blue, alpha?]
9
- if (Array.isArray(input) && typeof input[0] === "number") {
10
- if (input.length === 3) {
11
- return { color: `rgb(${input[0]},${input[1]},${input[2]})` };
12
- }
13
- if (input.length === 4) {
14
- const [r, g, b, a] = input;
15
- return {
16
- color: `rgb(${r},${g},${b})`,
17
- opacity: a,
18
- };
19
- }
20
- }
21
- // String eg 'black
22
- if (typeof input === "string") {
23
- return {
24
- color: input,
25
- };
26
- }
27
- return { color: DEFAULT_COLOR };
28
- }
@@ -1,2 +0,0 @@
1
- export * from "./color.helpers";
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../lib/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
@@ -1 +0,0 @@
1
- export * from "./color.helpers";
@@ -1,10 +0,0 @@
1
- import { Feature, FeatureCollection, Geometry } from "geojson";
2
- import { LayerSpecification, StyleSpecification } from "maplibre-gl";
3
- import { CircleLayerSpecification, FillLayerSpecification, LineLayerSpecification } from "@maplibre/maplibre-gl-style-spec";
4
- export declare function getGeometryTypes(features: Feature<Geometry>[]): string[];
5
- export declare function createDefaultLayersForGeometries(layerId: string, sourceId: string, geometryTypes: string[]): LayerSpecification[];
6
- export declare function createDefaultFillLayer(layerId: string, sourceId: string): FillLayerSpecification;
7
- export declare function createDefaultCircleLayer(layerId: string, sourceId: string): CircleLayerSpecification;
8
- export declare function createDefaultLineLayer(layerId: string, sourceId: string): LineLayerSpecification;
9
- export declare function createStyleFromGeoJson(datasetId: string, geojson: FeatureCollection<Geometry | null>): StyleSpecification;
10
- //# sourceMappingURL=maplibre.helpers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"maplibre.helpers.d.ts","sourceRoot":"","sources":["../lib/maplibre.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACrE,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,sBAAsB,EACvB,MAAM,kCAAkC,CAAC;AAE1C,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,EAAE,GAAG,MAAM,EAAE,CAQxE;AAED,wBAAgB,gCAAgC,CAC9C,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,MAAM,EAAE,GACtB,kBAAkB,EAAE,CAkBtB;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,sBAAsB,CAUxB;AACD,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,wBAAwB,CAa1B;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,sBAAsB,CAUxB;AAED,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,iBAAiB,CAAC,QAAQ,GAAG,IAAI,CAAC,GAC1C,kBAAkB,CAoBpB"}
@@ -1,78 +0,0 @@
1
- export function getGeometryTypes(features) {
2
- return features.reduce((types, feature) => {
3
- var _a;
4
- const type = (_a = feature.geometry) === null || _a === void 0 ? void 0 : _a.type.toLocaleLowerCase();
5
- if (type && !types.includes(type)) {
6
- types.push(type);
7
- }
8
- return types;
9
- }, []);
10
- }
11
- export function createDefaultLayersForGeometries(layerId, sourceId, geometryTypes) {
12
- const layers = [];
13
- if (geometryTypes.includes("polygon") ||
14
- geometryTypes.includes("multipolygon")) {
15
- layers.push(createDefaultFillLayer(layerId, sourceId));
16
- }
17
- if (geometryTypes.includes("point") || geometryTypes.includes("multipoint")) {
18
- layers.push(createDefaultCircleLayer(layerId, sourceId));
19
- }
20
- if (geometryTypes.includes("linestring") ||
21
- geometryTypes.includes("multilinestring")) {
22
- layers.push(createDefaultLineLayer(layerId, sourceId));
23
- }
24
- return layers;
25
- }
26
- export function createDefaultFillLayer(layerId, sourceId) {
27
- return {
28
- id: `${layerId}-fill`,
29
- type: "fill",
30
- source: sourceId,
31
- paint: {
32
- "fill-color": "#68C6DE",
33
- "fill-opacity": 0.6,
34
- },
35
- };
36
- }
37
- export function createDefaultCircleLayer(layerId, sourceId) {
38
- return {
39
- id: `${layerId}-circle`,
40
- type: "circle",
41
- source: sourceId,
42
- paint: {
43
- "circle-radius": ["interpolate", ["linear"], ["zoom"], 5, 4, 13, 15],
44
- "circle-color": "#60759F",
45
- "circle-opacity": 0.59,
46
- "circle-stroke-width": 0.5,
47
- "circle-stroke-color": "#4E8BD4",
48
- },
49
- };
50
- }
51
- export function createDefaultLineLayer(layerId, sourceId) {
52
- return {
53
- id: `${layerId}-line`,
54
- type: "line",
55
- source: sourceId,
56
- paint: {
57
- "line-color": "green",
58
- "line-width": 3,
59
- },
60
- };
61
- }
62
- export function createStyleFromGeoJson(datasetId, geojson) {
63
- datasetId = datasetId || Math.floor(Math.random() * 1000000).toString();
64
- const sourceId = `source-${datasetId}`;
65
- const layerId = `layer-${datasetId}`;
66
- const geometryTypes = getGeometryTypes(geojson.features);
67
- const layers = createDefaultLayersForGeometries(layerId, sourceId, geometryTypes);
68
- const styleDiff = {
69
- sources: {
70
- [sourceId]: {
71
- type: "geojson",
72
- data: geojson,
73
- },
74
- },
75
- layers,
76
- };
77
- return styleDiff;
78
- }