{"id":316,"date":"2015-03-17T16:56:44","date_gmt":"2015-03-17T21:56:44","guid":{"rendered":"http:\/\/cartometric.com\/blog\/?p=316"},"modified":"2015-03-17T16:56:44","modified_gmt":"2015-03-17T21:56:44","slug":"socket-served-internet-mapping-anyone","status":"publish","type":"post","link":"https:\/\/elrobis.com\/blog\/2015\/03\/17\/socket-served-internet-mapping-anyone\/","title":{"rendered":"Socket-served Internet mapping, anyone?"},"content":{"rendered":"<p>I may or may not be on to something.<\/p>\n<p>For awhile I&#8217;ve been growing more and more tired of the typical Internet mapping user experience. It&#8217;s basically this: open a map and zoom\/pan somewhere, wait a moment while (hopefully) some &#8220;working&#8221; graphic gives you a clue that the map hasn&#8217;t forgot about you; meanwhile, some basemap tiles load, then after a moment or two, &#8220;poof!&#8221; all the interactive data (i.e. the sole reason you are using that particular map) appears all at once.<\/p>\n<p>Fortunately, in most cases, the basemap tiles &#8220;sprinkle in&#8221; one by one as they become available, which does give the user an impression that something is happening. But more often than not, basemap tiles <em>dramatically<\/em> out-perform the vector data component, and the overall feel of the map becomes this kind of &#8220;clicky kludgy .. ..CLUNK&#8221;, as the tiles pepper in, followed by the hammer that is all the vector data landing at once.<\/p>\n<p>So I&#8217;ve always looked for ways to streamline the vector IO as much as possible&#8211;1) Maybe it&#8217;s possible to simplify the data a little, removing redundant vertices? 2) Maybe it&#8217;s possible to return that data with less coordinate precision (i.e. the number of decimal places in the coordinate values), because a precision above 8 probably isn&#8217;t even legit. 3) Is the database using it&#8217;s geometry index, or is it possible to better-tune the DB so that it handles the Data Access step more athletically? 4) ..what about pre-cacheing the entire data table into RAM so the DB never has to hit disk to serve a query on that table? &#8230;.that&#8217;s pretty much the request\/access step, but what about 5) returning the data in the leanest possible format&#8211;for example, GML is much heavier than GeoJSON. Or, 7) what about returning a home-rolled JSON response using Well Known Text (WKT) and just a few important fields, rather than providing the entire record for every feature?<\/p>\n<p>I feel like I&#8217;ve tried everything I know to try, and I just cant serve a deep table of polygons (specifically, parcel polygons) to go through all the motions as fast as I&#8217;d like. At the end of the day, the choke-point is the HTTP protocol, itself, and the very client &lt;&#8211;&gt; server paradigm that represents almost 100% of the static web. (By static web, I mean basic websites where you go to fetch assets, read\/learn things, watch things, etc. The Dynamic web would be things like video games, chat rooms, Skype, and stuff like that.)<\/p>\n<p>That got me to thinking, maybe an answer lives somewhere in the Dynamic web. A major service-level component of the dynamic web is the &#8220;Socket&#8221;, and they&#8217;ve been around for awhile. The original AOL chat rooms used sockets, as did instant messaging apps. Socket&#8217;s allow servers to &#8220;push&#8221; data into listening clients. This is why you don&#8217;t have to click a refresh button to see if your friend ever responded. The response just appears because it&#8217;s pushed in.<\/p>\n<p>For this reason, I wanted to explore the idea of a socket-served web map. I thought of it as being a chat-like interaction. The\u00a0 map says &#8220;hey I&#8217;m over here!&#8221; Then the server gets any relevant data and just pushes it right into the map. Most of the get\/access-level optimizations I described above apply equally here. However a win in user experience *may* come from the fact that each individual feature&#8212;much like the basemap tiles&#8212;can be drawn as it becomes available to the client. This removes a huge choke point imposed by the HTTP protocol, specifically waiting for the browser to receive the entire payload of data, parse it, and render it&#8212;all before you see the first feature. Instead, features are drawn one-by-one.<\/p>\n<p>My theory feels good, and the approach seems to work. At the very least it&#8217;s doing what I hoped. But I have yet to test in a deployed scenario. Right now it&#8217;s all on my development machine. But it looks pretty cool in action! check it out below.<\/p>\n<p>If anyone is interested, I&#8217;ll share the code. Otherwise, I&#8217;ll make it available after I get it a little further along and prove to myself it works well once deployed.<\/p>\n<p><iframe loading=\"lazy\" src=\"https:\/\/www.youtube.com\/embed\/Mr0a3x8kopE\" frameborder=\"0\" width=\"420\" height=\"315\"><\/iframe><\/p>\n<p><em>..to be continued<\/em><\/p>\n<p>&#8211; elrobis<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I may or may not be on to something. For awhile I&#8217;ve been growing more and more tired of the typical Internet mapping user experience. It&#8217;s basically this: open a map and zoom\/pan somewhere, wait a moment while (hopefully) some &#8220;working&#8221; graphic gives you a clue that the map hasn&#8217;t forgot about you; meanwhile, some [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/elrobis.com\/blog\/wp-json\/wp\/v2\/posts\/316"}],"collection":[{"href":"https:\/\/elrobis.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elrobis.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elrobis.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elrobis.com\/blog\/wp-json\/wp\/v2\/comments?post=316"}],"version-history":[{"count":5,"href":"https:\/\/elrobis.com\/blog\/wp-json\/wp\/v2\/posts\/316\/revisions"}],"predecessor-version":[{"id":322,"href":"https:\/\/elrobis.com\/blog\/wp-json\/wp\/v2\/posts\/316\/revisions\/322"}],"wp:attachment":[{"href":"https:\/\/elrobis.com\/blog\/wp-json\/wp\/v2\/media?parent=316"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elrobis.com\/blog\/wp-json\/wp\/v2\/categories?post=316"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elrobis.com\/blog\/wp-json\/wp\/v2\/tags?post=316"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}