Skip to content

Commit fc51871

Browse files
committed
Fixes rendering for Linestring and Polygon
Signed-off-by: Daniel Kastl <[email protected]>
1 parent 767a949 commit fc51871

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

src/components/gtt-client.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -886,23 +886,28 @@ export class GttClient {
886886
*/
887887
parseHistory() {
888888
document.querySelectorAll('div#history ul.details i').forEach((item: Element) => {
889-
const regex = new RegExp(/\w+[\s]?(\((-?\d+.\d+\s?-?\d+.\d+,?)+\))+/g)
889+
const regex = new RegExp(/\w+[\s]?(\(*(-?\d+.\d+\s?-?\d+.\d+,?)+\)*)+/g)
890890
const match = item.innerHTML.match(regex)
891891
if (match !== null) {
892892
const feature = new WKT().readFeature(
893-
match[0], {
893+
match.join(''), {
894894
dataProjection: 'EPSG:4326',
895895
featureProjection: 'EPSG:3857'
896896
}
897897
)
898-
const wkt = new WKT().writeFeature(
898+
let wkt = new WKT().writeFeature(
899899
feature, {
900900
dataProjection: 'EPSG:4326',
901901
featureProjection: 'EPSG:3857',
902-
decimals: 6
902+
decimals: 5
903903
}
904904
)
905-
item.innerHTML = `<a href="#" onclick="event.preventDefault();" class="wkt">${wkt}</a>`
905+
// Shorten long WKT's
906+
if (wkt.length > 30) {
907+
const parts = wkt.split(' ')
908+
wkt = parts[0] + '...' + parts[parts.length - 1]
909+
}
910+
item.innerHTML = `<a href="#" onclick="event.preventDefault();" class="wkt" data-feature="${match.join('')}">${wkt}</a>`
906911
}
907912
})
908913
}

0 commit comments

Comments
 (0)