From e54194de92cd883d28c22e925be58a6104c65705 Mon Sep 17 00:00:00 2001 From: Thibault Coupin Date: Wed, 22 Nov 2017 20:49:51 +0100 Subject: [PATCH] Fix substring and order for small edge, add arrow on test interface --- dev/static/index.html | 16 ++++++++++++++++ src/sqlBuilder.js | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/dev/static/index.html b/dev/static/index.html index c8ec506..9822cd3 100644 --- a/dev/static/index.html +++ b/dev/static/index.html @@ -18,6 +18,7 @@ +
@@ -124,6 +125,21 @@

Avoid:

mymap.removeLayer(resultLayer); } resultLayer = L.geoJSON(data).addTo(mymap); + var mainLineString = []; + resultLayer.eachLayer(function(lay){ + var geom = lay.feature.geometry; + if (geom.type == "LineString"){ + mainLineString = mainLineString.concat(geom.coordinates) + } + }) + for (let i in mainLineString){ + mainLineString[i]=mainLineString[i].reverse(); + } + resultLayer.addLayer(L.polylineDecorator(mainLineString, { + patterns: [ + {offset: 25, repeat: 50, symbol: L.Symbol.arrowHead({pixelSize: 15, pathOptions: {fillOpacity: 1, weight: 0}})} + ] + })); $("#results").empty(); $("#results").append("

Results

") $("#results").append(()=>{ diff --git a/src/sqlBuilder.js b/src/sqlBuilder.js index c9bb17e..64554b7 100644 --- a/src/sqlBuilder.js +++ b/src/sqlBuilder.js @@ -69,7 +69,7 @@ module.exports = { select ${types_aggregate} ${properties_list}, flag_groupid as seq, - st_asgeojson(st_union(the_geom)) the_geom from ( + st_asgeojson(ST_LineMerge(St_union(the_geom))) the_geom from ( select *, sum(flag_newgroup) over (order by seq) flag_groupid from ( select ${types_sections} @@ -77,6 +77,7 @@ module.exports = { (case when lag(${properties_agg}) OVER (order by seq)=${properties_agg} then 0 else 1 end) flag_newgroup, ${properties_select} ((((case + when tmp.source_node=-1 and tmp.target_node=-2 OR tmp.source_node=-2 and tmp.target_node=-1 then (case when ${startPoint.fraction} < ${endPoint.fraction} then ST_LineSubstring(edge_table.the_geom,${startPoint.fraction}, ${endPoint.fraction}) else st_reverse(ST_LineSubstring(edge_table.the_geom, ${endPoint.fraction}, ${startPoint.fraction})) end) when tmp.source_node=-1 then (case when tmp.target_node = edge_table.target then ST_LineSubstring(edge_table.the_geom,${startPoint.fraction} ,1) else st_reverse(ST_LineSubstring(edge_table.the_geom,0,${startPoint.fraction})) END) when tmp.target_node=-2 then (case when tmp.source_node = edge_table.source then ST_LineSubstring(edge_table.the_geom,0,${endPoint.fraction}) else st_reverse(ST_LineSubstring(edge_table.the_geom,${endPoint.fraction},1)) end) else (case when tmp.source_node = edge_table.source then edge_table.the_geom else st_reverse(edge_table.the_geom) END)