valhalla / demos

demos
MIT License
98 stars 58 forks source link

rendering contours not as polygons #179

Closed kevinkreiser closed 7 years ago

kevinkreiser commented 7 years ago

isochrones are contours, not polygons. the problem is, viewing them as polygons is handy but presents a lot of issues when rendering them over a map. if you are using raster tiles you'll need to render the polygons over top of the tiles. thsi means they must have some opacity. for something like vector tiles this isnt an issue as you can render the isochrone polygons under the roads for example and then not have opacity for the isochrones. anyway back to the problem at hand.

so we need some opacity. this leads to the problem that the server side algorithm just takes each contour that is a ring and says hey thsi is now a polygon. there are two problems here.

  1. sometimes the ring is actually the inner of another ring, ie a hole in the polygon. we can detect this and do the right thing with a little work.
  2. sometimes the rings have self intersections, this isnt really a problem to start with but once you want to do geometric operations between these polygons you start having issues.

so ive been trying to help @meghanhade with rendering contours as polygons and its exactly as #problematic as i was alluding to before. basically you cant ever be sure (without us doing a bunch of work in the backend) that the polygons will render properly. we have a bunch of options and ive outlined what i think is the best one in our server side code but the gist of it is, if you want to render polygons and you ask for multiple isochrones ie not just 15 minutes but 15 and 30 and 45, then you may not be able to render them as they may (self)intersect in weird ways. so ive punted on making that work because we dont have 2 weeks to fix it now.

ive done a bunch of work in the backend to keep polygonal output enabled if you choose it but ive defaulted it to giving back linestrings as self intersections dont matter so much and this is the canonical representation of a contour. see: valhalla/midgard#107 valhalla/baldr#314 valhalla/thor#

ive also done work to make it possible to render these with labels as tool tips that follow your mouse as you mose over the contours. you dont see the mouse in the picture but thats just because it was a screen caputure

labled_contours