@classic-homes/maps-core 0.2.7 → 0.2.9
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/{chunk-2NISJ7WE.js → chunk-6WMCIBJJ.js} +41 -194
- package/dist/chunk-EXGGK4H7.js +2822 -0
- package/dist/chunk-ZGUACUEF.js +156 -0
- package/dist/{data-DDS6ok7I.d.cts → data-k7o-Rne0.d.cts} +6 -2
- package/dist/{data-DDS6ok7I.d.ts → data-k7o-Rne0.d.ts} +6 -2
- package/dist/generator-CGfqiHvG.d.cts +139 -0
- package/dist/generator-CGfqiHvG.d.ts +139 -0
- package/dist/index.cjs +190 -7
- package/dist/index.d.cts +8 -1235
- package/dist/index.d.ts +8 -1235
- package/dist/index.js +6 -2613
- package/dist/marker-BjzgxVwm.d.ts +1490 -0
- package/dist/marker-zuhH2WoS.d.cts +1490 -0
- package/dist/{spatial-VV-zd88V.d.ts → spatial-Bo8nM3fC.d.ts} +2 -2
- package/dist/{spatial-J48Btm8f.d.cts → spatial-CU60awl8.d.cts} +2 -2
- package/dist/theme/index.d.cts +16 -141
- package/dist/theme/index.d.ts +16 -141
- package/dist/theme/index.js +2 -1
- package/dist/types/index.d.cts +93 -6
- package/dist/types/index.d.ts +93 -6
- package/dist/utils/index.cjs +3078 -0
- package/dist/utils/index.d.cts +50 -0
- package/dist/utils/index.d.ts +50 -0
- package/dist/utils/index.js +2 -0
- package/dist/workers/index.d.cts +2 -2
- package/dist/workers/index.d.ts +2 -2
- package/dist/workers/spatial.worker.js +9 -5
- package/package.json +9 -1
package/dist/index.cjs
CHANGED
|
@@ -1118,6 +1118,86 @@ function formatFeatureProperties(properties, options) {
|
|
|
1118
1118
|
function formatLabel(key) {
|
|
1119
1119
|
return key.replace(/_/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\b\w/g, (char) => char.toUpperCase());
|
|
1120
1120
|
}
|
|
1121
|
+
function isValidLongitude(lng) {
|
|
1122
|
+
return typeof lng === "number" && isFinite(lng) && lng >= -180 && lng <= 180;
|
|
1123
|
+
}
|
|
1124
|
+
function isValidLatitude(lat) {
|
|
1125
|
+
return typeof lat === "number" && isFinite(lat) && lat >= -90 && lat <= 90;
|
|
1126
|
+
}
|
|
1127
|
+
function validateCoordinates(coordinates) {
|
|
1128
|
+
if (!Array.isArray(coordinates)) {
|
|
1129
|
+
return { valid: false, error: "Coordinates must be an array" };
|
|
1130
|
+
}
|
|
1131
|
+
if (coordinates.length < 2) {
|
|
1132
|
+
return { valid: false, error: "Coordinates must have at least 2 elements [lng, lat]" };
|
|
1133
|
+
}
|
|
1134
|
+
const [lng, lat] = coordinates;
|
|
1135
|
+
if (typeof lng !== "number" || typeof lat !== "number") {
|
|
1136
|
+
return { valid: false, error: "Longitude and latitude must be numbers" };
|
|
1137
|
+
}
|
|
1138
|
+
if (!isFinite(lng) || !isFinite(lat)) {
|
|
1139
|
+
return { valid: false, error: "Coordinates must be finite numbers" };
|
|
1140
|
+
}
|
|
1141
|
+
if (lng < -180 || lng > 180) {
|
|
1142
|
+
return { valid: false, error: `Longitude ${lng} out of range [-180, 180]` };
|
|
1143
|
+
}
|
|
1144
|
+
if (lat < -90 || lat > 90) {
|
|
1145
|
+
return { valid: false, error: `Latitude ${lat} out of range [-90, 90]` };
|
|
1146
|
+
}
|
|
1147
|
+
return {
|
|
1148
|
+
valid: true,
|
|
1149
|
+
normalized: [lng, lat]
|
|
1150
|
+
};
|
|
1151
|
+
}
|
|
1152
|
+
function ensureValidCoordinates(coordinates) {
|
|
1153
|
+
const result = validateCoordinates(coordinates);
|
|
1154
|
+
if (!result.valid) {
|
|
1155
|
+
throw new Error(`Invalid coordinates: ${result.error}`);
|
|
1156
|
+
}
|
|
1157
|
+
return result.normalized;
|
|
1158
|
+
}
|
|
1159
|
+
function normalizeLongitude(lng) {
|
|
1160
|
+
if (!isFinite(lng)) return NaN;
|
|
1161
|
+
let normalized = lng % 360;
|
|
1162
|
+
if (normalized > 180) {
|
|
1163
|
+
normalized -= 360;
|
|
1164
|
+
} else if (normalized < -180) {
|
|
1165
|
+
normalized += 360;
|
|
1166
|
+
}
|
|
1167
|
+
return normalized;
|
|
1168
|
+
}
|
|
1169
|
+
function clampLatitude(lat) {
|
|
1170
|
+
if (!isFinite(lat)) return NaN;
|
|
1171
|
+
return Math.max(-90, Math.min(90, lat));
|
|
1172
|
+
}
|
|
1173
|
+
function validateBoundsArray(bounds) {
|
|
1174
|
+
if (!Array.isArray(bounds)) {
|
|
1175
|
+
return { valid: false, error: "Bounds must be an array" };
|
|
1176
|
+
}
|
|
1177
|
+
if (bounds.length !== 2) {
|
|
1178
|
+
return { valid: false, error: "Bounds must have exactly 2 elements [southwest, northeast]" };
|
|
1179
|
+
}
|
|
1180
|
+
const swResult = validateCoordinates(bounds[0]);
|
|
1181
|
+
if (!swResult.valid) {
|
|
1182
|
+
return { valid: false, error: `Invalid southwest corner: ${swResult.error}` };
|
|
1183
|
+
}
|
|
1184
|
+
const neResult = validateCoordinates(bounds[1]);
|
|
1185
|
+
if (!neResult.valid) {
|
|
1186
|
+
return { valid: false, error: `Invalid northeast corner: ${neResult.error}` };
|
|
1187
|
+
}
|
|
1188
|
+
const [, swLat] = swResult.normalized;
|
|
1189
|
+
const [, neLat] = neResult.normalized;
|
|
1190
|
+
if (swLat > neLat) {
|
|
1191
|
+
return {
|
|
1192
|
+
valid: false,
|
|
1193
|
+
error: `Southwest latitude (${swLat}) must be less than northeast latitude (${neLat})`
|
|
1194
|
+
};
|
|
1195
|
+
}
|
|
1196
|
+
return {
|
|
1197
|
+
valid: true,
|
|
1198
|
+
normalized: [swResult.normalized, neResult.normalized]
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
1121
1201
|
|
|
1122
1202
|
// src/utils/bounds.ts
|
|
1123
1203
|
function calculateBounds(geojson) {
|
|
@@ -1370,13 +1450,15 @@ function validateGeometry(geometry, prefix = "") {
|
|
|
1370
1450
|
errors.push(`${p}: unknown geometry type "${geometry.type}"`);
|
|
1371
1451
|
return errors;
|
|
1372
1452
|
}
|
|
1373
|
-
if (
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1453
|
+
if (geometry.type !== "GeometryCollection") {
|
|
1454
|
+
if (!("coordinates" in geometry) || geometry.coordinates === void 0) {
|
|
1455
|
+
errors.push(`${p}: missing coordinates`);
|
|
1456
|
+
return errors;
|
|
1457
|
+
}
|
|
1458
|
+
if (!Array.isArray(geometry.coordinates)) {
|
|
1459
|
+
errors.push(`${p}: coordinates must be an array`);
|
|
1460
|
+
return errors;
|
|
1461
|
+
}
|
|
1380
1462
|
}
|
|
1381
1463
|
switch (geometry.type) {
|
|
1382
1464
|
case "Point":
|
|
@@ -1401,6 +1483,20 @@ function validateGeometry(geometry, prefix = "") {
|
|
|
1401
1483
|
errors.push(`${p}: MultiPolygon must have at least one polygon`);
|
|
1402
1484
|
}
|
|
1403
1485
|
break;
|
|
1486
|
+
case "GeometryCollection": {
|
|
1487
|
+
const geomCollection = geometry;
|
|
1488
|
+
if (!("geometries" in geometry)) {
|
|
1489
|
+
errors.push(`${p}: GeometryCollection must have "geometries" array`);
|
|
1490
|
+
} else if (!Array.isArray(geomCollection.geometries)) {
|
|
1491
|
+
errors.push(`${p}: GeometryCollection "geometries" must be an array`);
|
|
1492
|
+
} else {
|
|
1493
|
+
geomCollection.geometries.forEach((geom, idx) => {
|
|
1494
|
+
const nestedErrors = validateGeometry(geom, `${p}.geometries[${idx}]`);
|
|
1495
|
+
errors.push(...nestedErrors);
|
|
1496
|
+
});
|
|
1497
|
+
}
|
|
1498
|
+
break;
|
|
1499
|
+
}
|
|
1404
1500
|
}
|
|
1405
1501
|
return errors;
|
|
1406
1502
|
}
|
|
@@ -1550,6 +1646,83 @@ async function expandClusterToBounds(map, sourceId, clusterId, options = {}) {
|
|
|
1550
1646
|
...maxZoom !== void 0 && { maxZoom }
|
|
1551
1647
|
});
|
|
1552
1648
|
}
|
|
1649
|
+
function createClusterStyles(options = {}) {
|
|
1650
|
+
const {
|
|
1651
|
+
smallColor = "#51bbd6",
|
|
1652
|
+
mediumColor = "#f1f075",
|
|
1653
|
+
largeColor = "#f28cb1",
|
|
1654
|
+
mediumThreshold = 100,
|
|
1655
|
+
largeThreshold = 750,
|
|
1656
|
+
smallRadius = 20,
|
|
1657
|
+
mediumRadius = 30,
|
|
1658
|
+
largeRadius = 40,
|
|
1659
|
+
strokeColor = "#fff",
|
|
1660
|
+
strokeWidth = 2,
|
|
1661
|
+
opacity = 0.85
|
|
1662
|
+
} = options.circle ?? {};
|
|
1663
|
+
const {
|
|
1664
|
+
textColor = "#333",
|
|
1665
|
+
textSize = 12,
|
|
1666
|
+
fontStack = ["Open Sans Bold", "Arial Unicode MS Bold"],
|
|
1667
|
+
abbreviated = false
|
|
1668
|
+
} = options.text ?? {};
|
|
1669
|
+
const {
|
|
1670
|
+
color: pointColor = "#11b4da",
|
|
1671
|
+
radius: pointRadius = 8,
|
|
1672
|
+
strokeColor: pointStrokeColor = "#fff",
|
|
1673
|
+
strokeWidth: pointStrokeWidth = 1
|
|
1674
|
+
} = options.unclusteredPoint ?? {};
|
|
1675
|
+
return {
|
|
1676
|
+
clusterCirclePaint: {
|
|
1677
|
+
"circle-color": [
|
|
1678
|
+
"step",
|
|
1679
|
+
["get", "point_count"],
|
|
1680
|
+
smallColor,
|
|
1681
|
+
mediumThreshold,
|
|
1682
|
+
mediumColor,
|
|
1683
|
+
largeThreshold,
|
|
1684
|
+
largeColor
|
|
1685
|
+
],
|
|
1686
|
+
"circle-radius": [
|
|
1687
|
+
"step",
|
|
1688
|
+
["get", "point_count"],
|
|
1689
|
+
smallRadius,
|
|
1690
|
+
mediumThreshold,
|
|
1691
|
+
mediumRadius,
|
|
1692
|
+
largeThreshold,
|
|
1693
|
+
largeRadius
|
|
1694
|
+
],
|
|
1695
|
+
"circle-stroke-color": strokeColor,
|
|
1696
|
+
"circle-stroke-width": strokeWidth,
|
|
1697
|
+
"circle-opacity": opacity
|
|
1698
|
+
},
|
|
1699
|
+
clusterTextPaint: {
|
|
1700
|
+
"text-color": textColor
|
|
1701
|
+
},
|
|
1702
|
+
clusterTextLayout: {
|
|
1703
|
+
"text-field": abbreviated ? ["get", "point_count_abbreviated"] : ["to-string", ["get", "point_count"]],
|
|
1704
|
+
"text-font": fontStack,
|
|
1705
|
+
"text-size": textSize,
|
|
1706
|
+
"text-allow-overlap": true
|
|
1707
|
+
},
|
|
1708
|
+
unclusteredPointPaint: {
|
|
1709
|
+
"circle-color": pointColor,
|
|
1710
|
+
"circle-radius": pointRadius,
|
|
1711
|
+
"circle-stroke-color": pointStrokeColor,
|
|
1712
|
+
"circle-stroke-width": pointStrokeWidth
|
|
1713
|
+
},
|
|
1714
|
+
clusterFilter: ["has", "point_count"],
|
|
1715
|
+
unclusteredFilter: ["!", ["has", "point_count"]]
|
|
1716
|
+
};
|
|
1717
|
+
}
|
|
1718
|
+
function createClusterCirclePaint(options = {}) {
|
|
1719
|
+
const styles = createClusterStyles({ circle: options });
|
|
1720
|
+
return styles.clusterCirclePaint;
|
|
1721
|
+
}
|
|
1722
|
+
function createClusterTextLayout(options = {}) {
|
|
1723
|
+
const styles = createClusterStyles({ text: options });
|
|
1724
|
+
return styles.clusterTextLayout;
|
|
1725
|
+
}
|
|
1553
1726
|
|
|
1554
1727
|
// src/utils/lod.ts
|
|
1555
1728
|
function groupFeaturesByProperty(geojson, options) {
|
|
@@ -4421,12 +4594,16 @@ exports.buildSpatialIndex = buildSpatialIndex;
|
|
|
4421
4594
|
exports.calculateBounds = calculateBounds;
|
|
4422
4595
|
exports.calculateCentroid = calculateCentroid;
|
|
4423
4596
|
exports.calculateZoomThresholds = calculateZoomThresholds;
|
|
4597
|
+
exports.clampLatitude = clampLatitude;
|
|
4424
4598
|
exports.clusterColorExpression = clusterColorExpression;
|
|
4425
4599
|
exports.clusterColors = clusterColors;
|
|
4426
4600
|
exports.combineBounds = combineBounds;
|
|
4427
4601
|
exports.countFeaturesByType = countFeaturesByType;
|
|
4428
4602
|
exports.createCategoricalColorExpression = createCategoricalColorExpression;
|
|
4429
4603
|
exports.createCircleStyle = createCircleStyle;
|
|
4604
|
+
exports.createClusterCirclePaint = createClusterCirclePaint;
|
|
4605
|
+
exports.createClusterStyles = createClusterStyles;
|
|
4606
|
+
exports.createClusterTextLayout = createClusterTextLayout;
|
|
4430
4607
|
exports.createContinuousColorExpression = createContinuousColorExpression;
|
|
4431
4608
|
exports.createDynamicLODManager = createDynamicLODManager;
|
|
4432
4609
|
exports.createExtrusionHeightExpression = createExtrusionHeightExpression;
|
|
@@ -4455,6 +4632,7 @@ exports.darkBasicStyle = darkBasicStyle;
|
|
|
4455
4632
|
exports.darkTheme = darkTheme;
|
|
4456
4633
|
exports.decimalToDMS = decimalToDMS;
|
|
4457
4634
|
exports.deepEqual = deepEqual;
|
|
4635
|
+
exports.ensureValidCoordinates = ensureValidCoordinates;
|
|
4458
4636
|
exports.expandCluster = expandCluster;
|
|
4459
4637
|
exports.expandClusterToBounds = expandClusterToBounds;
|
|
4460
4638
|
exports.extendBounds = extendBounds;
|
|
@@ -4522,6 +4700,8 @@ exports.inventoryStatusColors = inventoryStatusColors;
|
|
|
4522
4700
|
exports.isAnyLayerLoading = isAnyLayerLoading;
|
|
4523
4701
|
exports.isClusterFeature = isClusterFeature;
|
|
4524
4702
|
exports.isValidBounds = isValidBounds;
|
|
4703
|
+
exports.isValidLatitude = isValidLatitude;
|
|
4704
|
+
exports.isValidLongitude = isValidLongitude;
|
|
4525
4705
|
exports.lightBasicStyle = lightBasicStyle;
|
|
4526
4706
|
exports.lightTheme = lightTheme;
|
|
4527
4707
|
exports.loadGeoJSON = loadGeoJSON;
|
|
@@ -4530,6 +4710,7 @@ exports.lotAvailabilityColors = lotAvailabilityColors;
|
|
|
4530
4710
|
exports.lotSizeColorExpression = lotSizeColorExpression;
|
|
4531
4711
|
exports.lotSizeColors = lotSizeColors;
|
|
4532
4712
|
exports.nonMatchedColor = nonMatchedColor;
|
|
4713
|
+
exports.normalizeLongitude = normalizeLongitude;
|
|
4533
4714
|
exports.paintPropsEqual = paintPropsEqual;
|
|
4534
4715
|
exports.queryByBounds = queryByBounds;
|
|
4535
4716
|
exports.queryByBoundsWithStats = queryByBoundsWithStats;
|
|
@@ -4553,5 +4734,7 @@ exports.simplifyFeatureCollectionWithStats = simplifyFeatureCollectionWithStats;
|
|
|
4553
4734
|
exports.simplifyPolygon = simplifyPolygon;
|
|
4554
4735
|
exports.toggleLayerVisibility = toggleLayerVisibility;
|
|
4555
4736
|
exports.updateLayerState = updateLayerState;
|
|
4737
|
+
exports.validateBoundsArray = validateBoundsArray;
|
|
4738
|
+
exports.validateCoordinates = validateCoordinates;
|
|
4556
4739
|
exports.validateGeoJSON = validateGeoJSON;
|
|
4557
4740
|
exports.zoomToScale = zoomToScale;
|