Skip to content

Commit 5066217

Browse files
committed
ConnectAllPoints for gradient path attachment
1 parent 85e433c commit 5066217

File tree

5 files changed

+105
-39
lines changed

5 files changed

+105
-39
lines changed

configure/src/metaconfigs/layer-model-config.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1530,7 +1530,7 @@
15301530
"name": "Color Ramp",
15311531
"description": "Array of css colors indicating the color ramp. The first color represents the min value and the last color represents the max value in the layer.",
15321532
"type": "textarray",
1533-
"width": 10
1533+
"width": 8
15341534
},
15351535
{
15361536
"field": "variables.pathAttachments.gradient.weight",
@@ -1539,6 +1539,14 @@
15391539
"type": "number",
15401540
"min": 1,
15411541
"width": 2
1542+
},
1543+
{
1544+
"field": "variables.pathAttachments.gradient.connectAllPoints",
1545+
"name": "Connect all Points",
1546+
"description": "Draws a gradient path line between all such point features in order the appear in the file. Expects the geojson file to be a series of Point features. Otherwise expects an enhanced per-coordinate properties geojson format.",
1547+
"type": "checkbox",
1548+
"width": 2,
1549+
"defaultChecked": false
15421550
}
15431551
]
15441552
}

configure/src/metaconfigs/layer-query-config.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1679,7 +1679,7 @@
16791679
"name": "Color Ramp",
16801680
"description": "Array of css colors indicating the color ramp. The first color represents the min value and the last color represents the max value in the layer.",
16811681
"type": "textarray",
1682-
"width": 10
1682+
"width": 8
16831683
},
16841684
{
16851685
"field": "variables.pathAttachments.gradient.weight",
@@ -1688,6 +1688,14 @@
16881688
"type": "number",
16891689
"min": 1,
16901690
"width": 2
1691+
},
1692+
{
1693+
"field": "variables.pathAttachments.gradient.connectAllPoints",
1694+
"name": "Connect all Points",
1695+
"description": "Draws a gradient path line between all such point features in order the appear in the file. Expects the geojson file to be a series of Point features. Otherwise expects an enhanced per-coordinate properties geojson format.",
1696+
"type": "checkbox",
1697+
"width": 2,
1698+
"defaultChecked": false
16911699
}
16921700
]
16931701
}

configure/src/metaconfigs/layer-vector-config.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,7 @@
16191619
"name": "Color Ramp",
16201620
"description": "Array of css colors indicating the color ramp. The first color represents the min value and the last color represents the max value in the layer.",
16211621
"type": "textarray",
1622-
"width": 10
1622+
"width": 8
16231623
},
16241624
{
16251625
"field": "variables.pathAttachments.gradient.weight",
@@ -1628,6 +1628,14 @@
16281628
"type": "number",
16291629
"min": 1,
16301630
"width": 2
1631+
},
1632+
{
1633+
"field": "variables.pathAttachments.gradient.connectAllPoints",
1634+
"name": "Connect all Points",
1635+
"description": "Draws a gradient path line between all such point features in order the appear in the file. Expects the geojson file to be a series of Point features. Otherwise expects an enhanced per-coordinate properties geojson format.",
1636+
"type": "checkbox",
1637+
"width": 2,
1638+
"defaultChecked": false
16311639
}
16321640
]
16331641
}

configure/src/metaconfigs/layer-vectortile-config.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1587,7 +1587,7 @@
15871587
"name": "Color Ramp",
15881588
"description": "Array of css colors indicating the color ramp. The first color represents the min value and the last color represents the max value in the layer.",
15891589
"type": "textarray",
1590-
"width": 10
1590+
"width": 8
15911591
},
15921592
{
15931593
"field": "variables.pathAttachments.gradient.weight",
@@ -1596,6 +1596,14 @@
15961596
"type": "number",
15971597
"min": 1,
15981598
"width": 2
1599+
},
1600+
{
1601+
"field": "variables.pathAttachments.gradient.connectAllPoints",
1602+
"name": "Connect all Points",
1603+
"description": "Draws a gradient path line between all such point features in order the appear in the file. Expects the geojson file to be a series of Point features. Otherwise expects an enhanced per-coordinate properties geojson format.",
1604+
"type": "checkbox",
1605+
"width": 2,
1606+
"defaultChecked": false
15991607
}
16001608
]
16011609
}

src/essence/Basics/Layers_/LayerConstructors.js

Lines changed: 69 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1648,6 +1648,11 @@ const pathGradient = (geojson, layerObj, leafletLayerObject) => {
16481648
'red',
16491649
]),
16501650
weight: F_.getIn(pathGradientVar, 'weight', 4),
1651+
connectAllPoints: F_.getIn(
1652+
pathGradientVar,
1653+
'connectAllPoints',
1654+
false
1655+
),
16511656
}
16521657

16531658
// check validity
@@ -1682,53 +1687,82 @@ const pathGradient = (geojson, layerObj, leafletLayerObject) => {
16821687
var prevParentIndex = null
16831688
geojson.features.forEach((feature) => {
16841689
let path = []
1685-
F_.coordinateDepthTraversal(
1686-
feature.geometry.coordinates,
1687-
(array, _path) => {
1688-
// Find breaks in the coordinate array to find sepearate features
1689-
const splitPath = _path.split('.')
1690-
let parentIndex = null
1691-
if (splitPath.length >= 2) {
1692-
parentIndex = splitPath[splitPath.length - 2]
1693-
if (
1694-
prevParentIndex != null &&
1695-
parentIndex != prevParentIndex
1696-
) {
1697-
paths.push(path)
1698-
path = []
1699-
}
1700-
}
1701-
const value = F_.getIn(
1702-
getCoordProperties(geojson, feature, array),
1690+
if (pathGradientSettings.connectAllPoints) {
1691+
if (feature.geometry.type.toLowerCase() === 'point') {
1692+
let value = F_.getIn(
1693+
feature.properties,
17031694
pathGradientSettings.colorWithProp,
17041695
0
17051696
)
17061697
if (min > value) min = value
17071698
if (max < value) max = value
1708-
1709-
path.push([array[1], array[0], value])
1710-
1711-
// Save this for next run through
1712-
prevParentIndex = parentIndex
1699+
path = [
1700+
feature.geometry.coordinates[1],
1701+
feature.geometry.coordinates[0],
1702+
value,
1703+
]
17131704
}
1714-
)
1705+
} else {
1706+
F_.coordinateDepthTraversal(
1707+
feature.geometry.coordinates,
1708+
(array, _path) => {
1709+
// Find breaks in the coordinate array to find sepearate features
1710+
const splitPath = _path.split('.')
1711+
let parentIndex = null
1712+
if (splitPath.length >= 2) {
1713+
parentIndex = splitPath[splitPath.length - 2]
1714+
if (
1715+
prevParentIndex != null &&
1716+
parentIndex != prevParentIndex
1717+
) {
1718+
paths.push(path)
1719+
path = []
1720+
}
1721+
}
1722+
const value = F_.getIn(
1723+
getCoordProperties(geojson, feature, array),
1724+
pathGradientSettings.colorWithProp,
1725+
0
1726+
)
1727+
if (min > value) min = value
1728+
if (max < value) max = value
1729+
1730+
path.push([array[1], array[0], value])
1731+
1732+
// Save this for next run through
1733+
prevParentIndex = parentIndex
1734+
}
1735+
)
1736+
}
17151737
paths.push(path)
17161738
})
17171739

17181740
if (min === 0 && max === 0) max = 1
17191741

17201742
const hotlines = []
1721-
paths.forEach((path) => {
1722-
if (path.length > 0)
1723-
hotlines.push(
1724-
L.hotline(path, {
1725-
min: min,
1726-
max: max,
1727-
palette: steppedColorRamp,
1728-
weight: pathGradientSettings.weight,
1729-
})
1730-
)
1731-
})
1743+
1744+
if (pathGradientSettings.connectAllPoints) {
1745+
hotlines.push(
1746+
L.hotline(paths, {
1747+
min: min,
1748+
max: max,
1749+
palette: steppedColorRamp,
1750+
weight: pathGradientSettings.weight,
1751+
})
1752+
)
1753+
} else {
1754+
paths.forEach((path) => {
1755+
if (path.length > 0)
1756+
hotlines.push(
1757+
L.hotline(path, {
1758+
min: min,
1759+
max: max,
1760+
palette: steppedColorRamp,
1761+
weight: pathGradientSettings.weight,
1762+
})
1763+
)
1764+
})
1765+
}
17321766

17331767
const layer = L.layerGroup(hotlines)
17341768
layer.addDataEnhanced = function (

0 commit comments

Comments
 (0)