{"id":129,"date":"2022-09-19T17:51:29","date_gmt":"2022-09-19T17:51:29","guid":{"rendered":"https:\/\/oomap.dna-software.co.uk\/help\/?p=129"},"modified":"2022-09-19T17:52:59","modified_gmt":"2022-09-19T17:52:59","slug":"contour-perfectionism","status":"publish","type":"post","link":"https:\/\/oomap.dna-software.co.uk\/help\/contour-perfectionism\/","title":{"rendered":"Contour Perfectionism"},"content":{"rendered":"\n<p>The current contour generation process queries a database for all the contours in a certain area.  It then drops any very short contours as these are likely to be artefacts that aren&#8217;t useful, and draws tick marks to show slope direction.  To make sure the ticks appear on shorter contours, the frequency of tick marks is increased for shorter lines.<\/p>\n\n\n\n<p>Because the contours are generated in a block-by-block fashion, the above process can produce undesirable behaviour at the edges of these blocks &#8211; short segments missing and extra ticks &#8211; in both cases due to a single contour being made up of multiple segments from multiple blocks:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"725\" height=\"385\" src=\"https:\/\/oomap.dna-software.co.uk\/help\/wp-content\/uploads\/2022\/09\/image.png\" alt=\"\" class=\"wp-image-130\" srcset=\"https:\/\/oomap.dna-software.co.uk\/help\/wp-content\/uploads\/2022\/09\/image.png 725w, https:\/\/oomap.dna-software.co.uk\/help\/wp-content\/uploads\/2022\/09\/image-300x159.png 300w\" sizes=\"auto, (max-width: 725px) 100vw, 725px\" \/><figcaption>Contour issues<\/figcaption><\/figure>\n\n\n\n<p>This problem would go away if each contour could be stitched back together as a single contiguous line.  Easier said than done!<\/p>\n\n\n\n<p>To achieve this in PostGIS database world, each query result has to be first broken down into individual line segments, then all combined into a single MultiLineString.  ST_LineMerge will then join together adjacent lines, before the result is again broken down into separate, but hopefully complete, contour lines:<\/p>\n\n\n\nSELECT h.way as way, ST_Length(h.way) as length\n\tFROM\n\t(\n\t  SELECT (ST_Dump(ST_LineMerge(ST_collect(g.way)))).geom as way\n\t  FROM\n\t  (\n\t    SELECT (ST_Dump(ST_Intersection(way, !bbox!))).geom as way\n\t    FROM lidar3\n\t    WHERE (height*2)::integer % (10* &amp;contourSeparation; )::integer != 0\n\t    AND  (height*2)::integer % (2* &amp;contourSeparation; )::integer = 0\n\t    AND ST_Intersects(way,!bbox!)\n\t  ) as g\n) as h\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"794\" height=\"483\" src=\"https:\/\/oomap.dna-software.co.uk\/help\/wp-content\/uploads\/2022\/09\/image-1.png\" alt=\"\" class=\"wp-image-131\" srcset=\"https:\/\/oomap.dna-software.co.uk\/help\/wp-content\/uploads\/2022\/09\/image-1.png 794w, https:\/\/oomap.dna-software.co.uk\/help\/wp-content\/uploads\/2022\/09\/image-1-300x182.png 300w, https:\/\/oomap.dna-software.co.uk\/help\/wp-content\/uploads\/2022\/09\/image-1-768x467.png 768w\" sizes=\"auto, (max-width: 794px) 100vw, 794px\" \/><figcaption>Issues fixed<\/figcaption><\/figure>\n\n\n\n<p>Much better!<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The current contour generation process queries a database for all the contours in a certain area. It then drops any very short contours as these are likely to be artefacts that aren&#8217;t useful, and draws tick marks to show slope direction. To make sure the ticks appear on shorter contours, the frequency of tick marks [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":133,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-129","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/oomap.dna-software.co.uk\/help\/wp-json\/wp\/v2\/posts\/129","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/oomap.dna-software.co.uk\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/oomap.dna-software.co.uk\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/oomap.dna-software.co.uk\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/oomap.dna-software.co.uk\/help\/wp-json\/wp\/v2\/comments?post=129"}],"version-history":[{"count":2,"href":"https:\/\/oomap.dna-software.co.uk\/help\/wp-json\/wp\/v2\/posts\/129\/revisions"}],"predecessor-version":[{"id":134,"href":"https:\/\/oomap.dna-software.co.uk\/help\/wp-json\/wp\/v2\/posts\/129\/revisions\/134"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/oomap.dna-software.co.uk\/help\/wp-json\/wp\/v2\/media\/133"}],"wp:attachment":[{"href":"https:\/\/oomap.dna-software.co.uk\/help\/wp-json\/wp\/v2\/media?parent=129"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/oomap.dna-software.co.uk\/help\/wp-json\/wp\/v2\/categories?post=129"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/oomap.dna-software.co.uk\/help\/wp-json\/wp\/v2\/tags?post=129"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}