{"id":198,"date":"2024-10-04T13:06:08","date_gmt":"2024-10-04T21:06:08","guid":{"rendered":"https:\/\/salemdata.net\/johnpress\/?p=198"},"modified":"2024-10-04T13:06:08","modified_gmt":"2024-10-04T21:06:08","slug":"calculating-a-nw-segment-of-salems-class-d-air-space","status":"publish","type":"post","link":"https:\/\/salemdata.net\/johnpress\/?p=198","title":{"rendered":"Calculating a NW Segment of Salem&#8217;s Class D Air Space"},"content":{"rendered":"\n<p>I&#8217;m still working on the matter of the low flying Learjet over Salem, and in that matter, I have determined the jet first flew parallel to the FAA&#8217;s Class D airspace as much as it could before entering it.<\/p>\n\n\n\n<p>So then I wondered, why and what distance is involved.  So here is a picture of the FAA&#8217;s Class D air space over Salem.  It encompasses about 78 square miles.  I asked ChatGPT for a strategy on how to determine the distance of the segment and it assumed I could easily determine the coordinates of the interior and exterior corner of the shape using a mouse over a map.  I&#8217;m not thrilled with using a mouse over a map to obtain accurate coordinates, so I suggested we determine the points programmatically (through programming) and then I would have dead-accurate numbers &#8212; something the FAA and government might be comfortable with.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full wp-duotone-unset-1\"><img loading=\"lazy\" decoding=\"async\" width=\"890\" height=\"567\" src=\"https:\/\/salemdata.net\/johnpress\/wp-content\/uploads\/2024\/10\/tvnviewer_2024-10-04_13-24-15.png\" alt=\"3 dimensional depicting of Class D airspace over Salem, OR\" class=\"wp-image-199\" srcset=\"https:\/\/salemdata.net\/johnpress\/wp-content\/uploads\/2024\/10\/tvnviewer_2024-10-04_13-24-15.png 890w, https:\/\/salemdata.net\/johnpress\/wp-content\/uploads\/2024\/10\/tvnviewer_2024-10-04_13-24-15-300x191.png 300w, https:\/\/salemdata.net\/johnpress\/wp-content\/uploads\/2024\/10\/tvnviewer_2024-10-04_13-24-15-768x489.png 768w\" sizes=\"auto, (max-width: 890px) 100vw, 890px\" \/><\/figure>\n\n\n\n<p>The top most straight line segment point at the northwest  (pointing towards 11 o&#8217;clock) is the border that the Learjet flew along.  I wanted to know what that segment&#8217;s distance is.  So with the help of ChatGPT, we constructed a query that visits the 6,000+ points used to define the  air space shape above and determine for any given 3 points, what the angle is.  Then only those angles far away from 180 degrees (3 points in a straight line would have an angle of 180 degrees) or thereabout would be of interest and most likely represent corners.<\/p>\n\n\n\n<pre class=\"wp-block-code has-contrast-color has-base-background-color has-text-color has-background has-link-color wp-elements-b4069bc190ae4746ca8156c638203028\" style=\"padding-right:0;padding-left:0\"><code>nenrad=# WITH dumped_points AS (\nSELECT (ST_DumpPoints(geom)).path&#91;1] AS path,\n(ST_DumpPoints(geom)).geom AS dumppoint\nFROM air_space\nWHERE gid = 4899\n),\nnumbered_points AS (\nSELECT dumppoint,\nROW_NUMBER() OVER (ORDER BY path) AS rn\nFROM dumped_points\n),\nangles AS (\nSELECT\np1.rn AS set_number,\nST_X(p1.dumppoint) AS lon1, ST_Y(p1.dumppoint) AS lat1,\nST_X(p2.dumppoint) AS lon2, ST_Y(p2.dumppoint) AS lat2,\nST_X(p3.dumppoint) AS lon3, ST_Y(p3.dumppoint) AS lat3,\nDEGREES(ST_Angle(p1.dumppoint, p2.dumppoint, p3.dumppoint)) AS angle_degrees\nFROM numbered_points p1\nJOIN numbered_points p2 ON p2.rn = p1.rn + 1\nJOIN numbered_points p3 ON p3.rn = p1.rn + 2\n)\nSELECT * FROM angles\nWHERE angle_degrees &lt; 150\nor angle_degrees > 200\nORDER BY set_number;\nset_number |       lon1        |       lat1       |       lon2        |       lat2       |       lon3        |       lat3       |   angle_degrees\n------------+-------------------+------------------+-------------------+------------------+-------------------+------------------+--------------------\n1 | -123.049964745861 | 44.9677836638676 | -123.049464768662 | 44.9671697198823 |  -123.04943115166 | 44.9671835198864 |  106.8398394614957\n2848 | -122.933944159422 | 44.8639806424676 | -122.933962591422 | 44.8639666144649 | -122.933233883214 | 44.8634825285096 |  70.86996257022534\n2858 |  -122.91866256406 | 44.8537998004016 | -122.916841492541 |  44.852589327513 | -122.916921516541 | 44.8525284755014 | 289.13771073176343\n3400 | -122.970232557107 | 44.8293479767846 | -122.970238418108 | 44.8293467827839 |  -122.97092421055 | 44.8310512098155 | 259.59684676121486\n3410 | -122.976412000093 | 44.8446864590673 |  -122.97668646527 | 44.8453682200799 | -122.976745919277 | 44.8453561140732 | 100.41965248870801\n4982 | -123.092654881048 | 44.8910313170972 |  -123.09265841005 | 44.8910400430973 | -123.093617088157 | 44.8908438169895 | 100.45182726945418\n4992 | -123.112789106295 | 44.8869174938315 | -123.115185425562 | 44.8864264775618 | -123.115217833583 | 44.8865065555632 | 259.54640914412636\n6319 | -123.061262823349 | 44.9815778035296 | -123.061217070346 | 44.9815965915353 | -123.059966544847 | 44.9800618785723 | 253.15093018349765\n(8 rows)\n\nnenrad=#<\/code><\/pre>\n\n\n\n<p>ChatGPT then created an HTML page displaying a map showing where the 8 points appear on the map as I told it that I wanted to verify visually the above calculations.  Bingo: an HTML page showing me the points.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full wp-duotone-unset-2\"><img loading=\"lazy\" decoding=\"async\" width=\"565\" height=\"512\" src=\"https:\/\/salemdata.net\/johnpress\/wp-content\/uploads\/2024\/10\/tvnviewer_2024-10-04_13-30-45.png\" alt=\"\" class=\"wp-image-200\" srcset=\"https:\/\/salemdata.net\/johnpress\/wp-content\/uploads\/2024\/10\/tvnviewer_2024-10-04_13-30-45.png 565w, https:\/\/salemdata.net\/johnpress\/wp-content\/uploads\/2024\/10\/tvnviewer_2024-10-04_13-30-45-300x272.png 300w\" sizes=\"auto, (max-width: 565px) 100vw, 565px\" \/><\/figure>\n\n\n\n<p>Then I took the middle coordinates, &#8220;lon2&#8221; &amp; &#8220;lat2&#8221;, for set #1 and set #6319 and computed the distance:<\/p>\n\n\n\n<pre class=\"wp-block-code has-contrast-color has-base-background-color has-text-color has-background has-link-color wp-elements-56fcacb1a501d299ab3f988bade8116c\"><code>nenrad=# SELECT ST_Distance(\nST_Transform(ST_GeomFromText('POINT(-123.049464768662 44.9671697198823)', 4326), 3210),\nST_Transform(ST_GeomFromText('POINT(-123.061217070346 44.9815965915353)', 4326), 3210)\n) AS distance_meters;\ndistance_meters\n------------------\n9710.43676387841\n(1 row)\n\nnenrad=#<\/code><\/pre>\n\n\n\n<p>9710 meters which is about 6 miles.  <\/p>\n\n\n\n<p>Having fun with ChatGPT and FAA air space shapes!<\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m still working on the matter of the low flying Learjet over Salem, and in that matter, I have determined the jet first flew parallel to the FAA&#8217;s Class D airspace as much as it could before entering it. So then I wondered, why and what distance is involved. So here is a picture of [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":199,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48,37,12,1],"tags":[54,53],"class_list":["post-198","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-3d-map","category-ai","category-salem-oregon","category-uncategorized","tag-air-space","tag-faa"],"_links":{"self":[{"href":"https:\/\/salemdata.net\/johnpress\/index.php?rest_route=\/wp\/v2\/posts\/198","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/salemdata.net\/johnpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/salemdata.net\/johnpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/salemdata.net\/johnpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/salemdata.net\/johnpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=198"}],"version-history":[{"count":2,"href":"https:\/\/salemdata.net\/johnpress\/index.php?rest_route=\/wp\/v2\/posts\/198\/revisions"}],"predecessor-version":[{"id":202,"href":"https:\/\/salemdata.net\/johnpress\/index.php?rest_route=\/wp\/v2\/posts\/198\/revisions\/202"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/salemdata.net\/johnpress\/index.php?rest_route=\/wp\/v2\/media\/199"}],"wp:attachment":[{"href":"https:\/\/salemdata.net\/johnpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/salemdata.net\/johnpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/salemdata.net\/johnpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}