Skip to content

Commit

Permalink
Fix substring and order for small edge, add arrow on test interface
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoupin committed Nov 22, 2017
1 parent 71c97b1 commit e54194d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
16 changes: 16 additions & 0 deletions dev/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://cdn.rawgit.com/aratcliffe/Leaflet.contextmenu/2404757b/dist/leaflet.contextmenu.min.js"></script>
<script src="https://cdn.rawgit.com/leaflet-extras/leaflet.sprite/gh-pages/dist/leaflet.sprite.js"></script>
<script src="https://cdn.rawgit.com/bbecquet/Leaflet.PolylineDecorator/5b40bf0f/dist/leaflet.polylineDecorator.js"></script>
</head>
<body>
<div id="map"></div>
Expand Down Expand Up @@ -124,6 +125,21 @@ <h3>Avoid:</h3>
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("<h3>Results</h3>")
$("#results").append(()=>{
Expand Down
3 changes: 2 additions & 1 deletion src/sqlBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,15 @@ 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}
tmp.seq seq,
(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)
Expand Down

0 comments on commit e54194d

Please sign in to comment.